diff --git a/config/install/core.entity_form_display.taxonomy_term.sites.default.yml b/config/install/core.entity_form_display.taxonomy_term.sites.default.yml index 8af48aab..503b2868 100644 --- a/config/install/core.entity_form_display.taxonomy_term.sites.default.yml +++ b/config/install/core.entity_form_display.taxonomy_term.sites.default.yml @@ -8,7 +8,9 @@ dependencies: - 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_short_name - field.field.taxonomy_term.sites.field_show_table_of_contents + - field.field.taxonomy_term.sites.field_site_app_icon - 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 @@ -47,7 +49,7 @@ third_party_settings: label: 'Table of contents' region: content parent_name: '' - weight: 18 + weight: 19 format_type: details format_settings: classes: '' @@ -62,7 +64,7 @@ third_party_settings: label: 'Site theme values' region: content parent_name: '' - weight: 19 + weight: 20 format_type: details format_settings: classes: '' @@ -77,7 +79,7 @@ third_party_settings: label: 'Site feature flag values' region: content parent_name: '' - weight: 20 + weight: 21 format_type: details format_settings: classes: '' @@ -92,7 +94,7 @@ third_party_settings: label: 'Site favicon value' region: content parent_name: '' - weight: 21 + weight: 22 format_type: details format_settings: classes: '' @@ -108,7 +110,7 @@ third_party_settings: label: 'Site header corner graphics' region: content parent_name: '' - weight: 22 + weight: 24 format_type: details format_settings: classes: '' @@ -117,6 +119,22 @@ third_party_settings: open: false required_fields: true effect: none + group_site_app_icon: + children: + - field_site_app_icon + label: 'Site app icon' + region: content + parent_name: '' + weight: 23 + format_type: details + format_settings: + classes: '' + show_empty_fields: false + id: tide-site-app-icon + label_as_html: false + open: false + description: '' + required_fields: true id: taxonomy_term.sites.default targetEntityType: taxonomy_term bundle: sites @@ -124,7 +142,7 @@ mode: default content: field_acknowledgement_to_country: type: string_textarea - weight: 12 + weight: 13 region: content settings: rows: 5 @@ -155,12 +173,20 @@ content: third_party_settings: { } field_prominence_ack_to_country: type: string_textarea - weight: 13 + weight: 14 region: content settings: rows: 5 placeholder: '' third_party_settings: { } + field_short_name: + type: string_textfield + weight: 26 + region: content + settings: + size: 60 + placeholder: '' + third_party_settings: { } field_show_table_of_contents: type: boolean_checkbox weight: 17 @@ -168,6 +194,14 @@ content: settings: display_label: true third_party_settings: { } + field_site_app_icon: + type: image_image + weight: 25 + region: content + settings: + progress_indicator: throbber + preview_image_style: thumbnail + third_party_settings: { } field_site_domains: type: string_textarea weight: 4 @@ -266,7 +300,7 @@ content: third_party_settings: { } field_site_og_image: type: entity_browser_entity_reference - weight: 14 + weight: 15 region: content settings: entity_browser: tide_image_browser @@ -281,7 +315,7 @@ content: third_party_settings: { } field_site_show_exit_site: type: boolean_checkbox - weight: 11 + weight: 12 region: content settings: display_label: true @@ -296,7 +330,7 @@ content: third_party_settings: { } field_site_social_links: type: link_default - weight: 16 + weight: 17 region: content settings: placeholder_url: 'https://example.com/Social' @@ -323,7 +357,7 @@ content: third_party_settings: { } field_site_twitter_image: type: entity_browser_entity_reference - weight: 15 + weight: 16 region: content settings: entity_browser: tide_image_browser @@ -362,7 +396,7 @@ content: third_party_settings: { } status: type: boolean_checkbox - weight: 17 + weight: 18 region: content settings: display_label: true diff --git a/config/install/core.entity_view_display.taxonomy_term.sites.default.yml b/config/install/core.entity_view_display.taxonomy_term.sites.default.yml index 98416ecb..58587f0c 100644 --- a/config/install/core.entity_view_display.taxonomy_term.sites.default.yml +++ b/config/install/core.entity_view_display.taxonomy_term.sites.default.yml @@ -6,7 +6,9 @@ dependencies: - field.field.taxonomy_term.sites.field_additional_comment - 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_short_name - field.field.taxonomy_term.sites.field_show_table_of_contents + - field.field.taxonomy_term.sites.field_site_app_icon - field.field.taxonomy_term.sites.field_site_domains - field.field.taxonomy_term.sites.field_site_footer_logos - field.field.taxonomy_term.sites.field_site_footer_menu @@ -53,6 +55,14 @@ content: third_party_settings: { } weight: 12 region: content + field_short_name: + type: string + label: above + settings: + link_to_entity: false + third_party_settings: { } + weight: 18 + region: content field_show_table_of_contents: type: boolean label: above @@ -63,6 +73,21 @@ content: third_party_settings: { } weight: 15 region: content + field_site_app_icon: + type: image + label: above + settings: + image_link: '' + image_style: '' + image_loading: + attribute: lazy + svg_attributes: + width: null + height: null + svg_render_as_image: true + third_party_settings: { } + weight: 17 + region: content field_site_domains: type: basic_string label: above diff --git a/config/install/field.field.taxonomy_term.sites.field_short_name.yml b/config/install/field.field.taxonomy_term.sites.field_short_name.yml new file mode 100644 index 00000000..f42996b7 --- /dev/null +++ b/config/install/field.field.taxonomy_term.sites.field_short_name.yml @@ -0,0 +1,19 @@ +uuid: 02a974ba-fe98-4e96-918e-3509d82204c2 +langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.field_short_name + - taxonomy.vocabulary.sites +id: taxonomy_term.sites.field_short_name +field_name: field_short_name +entity_type: taxonomy_term +bundle: sites +label: 'Short name' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: { } +field_type: string diff --git a/config/install/field.field.taxonomy_term.sites.field_site_app_icon.yml b/config/install/field.field.taxonomy_term.sites.field_site_app_icon.yml new file mode 100644 index 00000000..a716618e --- /dev/null +++ b/config/install/field.field.taxonomy_term.sites.field_site_app_icon.yml @@ -0,0 +1,38 @@ +uuid: e662f8a0-1655-49a0-80b6-b568be653dd1 +langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.field_site_app_icon + - taxonomy.vocabulary.sites + module: + - image +id: taxonomy_term.sites.field_site_app_icon +field_name: field_site_app_icon +entity_type: taxonomy_term +bundle: sites +label: 'Site app icon' +description: '' +required: false +translatable: false +default_value: { } +default_value_callback: '' +settings: + handler: 'default:file' + handler_settings: { } + file_directory: '[date:custom:Y]-[date:custom:m]' + file_extensions: 'png gif jpg jpeg webp' + max_filesize: '' + max_resolution: 512x512 + min_resolution: 512x512 + alt_field: true + alt_field_required: true + title_field: false + title_field_required: false + default_image: + uuid: '' + alt: '' + title: '' + width: null + height: null +field_type: image diff --git a/config/install/field.field.taxonomy_term.sites.field_site_favicon.yml b/config/install/field.field.taxonomy_term.sites.field_site_favicon.yml index e2066c8b..601f16d5 100644 --- a/config/install/field.field.taxonomy_term.sites.field_site_favicon.yml +++ b/config/install/field.field.taxonomy_term.sites.field_site_favicon.yml @@ -22,8 +22,8 @@ settings: file_directory: '[date:custom:Y]-[date:custom:m]' file_extensions: 'png gif jpg jpeg' max_filesize: '' - max_resolution: '' - min_resolution: '' + max_resolution: 128x128 + min_resolution: 128x128 alt_field: true alt_field_required: true title_field: false diff --git a/config/install/field.storage.taxonomy_term.field_short_name.yml b/config/install/field.storage.taxonomy_term.field_short_name.yml new file mode 100644 index 00000000..494fbc44 --- /dev/null +++ b/config/install/field.storage.taxonomy_term.field_short_name.yml @@ -0,0 +1,21 @@ +uuid: 58e77572-512b-4cfd-b9f7-375e8db17bad +langcode: en +status: true +dependencies: + module: + - taxonomy +id: taxonomy_term.field_short_name +field_name: field_short_name +entity_type: taxonomy_term +type: string +settings: + max_length: 12 + case_sensitive: false + is_ascii: false +module: core +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/config/install/field.storage.taxonomy_term.field_site_app_icon.yml b/config/install/field.storage.taxonomy_term.field_site_app_icon.yml new file mode 100644 index 00000000..220ec3d6 --- /dev/null +++ b/config/install/field.storage.taxonomy_term.field_site_app_icon.yml @@ -0,0 +1,30 @@ +uuid: 2ab06add-41cb-4b33-8c68-91a484e76c57 +langcode: en +status: true +dependencies: + module: + - file + - image + - taxonomy +id: taxonomy_term.field_site_app_icon +field_name: field_site_app_icon +entity_type: taxonomy_term +type: image +settings: + target_type: file + display_field: false + display_default: false + uri_scheme: public + default_image: + uuid: '' + alt: '' + title: '' + width: null + height: null +module: image +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false +custom_storage: false diff --git a/config/optional/jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites.yml b/config/optional/jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites.yml index ac877a3b..b72806cf 100644 --- a/config/optional/jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites.yml +++ b/config/optional/jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites.yml @@ -116,3 +116,15 @@ resourceFields: enhancer: id: '' disabled: false + field_site_app_icon: + disabled: false + fieldName: field_site_app_icon + publicName: field_site_app_icon + enhancer: + id: '' + field_short_name: + disabled: false + fieldName: field_short_name + publicName: field_short_name + enhancer: + id: '' diff --git a/modules/tide_site_theming/tide_site_theming.install b/modules/tide_site_theming/tide_site_theming.install index 61fedd06..1e8641c4 100644 --- a/modules/tide_site_theming/tide_site_theming.install +++ b/modules/tide_site_theming/tide_site_theming.install @@ -5,6 +5,7 @@ * Install file. */ +use Drupal\Component\Utility\NestedArray; use Drupal\tide_site_theming\TideSiteThemingOperation; /** @@ -215,3 +216,79 @@ function tide_site_theming_update_8001() { } $config->save(); } + +/** + * Add site app icon and short name fields. + */ +function tide_site_theming_update_10001() { + $configs = [ + 'field.storage.taxonomy_term.field_short_name' => 'field_storage_config', + 'field.storage.taxonomy_term.field_site_app_icon' => 'field_storage_config', + 'field.field.taxonomy_term.sites.field_short_name' => 'field_config', + 'field.field.taxonomy_term.sites.field_site_app_icon' => 'field_config', + ]; + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_site') . '/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); + $id = $storage->getIDFromConfigName($config, $storage->getEntityType()->getConfigPrefix()); + if ($storage->load($id) == NULL) { + $config_entity = $storage->createFromStorageRecord($config_read); + $config_entity->save(); + } + } + + $form_configs = [ + 'core.entity_form_display.taxonomy_term.sites.default', + 'core.entity_view_display.taxonomy_term.sites.default', + 'field.field.taxonomy_term.sites.field_site_favicon', + ]; + foreach ($form_configs as $form_config) { + $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']) { + $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(); + } +} + +/** + * Add new fields to json:api. + */ +function tide_site_theming_update_10002() { + \Drupal::moduleHandler()->loadInclude('tide_core', 'inc', 'includes/helpers'); + $config_location = [\Drupal::service('extension.list.module')->getPath('tide_site') . '/config/optional']; + + $form_configs = [ + 'jsonapi_extras.jsonapi_resource_config.taxonomy_term--sites', + ]; + foreach ($form_configs as $form_config) { + $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']) { + $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(); + } +}