Browse Source

Issue #3127484 by daniel.bosen, chr.fritsch, volkerk: Update to Entity Browser 2.4

tags/3.4.5
Daniel Bosen GitHub 3 months ago
parent
commit
ade0f9a777
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 88 additions and 46 deletions
  1. +2
    -3
      composer.json
  2. +4
    -4
      config/optional/core.entity_form_display.paragraph.image.default.yml
  3. +5
    -4
      config/optional/core.entity_form_display.paragraph.video.default.yml
  4. +1
    -1
      config/optional/field.field.paragraph.image.field_image.yml
  5. +1
    -1
      config/optional/field.field.paragraph.video.field_video.yml
  6. +2
    -3
      drupal-org.make
  7. +2
    -0
      modules/thunder_media/thunder_media.module
  8. +6
    -2
      modules/thunder_paragraphs/thunder_paragraphs.module
  9. +0
    -28
      tests/src/FunctionalJavascript/Integration/InlineEntityFormTest.php
  10. +49
    -0
      thunder.install
  11. +10
    -0
      thunder.profile
  12. +6
    -0
      updates_checklist.yml

+ 2
- 3
composer.json View File

@@ -65,8 +65,7 @@
},
"drupal/entity_browser": {
"Provide inline entity form FieldWidgetDisplay": "https://www.drupal.org/files/issues/2019-07-04/2858438_17.patch",
"Entity Browser iFrame 100% height can cause vertical scrollbar #3055358": "https://www.drupal.org/files/issues/2019-05-21/entity-browser-iframe-scrollbar-3055358-4.patch",
"Re-order + remove broken with the Entity Reference (and File) widget": "https://www.drupal.org/files/issues/2019-10-18/entity-browser-reorder-remove-2851580-67-stable.patch"
"Re-order + remove broken with the Entity Reference (and File) widget": "https://www.drupal.org/files/issues/2020-03-30/2851580-83.patch"
},
"drupal/password_policy": {
"Policies should declare a config dependency on the plugin modules": "https://www.drupal.org/files/issues/2019-06-13/2918974-7.patch",
@@ -103,7 +102,7 @@
"drupal/dropzonejs": "^2.0-alpha2",
"drupal/empty_fields": "^1.0-alpha1",
"drupal/entity": "^1.0",
"drupal/entity_browser": "2.2",
"drupal/entity_browser": "2.4",
"drupal/entity_reference_revisions": "^1.3",
"drupal/field_group": "^3.0-rc2",
"drupal/focal_point": "^1.2",


+ 4
- 4
config/optional/core.entity_form_display.paragraph.image.default.yml View File

@@ -16,13 +16,13 @@ content:
weight: 0
settings:
entity_browser: image_browser
field_widget_display: inline_entity_form
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
open: true
selection_mode: selection_append
field_widget_display_settings:
form_mode: inline
field_widget_edit: false
field_widget_replace: false
third_party_settings: { }
type: entity_browser_entity_reference


+ 5
- 4
config/optional/core.entity_form_display.paragraph.video.default.yml View File

@@ -16,13 +16,14 @@ content:
weight: 0
settings:
entity_browser: video_browser
field_widget_display: inline_entity_form
field_widget_display: rendered_entity
field_widget_display_settings:
view_mode: thumbnail
field_widget_edit: true
field_widget_remove: true
open: true
selection_mode: selection_append
field_widget_display_settings:
form_mode: inline
field_widget_edit: false
field_widget_replace: false
third_party_settings: { }
region: content
type: entity_browser_entity_reference


+ 1
- 1
config/optional/field.field.paragraph.image.field_image.yml View File

@@ -11,7 +11,7 @@ entity_type: paragraph
bundle: image
label: Image
description: ''
required: true
required: false
translatable: false
default_value: { }
default_value_callback: ''


+ 1
- 1
config/optional/field.field.paragraph.video.field_video.yml View File

@@ -11,7 +11,7 @@ entity_type: paragraph
bundle: video
label: Video
description: ''
required: true
required: false
translatable: false
default_value: { }
default_value_callback: ''


+ 2
- 3
drupal-org.make View File

@@ -43,10 +43,9 @@ projects[empty_fields][version] = 1
projects[entity][type] = module
projects[entity][version] = 1
projects[entity_browser][type] = module
projects[entity_browser][version] = 2.2
projects[entity_browser][version] = 2.4
projects[entity_browser][patch][] = https://www.drupal.org/files/issues/2019-07-04/2858438_17.patch
projects[entity_browser][patch][] = https://www.drupal.org/files/issues/2019-05-21/entity-browser-iframe-scrollbar-3055358-4.patch
projects[entity_browser][patch][] = https://www.drupal.org/files/issues/2019-10-18/entity-browser-reorder-remove-2851580-67-stable.patch
projects[entity_browser][patch][] = https://www.drupal.org/files/issues/2020-03-30/2851580-83.patch
projects[entity_reference_revisions][type] = module
projects[entity_reference_revisions][version] = 1
projects[fb_instant_articles][type] = module


+ 2
- 0
modules/thunder_media/thunder_media.module View File

@@ -68,6 +68,8 @@ function thunder_media_field_widget_entity_browser_entity_reference_form_alter(&
$field_name = $items->getName();
switch ($field_name) {
case 'field_teaser_media':
case 'field_image':
case 'field_video':
case 'field_media_images':
_thunder_media_media_field_widget_form_alter_helper($element, 'image');
break;


+ 6
- 2
modules/thunder_paragraphs/thunder_paragraphs.module View File

@@ -28,10 +28,14 @@ function thunder_paragraphs_field_widget_third_party_settings_form(WidgetInterfa

/**
* Implements hook_field_widget_WIDGET_TYPE_form_alter().
*
* TODO: Remove in Thunder 4, or when the inline entity form FieldWidgetDisplay
* was removed.
*/
function thunder_paragraphs_field_widget_entity_browser_entity_reference_form_alter(&$element, FormStateInterface $form_state, $context) {
/* @var $context['widget'] EntityReferenceBrowserWidget */
if (isset($context['widget']) && ($context['widget']->getSetting('field_widget_display') == 'inline_entity_form')) {
/* @var $context ['widget'] EntityReferenceBrowserWidget */
if (isset($context['widget']) && ($context['widget']->getSetting('field_widget_display') === 'inline_entity_form')) {
\Drupal::messenger()->addWarning(t('The inline_entity_form field widget display is broken and will be removed in Thunder 4.0.0. Please use a different display for your %title field.', ['%title' => $element['#title']]));
$element['#attach_ief_submit'] = TRUE;
}
}


+ 0
- 28
tests/src/FunctionalJavascript/Integration/InlineEntityFormTest.php View File

@@ -45,32 +45,4 @@ class InlineEntityFormTest extends ThunderJavascriptTestBase {
->pageTextContains('New gallery name before collapse');
}

/**
* Test saving collapsed video paragraph.
*
* Test saving changes in inline entity form using the
* inline_entity_form_simple_plus widget inside video paragraph when the
* paragraph form is collapsed.
*
* Demo Article (node Id: 7) is used for testing.
*/
public function testVideoCollapse() {

// Test saving inline entity form when collapsing paragraph form.
$this->drupalGet("node/7/edit");
$page = $this->getSession()->getPage();

// Edit video paragraph.
$this->clickButtonCssSelector($page, '[data-drupal-selector="field-paragraphs-2-edit-2"]');
$this->setFieldValue($page, 'field_paragraphs[2][subform][field_video][current][items][0][display][field_copyright][0][value]', 'New copyright before collapse');

// Collapse parargraph form.
$this->clickButtonCssSelector($page, '[name="field_paragraphs_2_collapse"]');
$this->clickSave();

// Re-open edit form, value has changed.
$this->drupalGet("node/7/edit");
$this->assertSession()->pageTextContains('New copyright before collapse');
}

}

+ 49
- 0
thunder.install View File

@@ -186,3 +186,52 @@ function thunder_update_8306() {
// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}

/**
* Change entity browser widget in paragraphs integration.
*/
function thunder_update_8307() {
/** @var \Drupal\update_helper\Updater $updateHelper */
$updateHelper = \Drupal::service('update_helper.updater');
$configFactory = \Drupal::configFactory();

// Modify paragraph form displays using inline_entity_form.
$entityFormDisplayIds = Drupal::entityQuery('entity_form_display')
->condition('targetEntityType', 'paragraph')
->execute();

try {
$entityFormDisplayStorage = \Drupal::entityTypeManager()->getStorage('entity_form_display');
foreach ($entityFormDisplayIds as $entityFormDisplayId) {
/** @var \Drupal\Core\Entity\EntityDisplayBase $entityFormDisplay */
$entityFormDisplay = $entityFormDisplayStorage->load($entityFormDisplayId);

foreach ($entityFormDisplay->getComponents() as $name => $options) {
// Modify only entity_browser_entity_reference fields with field widget
// display 'inline_entity_form'.
if ($options['type'] !== 'entity_browser_entity_reference' || $options['settings']['field_widget_display'] !== 'inline_entity_form') {
continue;
}

unset($options['settings']['field_widget_display_settings']['form_mode']);
$options['settings']['field_widget_display'] = 'rendered_entity';
$options['settings']['field_widget_edit'] = TRUE;
$options['settings']['field_widget_display_settings']['view_mode'] = 'thumbnail';
$entityFormDisplay->setComponent($name, $options)->save();

// These kind of fields cannot be required.
$field_id = 'field.field.' . $entityFormDisplay->getTargetEntityTypeId() . '.' . $entityFormDisplay->get('bundle') . '.' . $name;
$field = $configFactory->getEditable($field_id);
$field->set('required', FALSE)->save();

$updateHelper->logger()->info('Converted field_widget_display from inline_entity form to rendered_entity for field ' . $name . ' in the ' . $entityFormDisplay->get('bundle') . ' paragraph ');
}
}
}
catch (\Exception $e) {
$updateHelper->logger()->error($e->getMessage());
}

// Output logged messages to related channel of update execution.
return $updateHelper->logger()->output();
}

+ 10
- 0
thunder.profile View File

@@ -397,3 +397,13 @@ function thunder_field_widget_info_alter(array &$info) {
unset($info['thunder_moderation_state_default']);
}
}

/**
* Implements hook_field_widget_multivalue_WIDGET_TYPE_form_alter().
*
* Removes the cardinality information from the #prefix element of the current
* selection.
*/
function thunder_field_widget_multivalue_entity_browser_entity_reference_form_alter(array &$elements, FormStateInterface $form_state, array $context) {
unset($elements['current']['#prefix']);
}

+ 6
- 0
updates_checklist.yml View File

@@ -45,3 +45,9 @@ v4.4:
'#description': '<p>This configuration update will update site configuration to newly provided configuration</p>'
'#description_successful': '<p>Configuration is successfully updated.</p>'
'#description_failed': '<p><strong>Update of configuration has failed. The order of paragraph types can be aligned manually in field_paragraphs field configuration for taxonomy terms of bundles news and tags.</strong><p>'
v4.5:
'#title': 'Update to version v4.5'
'#description': '<h3>These are the new features for this release:</h3>'
thunder_update_8307:
'#title': 'Update and reconfigure entity browser widget.'
'#description': '<p>The entity browser configuration in paragraphs has changed. We do not use the inline entity forms field widget anymore, and use the rendered entity instead. We recommend to manually check all paragraphs, that use the inline entity form field widget for media entities. Make sure those widgets are changed to rendered entity.</p>'

Loading…
Cancel
Save