diff --git a/modules/helfi_tpr_config/config/install/core.entity_form_display.tpr_service.tpr_service.default.yml b/modules/helfi_tpr_config/config/install/core.entity_form_display.tpr_service.tpr_service.default.yml index 76ec8b207..e51c694b3 100644 --- a/modules/helfi_tpr_config/config/install/core.entity_form_display.tpr_service.tpr_service.default.yml +++ b/modules/helfi_tpr_config/config/install/core.entity_form_display.tpr_service.tpr_service.default.yml @@ -30,7 +30,7 @@ content: third_party_settings: { } errand_services: type: readonly_field_widget - weight: 7 + weight: 8 region: content settings: label: above @@ -40,7 +40,7 @@ content: third_party_settings: { } field_content: type: paragraphs - weight: 9 + weight: 11 region: content settings: title: Paragraph @@ -59,7 +59,7 @@ content: third_party_settings: { } field_lower_content: type: paragraphs - weight: 11 + weight: 15 region: content settings: title: Paragraph @@ -78,14 +78,14 @@ content: third_party_settings: { } field_metatags: type: metatag_firehose - weight: 8 + weight: 10 region: content settings: sidebar: false third_party_settings: { } field_sidebar_content: type: paragraphs - weight: 10 + weight: 12 region: content settings: title: Paragraph @@ -104,7 +104,7 @@ content: third_party_settings: { } has_unit: type: readonly_field_widget - weight: 27 + weight: 18 region: content settings: label: above @@ -112,9 +112,16 @@ content: formatter_settings: { } show_description: false third_party_settings: { } + hide_service_points: + type: boolean_checkbox + weight: 14 + region: content + settings: + display_label: true + third_party_settings: { } hide_sidebar_navigation: type: boolean_checkbox - weight: 21 + weight: 16 region: content settings: display_label: true @@ -128,7 +135,7 @@ content: third_party_settings: { } links: type: readonly_field_widget - weight: 6 + weight: 7 region: content settings: label: above @@ -156,7 +163,7 @@ content: third_party_settings: { } name_synonyms: type: readonly_field_widget - weight: 26 + weight: 17 region: content settings: label: above @@ -166,13 +173,13 @@ content: third_party_settings: { } path: type: path - weight: 7 + weight: 9 region: content settings: { } third_party_settings: { } service_id: type: readonly_field_widget - weight: 28 + weight: 19 region: content settings: label: above @@ -181,7 +188,7 @@ content: show_description: false third_party_settings: { } simple_sitemap: - weight: 10 + weight: 13 region: content settings: { } third_party_settings: { } diff --git a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.default.yml b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.default.yml index 2339489c3..357442129 100644 --- a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.default.yml +++ b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.default.yml @@ -108,6 +108,7 @@ content: hidden: created: true has_unit: true + hide_service_points: true langcode: true name_synonyms: true service_id: true diff --git a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser.yml b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser.yml index 9d2a33016..e42cb5074 100644 --- a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser.yml +++ b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser.yml @@ -46,6 +46,7 @@ hidden: field_metatags: true field_sidebar_content: true has_unit: true + hide_service_points: true langcode: true links: true name_synonyms: true diff --git a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser_search_result.yml b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser_search_result.yml index 040aea576..4d1213a8a 100644 --- a/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser_search_result.yml +++ b/modules/helfi_tpr_config/config/install/core.entity_view_display.tpr_service.tpr_service.teaser_search_result.yml @@ -90,6 +90,7 @@ hidden: field_metatags: true field_sidebar_content: true has_unit: true + hide_service_points: true langcode: true links: true name_override: true diff --git a/modules/helfi_tpr_config/helfi_tpr_config.install b/modules/helfi_tpr_config/helfi_tpr_config.install index 76fde69ef..b93809a86 100644 --- a/modules/helfi_tpr_config/helfi_tpr_config.install +++ b/modules/helfi_tpr_config/helfi_tpr_config.install @@ -7,6 +7,8 @@ declare(strict_types=1); +use Drupal\Core\Field\BaseFieldDefinition; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\linkit\Entity\Profile; /** @@ -252,3 +254,25 @@ function helfi_tpr_config_update_9042(): void { \Drupal::service('helfi_platform_config.config_update_helper') ->update('helfi_tpr_config'); } + +/** + * UHF-8717: Add a field to tpr_service and re-import configs. + */ +function helfi_tpr_config_update_9043() : void { + $fields = []; + $fields['hide_service_points'] = BaseFieldDefinition::create('boolean') + ->setLabel(new TranslatableMarkup('Hide service points')) + ->setDescription(new TranslatableMarkup('Hide automatic service units listing')) + ->setTranslatable(TRUE) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + + foreach ($fields as $name => $field) { + \Drupal::entityDefinitionUpdateManager() + ->installFieldStorageDefinition($name, 'tpr_service', 'helfi_tpr_config', $field); + } + + // Re-import 'helfi_tpr_config' configuration. + \Drupal::service('helfi_platform_config.config_update_helper') + ->update('helfi_tpr_config'); +} diff --git a/modules/helfi_tpr_config/helfi_tpr_config.module b/modules/helfi_tpr_config/helfi_tpr_config.module index 353562b06..8d8c26e4c 100644 --- a/modules/helfi_tpr_config/helfi_tpr_config.module +++ b/modules/helfi_tpr_config/helfi_tpr_config.module @@ -7,7 +7,10 @@ declare(strict_types=1); +use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Render\Element; +use Drupal\Core\StringTranslation\TranslatableMarkup; use Drupal\Core\Url; use Drupal\helfi_platform_config\DTO\ParagraphTypeCollection; use Drupal\helfi_tpr_config\Entity\ServiceList; @@ -424,6 +427,9 @@ function template_preprocess_tpr_service_lower_content(array &$variables) : void } if (isset($variables['elements']['#tpr_service'])) { $variables['entity'] = $variables['elements']['#tpr_service']; + // Get 'hide_service_points' field value and pass it to the template. + $hide_service_points = $variables['entity']->get('hide_service_points')->value; + $variables['hide_service_points'] = boolval($hide_service_points); } } @@ -472,3 +478,20 @@ function helfi_tpr_config_form_views_exposed_form_alter(&$form, $form_state) : v ->value; } } + +/** + * Implements hook_entity_base_field_info(). + */ +function helfi_tpr_config_entity_base_field_info(EntityTypeInterface $entity_type) : array { + $fields = []; + + if ($entity_type->id() === 'tpr_service') { + $fields['hide_service_points'] = BaseFieldDefinition::create('boolean') + ->setLabel(new TranslatableMarkup('Hide service points')) + ->setDescription(new TranslatableMarkup('Hide automatic service units listing')) + ->setTranslatable(TRUE) + ->setDisplayConfigurable('form', TRUE) + ->setDisplayConfigurable('view', TRUE); + } + return $fields; +}