From 4c292f142357b1971dc9addb4b309b011abd435b Mon Sep 17 00:00:00 2001 From: Yeni Atencio <47239456+yeniatencio@users.noreply.github.com> Date: Wed, 14 Feb 2024 08:32:02 +1100 Subject: [PATCH] [SDPAP-8872]added accordion description (#473) * added hook update * added file --- ...rm_display.paragraph.accordion.default.yml | 28 ++++++++++++---- ...ew_display.paragraph.accordion.default.yml | 15 +++++++-- ...ew_display.paragraph.accordion.preview.yml | 14 ++++---- ...ragraph.accordion.field_paragraph_body.yml | 25 +++++++++++++++ tide_core.install | 32 +++++++++++++++++++ 5 files changed, 98 insertions(+), 16 deletions(-) create mode 100644 config/install/field.field.paragraph.accordion.field_paragraph_body.yml diff --git a/config/install/core.entity_form_display.paragraph.accordion.default.yml b/config/install/core.entity_form_display.paragraph.accordion.default.yml index cf5b07694..00740543a 100644 --- a/config/install/core.entity_form_display.paragraph.accordion.default.yml +++ b/config/install/core.entity_form_display.paragraph.accordion.default.yml @@ -4,11 +4,12 @@ dependencies: config: - field.field.paragraph.accordion.field_paragraph_accordion - field.field.paragraph.accordion.field_paragraph_accordion_style + - field.field.paragraph.accordion.field_paragraph_body - field.field.paragraph.accordion.field_paragraph_title - paragraphs.paragraphs_type.accordion module: - - content_moderation - paragraphs + - text id: paragraph.accordion.default targetEntityType: paragraph bundle: accordion @@ -17,36 +18,49 @@ content: field_paragraph_accordion: type: paragraphs weight: 3 + region: content settings: title: 'Accordion items' title_plural: 'Accordion content' edit_mode: closed closed_mode: preview autocollapse: all + closed_mode_threshold: 0 add_mode: button form_display_mode: default default_paragraph_type: accordion_content + default_paragraph_count: 1 + features: + collapse_edit_all: collapse_edit_all + duplicate: duplicate third_party_settings: { } - region: content field_paragraph_accordion_style: + type: options_buttons weight: 2 + region: content settings: { } third_party_settings: { } - type: options_buttons - region: content - field_paragraph_title: + field_paragraph_body: + type: text_textarea weight: 1 + region: content settings: - size: 60 + rows: 5 placeholder: '' third_party_settings: { } + field_paragraph_title: type: string_textfield + weight: 0 region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } moderation_state: type: moderation_state_default weight: 0 - settings: { } region: content + settings: { } third_party_settings: { } hidden: created: true diff --git a/config/install/core.entity_view_display.paragraph.accordion.default.yml b/config/install/core.entity_view_display.paragraph.accordion.default.yml index 1431a294b..4613cfe08 100644 --- a/config/install/core.entity_view_display.paragraph.accordion.default.yml +++ b/config/install/core.entity_view_display.paragraph.accordion.default.yml @@ -4,10 +4,12 @@ dependencies: config: - field.field.paragraph.accordion.field_paragraph_accordion - field.field.paragraph.accordion.field_paragraph_accordion_style + - field.field.paragraph.accordion.field_paragraph_body - field.field.paragraph.accordion.field_paragraph_title - paragraphs.paragraphs_type.accordion module: - entity_reference_revisions + - text id: paragraph.accordion.default targetEntityType: paragraph bundle: accordion @@ -15,20 +17,27 @@ mode: default content: field_paragraph_accordion: type: entity_reference_revisions_entity_view - weight: 1 label: hidden settings: view_mode: default link: '' third_party_settings: { } + weight: 1 + region: content + field_paragraph_body: + type: text_default + label: above + settings: { } + third_party_settings: { } + weight: 2 region: content field_paragraph_title: - weight: 0 + type: string label: hidden settings: link_to_entity: false third_party_settings: { } - type: string + weight: 0 region: content hidden: field_paragraph_accordion_style: true diff --git a/config/install/core.entity_view_display.paragraph.accordion.preview.yml b/config/install/core.entity_view_display.paragraph.accordion.preview.yml index ede1c4007..84e9bdee0 100644 --- a/config/install/core.entity_view_display.paragraph.accordion.preview.yml +++ b/config/install/core.entity_view_display.paragraph.accordion.preview.yml @@ -5,6 +5,7 @@ dependencies: - core.entity_view_mode.paragraph.preview - field.field.paragraph.accordion.field_paragraph_accordion - field.field.paragraph.accordion.field_paragraph_accordion_style + - field.field.paragraph.accordion.field_paragraph_body - field.field.paragraph.accordion.field_paragraph_title - paragraphs.paragraphs_type.accordion module: @@ -17,24 +18,25 @@ mode: preview content: field_paragraph_accordion: type: paragraph_summary - weight: 2 label: inline settings: { } third_party_settings: { } + weight: 2 region: content field_paragraph_accordion_style: type: list_default - weight: 1 - region: content label: inline settings: { } third_party_settings: { } + weight: 1 + region: content field_paragraph_title: type: string - weight: 0 - region: content label: hidden settings: link_to_entity: false third_party_settings: { } -hidden: { } + weight: 0 + region: content +hidden: + field_paragraph_body: true diff --git a/config/install/field.field.paragraph.accordion.field_paragraph_body.yml b/config/install/field.field.paragraph.accordion.field_paragraph_body.yml new file mode 100644 index 000000000..e6d72fc6f --- /dev/null +++ b/config/install/field.field.paragraph.accordion.field_paragraph_body.yml @@ -0,0 +1,25 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.paragraph.field_paragraph_body + - paragraphs.paragraphs_type.accordion + module: + - allowed_formats + - text +third_party_settings: + allowed_formats: + allowed_formats: { } +id: paragraph.accordion.field_paragraph_body +field_name: field_paragraph_body +entity_type: paragraph +bundle: accordion +label: 'Accordion description' +description: 'Add accordion description to display below accordion title.' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + allowed_formats: { } +field_type: text_long diff --git a/tide_core.install b/tide_core.install index b7a72bcc1..c3942a07e 100644 --- a/tide_core.install +++ b/tide_core.install @@ -92,3 +92,35 @@ function tide_core_update_10002() { $approver->grantPermission('tide node bulk update'); $approver->save(); } + +/** + * Add description field to accordion. + */ +function tide_core_update_10003() { + module_load_include('inc', 'tide_core', 'includes/helpers'); + $configs = [ + 'field.field.paragraph.accordion.field_paragraph_body' => 'field_config', + ]; + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_core') . '/config/install']; + // Check if field already exported to config/sync. + foreach ($configs as $config => $type) { + $config_read = _tide_read_config($config, $config_location, TRUE); + $storage = \Drupal::entityTypeManager()->getStorage($type); + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + + $form_configs = [ + 'core.entity_form_display.paragraph.accordion.default', + 'core.entity_view_display.paragraph.accordion.default', + 'core.entity_view_display.paragraph.accordion.preview', + ]; + foreach ($form_configs as $form_config) { + $config = \Drupal::configFactory()->getEditable($form_config); + $config_read = _tide_read_config($form_config, $config_location, FALSE); + $config->set('dependencies', $config_read['dependencies']); + $config->set('content', $config_read['content']); + $config->set('hidden', $config_read['hidden']); + $config->save(); + } +}