From 2674d22405e274e866c53fdbf5d84c66066883cb Mon Sep 17 00:00:00 2001 From: Brian Canini <canini.16@osu.edu> Date: Wed, 4 Mar 2020 11:06:20 -0500 Subject: [PATCH] Updating drupal/field_group (3.0.0-rc1 => 3.0.0) --- composer.json | 4 +- composer.lock | 30 +++---- vendor/composer/installed.json | 30 +++---- web/modules/field_group/CHANGELOG.txt | 57 ++++++++++++ web/modules/field_group/README.txt | 74 ++++++++++++---- web/modules/field_group/composer.json | 4 +- .../field_group.entity_display.schema.yml | 4 +- ...up.field_group_formatter_plugin.schema.yml | 27 ++++-- .../field_group_migrate.info.yml | 9 +- web/modules/field_group/field_group.api.php | 12 +-- web/modules/field_group/field_group.info.yml | 10 +-- web/modules/field_group/field_group.install | 22 +---- web/modules/field_group/field_group.module | 86 ++++++++++++++++--- .../field_group/field_group.post_update.php | 54 ++++++++++++ .../field_group/field_group.services.yml | 2 +- .../formatters/tabs/horizontal-tabs.css | 23 ++--- .../formatters/tabs/horizontal-tabs.js | 8 ++ .../field_group/formatters/tabs/tabs.js | 35 +++++--- web/modules/field_group/includes/field_ui.inc | 28 ++++-- .../src/Element/HorizontalTabs.php | 23 ++--- .../field_group/src/Element/VerticalTabs.php | 12 +++ .../src/Form/FieldGroupAddForm.php | 7 +- .../src/Form/FieldGroupDeleteForm.php | 2 +- .../Derivative/FieldGroupLocalAction.php | 2 +- .../FieldGroupFormatter/AccordionItem.php | 2 +- .../FieldGroupFormatter/Details.php | 2 +- .../FieldGroupFormatter/DetailsSidebar.php | 73 ++++++++++++++++ .../FieldGroupFormatter/Fieldset.php | 2 +- .../FieldGroupFormatter/HtmlElement.php | 2 +- .../field_group/FieldGroupFormatter/Tab.php | 2 +- .../field_group/FieldGroupFormatter/Tabs.php | 10 +-- .../src/Routing/RouteSubscriber.php | 2 +- .../field_group_test.info.yml | 9 +- .../src/Functional/EntityDisplayTest.php | 5 ++ .../FieldGroupWithoutFieldUiTest.php | 5 ++ .../src/Functional/ManageDisplayTest.php | 8 +- .../FunctionalJavascript/FieldGroupUiTest.php | 30 ++++--- 37 files changed, 516 insertions(+), 201 deletions(-) create mode 100644 web/modules/field_group/field_group.post_update.php create mode 100644 web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php diff --git a/composer.json b/composer.json index 8de26d8ad5..b34680c64b 100644 --- a/composer.json +++ b/composer.json @@ -121,7 +121,7 @@ "drupal/entity_reference_revisions": "1.3", "drupal/externalauth": "1.1", "drupal/features": "3.8", - "drupal/field_group": "3.0-rc1", + "drupal/field_group": "3.0", "drupal/field_permissions": "1.0-beta1", "drupal/file_browser": "1.1", "drupal/focal_point": "1.0-beta6", @@ -316,4 +316,4 @@ "php": "7.0.8" } } -} \ No newline at end of file +} diff --git a/composer.lock b/composer.lock index e304ef53bb..9314c3a6dd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9cebdfa2dca9a89bb18005ed1f9db499", + "content-hash": "4bc1ccf26701eb7dc540d0d74931ce45", "packages": [ { "name": "alchemy/zippy", @@ -4649,20 +4649,20 @@ }, { "name": "drupal/field_group", - "version": "3.0.0-rc1", + "version": "3.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/field_group.git", - "reference": "8.x-3.0-rc1" + "reference": "8.x-3.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0-rc1.zip", - "reference": "8.x-3.0-rc1", - "shasum": "e291b5468c834a344e9aa6cafd3a76171d473a22" + "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0.zip", + "reference": "8.x-3.0", + "shasum": "8d87cdc4abc417aa4d411bffcaeb0a3ef1afa497" }, "require": { - "drupal/core": "*" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { @@ -4670,11 +4670,11 @@ "dev-3.x": "3.x-dev" }, "drupal": { - "version": "8.x-3.0-rc1", - "datestamp": "1558647185", + "version": "8.x-3.0", + "datestamp": "1580250787", "security-coverage": { - "status": "not-covered", - "message": "RC releases are not covered by Drupal security advisories." + "status": "covered", + "message": "Covered by Drupal's security advisory policy" } } }, @@ -4696,12 +4696,12 @@ "homepage": "https://www.drupal.org/user/591438" }, { - "name": "swentel", - "homepage": "https://www.drupal.org/user/107403" + "name": "nils.destoop", + "homepage": "https://www.drupal.org/user/361625" }, { - "name": "zuuperman", - "homepage": "https://www.drupal.org/user/361625" + "name": "swentel", + "homepage": "https://www.drupal.org/user/107403" } ], "description": "Provides the field_group module.", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 899a4506a1..d33cdecc32 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -4789,21 +4789,21 @@ }, { "name": "drupal/field_group", - "version": "3.0.0-rc1", - "version_normalized": "3.0.0.0-RC1", + "version": "3.0.0", + "version_normalized": "3.0.0.0", "source": { "type": "git", "url": "https://git.drupalcode.org/project/field_group.git", - "reference": "8.x-3.0-rc1" + "reference": "8.x-3.0" }, "dist": { "type": "zip", - "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0-rc1.zip", - "reference": "8.x-3.0-rc1", - "shasum": "e291b5468c834a344e9aa6cafd3a76171d473a22" + "url": "https://ftp.drupal.org/files/projects/field_group-8.x-3.0.zip", + "reference": "8.x-3.0", + "shasum": "8d87cdc4abc417aa4d411bffcaeb0a3ef1afa497" }, "require": { - "drupal/core": "*" + "drupal/core": "^8 || ^9" }, "type": "drupal-module", "extra": { @@ -4811,11 +4811,11 @@ "dev-3.x": "3.x-dev" }, "drupal": { - "version": "8.x-3.0-rc1", - "datestamp": "1558647185", + "version": "8.x-3.0", + "datestamp": "1580250787", "security-coverage": { - "status": "not-covered", - "message": "RC releases are not covered by Drupal security advisories." + "status": "covered", + "message": "Covered by Drupal's security advisory policy" } } }, @@ -4838,12 +4838,12 @@ "homepage": "https://www.drupal.org/user/591438" }, { - "name": "swentel", - "homepage": "https://www.drupal.org/user/107403" + "name": "nils.destoop", + "homepage": "https://www.drupal.org/user/361625" }, { - "name": "zuuperman", - "homepage": "https://www.drupal.org/user/361625" + "name": "swentel", + "homepage": "https://www.drupal.org/user/107403" } ], "description": "Provides the field_group module.", diff --git a/web/modules/field_group/CHANGELOG.txt b/web/modules/field_group/CHANGELOG.txt index a9d603fd15..c73d2a0301 100644 --- a/web/modules/field_group/CHANGELOG.txt +++ b/web/modules/field_group/CHANGELOG.txt @@ -1,3 +1,60 @@ +8.x-3.0-rc1, 2019-03-28 +----------------------- +- View Mode '_custom' should not go through the entity_display_build_alter. +- Fix deprecated methods. +- Temp remove the typehinting. +- Fatal error when creating a paragraph. +- Use mb_* functions instead of deprecated Unicode::* methods. +- Large amount of fields causes tab functionality to break. +- Field_group_theme_suggestions_alter notices. +- Horizontal tab content is wrapped by detail border. +- Syntax error in HorizontalTabs.php causes module installation to fail. +- Duplicated fields with field_group on referenced ECK entities. +- Horizontal tabs break keyboard navigation. +- Accordion Doesn't Open on Error. +- Create field_group.api.php for D8 version. +- Choose sensible default tab for horizontal tabs. +- Extend signature of field_group_form_process(). +- Migrated field groups all disabled. +- Empty fieldgroups are showing in forms. +- Missing hook_help. +- Missing UI for description text for field groups. +- Field groups default region should never be null. +- Revert "Issue #2991400 by DuaelFr: Field groups default region should never be null". +- Field groups default region should never be null. +- How to create horizontal tabs with 8.x-3.x ?. +- XSS patch horizontal-tabs.js. +- Allow modules to define form elements beneath field groups before they are created. +- Field_group_migrate.info.yml should not contain "version: VERSION". +- 2998205: Fix call to member function errors when the plugin was not found. +- PHP message: Error: Call to a member function process() on null. +- Set default values in migrate destinations plugins. +- D6 migration doesn't generate the migrations templates. +- Change package name of migrate sub-modules. +- Accordion/Default State doesn't do anything. +- Fix access check for empty groups. +- Fix config schema. +- Markup ID of each tab is not unique. +- Revert "Issue #2904577: Duplicate CSS ID confuses behat". +- Duplicate CSS ID confuses behat. +- The region part of entity view config isn't set for old installs. +- Remove extra param in call to field_group_info_groups. +- Update the processGroup implementations. +- Cannot declare class HtmlElement. +- Fix extending preRenderGroup. +- Coding standards. +- Remove helpers.inc. +- Invalid CSS ID for field group causes error. +- Add option to set group label classes for HTML element type. +- Fix migration tests. +- Fix migrate unit test + accordion. +- Getting d6_field_group plugin must define the source_module property Error When Using migrate-upgrade. +- Field groups are not compatible with field layout. +- Accordion items with children with errors not open. +- Accordion doesn't work. +- Fix syntax errors. +- Convert module to use short array syntax (new coding standard). + 8.3.0-beta1, 2017-11-10 ------------------- - JS error: Modernizr is not defined. diff --git a/web/modules/field_group/README.txt b/web/modules/field_group/README.txt index 6c72570811..5a2a7ddb58 100644 --- a/web/modules/field_group/README.txt +++ b/web/modules/field_group/README.txt @@ -1,6 +1,17 @@ +CONTENTS OF THIS FILE +--------------------- + + * Introduction + * Requirements + * Installation + * Configuration + * Maintainers + +INTRODUCTION +------------ History: - Field_group was originally written when drupal 7 was released. For drupal 6, the module is - located in the CCK module (http://drupal.org/project/cck). + Field_group was originally written when drupal 7 was released. For drupal 6, + the module is located in the CCK module (http://drupal.org/project/cck). As drupal core has a fields API drupal > 6, the field_group module is considered a contribution. @@ -28,40 +39,65 @@ Available group types: - Tabs (horizontal and vertical) - Accordions - Details (Use this if you want collapsible fieldsets) + - Details Sidebar To submit bug reports and feature suggestions, or to track changes: http://drupal.org/project/issues/field_group --- Configuration -- -1. You can configure the field groups for different displays like, in managed_form_display and managed_display of the entity type. -2. You can create different field groups under managed_form_display by adding a new group under "Add new group" label and the format the grouping using the desired formatter for displaying the same. +REQUIREMENTS +------------ +None. + +INSTALLATION +------------ +Install as you would normally install a contributed Drupal module. Visit: +https://www.drupal.org/documentation/install/modules-themes/modules-8 +for further information. + +CONFIGURATION +------------- +1. You can configure the field groups for different displays like, in +managed_form_display and managed_display of the entity type. +2. You can create different field groups under managed_form_display by +adding a new group under "Add new group" label and the format the +grouping using the desired formatter for displaying the same. 3. Same thing can be done in managed_display. -4. The field grouping done in managed display will be reflected on the view detail page of the entity, while that done in the managed_form_display will be -reflected in the add/edit form of the entity. +4. The field grouping done in managed display will be reflected on the +view detail page of the entity, while that done in the +managed_form_display will be reflected in the add/edit form of the entity. -- Create field groups -- This section explains how to create groups of fields according to the type chosen. - Fieldsets : This group of fields makes the internal content in a fieldset. - It is possible to add a title and a caption (which appears at the bottom of the fieldset). - - Details : Similar to Fieldsets. You can configure them to be open (normal fieldset) or collapsed. + It is possible to add a title and a caption (which appears at + the bottom of the fieldset). + - Details : Similar to Fieldsets. You can configure them to be open (normal + fieldset) or collapsed. + - Details Sidebar: Similar to Details. You can configure them to be open + (normal fieldset) or collapsed and move them in the sidebar on + the node form. - Html element : This fieldgroup renders the inner content in a HTML element. You can configure attributes and label element. -The following two groupings works differently because you must associate them with an other grouping. +The following two groupings works differently because you must associate them with +an other grouping. - Accordions : This group of fields makes the child groups as a jQuery accordion. - As a first step you must create an Accordions group. You can set a label and choose an effect. - Then you can create an Accordion Item as a child. This group can contain fields. + As a first step you must create an Accordions group. You can set a + label and choose an effect. Then you can create an Accordion + Item as a child. This group can contain fields. - Tabs : This fieldgroup renders child groups in its own tabs wrapper. - As a first step you must create an Tabs group. You can set choose if you want that your tabs are show horizontally or vertically. - Then, you can create Tab as a child and choose one to be open by default. This group can contain fields. + As a first step you must create an Tabs group. You can set + choose if you want that your tabs are show horizontally or vertically. + Then, you can create Tab as a child and choose one to be open by default. + This group can contain fields. For all groups, you can add id or classes. -You can also choose if you want to mark a group as required if one of his fields is require (except for Accordions and Tabs : you must passed by their children). - --- MAINTAINERS -- +You can also choose if you want to mark a group as required if one of his fields is +require (except for Accordions and Tabs : you must passed by their children). +MAINTAINERS +----------- stalski - http://drupal.org/user/322618 zuuperman - http://drupal.org/user/361625 swentel - http://drupal.org/user/107403 --- INSPIRATORS -- - +Inspirators: yched - http://drupal.org/user/39567 diff --git a/web/modules/field_group/composer.json b/web/modules/field_group/composer.json index 82d0931841..ac893ea517 100644 --- a/web/modules/field_group/composer.json +++ b/web/modules/field_group/composer.json @@ -4,5 +4,7 @@ "type": "drupal-module", "license": "GPL-2.0+", "minimum-stability": "dev", - "require": {} + "require": { + "drupal/core": "^8 || ^9" + } } diff --git a/web/modules/field_group/config/schema/field_group.entity_display.schema.yml b/web/modules/field_group/config/schema/field_group.entity_display.schema.yml index a9fe072ec4..2f859c6288 100644 --- a/web/modules/field_group/config/schema/field_group.entity_display.schema.yml +++ b/web/modules/field_group/config/schema/field_group.entity_display.schema.yml @@ -12,7 +12,7 @@ core.entity_view_display.*.*.*.third_party.field_group: - type: string label: 'The field name' label: - type: string + type: label label: Readable name of the group parent_name: type: string @@ -43,7 +43,7 @@ core.entity_form_display.*.*.*.third_party.field_group: - type: string label: 'The field name' label: - type: string + type: label label: Readable name of the group region: type: string diff --git a/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml b/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml index c897f4aac9..01154220db 100644 --- a/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml +++ b/web/modules/field_group/config/schema/field_group.field_group_formatter_plugin.schema.yml @@ -14,8 +14,8 @@ field_group.field_group_formatter_plugin.accordion_item: type: string label: 'Formatting of the item' description: - type: string - label: 'description of the item' + type: label + label: 'Description of the item' required_fields: type: boolean label: 'Mark for required fields' @@ -27,17 +27,28 @@ field_group.field_group_formatter_plugin.details: open: type: boolean label: 'Display element open by default.' + description: + type: text + label: 'Description of the element' required_fields: type: boolean label: 'Mark for required fields' +field_group.field_group_formatter_plugin.details_sidebar: + type: field_group.field_group_formatter_plugin.details + label: 'Mapping for the details sidebar formatter settings' + mapping: + weight: + type: integer + label: 'Weight' + field_group.field_group_formatter_plugin.fieldset: type: field_group.field_group_formatter_plugin.base label: 'Mapping for the fieldset formatter settings' mapping: description: - type: string - label: 'description of the item' + type: label + label: 'Description of the item' required_fields: type: boolean label: 'Mark for required fields' @@ -79,8 +90,8 @@ field_group.field_group_formatter_plugin.tab: type: string label: 'default state for the tab' description: - type: string - label: 'description of the tab' + type: label + label: 'Description of the tab' required_fields: type: boolean label: 'Mark for required fields' @@ -93,7 +104,7 @@ field_group.field_group_formatter_plugin.tabs: type: string label: 'default state for the tabs' description: - type: string + type: label label: 'description of the tabs' required_fields: type: boolean @@ -107,7 +118,7 @@ field_group.field_group_formatter_plugin.base: label: 'Mapping for the base formatter settings' mapping: label: - type: string + type: label label: 'Label of the fieldgroup' classes: type: string diff --git a/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml b/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml index 96ef3018cf..f1a0fb93f4 100644 --- a/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml +++ b/web/modules/field_group/contrib/field_group_migrate/field_group_migrate.info.yml @@ -2,12 +2,11 @@ name: 'Field Group Migrate' type: module description: 'Provides the ability to migrate field groups from D6/D7 to D8.' package: Migration -# core: 8.x +core: 8.x dependencies: - field_group:field_group -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/field_group.api.php b/web/modules/field_group/field_group.api.php index 0125f5b380..a81977953f 100644 --- a/web/modules/field_group/field_group.api.php +++ b/web/modules/field_group/field_group.api.php @@ -65,21 +65,13 @@ function hook_field_group_pre_render_alter(array &$element, &$group, &$rendering } /** - * Alter the pre_rendered build of the form. + * Alter the pre_rendered build of the entity view. * * @param array $element * Group being rendered. */ function hook_field_group_build_pre_render_alter(array &$element) { - $form_id = $element['#form_id']; - if ($form_id == 'my_example_form' && isset($element['group_example'])) { - // Add form states to the field group. - $element['group_example']['#states'] = [ - 'visible' => [ - ':input[name="field_are_you_ok"]' => ['value' => 'yes'], - ], - ]; - } + $element['#fieldgroups']['my_group']['region'] = 'new_region'; } /** diff --git a/web/modules/field_group/field_group.info.yml b/web/modules/field_group/field_group.info.yml index d1c746ca45..42618f0d09 100644 --- a/web/modules/field_group/field_group.info.yml +++ b/web/modules/field_group/field_group.info.yml @@ -2,12 +2,12 @@ name: 'Field Group' type: module description: 'Provides the ability to group your fields on both form and display.' package : Fields -# core: 8.x +core: 8.x +core_version_requirement: ^8 || ^9 dependencies: - drupal:field -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/field_group.install b/web/modules/field_group/field_group.install index 7213f09bc4..659cf67a2f 100644 --- a/web/modules/field_group/field_group.install +++ b/web/modules/field_group/field_group.install @@ -6,26 +6,8 @@ */ /** - * Set the `region` portion of each field group. + * Removed in favor of hook_post_update script. */ function field_group_update_8301() { - foreach (['entity_form_display', 'entity_view_display'] as $entity_type) { - foreach (\Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple() as $display) { - /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ - if (in_array('field_group', $display->getThirdPartyProviders())) { - $field_groups = $display->getThirdPartySettings('field_group'); - $updated = FALSE; - foreach ($field_groups as $group_name => $data) { - if (!isset($data['region'])) { - $data['region'] = 'content'; - $display->setThirdPartySetting('field_group', $group_name, $data); - $updated = TRUE; - } - } - if ($updated) { - $display->save(); - } - } - } - } + // @see field_group_post_update_0001(). } diff --git a/web/modules/field_group/field_group.module b/web/modules/field_group/field_group.module index b2711b2408..2e794568cf 100644 --- a/web/modules/field_group/field_group.module +++ b/web/modules/field_group/field_group.module @@ -2,7 +2,7 @@ /** * @file - * Allows administrators to attach custom fields to fieldable types. + * Allows administrators to attach field groups. */ use Drupal\Core\Routing\RouteMatchInterface; @@ -182,9 +182,26 @@ function field_group_form_entity_view_display_edit_form_alter(&$form, FormStateI * Implements hook_field_info_max_weight(). */ function field_group_field_info_max_weight($entity_type, $bundle, $context, $context_mode) { + // Prevent recursion. + // @see https://www.drupal.org/project/drupal/issues/2966137 + static $recursion_tracker = []; + + // Track the entity display. + $key = $entity_type . ':' . $bundle . ':' . $context . ':' . $context_mode; + + // If entity display check was attempted but did not finish, do not continue. + if (isset($recursion_tracker[$key])) { + return NULL; + } + + // Mark this as an attempt at entity display check. + $recursion_tracker[$key] = TRUE; $groups = field_group_info_groups($entity_type, $bundle, $context, $context_mode); + // Remove the indicator once the entity display is successfully checked. + unset($recursion_tracker[$key]); + $weights = []; foreach ($groups as $group) { $weights[] = $group->weight; @@ -201,7 +218,7 @@ function field_group_form_alter(array &$form, FormStateInterface $form_state) { if ($form_object instanceof ContentEntityFormInterface && !$form_object instanceof ConfirmFormInterface) { /** - * @var \Drupal\Core\Entity\Entity\EntityFormDisplayInterface $form_display + * @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */ $storage = $form_state->getStorage(); if (!empty($storage['form_display'])) { @@ -239,7 +256,36 @@ function field_group_inline_entity_form_entity_form_alter(&$entity_form, FormSta ]; field_group_attach_groups($entity_form, $context); - $entity_form['#process'][] = 'field_group_form_process'; + field_group_form_process($entity_form); +} + +/** + * Implements hook_form_layout_builder_update_block_alter(). + */ +function field_group_form_layout_builder_update_block_alter(&$form, FormStateInterface $form_state) { + // Attach fieldgroups to the layout builder form for custom block types. + if (!isset($form['settings']['block_form']['#block'])) { + return; + } + + $context = [ + 'entity_type' => $form['settings']['block_form']['#block']->getEntityTypeId(), + 'bundle' => $form['settings']['block_form']['#block']->bundle(), + 'entity' => $form['settings']['block_form']['#block'], + 'display_context' => 'form', + 'mode' => 'default', + ]; + + field_group_attach_groups($form['settings']['block_form'], $context); + $form['settings']['block_form']['#process'][] = 'field_group_form_process'; +} + +/** + * Implements hook_form_layout_builder_add_block_alter(). + */ +function field_group_form_layout_builder_add_block_alter(&$form, FormStateInterface $form_state) { + // Call the update hook. + field_group_form_layout_builder_update_block_alter($form, $form_state); } /** @@ -283,6 +329,8 @@ function field_group_entity_view_alter(&$build, EntityInterface $entity, EntityD * Form that is being rendered. * * @deprecated Use field_group_form_process instead. + * + * @return array */ function field_group_form_pre_render(array $element) { return field_group_form_process($element); @@ -325,6 +373,9 @@ function field_group_form_process(array &$element, FormStateInterface $form_stat $element[$group_name]['#parents'] = $parents; $group_children_parent_group = implode('][', $parents); foreach ($group->children as $child) { + if (!empty($element[$child]['#field_group_ignore'])) { + continue; + } $element[$child]['#group'] = $group_children_parent_group; } } @@ -358,6 +409,8 @@ function field_group_form_process(array &$element, FormStateInterface $form_stat * * @param array $element * Entity being rendered. + * + * @return array */ function field_group_entity_view_pre_render(array $element) { field_group_build_entity_groups($element, 'view'); @@ -446,10 +499,9 @@ function field_group_field_group_form_process_build_alter(array &$element, $form /** * Implements hook_field_group_build_pre_render_alter(). * - * @param array $elements - * By address.field_group_entity_display_build_alter + * @param array $element */ -function field_group_field_group_build_pre_render_alter(& $element) { +function field_group_field_group_build_pre_render_alter(&$element) { // Someone is doing a node view, in a node view. Reset content. if (isset($element['#node']->content) && count($element['#node']->content) > 0) { $element['#node']->content = []; @@ -780,6 +832,8 @@ function field_group_pre_render(& $element, $group, & $rendering_object) { * * @param $context * The display context (entity type, form or view). + * + * @return string */ function field_group_get_content_element_key($context = 'default') { $keys = &drupal_static('field_group_content_elements'); @@ -794,16 +848,13 @@ function field_group_get_content_element_key($context = 'default') { if (isset($keys[$context])) { $key = $keys[$context]; } + return $key; } /** * Saves a group definition. * - * This function is called by ctools export when calls are made through - * ctools_export_crud_save(). It's also used as an api method to add groups to a - * display. - * * @param \stdClass $group * A group definition. * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display @@ -811,6 +862,8 @@ function field_group_get_content_element_key($context = 'default') { * * @return \Drupal\Core\Entity\Display\EntityDisplayInterface|null * The updated entity display. + * + * @throws \Drupal\Core\Entity\EntityStorageException */ function field_group_group_save($group, $display = NULL) { if ($display === NULL) { @@ -859,8 +912,10 @@ function field_group_group_save($group, $display = NULL) { * * @param $group * A group definition. + * + * @throws \Drupal\Core\Entity\EntityStorageException */ -function field_group_group_delete($group) { +function field_group_delete_field_group($group) { if ($group->context == 'form') { $display = EntityFormDisplay::load($group->entity_type . '.' . $group->bundle . '.' . $group->mode); } @@ -890,6 +945,8 @@ function field_group_group_delete($group) { * The context of the view mode (form or view) * @param $mode * The view mode. + * + * @return array */ function field_group_info_groups($entity_type, $bundle, $context, $mode) { if ($context == 'form') { @@ -935,6 +992,8 @@ function field_group_info_groups($entity_type, $bundle, $context, $mode) { * The context of the view mode (form or view) * @param $mode * The view mode to load. + * + * @return mixed */ function field_group_load_field_group($group_name, $entity_type, $bundle, $context, $mode) { $groups = field_group_info_groups($entity_type, $bundle, $context, $mode); @@ -956,6 +1015,8 @@ function field_group_load_field_group($group_name, $entity_type, $bundle, $conte * The context of the view mode (form or view) * @param string $mode * The view mode context the group will be rendered. + * + * @return bool */ function field_group_exists($group_name, $entity_type, $bundle, $context, $mode) { return (bool) field_group_load_field_group($group_name, $entity_type, $bundle, $context, $mode); @@ -1005,6 +1066,8 @@ function field_group_remove_empty_form_groups(&$element, $groups, $entity_type) * The element to check the empty state. * @param array $groups * Array of group objects. + * + * @return bool */ function field_group_remove_empty_display_groups(& $element, $groups) { @@ -1039,5 +1102,4 @@ function field_group_remove_empty_display_groups(& $element, $groups) { } return $empty_group; - } diff --git a/web/modules/field_group/field_group.post_update.php b/web/modules/field_group/field_group.post_update.php new file mode 100644 index 0000000000..04fc1cbccb --- /dev/null +++ b/web/modules/field_group/field_group.post_update.php @@ -0,0 +1,54 @@ +<?php + +/** + * @file + * Post update functions for Field Group. + */ + +/** + * Assign a region to Field Groups. + */ +function field_group_post_update_0001() { + foreach (['entity_form_display', 'entity_view_display'] as $entity_type) { + foreach (\Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple() as $display) { + /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */ + if (in_array('field_group', $display->getThirdPartyProviders())) { + $updated = FALSE; + + // Take Display Suite regions into account. + $has_ds = FALSE; + $ds_regions = []; + if ($entity_type == 'entity_view_display' && in_array('ds', $display->getThirdPartyProviders())) { + $ds = $display->getThirdPartySettings('ds'); + if (!empty($ds['regions'])) { + foreach ($ds['regions'] as $region_name => $region_fields) { + foreach ($region_fields as $field_name) { + $has_ds = TRUE; + $ds_regions[$field_name] = $region_name; + } + } + } + } + + $field_groups = $display->getThirdPartySettings('field_group'); + foreach ($field_groups as $group_name => $data) { + if (!isset($data['region'])) { + $region = 'content'; + if ($has_ds) { + $region = 'hidden'; + if (isset($ds_regions[$group_name])) { + $region = $ds_regions[$group_name]; + } + } + $data['region'] = $region; + $display->setThirdPartySetting('field_group', $group_name, $data); + $updated = TRUE; + } + } + if ($updated) { + $display->save(); + } + } + } + } +} diff --git a/web/modules/field_group/field_group.services.yml b/web/modules/field_group/field_group.services.yml index 1eafd00a99..5c6f68583c 100644 --- a/web/modules/field_group/field_group.services.yml +++ b/web/modules/field_group/field_group.services.yml @@ -4,7 +4,7 @@ services: parent: default_plugin_manager field_group.subscriber: class: Drupal\field_group\Routing\RouteSubscriber - arguments: ['@entity.manager'] + arguments: ['@entity_type.manager'] tags: - { name: event_subscriber } field_group.param_converter: diff --git a/web/modules/field_group/formatters/tabs/horizontal-tabs.css b/web/modules/field_group/formatters/tabs/horizontal-tabs.css index 5cb6ce314f..b28d5c9dea 100644 --- a/web/modules/field_group/formatters/tabs/horizontal-tabs.css +++ b/web/modules/field_group/formatters/tabs/horizontal-tabs.css @@ -13,10 +13,10 @@ display: inline-block; margin: 0; border: 0; - padding: 0px; + padding: 0; list-style: none; - background-color: #dedede; - border-right: 1px solid #dedede; /* LTR */ + background-color: #eee; + border-bottom: 1px solid #ccc; /* LTR */ width: 100%; height: auto; clear: both; @@ -41,7 +41,6 @@ .horizontal-tabs .horizontal-tab-button { background: #eee; border-right: 1px solid #ccc; /* LTR */ - padding: 1px; padding-top: 0; margin: 0; min-width: 5em; /* IE7 */ @@ -62,7 +61,7 @@ .horizontal-tabs .horizontal-tab-button a:hover { outline: none; - background-color: #ededdd; + background-color: #fff; } .horizontal-tabs .horizontal-tab-button li:hover, @@ -83,7 +82,8 @@ .horizontal-tab-button.selected { background-color: #fff; - padding: 0 0 1px 0; + border-bottom: 1px solid #fff; + margin-bottom: -1px; } [dir="rtl"] .horizontal-tab-button.selected { @@ -95,9 +95,9 @@ .horizontal-tabs ul.horizontal-tabs-list li.selected a { display: block; text-decoration: none; - padding: 0.5em 0.6em 0.3em 0.6em; + padding: 0.6em 1em; position: relative; - top: 0px; + top: 0; } .horizontal-tab-button .selected strong { @@ -121,10 +121,3 @@ div.field-group-htabs-wrapper .field-group-format-wrapper { padding: 0 0 0.6em; } -/*hide*/ -.horizontal-tabs .horizontal-tab-hidden { - display: block; - position: absolute; - top: -100000000px; - width: 100%; -} diff --git a/web/modules/field_group/formatters/tabs/horizontal-tabs.js b/web/modules/field_group/formatters/tabs/horizontal-tabs.js index 363e63e4e1..ca0dc04ca5 100644 --- a/web/modules/field_group/formatters/tabs/horizontal-tabs.js +++ b/web/modules/field_group/formatters/tabs/horizontal-tabs.js @@ -149,9 +149,11 @@ .each(function () { var tab = $(this).data('horizontalTab'); tab.details.addClass('horizontal-tab-hidden'); + tab.details.hide(); tab.item.removeClass('selected'); }) .end() + .show() .siblings(':hidden.horizontal-tabs-active-tab') .val(this.details.attr('id')); this.item.addClass('selected'); @@ -175,6 +177,9 @@ tabShow: function () { // Display the tab. this.item.removeClass('horizontal-tab-hidden'); + this.item.show(); + alert('show'); + // Update .first marker for items. We need recurse from parent to retain the // actual DOM element order as jQuery implements sortOrder, but not as public // method. @@ -195,6 +200,9 @@ tabHide: function () { // Hide this tab. this.item.addClass('horizontal-tab-hidden'); + this.item.hide(); + alert('hide'); + // Update .first marker for items. We need recurse from parent to retain the // actual DOM element order as jQuery implements sortOrder, but not as public // method. diff --git a/web/modules/field_group/formatters/tabs/tabs.js b/web/modules/field_group/formatters/tabs/tabs.js index c2c5b5d31a..9e1bdb4003 100644 --- a/web/modules/field_group/formatters/tabs/tabs.js +++ b/web/modules/field_group/formatters/tabs/tabs.js @@ -15,21 +15,28 @@ // Add required fields mark to any element containing required fields var direction = group_info.settings.direction; - $(context).find('[data-' + direction + '-tabs-panes] details').once('fieldgroup-effects').each(function () { - - var $this = $(this); - if (typeof $(this).data(direction + 'Tab') !== 'undefined') { - - if ($this.is('.required-fields') && ($this.find('[required]').length > 0 || $this.find('.form-required').length > 0)) { - $this.data(direction + 'Tab').link.find('strong:first').addClass('form-required'); - } - - if ($('.error', $this).length) { - $this.data(direction + 'Tab').link.parent().addClass('error'); - Drupal.FieldGroup.setGroupWithfocus($this); - $this.data(direction + 'Tab').focus(); + $(context).find('[data-' + direction + '-tabs-panes]').each(function () { + var errorFocussed = false; + $(this).find('> details').once('fieldgroup-effects').each(function () { + var $this = $(this); + if (typeof $this.data(direction + 'Tab') !== 'undefined') { + + if ($this.is('.required-fields') && ($this.find('[required]').length > 0 || $this.find('.form-required').length > 0)) { + $this.data(direction + 'Tab').link.find('strong:first').addClass('form-required'); + } + + if ($('.error', $this).length) { + $this.data(direction + 'Tab').link.parent().addClass('error'); + + // Focus the first tab with error. + if (!errorFocussed) { + Drupal.FieldGroup.setGroupWithfocus($this); + $this.data(direction + 'Tab').focus(); + errorFocussed = true; + } + } } - } + }); }); } diff --git a/web/modules/field_group/includes/field_ui.inc b/web/modules/field_group/includes/field_ui.inc index 318dd1ef90..0a14e6b771 100644 --- a/web/modules/field_group/includes/field_ui.inc +++ b/web/modules/field_group/includes/field_ui.inc @@ -42,7 +42,8 @@ function field_group_field_ui_form_params($form, EntityDisplayBase $display) { $params->parents = []; foreach ($params->groups as $name => $group) { foreach ($group->children as $child) { - // Field UI js sometimes can trigger an endless loop. Check if the parent of this field is not a child. + // Field UI js sometimes can trigger an endless loop. Check if the parent + // of this field is not a child. if ($child !== $group->parent_name) { $params->parents[$child] = $name; } @@ -50,12 +51,23 @@ function field_group_field_ui_form_params($form, EntityDisplayBase $display) { } // Get possible regions. - $layout_info = $display->getThirdPartySettings('field_layout'); - if (!empty($layout_info) && isset($layout_info['id'])) { - $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($layout_info['id']); + // TODO remove the field layout part when it's remove from in core. + // see https://www.drupal.org/project/field_group/issues/3086019 + $ds_info = $display->getThirdPartySettings('ds'); + $field_layout_info = $display->getThirdPartySettings('field_layout'); + /** @var \Drupal\Core\Layout\LayoutDefinition $layout */ + if (!empty($field_layout_info) && isset($field_layout_info['id'])) { + $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($field_layout_info['id']); $params->available_regions = $layout->getRegionNames(); $params->default_region = $layout->getDefaultRegion() ?: 'hidden'; } + elseif (!empty($ds_info['layout']['id'])) { + $layout = \Drupal::service('plugin.manager.core.layout')->getDefinition($ds_info['layout']['id']); + $params->available_regions = $layout->getRegionNames(); + // Hidden is an available region too, as weird as it may seems. + $params->available_regions[] = 'hidden'; + $params->default_region = $layout->getDefaultRegion() ?: 'hidden'; + } else { $params->available_regions = ['content', 'hidden']; $params->default_region = 'hidden'; @@ -93,7 +105,7 @@ function field_group_field_ui_display_form_alter(&$form, FormStateInterface $for $entity_display_form = $form_state->getBuildInfo()['callback_object']; if (!$entity_display_form instanceof EntityDisplayFormBase) { - throw new InvalidArgumentException('Unkown callback object.'); + throw new InvalidArgumentException('Unknown callback object.'); } $display = $entity_display_form->getEntity(); @@ -166,7 +178,7 @@ function field_group_field_ui_display_form_alter(&$form, FormStateInterface $for '#region_callback' => 'field_group_display_overview_row_region', '#js_settings' => ['rowHandler' => 'group'], 'human_name' => [ - '#markup' => Html::escape(t($group->label)), + '#markup' => $group->label, '#prefix' => '<span class="group-label">', '#suffix' => '</span>', ], @@ -453,8 +465,8 @@ function field_group_field_overview_submit($form, FormStateInterface $form_state $group = $groups[$group_name]; $group->label = $field_group_form_state[$group_name]->label; - // Sometimes field UI does a fuckup if people drag to fast when switching nested values. - // This results in an endless loop => Cleanup before saving. + // Sometimes field UI freaks a bit if people drag to fast when switching + // nested values which results in an endless loop, so cleanup first. // unset($children[$group_name][$form_values[$group_name]['parent']]);. $group->children = array_keys($children[$group_name]); $group->parent_name = $form_values[$group_name]['parent']; diff --git a/web/modules/field_group/src/Element/HorizontalTabs.php b/web/modules/field_group/src/Element/HorizontalTabs.php index dab221c922..e3c642d8d1 100644 --- a/web/modules/field_group/src/Element/HorizontalTabs.php +++ b/web/modules/field_group/src/Element/HorizontalTabs.php @@ -72,6 +72,18 @@ public static function preRenderGroup($element) { } } + // Search for the correct default active tab. + $group_identifier = implode('][', $element['#parents']); + if (!empty($element['#groups'][$group_identifier])) { + $children = Element::children($element['#groups'][$group_identifier], TRUE); + foreach ($children as $key) { + if (!empty($element['#groups'][$group_identifier][$key]['#open'])) { + $element['#default_tab'] = $element['#groups'][$group_identifier][$key]['#id']; + $element[str_replace('][', '__', $group_identifier) . '__active_tab']['#value'] = $element['#default_tab']; + } + } + } + return $element; } @@ -118,18 +130,7 @@ public static function processHorizontalTabs(array &$element, FormStateInterface $element['#default_tab'] = $form_state->getValue($name . '__active_tab'); } - $groups = &$form_state->getGroups(); - $group_name = $element['#group_name']; $displayed_tab = isset($element['#default_tab']) ? $element['#default_tab'] : ''; - if (isset($groups[$group_name]) && empty($displayed_tab)) { - foreach (Element::children($groups[$group_name]) as $child) { - $child_group = $groups[$group_name][$child]; - if (!empty($child_group['#open']) || empty($displayed_tab)) { - // Use the last open group or the first group if none are open. - $displayed_tab = $child_group['#id']; - } - } - } // The JavaScript stores the currently selected tab in this hidden // field so that the active tab can be restored the next time the diff --git a/web/modules/field_group/src/Element/VerticalTabs.php b/web/modules/field_group/src/Element/VerticalTabs.php index 5b56bf4694..598e24cf47 100644 --- a/web/modules/field_group/src/Element/VerticalTabs.php +++ b/web/modules/field_group/src/Element/VerticalTabs.php @@ -47,6 +47,18 @@ public static function preRenderGroup($element) { } } + // Search for the correct default active tab. + $group_identifier = implode('][', $element['#parents']); + if (!empty($element['#groups'][$group_identifier])) { + $children = Element::children($element['#groups'][$group_identifier], TRUE); + foreach ($children as $key) { + if (!empty($element['#groups'][$group_identifier][$key]['#open'])) { + $element['#default_tab'] = $element['#groups'][$group_identifier][$key]['#id']; + $element[str_replace('][', '__', $group_identifier) . '__active_tab']['#value'] = $element['#default_tab']; + } + } + } + return $element; } diff --git a/web/modules/field_group/src/Form/FieldGroupAddForm.php b/web/modules/field_group/src/Form/FieldGroupAddForm.php index 987a3757b2..a69b5904be 100644 --- a/web/modules/field_group/src/Form/FieldGroupAddForm.php +++ b/web/modules/field_group/src/Form/FieldGroupAddForm.php @@ -112,10 +112,10 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t $this->context = $context; if ($context == 'form') { - $this->mode = \Drupal::request()->get('form_mode_name'); + $this->mode = $this->getRequest()->get('form_mode_name'); } else { - $this->mode = \Drupal::request()->get('view_mode_name'); + $this->mode = $this->getRequest()->get('view_mode_name'); } if (empty($this->mode)) { @@ -153,7 +153,7 @@ public function buildFormatterSelectionForm(array &$form, FormStateInterface $fo '#type' => 'select', '#title' => $this->t('Add a new group'), '#options' => $formatter_options, - '#empty_option' => $this->t('- Select a group type -'), + '#empty_option' => $this->t('- Select a field group type -'), '#required' => TRUE, ]; @@ -272,6 +272,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { 'parent_name' => '', 'weight' => 20, 'format_type' => $form_state->get('group_formatter'), + 'region' => 'hidden', ]; $new_group->format_settings = $form_state->getValue('format_settings'); diff --git a/web/modules/field_group/src/Form/FieldGroupDeleteForm.php b/web/modules/field_group/src/Form/FieldGroupDeleteForm.php index 3cf86b88f9..fafb76f1f1 100644 --- a/web/modules/field_group/src/Form/FieldGroupDeleteForm.php +++ b/web/modules/field_group/src/Form/FieldGroupDeleteForm.php @@ -80,7 +80,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $bundles = \Drupal::service('entity_type.bundle.info')->getAllBundleInfo(); $bundle_label = $bundles[$this->fieldGroup->entity_type][$this->fieldGroup->bundle]['label']; - field_group_group_delete($this->fieldGroup); + field_group_delete_field_group($this->fieldGroup); $this->messenger->addMessage(t('The group %group has been deleted from the %type content type.', ['%group' => t($this->fieldGroup->label), '%type' => $bundle_label])); diff --git a/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php b/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php index 64972b603c..5990efd927 100644 --- a/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php +++ b/web/modules/field_group/src/Plugin/Derivative/FieldGroupLocalAction.php @@ -63,7 +63,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { if ($entity_type->get('field_ui_base_route')) { $default_options = [ - 'title' => $this->t('Add group'), + 'title' => $this->t('Add field group'), ]; $this->derivatives['field_group_add_' . $entity_type_id . '_form_display'] = [ diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php index afab3bc4a1..dd8feac371 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php @@ -35,7 +35,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'field_group_accordion_item', '#effect' => $this->getSetting('effect'), - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), ]; if ($this->getSetting('id')) { diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php index d1384cc1c6..fdbde635ba 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Details.php @@ -27,7 +27,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'details', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#open' => $this->getSetting('open'), '#description' => $this->getSetting('description'), ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php new file mode 100644 index 0000000000..aa1563bc1c --- /dev/null +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/DetailsSidebar.php @@ -0,0 +1,73 @@ +<?php + +namespace Drupal\field_group\Plugin\field_group\FieldGroupFormatter; + +/** + * Details Sidebar element. + * + * @FieldGroupFormatter( + * id = "details_sidebar", + * label = @Translation("Details Sidebar"), + * description = @Translation("Add a details sidebar element"), + * supported_contexts = { + * "form", + * "view" + * } + * ) + */ +class DetailsSidebar extends Details { + + /** + * {@inheritdoc} + */ + public function process(&$element, $processed_object) { + parent::process($element, $processed_object); + + $element['#group'] = 'advanced'; + + if ($this->getSetting('weight')) { + $element['#weight'] = $this->getSetting('weight'); + } + } + + /** + * {@inheritdoc} + */ + public function settingsForm() { + $form = parent::settingsForm(); + + $form['weight'] = [ + '#type' => 'number', + '#title' => $this->t('Weight'), + '#default_value' => $this->getSetting('weight'), + ]; + + return $form; + } + + /** + * {@inheritdoc} + */ + public function settingsSummary() { + $summary = parent::settingsSummary(); + + if ($this->getSetting('weight')) { + $summary[] = $this->t('Weight: @weight', + ['@weight' => $this->getSetting('weight')] + ); + } + + return $summary; + } + + /** + * {@inheritdoc} + */ + public static function defaultContextSettings($context) { + $defaults = parent::defaultContextSettings($context); + $defaults['weight'] = 0; + + return $defaults; + } + +} diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php index 4245b7ee35..327d857b33 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php @@ -27,7 +27,7 @@ public function process(&$element, $processed_object) { $element += [ '#type' => 'fieldset', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#attributes' => [], '#description' => $this->getSetting('description'), ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php index 60e4d539c1..94015806df 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php @@ -71,7 +71,7 @@ public function process(&$element, $processed_object) { $element['#attributes'] = $element_attributes; if ($this->getSetting('show_label')) { $element['#title_element'] = $this->getSetting('label_element'); - $element['#title'] = Html::escape($this->t($this->getLabel())); + $element['#title'] = $this->getLabel(); $element['#title_attributes'] = new Attribute(); if (!empty($this->getSetting('label_element_classes'))) { diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php index fe58da6dfb..ba2c728baa 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tab.php @@ -34,7 +34,7 @@ public function process(&$element, $processed_object) { $add = [ '#type' => 'details', - '#title' => Html::escape($this->t($this->getLabel())), + '#title' => $this->getLabel(), '#description' => $this->getSetting('description'), '#group' => $this->group->parent_name, ]; diff --git a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php index 56d58d45db..de6b562b73 100644 --- a/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php +++ b/web/modules/field_group/src/Plugin/field_group/FieldGroupFormatter/Tabs.php @@ -46,7 +46,7 @@ public function process(&$element, $processed_object) { // By default tabs don't have titles but you can override it in the theme. if ($this->getLabel()) { - $element['#title'] = Html::escape($this->getLabel()); + $element['#title'] = $this->getLabel(); } $element += [ @@ -54,14 +54,6 @@ public function process(&$element, $processed_object) { '#theme_wrappers' => [$this->getSetting('direction') . '_tabs'], ]; - // Search for a tab that was marked as open. First one wins. - foreach (Element::children($element) as $tab_name) { - if (!empty($element[$tab_name]['#open'])) { - $element[$this->group->group_name . '__active_tab']['#default_value'] = $tab_name; - break; - } - } - } /** diff --git a/web/modules/field_group/src/Routing/RouteSubscriber.php b/web/modules/field_group/src/Routing/RouteSubscriber.php index 2ca276b2d2..bae6a2c3a0 100644 --- a/web/modules/field_group/src/Routing/RouteSubscriber.php +++ b/web/modules/field_group/src/Routing/RouteSubscriber.php @@ -68,7 +68,7 @@ protected function alterRoutes(RouteCollection $collection) { $defaults_add = [ 'entity_type_id' => $entity_type_id, '_form' => '\Drupal\field_group\Form\FieldGroupAddForm', - '_title' => 'Add group', + '_title' => 'Add field group', ]; // If the entity type has no bundles and it doesn't use {bundle} in its diff --git a/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml b/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml index cb1a2dd8c1..279040ed8e 100644 --- a/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml +++ b/web/modules/field_group/tests/modules/field_group_test/field_group_test.info.yml @@ -1,12 +1,11 @@ name: 'Field Group Test' description: 'Test module for Field Group' -# core: 8.x +core: 8.x package: 'Fields' type: module hidden: TRUE -# Information added by Drupal.org packaging script on 2019-05-23 -version: '8.x-3.0-rc1' -core: '8.x' +# Information added by Drupal.org packaging script on 2020-01-28 +version: '8.x-3.0' project: 'field_group' -datestamp: 1558647188 +datestamp: 1580250789 diff --git a/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php b/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php index ce2e20d703..7eda8fa638 100644 --- a/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php +++ b/web/modules/field_group/tests/src/Functional/EntityDisplayTest.php @@ -40,6 +40,11 @@ class EntityDisplayTest extends BrowserTestBase { */ protected $node; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'classy'; + /** * {@inheritdoc} */ diff --git a/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php b/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php index bcb7600984..4c443882be 100644 --- a/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php +++ b/web/modules/field_group/tests/src/Functional/FieldGroupWithoutFieldUiTest.php @@ -17,6 +17,11 @@ class FieldGroupWithoutFieldUiTest extends BrowserTestBase { */ public static $modules = ['field_group', 'block']; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * Test that local actions show up without field ui enabled. */ diff --git a/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php b/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php index f05c56d1c2..f23f7f62c4 100644 --- a/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php +++ b/web/modules/field_group/tests/src/Functional/ManageDisplayTest.php @@ -25,7 +25,10 @@ class ManageDisplayTest extends BrowserTestBase { */ protected $type; - protected $strictConfigSchema = FALSE; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; /** * {@inheritdoc} @@ -84,6 +87,9 @@ public function testCreateGroup() { $this->group = field_group_load_field_group($group_name, 'node', $this->type, 'form', 'default'); $this->assertNotNull($group, 'Group was loaded'); + // Test if region key is set. + $this->assertEquals('hidden', $this->group->region); + // Add new group on the 'Manage display' page. $this->drupalPostForm('admin/structure/types/manage/' . $this->type . '/display/add-group', $group, 'Save and continue'); $this->drupalPostForm(NULL, [], 'Create group'); diff --git a/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php b/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php index e237c73f14..48b9eb4efb 100644 --- a/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php +++ b/web/modules/field_group/tests/src/FunctionalJavascript/FieldGroupUiTest.php @@ -30,6 +30,11 @@ class FieldGroupUiTest extends WebDriverTestBase { */ protected $nodeType; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'stark'; + /** * {@inheritdoc} */ @@ -62,15 +67,19 @@ public function setUp() { */ public function testCreateAndEdit() { foreach (['test_1', 'test_2'] as $name) { - $group = [ - 'group_formatter' => 'details', - 'label' => 'Test 1', - 'group_name' => $name, - ]; - - // Add new group on the 'Manage form display' page. - $this->drupalPostForm('admin/structure/types/manage/' . $this->nodeType . '/form-display/add-group', $group, 'Save and continue'); - $this->drupalPostForm(NULL, [], 'Create group'); + $this->drupalGet('admin/structure/types/manage/' . $this->nodeType . '/form-display/add-group'); + $page = $this->getSession()->getPage(); + + // Type the label to activate the machine name field and the edit button. + $page->fillField('group_formatter', 'details'); + $page->fillField('label', 'Test 1'); + // Wait for the machine name widget to be activated. + $this->assertSession()->waitForElementVisible('css', 'button[type=button].link:contains(Edit)'); + // Activate the machine name text field. + $page->pressButton('Edit'); + $page->fillField('Machine-readable name', $name); + $page->pressButton('Save and continue'); + $page->pressButton('Create group'); } // Update title in group 1. @@ -100,10 +109,7 @@ public function testCreateAndEdit() { /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $display */ $display = EntityFormDisplay::load("node.{$this->nodeType}.default"); $this->assertSame('Test 1 - Update', $display->getThirdPartySetting('field_group', 'group_test_1')['label']); - $this->assertSame('Test 1 - Update', $display->getThirdPartySetting('field_group', 'group_test_1')['format_settings']['label']); - $this->assertSame('Test 2 - Update', $display->getThirdPartySetting('field_group', 'group_test_2')['label']); - $this->assertSame('Test 2 - Update', $display->getThirdPartySetting('field_group', 'group_test_2')['format_settings']['label']); } } -- GitLab