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 0000000..4b5a036 --- /dev/null +++ b/config/install/field.field.taxonomy_term.sites.field_short_name.yml @@ -0,0 +1,19 @@ +uuid: 3bfef526-070c-4a20-a671-7e4cd7799bc3 +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 0000000..c4e311b --- /dev/null +++ b/config/install/field.field.taxonomy_term.sites.field_site_app_icon.yml @@ -0,0 +1,38 @@ +uuid: 148ec44d-98a7-489f-af6a-c39ef740b4aa +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 e2066c8..601f16d 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 0000000..2889afc --- /dev/null +++ b/config/install/field.storage.taxonomy_term.field_short_name.yml @@ -0,0 +1,21 @@ +uuid: 8fddc614-5935-4014-8a0a-9c4a200ddea9 +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 0000000..2628ef9 --- /dev/null +++ b/config/install/field.storage.taxonomy_term.field_site_app_icon.yml @@ -0,0 +1,34 @@ +uuid: 5701f011-5ad2-46d5-9b59-24c52ed1fd36 +langcode: en +status: true +dependencies: + module: + - field_permissions + - file + - image + - taxonomy +third_party_settings: + field_permissions: + permission_type: public +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/modules/tide_site_theming/src/TideSiteThemingOperation.php b/modules/tide_site_theming/src/TideSiteThemingOperation.php index 37fc435..8710e5c 100644 --- a/modules/tide_site_theming/src/TideSiteThemingOperation.php +++ b/modules/tide_site_theming/src/TideSiteThemingOperation.php @@ -130,6 +130,38 @@ public function requiredChangesForTheming() { ]; $entity_form_display->setThirdPartySetting('field_group', 'group_site_favicon_value', $field_group['group_site_favicon_value']); + // Adds app icon. + $entity_form_display->setComponent('field_site_app_icon', [ + 'type' => 'image_image', + 'weight' => 20, + 'region' => 'content', + 'settings' => [ + 'progress_indicator' => 'throbber', + 'preview_image_style' => 'thumbnail', + ], + 'third_party_settings' => [], + ]); + $field_group = $entity_form_display->getThirdPartySettings('field_group'); + $field_group['group_site_app_icon'] = [ + 'children' => [ + 'field_site_app_icon', + ], + 'parent_name' => '', + 'label' => 'Site app icon', + 'weight' => 19, + 'format_type' => 'details', + 'region' => 'content', + 'format_settings' => [ + 'classes' => '', + 'show_empty_fields' => FALSE, + 'id' => 'tide-site-app-icon', + 'open' => FALSE, + 'required_fields' => TRUE, + 'effect' => 'none', + ], + ]; + $entity_form_display->setThirdPartySetting('field_group', 'group_site_app_icon', $field_group['group_site_app_icon']); + // Adds header corner graphics. $entity_form_display->setComponent('field_top_corner_graphic', [ 'type' => 'image_image', @@ -219,7 +251,7 @@ public function requiredChangesForTheming() { ], 'third_party_settings' => [], ])->save(); - $entity_view_display->setComponent('field_top_corner_graphic', [ + $entity_view_display->setComponent('field_site_app_icon', [ 'type' => 'image', 'weight' => 19, 'label' => 'above', @@ -238,7 +270,7 @@ public function requiredChangesForTheming() { ], 'third_party_settings' => [], ])->save(); - $entity_view_display->setComponent('field_bottom_corner_graphic', [ + $entity_view_display->setComponent('field_top_corner_graphic', [ 'type' => 'image', 'weight' => 20, 'label' => 'above', @@ -257,6 +289,25 @@ public function requiredChangesForTheming() { ], 'third_party_settings' => [], ])->save(); + $entity_view_display->setComponent('field_bottom_corner_graphic', [ + 'type' => 'image', + 'weight' => 21, + 'label' => 'above', + 'region' => 'content', + 'settings' => [ + 'image_link' => '', + 'image_style' => '', + 'svg_attributes' => [ + 'width' => NULL, + 'height' => NULL, + ], + 'svg_render_as_image' => TRUE, + 'image_loading' => [ + 'attribute' => 'lazy', + ], + ], + 'third_party_settings' => [], + ])->save(); } // Grant view preview links block to default roles from tide_core. @@ -272,6 +323,7 @@ public function requiredChangesForTheming() { 'field_site_theme_values', 'field_site_feature_flags', 'field_site_favicon', + 'field_site_app_icon', 'field_top_corner_graphic', 'field_bottom_corner_graphic', ]; diff --git a/modules/tide_site_theming/tide_site_theming.install b/modules/tide_site_theming/tide_site_theming.install index 61fedd0..5948d7f 100644 --- a/modules/tide_site_theming/tide_site_theming.install +++ b/modules/tide_site_theming/tide_site_theming.install @@ -215,3 +215,28 @@ 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', + ]; + module_load_include('inc', 'tide_core', '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(); + } + } + +}