updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
+90 -54
View File
@@ -3,7 +3,7 @@
* Attaches the behaviors for the Field UI module.
*/
(function ($, Drupal, drupalSettings) {
(function($, Drupal, drupalSettings) {
/**
* @type {Drupal~behavior}
*
@@ -12,26 +12,34 @@
*/
Drupal.behaviors.fieldUIFieldStorageAddForm = {
attach(context) {
const $form = $(context).find('[data-drupal-selector="field-ui-field-storage-add-form"]').once('field_ui_add');
const $form = $(context)
.find('[data-drupal-selector="field-ui-field-storage-add-form"]')
.once('field_ui_add');
if ($form.length) {
// Add a few 'js-form-required' and 'form-required' css classes here.
// We can not use the Form API '#required' property because both label
// elements for "add new" and "re-use existing" can never be filled and
// submitted at the same time. The actual validation will happen
// server-side.
$form.find(
'.js-form-item-label label,' +
'.js-form-item-field-name label,' +
'.js-form-item-existing-storage-label label')
$form
.find(
'.js-form-item-label label,' +
'.js-form-item-field-name label,' +
'.js-form-item-existing-storage-label label',
)
.addClass('js-form-required form-required');
const $newFieldType = $form.find('select[name="new_storage_type"]');
const $existingStorageName = $form.find('select[name="existing_storage_name"]');
const $existingStorageLabel = $form.find('input[name="existing_storage_label"]');
const $existingStorageName = $form.find(
'select[name="existing_storage_name"]',
);
const $existingStorageLabel = $form.find(
'input[name="existing_storage_label"]',
);
// When the user selects a new field type, clear the "existing field"
// selection.
$newFieldType.on('change', function () {
$newFieldType.on('change', function() {
if ($(this).val() !== '') {
// Reset the "existing storage name" selection.
$existingStorageName.val('').trigger('change');
@@ -40,15 +48,19 @@
// When the user selects an existing storage name, clear the "new field
// type" selection and populate the 'existing_storage_label' element.
$existingStorageName.on('change', function () {
$existingStorageName.on('change', function() {
const value = $(this).val();
if (value !== '') {
// Reset the "new field type" selection.
$newFieldType.val('').trigger('change');
// Pre-populate the "existing storage label" element.
if (typeof drupalSettings.existingFieldLabels[value] !== 'undefined') {
$existingStorageLabel.val(drupalSettings.existingFieldLabels[value]);
if (
typeof drupalSettings.existingFieldLabels[value] !== 'undefined'
) {
$existingStorageLabel.val(
drupalSettings.existingFieldLabels[value],
);
}
}
});
@@ -68,9 +80,16 @@
*/
Drupal.behaviors.fieldUIDisplayOverview = {
attach(context, settings) {
$(context).find('table#field-display-overview').once('field-display-overview').each(function () {
Drupal.fieldUIOverview.attach(this, settings.fieldUIRowsData, Drupal.fieldUIDisplayOverview);
});
$(context)
.find('table#field-display-overview')
.once('field-display-overview')
.each(function() {
Drupal.fieldUIOverview.attach(
this,
settings.fieldUIRowsData,
Drupal.fieldUIDisplayOverview,
);
});
},
};
@@ -80,7 +99,6 @@
* @namespace
*/
Drupal.fieldUIOverview = {
/**
* Attaches the fieldUIOverview behavior.
*
@@ -99,19 +117,21 @@
tableDrag.row.prototype.onSwap = this.onSwap;
// Create row handlers.
$(table).find('tr.draggable').each(function () {
// Extract server-side data for the row.
const row = this;
if (row.id in rowsData) {
const data = rowsData[row.id];
data.tableDrag = tableDrag;
$(table)
.find('tr.draggable')
.each(function() {
// Extract server-side data for the row.
const row = this;
if (row.id in rowsData) {
const data = rowsData[row.id];
data.tableDrag = tableDrag;
// Create the row handler, make it accessible from the DOM row
// element.
const rowHandler = new rowHandlers[data.rowHandler](row, data);
$(row).data('fieldUIRowHandler', rowHandler);
}
});
// Create the row handler, make it accessible from the DOM row
// element.
const rowHandler = new rowHandlers[data.rowHandler](row, data);
$(row).data('fieldUIRowHandler', rowHandler);
}
});
},
/**
@@ -150,7 +170,10 @@
const rowHandler = $row.data('fieldUIRowHandler');
if (typeof rowHandler !== 'undefined') {
const regionRow = $row.prevAll('tr.region-message').get(0);
const region = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
const region = regionRow.className.replace(
/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/,
'$2',
);
if (region !== rowHandler.region) {
// Let the row handler deal with the region change.
@@ -173,26 +196,37 @@
*/
onSwap(draggedRow) {
const rowObject = this;
$(rowObject.table).find('tr.region-message').each(function () {
const $this = $(this);
// If the dragged row is in this region, but above the message row, swap
// it down one space.
if ($this.prev('tr').get(0) === rowObject.group[rowObject.group.length - 1]) {
// Prevent a recursion problem when using the keyboard to move rows
// up.
if ((rowObject.method !== 'keyboard' || rowObject.direction === 'down')) {
rowObject.swap('after', this);
$(rowObject.table)
.find('tr.region-message')
.each(function() {
const $this = $(this);
// If the dragged row is in this region, but above the message row, swap
// it down one space.
if (
$this.prev('tr').get(0) ===
rowObject.group[rowObject.group.length - 1]
) {
// Prevent a recursion problem when using the keyboard to move rows
// up.
if (
rowObject.method !== 'keyboard' ||
rowObject.direction === 'down'
) {
rowObject.swap('after', this);
}
}
}
// This region has become empty.
if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length === 0) {
$this.removeClass('region-populated').addClass('region-empty');
}
// This region has become populated.
else if ($this.is('.region-empty')) {
$this.removeClass('region-empty').addClass('region-populated');
}
});
// This region has become empty.
if (
$this.next('tr').is(':not(.draggable)') ||
$this.next('tr').length === 0
) {
$this.removeClass('region-populated').addClass('region-empty');
}
// This region has become populated.
else if ($this.is('.region-empty')) {
$this.removeClass('region-empty').addClass('region-populated');
}
});
},
/**
@@ -212,14 +246,14 @@
// Separate keys and values.
const rowNames = [];
const ajaxElements = [];
Object.keys(rows || {}).forEach((rowName) => {
Object.keys(rows || {}).forEach(rowName => {
rowNames.push(rowName);
ajaxElements.push(rows[rowName]);
});
if (rowNames.length) {
// Add a throbber next each of the ajaxElements.
$(ajaxElements).after('<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>');
$(ajaxElements).after(Drupal.theme.ajaxProgressThrobber());
// Fire the Ajax update.
$('input[name=refresh_rows]').val(rowNames.join(' '));
@@ -254,7 +288,7 @@
* @return {Drupal.fieldUIDisplayOverview.field}
* The field row handler constructed.
*/
Drupal.fieldUIDisplayOverview.field = function (row, data) {
Drupal.fieldUIDisplayOverview.field = function(row, data) {
this.row = row;
this.name = data.name;
this.region = data.region;
@@ -273,7 +307,6 @@
};
Drupal.fieldUIDisplayOverview.field.prototype = {
/**
* Returns the region corresponding to the current form values of the row.
*
@@ -313,7 +346,10 @@
// Restore the formatter back to the default formatter. Pseudo-fields
// do not have default formatters, we just return to 'visible' for
// those.
const value = (typeof this.defaultPlugin !== 'undefined') ? this.defaultPlugin : this.$pluginSelect.find('option').val();
const value =
typeof this.defaultPlugin !== 'undefined'
? this.defaultPlugin
: this.$pluginSelect.find('option').val();
if (typeof value !== 'undefined') {
this.$pluginSelect.val(value);
@@ -325,4 +361,4 @@
return refreshRows;
},
};
}(jQuery, Drupal, drupalSettings));
})(jQuery, Drupal, drupalSettings);
+1 -1
View File
@@ -5,4 +5,4 @@ package: Core
version: VERSION
core: 8.x
dependencies:
- field
- drupal:field
+1 -1
View File
@@ -126,7 +126,7 @@
});
if (rowNames.length) {
$(ajaxElements).after('<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>');
$(ajaxElements).after(Drupal.theme.ajaxProgressThrobber());
$('input[name=refresh_rows]').val(rowNames.join(' '));
$('input[data-drupal-selector="edit-refresh"]').trigger('mousedown');
@@ -21,7 +21,8 @@ class FieldConfigListController extends EntityListController {
* The current route match.
*
* @return array
* A render array as expected by drupal_render().
* A render array as expected by
* \Drupal\Core\Render\RendererInterface::render().
*/
public function listing($entity_type_id = NULL, $bundle = NULL, RouteMatchInterface $route_match = NULL) {
return $this->entityManager()->getListBuilder('field_config')->render($entity_type_id, $bundle);
@@ -38,7 +38,7 @@ class FieldUiTable extends Table {
* @return array
* The $element with prepared variables ready for field-ui-table.html.twig.
*
* @see drupal_render()
* @see \Drupal\Core\Render\RendererInterface::render()
* @see \Drupal\Core\Render\Element\Table::preRenderTable()
*/
public static function tablePreRender($elements) {
@@ -159,7 +159,7 @@ class FieldUiTable extends Table {
$elements['#rows'][] = [
'class' => [
'region-title',
'region-' . $region_name_class . '-title'
'region-' . $region_name_class . '-title',
],
'no_striping' => TRUE,
'data' => [
@@ -36,6 +36,8 @@ class EntityDisplayModeListBuilder extends ConfigEntityListBuilder {
public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, array $entity_types) {
parent::__construct($entity_type, $storage);
// Override the default limit (50) in order to display all view modes.
$this->limit = FALSE;
$this->entityTypes = $entity_types;
}
@@ -162,7 +162,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'weight' => 10,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-edit-form"),
'attributes' => [
'title' => $this->t('Edit field settings.')
'title' => $this->t('Edit field settings.'),
],
];
}
@@ -172,7 +172,7 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'weight' => 100,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-delete-form"),
'attributes' => [
'title' => $this->t('Delete field.')
'title' => $this->t('Delete field.'),
],
];
}
@@ -55,10 +55,10 @@ class FieldUiPermissions implements ContainerInjectionInterface {
'restrict access' => TRUE,
];
$permissions['administer ' . $entity_type_id . ' form display'] = [
'title' => $this->t('%entity_label: Administer form display', ['%entity_label' => $entity_type->getLabel()])
'title' => $this->t('%entity_label: Administer form display', ['%entity_label' => $entity_type->getLabel()]),
];
$permissions['administer ' . $entity_type_id . ' display'] = [
'title' => $this->t('%entity_label: Administer display', ['%entity_label' => $entity_type->getLabel()])
'title' => $this->t('%entity_label: Administer display', ['%entity_label' => $entity_type->getLabel()]),
];
}
}
@@ -94,11 +94,11 @@ abstract class EntityDisplayFormBase extends EntityForm {
'content' => [
'title' => $this->t('Content'),
'invisible' => TRUE,
'message' => $this->t('No field is displayed.')
'message' => $this->t('No field is displayed.'),
],
'hidden' => [
'title' => $this->t('Disabled', [], ['context' => 'Plural']),
'message' => $this->t('No field is hidden.')
'message' => $this->t('No field is hidden.'),
],
];
}
@@ -147,7 +147,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
];
if (empty($field_definitions) && empty($extra_fields) && $route_info = FieldUI::getOverviewRouteInfo($this->entity->getTargetEntityTypeId(), $this->entity->getTargetBundle())) {
drupal_set_message($this->t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => $route_info->toString()]), 'warning');
$this->messenger()->addWarning($this->t('There are no fields yet added. You can add new fields on the <a href=":link">Manage fields</a> page.', [':link' => $route_info->toString()]));
return $form;
}
@@ -210,6 +210,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
if ($enabled_displays = array_filter($this->getDisplayStatuses())) {
$default = array_keys(array_intersect_key($display_mode_options, $enabled_displays));
}
natcasesort($display_mode_options);
$form['modes']['display_modes_custom'] = [
'#type' => 'checkboxes',
'#title' => $this->t('Use custom display settings for the following @display_context modes', ['@display_context' => $this->displayContext]),
@@ -241,7 +242,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
// spinners will be added manually by the client-side script.
'progress' => 'none',
],
'#attributes' => ['class' => ['visually-hidden']]
'#attributes' => ['class' => ['visually-hidden']],
];
$form['actions'] = ['#type' => 'actions'];
@@ -544,7 +545,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
$display_mode_label = $display_modes[$mode]['label'];
$url = $this->getOverviewUrl($mode);
drupal_set_message($this->t('The %display_mode mode now uses custom display settings. You might want to <a href=":url">configure them</a>.', ['%display_mode' => $display_mode_label, ':url' => $url->toString()]));
$this->messenger()->addStatus($this->t('The %display_mode mode now uses custom display settings. You might want to <a href=":url">configure them</a>.', ['%display_mode' => $display_mode_label, ':url' => $url->toString()]));
}
$statuses[$mode] = !empty($value);
}
@@ -552,7 +553,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
$this->saveDisplayStatuses($statuses);
}
drupal_set_message($this->t('Your settings have been saved.'));
$this->messenger()->addStatus($this->t('Your settings have been saved.'));
}
/**
@@ -702,7 +703,7 @@ abstract class EntityDisplayFormBase extends EntityForm {
*
* @return array
*
* @see drupal_render()
* @see \Drupal\Core\Render\RendererInterface::render()
* @see \Drupal\Core\Render\Element\Table::preRenderTable()
*
* @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
@@ -78,7 +78,7 @@ abstract class EntityDisplayModeFormBase extends EntityForm {
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
drupal_set_message($this->t('Saved the %label @entity-type.', ['%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel()]));
$this->messenger()->addStatus($this->t('Saved the %label @entity-type.', ['%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel()]));
$this->entity->save();
\Drupal::entityManager()->clearCachedFieldDefinitions();
$form_state->setRedirectUrl($this->entity->urlInfo('collection'));
@@ -73,8 +73,8 @@ class EntityViewDisplayEditForm extends EntityDisplayFormBase {
// Insert an empty placeholder for the label column.
$label = [
'empty_cell' => [
'#markup' => '&nbsp;'
]
'#markup' => '&nbsp;',
],
];
$label_position = array_search('plugin', array_keys($extra_field_row));
$extra_field_row = array_slice($extra_field_row, 0, $label_position, TRUE) + $label + array_slice($extra_field_row, $label_position, count($extra_field_row) - 1, TRUE);
@@ -98,10 +98,10 @@ class FieldConfigDeleteForm extends EntityDeleteForm {
if ($field_storage && !$field_storage->isLocked()) {
$this->entity->delete();
drupal_set_message($this->t('The field %field has been deleted from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
$this->messenger()->addStatus($this->t('The field %field has been deleted from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
}
else {
drupal_set_message($this->t('There was a problem removing the %field from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]), 'error');
$this->messenger()->addError($this->t('There was a problem removing the %field from the %type content type.', ['%field' => $this->entity->label(), '%type' => $bundle_label]));
}
$form_state->setRedirectUrl($this->getCancelUrl());
@@ -77,7 +77,7 @@ class FieldConfigEditForm extends EntityForm {
$ids = (object) [
'entity_type' => $this->entity->getTargetEntityTypeId(),
'bundle' => $this->entity->getTargetBundle(),
'entity_id' => NULL
'entity_id' => NULL,
];
$form['#entity'] = _field_create_entity_from_ids($ids);
$items = $form['#entity']->get($this->entity->getName());
@@ -177,7 +177,7 @@ class FieldConfigEditForm extends EntityForm {
public function save(array $form, FormStateInterface $form_state) {
$this->entity->save();
drupal_set_message($this->t('Saved %label configuration.', ['%label' => $this->entity->getLabel()]));
$this->messenger()->addStatus($this->t('Saved %label configuration.', ['%label' => $this->entity->getLabel()]));
$request = $this->getRequest();
if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) {
@@ -370,7 +370,7 @@ class FieldStorageAddForm extends FormBase {
}
catch (\Exception $e) {
$error = TRUE;
drupal_set_message($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]), 'error');
$this->messenger()->addError($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]));
}
}
@@ -401,7 +401,7 @@ class FieldStorageAddForm extends FormBase {
}
catch (\Exception $e) {
$error = TRUE;
drupal_set_message($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]), 'error');
$this->messenger()->addError($this->t('There was a problem creating field %label: @message', ['%label' => $values['label'], '@message' => $e->getMessage()]));
}
}
@@ -411,7 +411,7 @@ class FieldStorageAddForm extends FormBase {
$form_state->setRedirectUrl(FieldUI::getNextDestination($destinations, $form_state));
}
elseif (!$error) {
drupal_set_message($this->t('Your settings have been saved.'));
$this->messenger()->addStatus($this->t('Your settings have been saved.'));
}
}
@@ -84,7 +84,7 @@ class FieldStorageConfigEditForm extends EntityForm {
$ids = (object) [
'entity_type' => $form_state->get('entity_type_id'),
'bundle' => $form_state->get('bundle'),
'entity_id' => NULL
'entity_id' => NULL,
];
$entity = _field_create_entity_from_ids($ids);
$items = $entity->get($this->entity->getName());
@@ -222,7 +222,7 @@ class FieldStorageConfigEditForm extends EntityForm {
$field_label = $form_state->get('field_config')->label();
try {
$this->entity->save();
drupal_set_message($this->t('Updated field %label field settings.', ['%label' => $field_label]));
$this->messenger()->addStatus($this->t('Updated field %label field settings.', ['%label' => $field_label]));
$request = $this->getRequest();
if (($destinations = $request->query->get('destinations')) && $next_destination = FieldUI::getNextDestination($destinations)) {
$request->query->remove('destinations');
@@ -233,7 +233,7 @@ class FieldStorageConfigEditForm extends EntityForm {
}
}
catch (\Exception $e) {
drupal_set_message($this->t('Attempt to update field %label failed: %message.', ['%label' => $field_label, '%message' => $e->getMessage()]), 'error');
$this->messenger()->addStatus($this->t('Attempt to update field %label failed: %message.', ['%label' => $field_label, '%message' => $e->getMessage()]));
}
}
@@ -2,7 +2,6 @@
namespace Drupal\field_ui\Tests;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\Core\Entity\EntityInterface;
@@ -48,7 +47,7 @@ class ManageDisplayTest extends WebTestBase {
$vocabulary = Vocabulary::create([
'name' => $this->randomMachineName(),
'description' => $this->randomMachineName(),
'vid' => Unicode::strtolower($this->randomMachineName()),
'vid' => mb_strtolower($this->randomMachineName()),
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'help' => '',
'nodes' => ['article' => 'article'],
@@ -119,7 +118,7 @@ class ManageDisplayTest extends WebTestBase {
$edit = [
'fields[field_test][type]' => 'field_test_multiple',
'fields[field_test][region]' => 'content',
'refresh_rows' => 'field_test'
'refresh_rows' => 'field_test',
];
$this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Refresh')]);
$format = 'field_test_multiple';
@@ -252,6 +251,7 @@ class ManageDisplayTest extends WebTestBase {
}, $result);
$expected_options = [
'test_field_widget',
'test_field_widget_multilingual',
'test_field_widget_multiple',
];
$this->assertEqual($options, $expected_options, 'The expected widget ordering is respected.');
@@ -313,8 +313,8 @@ class ManageDisplayTest extends WebTestBase {
$this->drupalGet($manage_display);
// Checks if the select elements contain the specified options.
$this->assertFieldSelectOptions('fields[field_test][type]', ['test_field_widget', 'test_field_widget_multiple']);
$this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', ['test_field_widget']);
$this->assertFieldSelectOptions('fields[field_test][type]', ['test_field_widget', 'test_field_widget_multilingual', 'test_field_widget_multiple']);
$this->assertFieldSelectOptions('fields[field_onewidgetfield][type]', ['test_field_widget', 'test_field_widget_multilingual']);
// Ensure that fields can be hidden directly by changing the region.
$this->assertFieldByName('fields[field_test][region]', 'content');
@@ -2,7 +2,7 @@
namespace Drupal\field_ui\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
@@ -409,7 +409,7 @@ class ManageFieldsTest extends WebTestBase {
FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'node',
'type' => 'test_field'
'type' => 'test_field',
])->save();
$field = FieldConfig::create([
'field_name' => $field_name,
@@ -548,7 +548,7 @@ class ManageFieldsTest extends WebTestBase {
'entity_type' => 'node',
'type' => 'test_field',
'cardinality' => 1,
'locked' => TRUE
'locked' => TRUE,
]);
$field_storage->save();
FieldConfig::create([
@@ -616,10 +616,10 @@ class ManageFieldsTest extends WebTestBase {
$field_types = \Drupal::service('plugin.manager.field.field_type')->getDefinitions();
foreach ($field_types as $field_type => $definition) {
if (empty($definition['no_ui'])) {
$this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), SafeMarkup::format('Configurable field type @field_type is available.', ['@field_type' => $field_type]));
$this->assertTrue($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), new FormattableMarkup('Configurable field type @field_type is available.', ['@field_type' => $field_type]));
}
else {
$this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), SafeMarkup::format('Non-configurable field type @field_type is not available.', ['@field_type' => $field_type]));
$this->assertFalse($this->xpath('//select[@id="edit-new-storage-type"]//option[@value=:field_type]', [':field_type' => $field_type]), new FormattableMarkup('Non-configurable field type @field_type is not available.', ['@field_type' => $field_type]));
}
}
}
@@ -19,7 +19,7 @@ class EntityDisplayModeTest extends BrowserTestBase {
*
* @var string[]
*/
public static $modules = ['block', 'entity_test', 'field_ui'];
public static $modules = ['block', 'entity_test', 'field_ui', 'node'];
/**
* {@inheritdoc}
@@ -27,6 +27,12 @@ class EntityDisplayModeTest extends BrowserTestBase {
protected function setUp() {
parent::setUp();
// Create a node type.
$this->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('page_title_block');
}
@@ -140,4 +146,62 @@ class EntityDisplayModeTest extends BrowserTestBase {
$this->assertRaw(t('The form mode %label has been deleted.', ['%label' => $edit['label']]));
}
/**
* Tests if view modes appear in alphabetical order by visible name.
*
* The machine name should not be used for sorting.
*
* @see https://www.drupal.org/node/2858569
*/
public function testAlphabeticalDisplaySettings() {
$this->drupalLogin($this->drupalCreateUser([
'access administration pages',
'administer content types',
'administer display modes',
'administer nodes',
'administer node fields',
'administer node display',
'administer node form display',
'view the administration theme',
]));
$this->drupalGet('admin/structure/types/manage/article/display');
// Verify that the order of view modes is alphabetical by visible label.
// Since the default view modes all have machine names which coincide with
// the English labels, they should appear in alphabetical order, by default
// if viewing the site in English and if no changes have been made. We will
// verify this first.
$page_text = $this->getTextContent();
$start = strpos($page_text, 'view modes');
$pos = $start;
$list = ['Full content', 'RSS', 'Search index', 'Search result', 'Teaser'];
foreach ($list as $name) {
$new_pos = strpos($page_text, $name, $start);
$this->assertTrue($new_pos > $pos, 'Order of ' . $name . ' is correct on page');
$pos = $new_pos;
}
// Now that we have verified the original display order, we can change the
// label for one of the view modes. If we rename "Teaser" to "Breezer", it
// should appear as the first of the listed view modes:
// Set new values and enable test plugins.
$edit = [
'label' => 'Breezer',
];
$this->drupalPostForm('admin/structure/display-modes/view/manage/node.teaser', $edit, 'Save');
$this->assertSession()->pageTextContains('Saved the Breezer view mode.');
// Re-open the display settings for the article content type and verify
// that changing "Teaser" to "Breezer" makes it appear before "Full
// content".
$this->drupalGet('admin/structure/types/manage/article/display');
$page_text = $this->getTextContent();
$start = strpos($page_text, 'view modes');
$pos = $start;
$list = ['Breezer', 'Full content'];
foreach ($list as $name) {
$new_pos = strpos($page_text, $name, $start);
$this->assertTrue($new_pos > $pos, 'Order of ' . $name . ' is correct on page');
$pos = $new_pos;
}
}
}
@@ -3,14 +3,14 @@
namespace Drupal\Tests\field_ui\FunctionalJavascript;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
/**
* Tests the UI for entity displays.
*
* @group field_ui
*/
class EntityDisplayTest extends JavascriptTestBase {
class EntityDisplayTest extends WebDriverTestBase {
/**
* {@inheritdoc}
@@ -50,7 +50,8 @@ class EntityDisplayTest extends JavascriptTestBase {
$this->drupalGet('entity_test/structure/entity_test/form-display');
$this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'content')->isSelected());
$this->getSession()->getPage()->pressButton('Show row weights');
$this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]');
$this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'hidden');
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
@@ -72,6 +73,8 @@ class EntityDisplayTest extends JavascriptTestBase {
$this->drupalGet('entity_test/structure/entity_test/display');
$this->assertSession()->elementExists('css', '.region-content-message.region-empty');
$this->getSession()->getPage()->pressButton('Show row weights');
$this->assertSession()->waitForElementVisible('css', '[name="fields[field_test_text][region]"]');
$this->assertTrue($this->assertSession()->optionExists('fields[field_test_text][region]', 'hidden')->isSelected());
$this->getSession()->getPage()->selectFieldOption('fields[field_test_text][region]', 'content');
@@ -92,12 +95,16 @@ class EntityDisplayTest extends JavascriptTestBase {
public function testExtraFields() {
entity_test_create_bundle('bundle_with_extra_fields');
$this->drupalGet('entity_test/structure/bundle_with_extra_fields/display');
$this->assertSession()->waitForElement('css', '.tabledrag-handle');
$id = $this->getSession()->getPage()->find('css', '[name="form_build_id"]')->getValue();
$extra_field_row = $this->getSession()->getPage()->find('css', '#display-extra-field');
$disabled_region_row = $this->getSession()->getPage()->find('css', '.region-hidden-title');
$extra_field_row->find('css', '.handle')->dragTo($disabled_region_row);
$this->assertSession()->assertWaitOnAjaxRequest();
$this->assertSession()
->waitForElement('css', "[name='form_build_id']:not([value='$id'])");
$this->submitForm([], 'Save');
$this->assertSession()->pageTextContains('Your settings have been saved.');
@@ -3,7 +3,6 @@
namespace Drupal\Tests\field_ui\Kernel;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Database\Database;
use Drupal\Core\Entity\Display\EntityDisplayInterface;
@@ -87,7 +86,7 @@ class EntityDisplayTest extends KernelTestBase {
'link_to_entity' => FALSE,
],
'third_party_settings' => [],
'region' => 'content'
'region' => 'content',
];
$this->assertEqual($display->getComponents(), $expected);
@@ -166,7 +165,15 @@ class EntityDisplayTest extends KernelTestBase {
// Check that the default visibility taken into account for extra fields
// unknown in the display.
$this->assertEqual($display->getComponent('display_extra_field'), ['weight' => 5, 'region' => 'content']);
$this->assertEqual(
$display->getComponent('display_extra_field'),
[
'weight' => 5,
'region' => 'content',
'settings' => [],
'third_party_settings' => [],
]
);
$this->assertNull($display->getComponent('display_extra_field_hidden'));
// Check that setting explicit options overrides the defaults.
@@ -214,7 +221,7 @@ class EntityDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
'type' => 'test_field',
]);
$field_storage->save();
$field = FieldConfig::create([
@@ -360,7 +367,7 @@ class EntityDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
'type' => 'test_field',
]);
$field_storage->save();
$field = FieldConfig::create([
@@ -409,7 +416,7 @@ class EntityDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
'type' => 'text',
]);
$field_storage->save();
$field = FieldConfig::create([
@@ -515,14 +522,14 @@ class EntityDisplayTest extends KernelTestBase {
// Create two arbitrary user roles.
for ($i = 0; $i < 2; $i++) {
$roles[$i] = Role::create([
'id' => Unicode::strtolower($this->randomMachineName()),
'id' => mb_strtolower($this->randomMachineName()),
'label' => $this->randomString(),
]);
$roles[$i]->save();
}
// Create a field of type 'test_field' attached to 'entity_test'.
$field_name = Unicode::strtolower($this->randomMachineName());
$field_name = mb_strtolower($this->randomMachineName());
FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
@@ -55,7 +55,7 @@ class EntityFormDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
'type' => 'test_field',
]);
$field_storage->save();
$field = FieldConfig::create([
@@ -185,7 +185,7 @@ class EntityFormDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'test_field'
'type' => 'test_field',
]);
$field_storage->save();
$field = FieldConfig::create([
@@ -234,7 +234,7 @@ class EntityFormDisplayTest extends KernelTestBase {
$field_storage = FieldStorageConfig::create([
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'text'
'type' => 'text',
]);
$field_storage->save();
$field = FieldConfig::create([