Skip to content

Commit

Permalink
[SDPAP-8872]added accordion description (#473)
Browse files Browse the repository at this point in the history
* added hook update

* added file
  • Loading branch information
yeniatencio authored Feb 13, 2024
1 parent e15780e commit 4c292f1
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,40 @@ 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions tide_core.install
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

0 comments on commit 4c292f1

Please sign in to comment.