diff --git a/composer.json b/composer.json index e4884d17de..54f5c8fbfc 100644 --- a/composer.json +++ b/composer.json @@ -60,6 +60,7 @@ "drupal/samlauth": "^3.9", "drupal/simple_sitemap": "^4.1", "drupal/simplify_menu": "^3.1", + "drupal/sortableviews": "^1.3", "drupal/tome": "^1.6", "drupal/twig_tweak": "^3.1", "drupal/uswds_base": "^2.4", diff --git a/composer.lock b/composer.lock index 81677cd04d..740db231cb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4e1f368b2f2ff65203fb05e16c6d823b", + "content-hash": "06ca7c5968b37fb09f0f66a126ffa880", "packages": [ { "name": "asm89/stack-cors", @@ -5334,6 +5334,54 @@ "source": "https://git.drupalcode.org/project/simplify_menu" } }, + { + "name": "drupal/sortableviews", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://git.drupalcode.org/project/sortableviews.git", + "reference": "8.x-1.3" + }, + "dist": { + "type": "zip", + "url": "https://ftp.drupal.org/files/projects/sortableviews-8.x-1.3.zip", + "reference": "8.x-1.3", + "shasum": "e00af8d49ea76d3e6fc94b720fd9dd2fc71232af" + }, + "require": { + "drupal/core": "^8.8 || ^9 || ^10 || ^11" + }, + "type": "drupal-module", + "extra": { + "drupal": { + "version": "8.x-1.3", + "datestamp": "1723559494", + "security-coverage": { + "status": "covered", + "message": "Covered by Drupal's security advisory policy" + } + } + }, + "notification-url": "https://packages.drupal.org/8/downloads", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "DieterHolvoet", + "homepage": "https://www.drupal.org/user/3567222" + }, + { + "name": "ibustos", + "homepage": "https://www.drupal.org/user/2476894" + } + ], + "description": "Enables users to sort views by using drag and drop", + "homepage": "https://www.drupal.org/project/sortableviews", + "support": { + "source": "https://git.drupalcode.org/project/sortableviews" + } + }, { "name": "drupal/token", "version": "1.14.0", diff --git a/config/sync/core.entity_form_display.node.basic_page.default.yml b/config/sync/core.entity_form_display.node.basic_page.default.yml index 3b6ff7785f..12cfde2bd3 100644 --- a/config/sync/core.entity_form_display.node.basic_page.default.yml +++ b/config/sync/core.entity_form_display.node.basic_page.default.yml @@ -169,7 +169,26 @@ content: region: content settings: placeholder: '' - third_party_settings: { } + third_party_settings: + conditional_fields: + 57036002-dda5-4980-9704-719cb0ab3a40: + entity_type: node + bundle: basic_page + dependee: field_page_type + settings: + state: '!visible' + reset: false + condition: value + grouping: AND + values_set: 1 + value: '' + values: { } + value_form: + - + target_id: '10' + effect: show + effect_options: { } + selector: '' field_benefits_callout_button: type: string_textfield weight: 46 diff --git a/config/sync/core.extension.yml b/config/sync/core.extension.yml index 455f59ecb5..63a9c13a5f 100644 --- a/config/sync/core.extension.yml +++ b/config/sync/core.extension.yml @@ -79,6 +79,7 @@ module: settings_tray: 0 simple_sitemap: 0 simplify_menu: 0 + sortableviews: 0 system: 0 taxonomy: 0 telephone: 0 diff --git a/config/sync/field.field.node.basic_page.field_benefit_search_weight.yml b/config/sync/field.field.node.basic_page.field_benefit_search_weight.yml index 1e6c92e73c..f51d2b67c4 100644 --- a/config/sync/field.field.node.basic_page.field_benefit_search_weight.yml +++ b/config/sync/field.field.node.basic_page.field_benefit_search_weight.yml @@ -16,8 +16,8 @@ translatable: false default_value: { } default_value_callback: '' settings: - min: -50 - max: 50 + min: 0 + max: null prefix: '' suffix: '' field_type: integer diff --git a/config/sync/user.role.content_administrator.yml b/config/sync/user.role.content_administrator.yml index 2d84e1d055..f3b438f12d 100644 --- a/config/sync/user.role.content_administrator.yml +++ b/config/sync/user.role.content_administrator.yml @@ -42,6 +42,7 @@ dependencies: - taxonomy - toolbar - usa_content_moderation_notifications + - usagov_benefit_category_search id: content_administrator label: 'Content Administrator' weight: 5 @@ -63,6 +64,7 @@ permissions: - 'administer sitemap settings' - 'administer taxonomy' - 'break content lock' + - 'change benefit page weights' - 'create agency_synonym content' - 'create audio media' - 'create basic_page content' diff --git a/config/sync/views.view.manage_benefits_search_sort.yml b/config/sync/views.view.manage_benefits_search_sort.yml new file mode 100644 index 0000000000..b8504b6e6b --- /dev/null +++ b/config/sync/views.view.manage_benefits_search_sort.yml @@ -0,0 +1,737 @@ +uuid: 2e4150e7-b4bd-48c2-b217-d4b0045a9adf +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_benefits_category + - node.type.basic_page + - system.menu.admin + - taxonomy.vocabulary.benefits_category + - taxonomy.vocabulary.page_type + content: + - 'taxonomy_term:page_type:24ada0c8-3397-4b5f-a8bc-55adff307199' + module: + - node + - sortableviews + - taxonomy + - user +id: manage_benefits_search_sort +label: 'Manage Benefits Search Sort' +module: views +description: 'Provides pages for users to use a draggable UI for setting search weight.' +tag: '' +base_table: node_field_data +base_field: nid +display: + default: + id: default + display_title: Default + display_plugin: default + position: 0 + display_options: + title: 'Manage Benefits Category Sort, English' + fields: + sortable_handle: + id: sortable_handle + table: node_field_data + field: sortable_handle + relationship: none + group_type: group + admin_label: '' + entity_type: node + plugin_id: sortable_views_handle + label: '' + exclude: false + 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 + status: + id: status + table: node_field_data + field: status + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: status + plugin_id: field + 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: boolean + settings: + format: custom + format_custom_false: Unpublisehd + format_custom_true: Published + 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 + title: + id: title + table: node_field_data + field: title + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: title + plugin_id: field + label: Title + exclude: false + alter: + alter_text: true + text: '{{ title }} ({{ status }})' + 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: false + ellipsis: false + 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: true + click_sort_column: value + type: string + settings: + link_to_entity: 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 + field_benefits_category: + id: field_benefits_category + table: node__field_benefits_category + field: field_benefits_category + relationship: none + group_type: group + admin_label: '' + plugin_id: field + label: 'Benefits Category' + exclude: false + 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: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: target_id + type: entity_reference_label + settings: + link: false + group_column: target_id + 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 + pager: + type: none + options: + offset: 0 + exposed_form: + type: basic + options: + submit_button: Apply + reset_button: false + reset_button_label: Reset + exposed_sorts_label: 'Sort by' + expose_sort_order: true + sort_asc_label: Asc + sort_desc_label: Desc + access: + type: perm + options: + perm: 'change benefit page weights' + cache: + type: tag + options: { } + empty: { } + sorts: + field_benefit_search_weight_value: + id: field_benefit_search_weight_value + table: node__field_benefit_search_weight + field: field_benefit_search_weight_value + relationship: none + group_type: group + admin_label: '' + plugin_id: standard + order: DESC + expose: + label: '' + field_identifier: '' + exposed: false + arguments: { } + filters: + type: + id: type + table: node_field_data + field: type + entity_type: node + entity_field: type + plugin_id: bundle + value: + basic_page: basic_page + field_page_type_target_id: + id: field_page_type_target_id + table: node__field_page_type + field: field_page_type_target_id + relationship: none + group_type: group + admin_label: '' + plugin_id: taxonomy_index_tid + operator: or + value: + 10: 10 + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + vid: page_type + type: select + hierarchy: false + limit: true + error_message: true + field_benefits_category_target_id: + id: field_benefits_category_target_id + table: node__field_benefits_category + field: field_benefits_category_target_id + relationship: none + group_type: group + admin_label: '' + plugin_id: taxonomy_index_tid + operator: 'not empty' + value: { } + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + vid: benefits_category + type: textfield + hierarchy: false + limit: true + error_message: true + langcode: + id: langcode + table: node + field: langcode + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: langcode + plugin_id: language + operator: in + value: + en: en + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + style: + type: sortable_table + options: + grouping: { } + row_class: '' + default_row_class: true + columns: + title: title + field_benefits_category: field_benefits_category + default: '-1' + info: + title: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' + field_benefits_category: + align: '' + separator: '' + empty_column: false + responsive: '' + override: false + sticky: false + summary: '' + empty_table: false + caption: '' + description: '' + weight_field: field_benefit_search_weight + row: + type: fields + query: + type: views_query + options: + query_comment: '' + disable_sql_rewrite: false + distinct: true + replica: false + query_tags: { } + relationships: { } + header: + save_sortable_changes: + id: save_sortable_changes + table: node_field_data + field: save_sortable_changes + relationship: none + group_type: group + admin_label: '' + entity_type: node + plugin_id: save_sortable_changes + empty: false + footer: + save_sortable_changes: + id: save_sortable_changes + table: node_field_data + field: save_sortable_changes + relationship: none + group_type: group + admin_label: '' + entity_type: node + plugin_id: save_sortable_changes + empty: false + display_extenders: { } + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - 'user.node_grants:view' + - user.permissions + tags: + - 'config:field.storage.node.field_benefits_category' + page_en: + id: page_en + display_title: 'Sort English' + display_plugin: page + position: 1 + display_options: + display_description: '' + display_extenders: { } + path: admin/manage-benefits-search-sort/en + menu: + type: normal + title: 'Manage English Search Results' + description: '' + weight: 0 + expanded: false + menu_name: admin + parent: usagov_benefit_category_search.admin + context: '0' + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - 'user.node_grants:view' + - user.permissions + tags: + - 'config:field.storage.node.field_benefits_category' + page_es: + id: page_es + display_title: 'Sort Spanish' + display_plugin: page + position: 1 + display_options: + title: 'Manage Benefits Category Sort, Spanish' + filters: + type: + id: type + table: node_field_data + field: type + entity_type: node + entity_field: type + plugin_id: bundle + value: + basic_page: basic_page + field_page_type_target_id: + id: field_page_type_target_id + table: node__field_page_type + field: field_page_type_target_id + relationship: none + group_type: group + admin_label: '' + plugin_id: taxonomy_index_tid + operator: or + value: + 10: 10 + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + vid: page_type + type: select + hierarchy: false + limit: true + error_message: true + field_benefits_category_target_id: + id: field_benefits_category_target_id + table: node__field_benefits_category + field: field_benefits_category_target_id + relationship: none + group_type: group + admin_label: '' + plugin_id: taxonomy_index_tid + operator: 'not empty' + value: { } + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + reduce_duplicates: false + vid: benefits_category + type: textfield + hierarchy: false + limit: true + error_message: true + langcode: + id: langcode + table: node + field: langcode + relationship: none + group_type: group + admin_label: '' + entity_type: node + entity_field: langcode + plugin_id: language + operator: in + value: + es: es + group: 1 + exposed: false + expose: + operator_id: '' + label: '' + description: '' + use_operator: false + operator: '' + operator_limit_selection: false + operator_list: { } + identifier: '' + required: false + remember: false + multiple: false + remember_roles: + authenticated: authenticated + reduce: false + is_grouped: false + group_info: + label: '' + description: '' + identifier: '' + optional: true + widget: select + multiple: false + remember: false + default_group: All + default_group_multiple: { } + group_items: { } + filter_groups: + operator: AND + groups: + 1: AND + defaults: + title: false + filters: false + filter_groups: false + display_description: '' + display_extenders: { } + path: admin/manage-benefits-search-sort/es + menu: + type: normal + title: 'Manage Spanish Search Results' + description: '' + weight: 0 + expanded: false + menu_name: admin + parent: usagov_benefit_category_search.admin + context: '0' + cache_metadata: + max-age: -1 + contexts: + - 'languages:language_content' + - 'languages:language_interface' + - 'user.node_grants:view' + - user.permissions + tags: + - 'config:field.storage.node.field_benefits_category' diff --git a/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.module b/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.module index 4e48da59ef..d150088c08 100644 --- a/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.module +++ b/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.module @@ -1,7 +1,9 @@ getParameter('node'); + if ($node->getType() !== 'basic_page') { + return; + } + + $pageType = usa_twig_vars_get_page_type($node); + if ($pageType !== 'Benefits Category Search') { + return; + } + + $view = match($node->language()->getId()) { + 'en' => 'view.manage_benefits_search_sort.page_en', + 'es' => 'view.manage_benefits_search_sort.page_es' + }; + + $userCurrent = \Drupal::currentUser(); + $url = Url::fromRoute($view); + $data['tabs'][0]['usagov_benefit_category_search.manage_sort'] = [ + '#access' => $url->access($userCurrent), + '#theme' => 'menu_local_task', + '#acive' => FALSE, + '#link' => [ + 'title' => 'Sort Results', + 'url' => $url, + ], + '#weight' => 20, + ]; + + $cacheability->addCacheContexts([ + 'user.permissions', + ]); +} diff --git a/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.permissions.yml b/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.permissions.yml new file mode 100644 index 0000000000..25622dea85 --- /dev/null +++ b/web/modules/custom/usagov_benefit_category_search/usagov_benefit_category_search.permissions.yml @@ -0,0 +1,3 @@ +change benefit page weights: + title: 'Change Benefit Weights' + description: 'Access the view to manage the order of benefit search results'