From 51ba48b14a600f183852e1c80270fa7e11157f8c Mon Sep 17 00:00:00 2001 From: Janette Day Date: Wed, 5 Feb 2020 16:11:06 -0600 Subject: [PATCH] Add link to react json form editor --- .../install/views.view.dkan_content.yml | 117 +++++++++++++++++- modules/custom/dkan_admin/dkan_admin.module | 26 ++++ 2 files changed, 142 insertions(+), 1 deletion(-) diff --git a/modules/custom/dkan_admin/config/install/views.view.dkan_content.yml b/modules/custom/dkan_admin/config/install/views.view.dkan_content.yml index 815bdc53b..a3723305b 100644 --- a/modules/custom/dkan_admin/config/install/views.view.dkan_content.yml +++ b/modules/custom/dkan_admin/config/install/views.view.dkan_content.yml @@ -9,7 +9,7 @@ dependencies: - user - views_bulk_operations _core: - default_config_hash: sIHLrlWWGhDodotLDzoAJlqrnlv7OKphojbYzgYptFk + default_config_hash: NRDZnPbQCKTmXDMpa6hNSS4dVTbFhvzk2fCeMlZ6y3I id: dkan_content label: 'DKAN Content' module: node @@ -414,6 +414,121 @@ display: plugin_id: field entity_type: node entity_field: changed + nid: + id: nid + table: node_field_data + field: nid + relationship: none + group_type: group + admin_label: '' + label: '' + exclude: true + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: false + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: number_integer + settings: + thousand_separator: '' + prefix_suffix: true + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + entity_type: node + entity_field: nid + plugin_id: field + nothing: + id: nothing + table: views + field: nothing + relationship: none + group_type: group + admin_label: '' + label: Edit + exclude: false + alter: + alter_text: true + text: edit + make_link: true + path: '/node/{{ nid }}/edit' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: false + plugin_id: custom filters: title: id: title diff --git a/modules/custom/dkan_admin/dkan_admin.module b/modules/custom/dkan_admin/dkan_admin.module index a970e9fc1..32d5be8be 100644 --- a/modules/custom/dkan_admin/dkan_admin.module +++ b/modules/custom/dkan_admin/dkan_admin.module @@ -29,4 +29,30 @@ function dkan_admin_form_views_exposed_form_alter(&$form, FormStateInterface $fo '#default_value' => '', ]; } +} + +/** + * Implements template_preprocess_views_view_fields(). + */ +function dkan_admin_preprocess_views_view_field(&$vars) { + // To access current row entity. + $entity = $vars['row']->_entity; + $entity_id = $entity->id(); + $uuid = $entity->uuid->value; + + // To access entities from relationship. + // $entities = $vars['row']->_relationship_entities; + + if (isset($vars['view']) + && ($vars['view']->id() == 'dkan_content') + && ($vars['view']->current_display == 'page_1')) { + + if (isset($vars['view']->field) && (count($vars['view']->field) > 0)) { + if ($vars['field']->field == 'nothing' && $entity->field_data_type->value == 'dataset') { + $vars['output'] = [ + '#markup' => 'edit', + ]; + } + } + } } \ No newline at end of file