Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

[SD-112] Resolve the issue of the site form layout crashing. #157

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ dependencies:
- entity_browser.browser.tide_image_browser
- field.field.taxonomy_term.sites.field_acknowledgement_to_country
- field.field.taxonomy_term.sites.field_additional_comment
- field.field.taxonomy_term.sites.field_bottom_corner_graphic
- field.field.taxonomy_term.sites.field_print_friendly_logo
- field.field.taxonomy_term.sites.field_prominence_ack_to_country
- field.field.taxonomy_term.sites.field_show_table_of_contents
- field.field.taxonomy_term.sites.field_site_domains
- field.field.taxonomy_term.sites.field_site_favicon
- field.field.taxonomy_term.sites.field_site_feature_flags
- field.field.taxonomy_term.sites.field_site_footer_logos
- field.field.taxonomy_term.sites.field_site_footer_menu
- field.field.taxonomy_term.sites.field_site_footer_text
Expand All @@ -19,16 +22,21 @@ dependencies:
- field.field.taxonomy_term.sites.field_site_show_exit_site
- field.field.taxonomy_term.sites.field_site_slogan
- field.field.taxonomy_term.sites.field_site_social_links
- field.field.taxonomy_term.sites.field_site_theme_values
- field.field.taxonomy_term.sites.field_site_twitter_image
- field.field.taxonomy_term.sites.field_title_of_table_of_contents
- field.field.taxonomy_term.sites.field_top_corner_graphic
- image.style.thumbnail
- taxonomy.vocabulary.sites
module:
- entity_browser
- field_group
- file
- key_value_field
- link
- maxlength
- paragraphs
- svg_image
- text
third_party_settings:
field_group:
Expand All @@ -39,7 +47,7 @@ third_party_settings:
label: 'Table of contents'
region: content
parent_name: ''
weight: 19
weight: 18
format_type: details
format_settings:
classes: ''
Expand All @@ -48,14 +56,75 @@ third_party_settings:
open: false
description: ''
required_fields: true
group_site_theme_values:
children:
- field_site_theme_values
label: 'Site theme values'
region: content
parent_name: ''
weight: 19
format_type: details
format_settings:
classes: ''
show_empty_fields: false
id: tide-site-theming-fileds
open: false
required_fields: true
effect: none
group_site_feature_flag_values:
children:
- field_site_feature_flags
label: 'Site feature flag values'
region: content
parent_name: ''
weight: 20
format_type: details
format_settings:
classes: ''
show_empty_fields: false
id: tide-feature-flag-fields
open: false
required_fields: true
effect: none
group_site_favicon_value:
children:
- field_site_favicon
label: 'Site favicon value'
region: content
parent_name: ''
weight: 21
format_type: details
format_settings:
classes: ''
show_empty_fields: false
id: tide-site-favicon-field
open: false
required_fields: true
effect: none
group_site_header_corner_graphic:
children:
- field_top_corner_graphic
- field_bottom_corner_graphic
label: 'Site header corner graphics'
region: content
parent_name: ''
weight: 22
format_type: details
format_settings:
classes: ''
show_empty_fields: false
id: tide-site-header-corner-graphics
open: false
required_fields: true
effect: none
id: taxonomy_term.sites.default
targetEntityType: taxonomy_term
bundle: sites
mode: default
content:
field_acknowledgement_to_country:
type: string_textarea
weight: 13
weight: 12
region: content
settings:
rows: 5
Expand All @@ -69,6 +138,14 @@ content:
rows: 5
placeholder: ''
third_party_settings: { }
field_bottom_corner_graphic:
type: image_image
weight: 1
region: content
settings:
progress_indicator: throbber
preview_image_style: thumbnail
third_party_settings: { }
field_print_friendly_logo:
type: file_generic
weight: 3
Expand All @@ -78,7 +155,7 @@ content:
third_party_settings: { }
field_prominence_ack_to_country:
type: string_textarea
weight: 14
weight: 13
region: content
settings:
rows: 5
Expand All @@ -104,6 +181,30 @@ content:
maxlength_js_label: 'Content limited to @limit characters, remaining: <strong>@remaining</strong>'
maxlength_js_enforce: false
maxlength_js_truncate_html: false
field_site_favicon:
type: image_image
weight: 0
region: content
settings:
progress_indicator: throbber
preview_image_style: thumbnail
third_party_settings: { }
field_site_feature_flags:
type: key_value_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
key_label: Key
value_label: Value
description_label: Description
description_rows: 5
key_size: 60
key_placeholder: ''
description_enabled: true
description_placeholder: ''
third_party_settings: { }
field_site_footer_logos:
type: entity_reference_paragraphs
weight: 9
Expand Down Expand Up @@ -165,7 +266,7 @@ content:
third_party_settings: { }
field_site_og_image:
type: entity_browser_entity_reference
weight: 15
weight: 14
region: content
settings:
entity_browser: tide_image_browser
Expand Down Expand Up @@ -195,7 +296,7 @@ content:
third_party_settings: { }
field_site_social_links:
type: link_default
weight: 17
weight: 16
region: content
settings:
placeholder_url: 'https://example.com/Social'
Expand All @@ -204,9 +305,25 @@ content:
maxlength:
maxlength_js: 35
maxlength_js_label: 'Link text limited to @limit characters, remaining: <strong>@remaining</strong>'
field_site_theme_values:
type: key_value_textfield
weight: 0
region: content
settings:
size: 60
placeholder: ''
key_label: Key
value_label: Value
description_label: Description
description_rows: 5
key_size: 60
key_placeholder: ''
description_enabled: true
description_placeholder: ''
third_party_settings: { }
field_site_twitter_image:
type: entity_browser_entity_reference
weight: 16
weight: 15
region: content
settings:
entity_browser: tide_image_browser
Expand All @@ -227,6 +344,14 @@ content:
size: 60
placeholder: ''
third_party_settings: { }
field_top_corner_graphic:
type: image_image
weight: 0
region: content
settings:
progress_indicator: throbber
preview_image_style: thumbnail
third_party_settings: { }
name:
type: string_textfield
weight: 0
Expand All @@ -237,7 +362,7 @@ content:
third_party_settings: { }
status:
type: boolean_checkbox
weight: 18
weight: 17
region: content
settings:
display_label: true
Expand Down
1 change: 1 addition & 0 deletions tide_site.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:
- drupal:text
- drupal:user
- drupal:path_alias
- key_value_field:key_value_field
- pathauto:pathauto
- dpc-sdp:tide_core
- dpc-sdp:tide_media
Expand Down
25 changes: 18 additions & 7 deletions tide_site.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Install file for tide_site.
*/

use Drupal\Component\Utility\NestedArray;

/**
* Implements hook_install().
*/
Expand All @@ -22,7 +24,7 @@ function tide_site_install() {
* New field taxonomy image logo.
*/
function tide_site_update_10001() {
module_load_include('inc', 'tide_core', 'includes/helpers');
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't use deprecated functions.

\Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers');
$config_location = [\Drupal::service('extension.list.module')->getPath('tide_site') . '/config/install'];

$configs = [
Expand All @@ -42,11 +44,20 @@ function tide_site_update_10001() {
'core.entity_view_display.taxonomy_term.sites.default',
];
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();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arbitrarily overwriting active configurations may lead to layout inconsistencies.

$rewrite = _tide_read_config($form_config, $config_location, FALSE);
$display_config_entity = \Drupal::configFactory()->getEditable($form_config);
$original_config = $display_config_entity->getRawData();
$rewritten_config = NestedArray::mergeDeep($original_config, $rewrite);
if ($rewritten_config['dependencies']) {
Copy link
Collaborator Author

@vincent-gao vincent-gao Aug 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I need to handle the dependencies data seems to be due to a bug with NestedArray::mergeDeep (I'm not entirely sure), which causes data duplication within dependencies. I might need to check Drupal.org for more information it's not a bug, unfortunately.

$dependencies = $rewritten_config['dependencies'];
foreach ($dependencies as $type => $items) {
$uniqueItems = array_unique($items);
sort($uniqueItems);
$dependencies[$type] = $uniqueItems;
}
$rewritten_config['dependencies'] = $dependencies;
}
$display_config_entity->setData($rewritten_config);
$display_config_entity->save();
}
}
Loading