Skip to content

Commit

Permalink
Merge 465089f into af36011
Browse files Browse the repository at this point in the history
  • Loading branch information
dire authored Sep 19, 2023
2 parents af36011 + 465089f commit bad38b1
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ content:
third_party_settings: { }
errand_services:
type: readonly_field_widget
weight: 7
weight: 8
region: content
settings:
label: above
Expand All @@ -40,7 +40,7 @@ content:
third_party_settings: { }
field_content:
type: paragraphs
weight: 9
weight: 11
region: content
settings:
title: Paragraph
Expand All @@ -59,7 +59,7 @@ content:
third_party_settings: { }
field_lower_content:
type: paragraphs
weight: 11
weight: 15
region: content
settings:
title: Paragraph
Expand All @@ -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
Expand All @@ -104,17 +104,24 @@ content:
third_party_settings: { }
has_unit:
type: readonly_field_widget
weight: 27
weight: 18
region: content
settings:
label: above
formatter_type: null
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
Expand All @@ -128,7 +135,7 @@ content:
third_party_settings: { }
links:
type: readonly_field_widget
weight: 6
weight: 7
region: content
settings:
label: above
Expand Down Expand Up @@ -156,7 +163,7 @@ content:
third_party_settings: { }
name_synonyms:
type: readonly_field_widget
weight: 26
weight: 17
region: content
settings:
label: above
Expand All @@ -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
Expand All @@ -181,7 +188,7 @@ content:
show_description: false
third_party_settings: { }
simple_sitemap:
weight: 10
weight: 13
region: content
settings: { }
third_party_settings: { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ content:
hidden:
created: true
has_unit: true
hide_service_points: true
langcode: true
name_synonyms: true
service_id: true
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions modules/helfi_tpr_config/helfi_tpr_config.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

declare(strict_types=1);

use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\linkit\Entity\Profile;

/**
Expand Down Expand Up @@ -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');
}
23 changes: 23 additions & 0 deletions modules/helfi_tpr_config/helfi_tpr_config.module
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}

0 comments on commit bad38b1

Please sign in to comment.