upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
+2 -1
View File
@@ -255,7 +255,8 @@ function views_ui_standard_display_dropdown(&$form, FormStateInterface $form_sta
$form['override']['dropdown'] = [
'#type' => 'select',
'#title' => t('For'), // @TODO: Translators may need more context than this.
// @TODO: Translators may need more context than this.
'#title' => t('For'),
'#options' => $display_dropdown,
];
if ($current_display->isDefaulted($section)) {
+1 -1
View File
@@ -147,7 +147,7 @@
margin-bottom: 2em;
}
@media screen and (min-width:45em) { /* 720px */
@media screen and (min-width: 45em) { /* 720px */
.views-display-columns > * {
float: left; /* LTR */
margin-left: 2%; /* LTR */
@@ -158,7 +158,7 @@ details.box-padding {
/* Hide 'remove' checkboxes. */
.views-remove-checkbox {
display: none;
display: none;
}
/* sizes the labels of checkboxes and radio button to the height of the text */
@@ -345,7 +345,7 @@ td.group-title {
padding: 0;
width: auto;
}
.views-displays .tabs li.add ul.action-list li{
.views-displays .tabs li.add ul.action-list li {
margin: 0;
}
.views-displays .tabs.secondary li {
@@ -402,7 +402,7 @@ td.group-title {
color: #0074bd;
background-color: #f1f1f1;
}
.views-displays .tabs .action-list li {
.views-displays .tabs .action-list li {
background-color: #f1f1f1;
border-color: #cbcbcb;
border-style: solid;
@@ -412,10 +412,10 @@ td.group-title {
.views-displays .tabs .action-list li:first-child {
border-width: 1px 1px 0;
}
.views-displays .action-list li:last-child {
.views-displays .action-list li:last-child {
border-width: 0 1px 1px;
}
.views-displays .tabs .action-list li:last-child {
.views-displays .tabs .action-list li:last-child {
border-width: 0 1px 1px;
}
.views-displays .tabs .action-list input.form-submit {
@@ -483,7 +483,7 @@ td.group-title {
.view-preview-form .form-actions {
vertical-align: top;
}
@media screen and (min-width:45em) { /* 720px */
@media screen and (min-width: 45em) { /* 720px */
.view-preview-form .form-type-textfield .description {
white-space: nowrap;
}
+244
View File
@@ -0,0 +1,244 @@
/**
* @file
* Handles AJAX submission and response in Views UI.
*/
(function ($, Drupal, drupalSettings) {
/**
* Ajax command for highlighting elements.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {string} response.selector
* The selector in question.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
$('.hilited').removeClass('hilited');
$(response.selector).addClass('hilited');
};
/**
* Ajax command to set the form submit action in the views modal edit form.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response. Contains .url
* @param {string} [status]
* The XHR status code?
*/
Drupal.AjaxCommands.prototype.viewsSetForm = function (ajax, response, status) {
const $form = $('.js-views-ui-dialog form');
// Identify the button that was clicked so that .ajaxSubmit() can use it.
// We need to do this for both .click() and .mousedown() since JavaScript
// code might trigger either behavior.
const $submit_buttons = $form.find('input[type=submit].js-form-submit, button.js-form-submit').once('views-ajax-submit');
$submit_buttons.on('click mousedown', function () {
this.form.clk = this;
});
$form.once('views-ajax-submit').each(function () {
const $form = $(this);
const element_settings = {
url: response.url,
event: 'submit',
base: $form.attr('id'),
element: this,
};
const ajaxForm = Drupal.ajax(element_settings);
ajaxForm.$form = $form;
});
};
/**
* Ajax command to show certain buttons in the views edit form.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {bool} response.changed
* Whether the state changed for the buttons or not.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
if (response.changed) {
$('div.views-edit-view div.view-changed.messages').removeClass('js-hide');
}
};
/**
* Ajax command for triggering preview.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} [response]
* The Ajax response.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
if ($('input#edit-displays-live-preview').is(':checked')) {
$('#preview-submit').trigger('click');
}
};
/**
* Ajax command to replace the title of a page.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {string} response.siteName
* The site name.
* @param {string} response.title
* The new page title.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
const doc = document;
// For the <title> element, make a best-effort attempt to replace the page
// title and leave the site name alone. If the theme doesn't use the site
// name in the <title> element, this will fail.
const oldTitle = doc.title;
// Escape the site name, in case it has special characters in it, so we can
// use it in our regex.
const escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
const re = new RegExp(`.+ (.) ${escapedSiteName}`);
doc.title = oldTitle.replace(re, `${response.title} $1 ${response.siteName}`);
$('h1.page-title').text(response.title);
};
/**
* Get rid of irritating tabledrag messages.
*
* @return {Array}
* An array of messages. Always empty array, to get rid of the messages.
*/
Drupal.theme.tableDragChangedWarning = function () {
return [];
};
/**
* Trigger preview when the "live preview" checkbox is checked.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches behavior to trigger live preview if the live preview option is
* checked.
*/
Drupal.behaviors.livePreview = {
attach(context) {
$('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () {
if ($(this).is(':checked')) {
$('#preview-submit').trigger('click');
}
});
},
};
/**
* Sync preview display.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches behavior to sync the preview display when needed.
*/
Drupal.behaviors.syncPreviewDisplay = {
attach(context) {
$('#views-tabset a').once('views-ajax').on('click', function () {
const href = $(this).attr('href');
// Cut of #views-tabset.
const display_id = href.substr(11);
// Set the form element.
$('#views-live-preview #preview-display-id').val(display_id);
});
},
};
/**
* Ajax behaviors for the views_ui module.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches ajax behaviors to the elements with the classes in question.
*/
Drupal.behaviors.viewsAjax = {
collapseReplaced: false,
attach(context, settings) {
const base_element_settings = {
event: 'click',
progress: { type: 'fullscreen' },
};
// Bind AJAX behaviors to all items showing the class.
$('a.views-ajax-link', context).once('views-ajax').each(function () {
const element_settings = base_element_settings;
element_settings.base = $(this).attr('id');
element_settings.element = this;
// Set the URL to go to the anchor.
if ($(this).attr('href')) {
element_settings.url = $(this).attr('href');
}
Drupal.ajax(element_settings);
});
$('div#views-live-preview a')
.once('views-ajax').each(function () {
// We don't bind to links without a URL.
if (!$(this).attr('href')) {
return true;
}
const element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this).attr('href');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
});
// Within a live preview, make exposed widget form buttons re-trigger the
// Preview button.
// @todo Revisit this after fixing Views UI to display a Preview outside
// of the main Edit form.
$('div#views-live-preview input[type=submit]')
.once('views-ajax').each(function (event) {
$(this).on('click', function () {
this.form.clk = this;
return true;
});
const element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this.form).attr('action');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.event = 'click';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
});
},
};
}(jQuery, Drupal, drupalSettings));
+50 -154
View File
@@ -1,44 +1,19 @@
/**
* @file
* Handles AJAX submission and response in Views UI.
*/
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, drupalSettings) {
'use strict';
/**
* Ajax command for highlighting elements.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {string} response.selector
* The selector in question.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsHighlight = function (ajax, response, status) {
$('.hilited').removeClass('hilited');
$(response.selector).addClass('hilited');
};
/**
* Ajax command to set the form submit action in the views modal edit form.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response. Contains .url
* @param {string} [status]
* The XHR status code?
*/
Drupal.AjaxCommands.prototype.viewsSetForm = function (ajax, response, status) {
var $form = $('.js-views-ui-dialog form');
// Identify the button that was clicked so that .ajaxSubmit() can use it.
// We need to do this for both .click() and .mousedown() since JavaScript
// code might trigger either behavior.
var $submit_buttons = $form.find('input[type=submit].js-form-submit, button.js-form-submit').once('views-ajax-submit');
$submit_buttons.on('click mousedown', function () {
this.form.clk = this;
@@ -56,18 +31,6 @@
});
};
/**
* Ajax command to show certain buttons in the views edit form.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {bool} response.changed
* Whether the state changed for the buttons or not.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsShowButtons = function (ajax, response, status) {
$('div.views-edit-view div.form-actions').removeClass('js-hide');
if (response.changed) {
@@ -75,44 +38,17 @@
}
};
/**
* Ajax command for triggering preview.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} [response]
* The Ajax response.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsTriggerPreview = function (ajax, response, status) {
if ($('input#edit-displays-live-preview').is(':checked')) {
$('#preview-submit').trigger('click');
}
};
/**
* Ajax command to replace the title of a page.
*
* @param {Drupal.Ajax} [ajax]
* An Ajax object.
* @param {object} response
* The Ajax response.
* @param {string} response.siteName
* The site name.
* @param {string} response.title
* The new page title.
* @param {number} [status]
* The HTTP status code.
*/
Drupal.AjaxCommands.prototype.viewsReplaceTitle = function (ajax, response, status) {
var doc = document;
// For the <title> element, make a best-effort attempt to replace the page
// title and leave the site name alone. If the theme doesn't use the site
// name in the <title> element, this will fail.
var oldTitle = doc.title;
// Escape the site name, in case it has special characters in it, so we can
// use it in our regex.
var escapedSiteName = response.siteName.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
var re = new RegExp('.+ (.) ' + escapedSiteName);
doc.title = oldTitle.replace(re, response.title + ' $1 ' + response.siteName);
@@ -120,27 +56,12 @@
$('h1.page-title').text(response.title);
};
/**
* Get rid of irritating tabledrag messages.
*
* @return {Array}
* An array of messages. Always empty array, to get rid of the messages.
*/
Drupal.theme.tableDragChangedWarning = function () {
return [];
};
/**
* Trigger preview when the "live preview" checkbox is checked.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches behavior to trigger live preview if the live preview option is
* checked.
*/
Drupal.behaviors.livePreview = {
attach: function (context) {
attach: function attach(context) {
$('input#edit-displays-live-preview', context).once('views-ajax').on('click', function () {
if ($(this).is(':checked')) {
$('#preview-submit').trigger('click');
@@ -149,101 +70,76 @@
}
};
/**
* Sync preview display.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches behavior to sync the preview display when needed.
*/
Drupal.behaviors.syncPreviewDisplay = {
attach: function (context) {
attach: function attach(context) {
$('#views-tabset a').once('views-ajax').on('click', function () {
var href = $(this).attr('href');
// Cut of #views-tabset.
var display_id = href.substr(11);
// Set the form element.
$('#views-live-preview #preview-display-id').val(display_id);
});
}
};
/**
* Ajax behaviors for the views_ui module.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches ajax behaviors to the elements with the classes in question.
*/
Drupal.behaviors.viewsAjax = {
collapseReplaced: false,
attach: function (context, settings) {
attach: function attach(context, settings) {
var base_element_settings = {
event: 'click',
progress: {type: 'fullscreen'}
progress: { type: 'fullscreen' }
};
// Bind AJAX behaviors to all items showing the class.
$('a.views-ajax-link', context).once('views-ajax').each(function () {
var element_settings = base_element_settings;
element_settings.base = $(this).attr('id');
element_settings.element = this;
// Set the URL to go to the anchor.
if ($(this).attr('href')) {
element_settings.url = $(this).attr('href');
}
Drupal.ajax(element_settings);
});
$('div#views-live-preview a')
.once('views-ajax').each(function () {
// We don't bind to links without a URL.
if (!$(this).attr('href')) {
return true;
}
$('div#views-live-preview a').once('views-ajax').each(function () {
if (!$(this).attr('href')) {
return true;
}
var element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this).attr('href');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
var element_settings = base_element_settings;
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
element_settings.url = $(this).attr('href');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
});
$('div#views-live-preview input[type=submit]').once('views-ajax').each(function (event) {
$(this).on('click', function () {
this.form.clk = this;
return true;
});
var element_settings = base_element_settings;
// Within a live preview, make exposed widget form buttons re-trigger the
// Preview button.
// @todo Revisit this after fixing Views UI to display a Preview outside
// of the main Edit form.
$('div#views-live-preview input[type=submit]')
.once('views-ajax').each(function (event) {
$(this).on('click', function () {
this.form.clk = this;
return true;
});
var element_settings = base_element_settings;
// Set the URL to go to the anchor.
element_settings.url = $(this.form).attr('action');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.url = $(this.form).attr('action');
if (Drupal.Views.getPath(element_settings.url).substring(0, 21) !== 'admin/structure/views') {
return true;
}
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.event = 'click';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
});
element_settings.wrapper = 'views-preview-wrapper';
element_settings.method = 'replaceWith';
element_settings.event = 'click';
element_settings.base = $(this).attr('id');
element_settings.element = this;
Drupal.ajax(element_settings);
});
}
};
})(jQuery, Drupal, drupalSettings);
})(jQuery, Drupal, drupalSettings);
@@ -0,0 +1,56 @@
/**
* @file
* Views dialog behaviors.
*/
(function ($, Drupal, drupalSettings) {
function handleDialogResize(e) {
const $modal = $(e.currentTarget);
const $viewsOverride = $modal.find('[data-drupal-views-offset]');
const $scroll = $modal.find('[data-drupal-views-scroll]');
let offset = 0;
let modalHeight;
if ($scroll.length) {
// Add a class to do some styles adjustments.
$modal.closest('.views-ui-dialog').addClass('views-ui-dialog-scroll');
// Let scroll element take all the height available.
$scroll.css({ overflow: 'visible', height: 'auto' });
modalHeight = $modal.height();
$viewsOverride.each(function () {
offset += $(this).outerHeight();
});
// Take internal padding into account.
const scrollOffset = $scroll.outerHeight() - $scroll.height();
$scroll.height(modalHeight - offset - scrollOffset);
// Reset scrolling properties.
$modal.css('overflow', 'hidden');
$scroll.css('overflow', 'auto');
}
}
/**
* Functionality for views modals.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches modal functionality for views.
* @prop {Drupal~behaviorDetach} detach
* Detaches the modal functionality.
*/
Drupal.behaviors.viewsModalContent = {
attach(context) {
$('body').once('viewsDialog').on('dialogContentResize.viewsDialog', '.ui-dialog-content', handleDialogResize);
// When expanding details, make sure the modal is resized.
$(context).find('.scroll').once('detailsUpdate').on('click', 'summary', (e) => {
$(e.currentTarget).trigger('dialogContentResize');
});
},
detach(context, settings, trigger) {
if (trigger === 'unload') {
$('body').removeOnce('viewsDialog').off('.viewsDialog');
}
},
};
}(jQuery, Drupal, drupalSettings));
+17 -29
View File
@@ -1,58 +1,46 @@
/**
* @file
* Views dialog behaviors.
*/
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal, drupalSettings) {
'use strict';
function handleDialogResize(e) {
var $modal = $(e.currentTarget);
var $viewsOverride = $modal.find('[data-drupal-views-offset]');
var $scroll = $modal.find('[data-drupal-views-scroll]');
var offset = 0;
var modalHeight;
var modalHeight = void 0;
if ($scroll.length) {
// Add a class to do some styles adjustments.
$modal.closest('.views-ui-dialog').addClass('views-ui-dialog-scroll');
// Let scroll element take all the height available.
$scroll.css({overflow: 'visible', height: 'auto'});
modalHeight = $modal.height();
$viewsOverride.each(function () { offset += $(this).outerHeight(); });
// Take internal padding into account.
$scroll.css({ overflow: 'visible', height: 'auto' });
modalHeight = $modal.height();
$viewsOverride.each(function () {
offset += $(this).outerHeight();
});
var scrollOffset = $scroll.outerHeight() - $scroll.height();
$scroll.height(modalHeight - offset - scrollOffset);
// Reset scrolling properties.
$modal.css('overflow', 'hidden');
$scroll.css('overflow', 'auto');
}
}
/**
* Functionality for views modals.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches modal functionality for views.
* @prop {Drupal~behaviorDetach} detach
* Detaches the modal functionality.
*/
Drupal.behaviors.viewsModalContent = {
attach: function (context) {
attach: function attach(context) {
$('body').once('viewsDialog').on('dialogContentResize.viewsDialog', '.ui-dialog-content', handleDialogResize);
// When expanding details, make sure the modal is resized.
$(context).find('.scroll').once('detailsUpdate').on('click', 'summary', function (e) {
$(e.currentTarget).trigger('dialogContentResize');
});
},
detach: function (context, settings, trigger) {
detach: function detach(context, settings, trigger) {
if (trigger === 'unload') {
$('body').removeOnce('viewsDialog').off('.viewsDialog');
}
}
};
})(jQuery, Drupal, drupalSettings);
})(jQuery, Drupal, drupalSettings);
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,50 @@
/**
* @file
* Views listing behaviors.
*/
(function ($, Drupal) {
/**
* Filters the view listing tables by a text input search string.
*
* Text search input: input.views-filter-text
* Target table: input.views-filter-text[data-table]
* Source text: [data-drupal-selector="views-table-filter-text-source"]
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the filter functionality to the views admin text search field.
*/
Drupal.behaviors.viewTableFilterByText = {
attach(context, settings) {
const $input = $('input.views-filter-text').once('views-filter-text');
const $table = $($input.attr('data-table'));
let $rows;
function filterViewList(e) {
const query = $(e.target).val().toLowerCase();
function showViewRow(index, row) {
const $row = $(row);
const $sources = $row.find('[data-drupal-selector="views-table-filter-text-source"]');
const textMatch = $sources.text().toLowerCase().indexOf(query) !== -1;
$row.closest('tr').toggle(textMatch);
}
// Filter if the length of the query is at least 2 characters.
if (query.length >= 2) {
$rows.each(showViewRow);
}
else {
$rows.show();
}
}
if ($table.length) {
$rows = $table.find('tbody tr');
$input.on('keyup', filterViewList);
}
},
};
}(jQuery, Drupal));
+9 -25
View File
@@ -1,29 +1,16 @@
/**
* @file
* Views listing behaviors.
*/
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(function ($, Drupal) {
'use strict';
/**
* Filters the view listing tables by a text input search string.
*
* Text search input: input.views-filter-text
* Target table: input.views-filter-text[data-table]
* Source text: [data-drupal-selector="views-table-filter-text-source"]
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Attaches the filter functionality to the views admin text search field.
*/
Drupal.behaviors.viewTableFilterByText = {
attach: function (context, settings) {
attach: function attach(context, settings) {
var $input = $('input.views-filter-text').once('views-filter-text');
var $table = $($input.attr('data-table'));
var $rows;
var $rows = void 0;
function filterViewList(e) {
var query = $(e.target).val().toLowerCase();
@@ -35,11 +22,9 @@
$row.closest('tr').toggle(textMatch);
}
// Filter if the length of the query is at least 2 characters.
if (query.length >= 2) {
$rows.each(showViewRow);
}
else {
} else {
$rows.show();
}
}
@@ -50,5 +35,4 @@
}
}
};
}(jQuery, Drupal));
})(jQuery, Drupal);
@@ -176,7 +176,7 @@ class AddHandler extends ViewsFormBase {
$view->getStandardButtons($form, $form_state, 'views_ui_add_handler_form', $this->t('Add and configure @types', ['@types' => $ltitle]));
// Remove the default submit function.
$form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function($var) {
$form['actions']['submit']['#submit'] = array_filter($form['actions']['submit']['#submit'], function ($var) {
return !(is_array($var) && isset($var[1]) && $var[1] == 'standardSubmit');
});
$form['actions']['submit']['#submit'][] = [$view, 'submitItemAdd'];
@@ -125,11 +125,13 @@ class Rearrange extends ViewsFormBase {
'#attributes' => ['class' => ['views-remove-checkbox']],
'#default_value' => 0,
'#suffix' => \Drupal::l(SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
Url::fromRoute('<none>', [], ['attributes' => [
'id' => 'views-remove-link-' . $id,
'class' => ['views-hidden', 'views-button-remove', 'views-remove-link'],
'alt' => $this->t('Remove this item'),
'title' => $this->t('Remove this item')],
Url::fromRoute('<none>', [], [
'attributes' => [
'id' => 'views-remove-link-' . $id,
'class' => ['views-hidden', 'views-button-remove', 'views-remove-link'],
'alt' => $this->t('Remove this item'),
'title' => $this->t('Remove this item'),
],
])
),
];
@@ -119,7 +119,8 @@ class RearrangeFilter extends ViewsFormBase {
],
];
$form['remove_groups'][$id] = []; // to prevent a notice
// To prevent a notice.
$form['remove_groups'][$id] = [];
if ($id != 1) {
$form['remove_groups'][$id] = [
'#type' => 'submit',
@@ -74,7 +74,7 @@ class BreakLockForm extends EntityConfirmFormBase {
'#theme' => 'username',
'#account' => $account,
];
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => drupal_render($username)]);
return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => \Drupal::service('renderer')->render($username)]);
}
/**
+2 -2
View File
@@ -129,7 +129,7 @@ class ViewEditForm extends ViewFormBase {
'#account' => $this->entityManager->getStorage('user')->load($view->lock->owner),
];
$lock_message_substitutions = [
'@user' => drupal_render($username),
'@user' => \Drupal::service('renderer')->render($username),
'@age' => $this->dateFormatter->formatTimeDiffSince($view->lock->updated),
':url' => $view->url('break-lock-form'),
];
@@ -262,7 +262,7 @@ class ViewEditForm extends ViewFormBase {
// options.
$display_handler = $executable->displayHandlers->get($id);
if ($attachments = $display_handler->getAttachedDisplays()) {
foreach ($attachments as $attachment ) {
foreach ($attachments as $attachment) {
$attached_options = $executable->displayHandlers->get($attachment)->getOption('displays');
unset($attached_options[$id]);
$executable->displayHandlers->get($attachment)->setOption('displays', $attached_options);
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- views_ui
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- views_ui
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -4,7 +4,7 @@ namespace Drupal\Tests\views_ui\Functional;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Tests the UI of generic display path plugin.
@@ -13,6 +13,7 @@ use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
* @see \Drupal\views\Plugin\views\display\PathPluginBase
*/
class DisplayPathTest extends UITestBase {
use AssertPageCacheContextsAndTagsTrait;
protected function setUp($import_test_views = TRUE) {
@@ -165,7 +166,7 @@ class DisplayPathTest extends UITestBase {
unset($menu_options['@attributes']);
// Convert array to make the next assertion possible.
$menu_options = array_map(function($element) {
$menu_options = array_map(function ($element) {
return $element->getText();
}, $menu_options);
@@ -0,0 +1,320 @@
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Entity\View;
/**
* Tests exposed forms UI functionality.
*
* @group views_ui
*/
class ExposedFormUITest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_exposed_admin_ui'];
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'views_ui', 'block', 'taxonomy', 'field_ui', 'datetime'];
/**
* Array of error message strings raised by the grouped form.
*
* @var array
*
* @see FilterPluginBase::buildGroupValidate
*/
protected $groupFormUiErrors = [];
protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$this->drupalCreateContentType(['type' => 'article']);
$this->drupalCreateContentType(['type' => 'page']);
// Create some random nodes.
for ($i = 0; $i < 5; $i++) {
$this->drupalCreateNode();
}
// Error strings used in the grouped filter form validation.
$this->groupFormUiErrors['missing_value'] = t('A value is required if the label for this item is defined.');
$this->groupFormUiErrors['missing_title'] = t('A label is required if the value for this item is defined.');
$this->groupFormUiErrors['missing_title_empty_operator'] = t('A label is required for the specified operator.');
}
/**
* Tests the admin interface of exposed filter and sort items.
*/
public function testExposedAdminUi() {
$edit = [];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
// Be sure that the button is called exposed.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose filter'));
// The first time the filter UI is displayed, the operator and the
// value forms should be shown.
$this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists');
$this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
// Click the Expose filter button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
// Check the label of the expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide filter'));
// After exposing the filter, Operator and Value should be still here.
$this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists');
$this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists');
// Check the validations of the filter handler.
$edit = [];
$edit['options[expose][identifier]'] = '';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText(t('The identifier is required if the filter is exposed.'));
$edit = [];
$edit['options[expose][identifier]'] = 'value';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText(t('This identifier is not allowed.'));
// Now check the sort criteria.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created');
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Expose sort'));
$this->assertNoFieldById('edit-options-expose-label', '', 'Make sure no label field is shown');
// Un-expose the filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm(NULL, [], t('Hide filter'));
// After Un-exposing the filter, Operator and Value should be shown again.
$this->assertFieldById('edit-options-operator-in', 'in', 'Operator In exists after hide filter');
$this->assertFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In exists after hide filter');
$this->assertFieldById('edit-options-value-page', '', 'Checkbox for Page exists after hide filter');
$this->assertFieldById('edit-options-value-article', '', 'Checkbox for Article exists after hide filter');
// Click the Expose sort button.
$edit = [];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/sort/created', $edit, t('Expose sort'));
// Check the label of the expose button.
$this->helperButtonHasLabel('edit-options-expose-button-button', t('Hide sort'));
$this->assertFieldById('edit-options-expose-label', 'Authored on', 'Make sure a label field is shown');
// Test adding a new exposed sort criteria.
$view_id = $this->randomView()['id'];
$this->drupalGet("admin/structure/views/nojs/add-handler/$view_id/default/sort");
$this->drupalPostForm(NULL, ['name[node_field_data.created]' => 1], t('Add and configure @handler', ['@handler' => t('sort criteria')]));
$this->assertFieldByXPath('//input[@name="options[order]" and @checked="checked"]', 'ASC', 'The default order is set.');
// Change the order and expose the sort.
$this->drupalPostForm(NULL, ['options[order]' => 'DESC'], t('Apply'));
$this->drupalPostForm("admin/structure/views/nojs/handler/$view_id/default/sort/created", [], t('Expose sort'));
$this->assertFieldByXPath('//input[@name="options[order]" and @checked="checked"]', 'DESC');
$this->assertFieldByName('options[expose][label]', 'Authored on', 'The default label is set.');
// Change the label and save the view.
$edit = ['options[expose][label]' => $this->randomString()];
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->drupalPostForm(NULL, [], t('Save'));
// Check that the values were saved.
$display = View::load($view_id)->getDisplay('default');
$this->assertTrue($display['display_options']['sorts']['created']['exposed']);
$this->assertEqual($display['display_options']['sorts']['created']['expose'], ['label' => $edit['options[expose][label]']]);
$this->assertEqual($display['display_options']['sorts']['created']['order'], 'DESC');
}
/**
* Tests the admin interface of exposed grouped filters.
*/
public function testGroupedFilterAdminUi() {
$edit = [];
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
// Click the Expose filter button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', $edit, t('Expose filter'));
// Check the label of the grouped filters button.
$this->helperButtonHasLabel('edit-options-group-button-button', t('Grouped filters'));
// Click the Grouped Filters button.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm(NULL, [], t('Grouped filters'));
// After click on 'Grouped Filters', the standard operator and value should
// not be displayed.
$this->assertNoFieldById('edit-options-operator-in', 'in', 'Operator In not exists');
$this->assertNoFieldById('edit-options-operator-not-in', 'not in', 'Operator Not In not exists');
$this->assertNoFieldById('edit-options-value-page', '', 'Checkbox for Page not exists');
$this->assertNoFieldById('edit-options-value-article', '', 'Checkbox for Article not exists');
// Check that after click on 'Grouped Filters', a new button is shown to
// add more items to the list.
$this->helperButtonHasLabel('edit-options-group-info-add-group', t('Add another item'));
// Validate a single entry for a grouped filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default');
$this->assertNoGroupedFilterErrors();
// Validate multiple entries for grouped filters.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$edit["options[group_info][group_items][2][title]"] = 'Is Page';
$edit["options[group_info][group_items][2][value][page]"] = 'page';
$edit["options[group_info][group_items][3][title]"] = 'Is Page and Article';
$edit["options[group_info][group_items][3][value][article]"] = 'article';
$edit["options[group_info][group_items][3][value][page]"] = 'page';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'Correct validation of the node type filter.');
$this->assertNoGroupedFilterErrors();
// Validate an "is empty" filter -- title without value is valid.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
$edit = [];
$edit["options[group_info][group_items][1][title]"] = 'No body';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "empty" operator validates correctly.');
$this->assertNoGroupedFilterErrors();
// Ensure the string "0" can be used as a value for numeric filters.
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.nid]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
$this->drupalPostForm(NULL, [], t('Expose filter'));
$this->drupalPostForm(NULL, [], t('Grouped filters'));
$edit = [];
$edit['options[group_info][group_items][1][title]'] = 'Testing zero';
$edit['options[group_info][group_items][1][operator]'] = '>';
$edit['options[group_info][group_items][1][value][value]'] = '0';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'A string "0" is a valid value.');
$this->assertNoGroupedFilterErrors();
// Ensure "between" filters validate correctly.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/nid');
$edit['options[group_info][group_items][1][title]'] = 'ID between test';
$edit['options[group_info][group_items][1][operator]'] = 'between';
$edit['options[group_info][group_items][1][value][min]'] = '0';
$edit['options[group_info][group_items][1][value][max]'] = '10';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertUrl('admin/structure/views/view/test_exposed_admin_ui/edit/default', [], 'The "between" filter validates correctly.');
$this->assertNoGroupedFilterErrors();
}
public function testGroupedFilterAdminUiErrors() {
// Select the empty operator without a title specified.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/body_value');
$edit = [];
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][operator]"] = 'empty';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_title_empty_operator']);
// Specify a title without a value.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
$edit = [];
$edit["options[group_info][group_items][1][title]"] = 'Is Article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_value']);
// Specify a value without a title.
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type');
$edit = [];
$edit["options[group_info][group_items][1][title]"] = '';
$edit["options[group_info][group_items][1][value][article]"] = 'article';
$this->drupalPostForm(NULL, $edit, t('Apply'));
$this->assertText($this->groupFormUiErrors['missing_title']);
}
/**
* Asserts that there are no Grouped Filters errors.
*
* @param string $message
* The assert message.
* @param string $group
* The assertion group.
*
* @return bool
* Result of the assertion.
*/
protected function assertNoGroupedFilterErrors($message = '', $group = 'Other') {
foreach ($this->groupFormUiErrors as $error) {
$err_message = $message;
if (empty($err_message)) {
$err_message = "Verify that '$error' is not in the HTML output.";
}
if (empty($message)) {
return $this->assertNoRaw($error, $err_message, $group);
}
}
return TRUE;
}
/**
* Tests the configuration of grouped exposed filters.
*/
public function testExposedGroupedFilter() {
// Click the Expose filter button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Expose filter'));
// Select 'Grouped filters' radio button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/type', [], t('Grouped filters'));
// Add 3 groupings.
$edit = [
'options[group_button][radios][radios]' => 1,
'options[group_info][group_items][1][title]' => '1st',
'options[group_info][group_items][1][value][all]' => 'all',
'options[group_info][group_items][2][title]' => '2nd',
'options[group_info][group_items][2][value][article]' => 'article',
'options[group_info][group_items][3][title]' => '3rd',
'options[group_info][group_items][3][value][page]' => 'page',
];
// Apply the filter settings.
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Check that the view is saved without errors.
$this->drupalPostForm(NULL, [], t('Save'));
$this->assertResponse(200);
// Click the Expose filter button.
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_exposed_admin_ui/default/filter', ['name[node_field_data.status]' => 1], t('Add and configure filter criteria'));
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status', [], t('Expose filter'));
// Select 'Grouped filters' radio button.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status', [], t('Grouped filters'));
// Add 3 groupings.
$edit = [
'options[group_button][radios][radios]' => 1,
'options[group_info][group_items][1][title]' => 'Any',
'options[group_info][group_items][1][value]' => 'All',
'options[group_info][group_items][2][title]' => 'Published',
'options[group_info][group_items][2][value]' => 1,
'options[group_info][group_items][3][title]' => 'Unpublished',
'options[group_info][group_items][3][value]' => 0,
];
// Apply the filter settings.
$this->drupalPostForm(NULL, $edit, t('Apply'));
// Check that the view is saved without errors.
$this->drupalPostForm(NULL, [], t('Save'));
$this->assertResponse(200);
$this->drupalGet('admin/structure/views/nojs/handler/test_exposed_admin_ui/default/filter/status');
// Assert the same settings defined before still are there.
$this->assertFieldChecked('edit-options-group-info-group-items-1-value-all');
$this->assertFieldChecked('edit-options-group-info-group-items-2-value-1');
$this->assertFieldChecked('edit-options-group-info-group-items-3-value-0');
}
}
@@ -42,6 +42,8 @@ class HandlerTest extends UITestBase {
* Overrides \Drupal\views\Tests\ViewTestBase::schemaDefinition().
*
* Adds a uid column to test the relationships.
*
* @internal
*/
protected function schemaDefinition() {
$schema = parent::schemaDefinition();
@@ -0,0 +1,249 @@
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\views\Entity\View;
/**
* Tests some general functionality of editing views, like deleting a view.
*
* @group views_ui
*/
class ViewEditTest extends UITestBase {
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = ['test_view', 'test_display', 'test_groupwise_term_ui'];
/**
* Tests the delete link on a views UI.
*/
public function testDeleteLink() {
$this->drupalGet('admin/structure/views/view/test_view');
$this->assertLink(t('Delete view'), 0, 'Ensure that the view delete link appears');
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view');
$this->assertTrue($view instanceof View);
$this->clickLink(t('Delete view'));
$this->assertUrl('admin/structure/views/view/test_view/delete');
$this->drupalPostForm(NULL, [], t('Delete'));
$this->assertRaw(t('The view %name has been deleted.', ['%name' => $view->label()]));
$this->assertUrl('admin/structure/views');
$view = $this->container->get('entity.manager')->getStorage('view')->load('test_view');
$this->assertFalse($view instanceof View);
}
/**
* Tests the machine name and administrative comment forms.
*/
public function testOtherOptions() {
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new attachment display.
$this->drupalPostForm(NULL, [], 'Add Attachment');
// Test that a long administrative comment is truncated.
$edit = ['display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply');
$this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...');
// Change the machine name for the display from page_1 to test_1.
$edit = ['display_id' => 'test_1'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_id', $edit, 'Apply');
$this->assertLink(t('test_1'));
// Save the view, and test the new ID has been saved.
$this->drupalPostForm(NULL, [], 'Save');
$view = \Drupal::entityManager()->getStorage('view')->load('test_view');
$displays = $view->get('display');
$this->assertTrue(!empty($displays['test_1']), 'Display data found for new display ID key.');
$this->assertIdentical($displays['test_1']['id'], 'test_1', 'New display ID matches the display ID key.');
$this->assertFalse(array_key_exists('attachment_1', $displays), 'Old display ID not found.');
// Set to the same machine name and save the View.
$edit = ['display_id' => 'test_1'];
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/test_1/display_id', $edit, 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
$this->assertLink(t('test_1'));
// Test the form validation with invalid IDs.
$machine_name_edit_url = 'admin/structure/views/nojs/display/test_view/test_1/display_id';
$error_text = t('Display name must be letters, numbers, or underscores only.');
// Test that potential invalid display ID requests are detected
try {
$this->drupalGet('admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title');
$this->fail('Expected error, when setDisplay() called with invalid display ID');
}
catch (\Exception $e) {
$this->assertContains('setDisplay() called with invalid display ID "fake_display_name".', $e->getMessage());
}
$edit = ['display_id' => 'test 1'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText($error_text);
$edit = ['display_id' => 'test_1#'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText($error_text);
// Test using an existing display ID.
$edit = ['display_id' => 'default'];
$this->drupalPostForm($machine_name_edit_url, $edit, 'Apply');
$this->assertText(t('Display id should be unique.'));
// Test that the display ID has not been changed.
$this->drupalGet('admin/structure/views/view/test_view/edit/test_1');
$this->assertLink(t('test_1'));
// Test that validation does not run on cancel.
$this->drupalGet('admin/structure/views/view/test_view');
// Delete the field to cause an error on save.
$fields = [];
$fields['fields[age][removed]'] = 1;
$fields['fields[id][removed]'] = 1;
$fields['fields[name][removed]'] = 1;
$this->drupalPostForm('admin/structure/views/nojs/rearrange/test_view/default/field', $fields, t('Apply'));
$this->drupalPostForm(NULL, [], 'Save');
$this->drupalPostForm(NULL, [], t('Cancel'));
$this->assertNoFieldByXpath('//div[contains(@class, "error")]', FALSE, 'No error message is displayed.');
$this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page..');
}
/**
* Tests the language options on the views edit form.
*/
public function testEditFormLanguageOptions() {
$assert_session = $this->assertSession();
// Language options should not exist without language module.
$test_views = [
'test_view' => 'default',
'test_display' => 'page_1',
];
foreach ($test_views as $view_name => $display) {
$this->drupalGet('admin/structure/views/view/' . $view_name);
$this->assertResponse(200);
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
$this->assertNoLinkByHref($langcode_url);
$assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertNoLink(t('Content language of view row'));
}
// Make the site multilingual and test the options again.
$this->container->get('module_installer')->install(['language', 'content_translation']);
ConfigurableLanguage::createFromLangcode('hu')->save();
$this->resetAll();
$this->rebuildContainer();
// Language options should now exist with entity language the default.
foreach ($test_views as $view_name => $display) {
$this->drupalGet('admin/structure/views/view/' . $view_name);
$this->assertResponse(200);
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
if ($view_name == 'test_view') {
$this->assertNoLinkByHref($langcode_url);
$assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertNoLink(t('Content language of view row'));
}
else {
$this->assertLinkByHref($langcode_url);
$assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')]));
$this->assertLink(t('Content language of view row'));
}
$this->drupalGet($langcode_url);
$this->assertResponse(200);
if ($view_name == 'test_view') {
$this->assertText(t('The view is not based on a translatable entity type or the site is not multilingual.'));
}
else {
$this->assertFieldByName('rendering_language', '***LANGUAGE_entity_translation***');
// Test that the order of the language list is similar to other language
// lists, such as in the content translation settings.
$expected_elements = [
'***LANGUAGE_entity_translation***',
'***LANGUAGE_entity_default***',
'***LANGUAGE_site_default***',
'***LANGUAGE_language_interface***',
'en',
'hu',
];
$elements = $this->xpath('//select[@id="edit-rendering-language"]/option');
// Compare values inside the option elements with expected values.
for ($i = 0; $i < count($elements); $i++) {
$this->assertEqual($elements[$i]->getAttribute('value'), $expected_elements[$i]);
}
// Check that the selected values are respected even we they are not
// supposed to be listed.
// Give permission to edit languages to authenticated users.
$edit = [
'authenticated[administer languages]' => TRUE,
];
$this->drupalPostForm('/admin/people/permissions', $edit, t('Save permissions'));
// Enable Content language negotiation so we have one more item
// to select.
$edit = [
'language_content[configurable]' => TRUE,
];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Choose the new negotiation as the rendering language.
$edit = [
'rendering_language' => '***LANGUAGE_language_content***',
];
$this->drupalPostForm('/admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language', $edit, t('Apply'));
// Disable language content negotiation.
$edit = [
'language_content[configurable]' => FALSE,
];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check that the previous selection is listed and selected.
$this->drupalGet($langcode_url);
$element = $this->xpath('//select[@id="edit-rendering-language"]/option[@value="***LANGUAGE_language_content***" and @selected="selected"]');
$this->assertFalse(empty($element), 'Current selection is not lost');
// Check the order for the langcode filter.
$langcode_url = 'admin/structure/views/nojs/handler/' . $view_name . '/' . $display . '/filter/langcode';
$this->drupalGet($langcode_url);
$this->assertResponse(200);
$expected_elements = [
'all',
'***LANGUAGE_site_default***',
'***LANGUAGE_language_interface***',
'***LANGUAGE_language_content***',
'en',
'hu',
'und',
'zxx',
];
$elements = $this->xpath('//div[@id="edit-options-value"]//input');
// Compare values inside the option elements with expected values.
for ($i = 0; $i < count($elements); $i++) {
$this->assertEqual($elements[$i]->getAttribute('value'), $expected_elements[$i]);
}
}
}
}
/**
* Tests Representative Node for a Taxonomy Term.
*/
public function testRelationRepresentativeNode() {
// Populate and submit the form.
$edit["name[taxonomy_term_field_data.tid_representative]"] = TRUE;
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_groupwise_term_ui/default/relationship', $edit, 'Add and configure relationships');
// Apply changes.
$edit = [];
$this->drupalPostForm('admin/structure/views/nojs/handler/test_groupwise_term_ui/default/relationship/tid_representative', $edit, 'Apply');
}
}
@@ -0,0 +1,111 @@
<?php
namespace Drupal\Tests\views_ui\Functional;
use Drupal\Tests\tour\Functional\TourTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Tests the Views UI tour.
*
* @group views_ui
*/
class ViewsUITourTest extends TourTestBase {
/**
* An admin user with administrative permissions for views.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* String translation storage object.
*
* @var \Drupal\locale\StringStorageInterface
*/
protected $localeStorage;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['views_ui', 'tour', 'language', 'locale'];
protected function setUp() {
parent::setUp();
$this->adminUser = $this->drupalCreateUser(['administer views', 'access tour']);
$this->drupalLogin($this->adminUser);
}
/**
* Tests views_ui tour tip availability.
*/
public function testViewsUiTourTips() {
// Create a basic view that shows all content, with a page and a block
// display.
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['page[create]'] = 1;
$view['page[path]'] = $this->randomMachineName(16);
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$this->assertTourTips();
}
/**
* Tests views_ui tour tip availability in a different language.
*/
public function testViewsUiTourTipsTranslated() {
$langcode = 'nl';
// Add a default locale storage for this test.
$this->localeStorage = $this->container->get('locale.storage');
// Add Dutch language programmatically.
ConfigurableLanguage::createFromLangcode($langcode)->save();
// Handler titles that need translations.
$handler_titles = [
'Format',
'Fields',
'Sort criteria',
'Filter criteria',
];
foreach ($handler_titles as $handler_title) {
// Create source string.
$source = $this->localeStorage->createString([
'source' => $handler_title
]);
$source->save();
$this->createTranslation($source, $langcode);
}
// Create a basic view that shows all content, with a page and a block
// display.
$view['label'] = $this->randomMachineName(16);
$view['id'] = strtolower($this->randomMachineName(16));
$view['page[create]'] = 1;
$view['page[path]'] = $this->randomMachineName(16);
// Load the page in dutch.
$this->drupalPostForm(
$langcode . '/admin/structure/views/add',
$view,
t('Save and edit')
);
$this->assertTourTips();
}
/**
* Creates single translation for source string.
*/
public function createTranslation($source, $langcode) {
return $this->localeStorage->createTranslation([
'lid' => $source->lid,
'language' => $langcode,
'translation' => $this->randomMachineName(100),
])->save();
}
}
@@ -118,7 +118,7 @@ class ViewsListingTest extends JavascriptTestBase {
* @return array
*/
protected function filterVisibleElements($elements) {
$elements = array_filter($elements, function($element) {
$elements = array_filter($elements, function ($element) {
return $element->isVisible();
});
return $elements;
+3 -3
View File
@@ -8,8 +8,8 @@ configure: entity.view.collection
dependencies:
- views
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929