Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -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)) {
|
||||
|
@ -285,7 +286,7 @@ function views_ui_build_form_url(FormStateInterface $form_state) {
|
|||
$route_parameters = [
|
||||
'js' => $ajax,
|
||||
'view' => $name,
|
||||
'display_id' => $display_id
|
||||
'display_id' => $display_id,
|
||||
];
|
||||
$url = Url::fromRoute($route_name, $route_parameters);
|
||||
if ($type = $form_state->get('type')) {
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
opacity: 0.5;
|
||||
}
|
||||
.views-display-tab .details-wrapper > .views-ui-display-tab-bucket .actions {
|
||||
opacity: 1.0;
|
||||
opacity: 1;
|
||||
}
|
||||
.views-displays .tabs .add {
|
||||
position: relative;
|
||||
|
@ -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 */
|
||||
|
|
|
@ -37,11 +37,11 @@
|
|||
background: linear-gradient(-90deg, #fff 0, #e8e8e8 100%) no-repeat, repeat-y;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 0 0 rgba(0,0,0,0.3333) inset;
|
||||
box-shadow: 0 0 0 rgba(0, 0, 0, 0.3333) inset;
|
||||
}
|
||||
.views-admin a.icon:hover {
|
||||
border-color: #d0d0d0;
|
||||
box-shadow: 0 0 1px rgba(0,0,0,0.3333) inset;
|
||||
box-shadow: 0 0 1px rgba(0, 0, 0, 0.3333) inset;
|
||||
}
|
||||
.views-admin a.icon:active {
|
||||
border-color: #c0c0c0;
|
||||
|
@ -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 {
|
||||
|
@ -431,7 +431,7 @@ td.group-title {
|
|||
background-color: #ddd;
|
||||
}
|
||||
.edit-display-settings {
|
||||
margin: 12px 12px 0 12px
|
||||
margin: 12px 12px 0 12px;
|
||||
}
|
||||
.edit-display-settings-top.views-ui-display-tab-bucket {
|
||||
border: 1px solid #f3f3f3;
|
||||
|
@ -483,7 +483,8 @@ 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;
|
||||
}
|
||||
|
@ -574,7 +575,7 @@ td.group-title {
|
|||
border-top: none;
|
||||
}
|
||||
.views-filterable-options {
|
||||
border-top: 1px solid #ccc;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
.filterable-option .form-item {
|
||||
margin-bottom: 0;
|
||||
|
@ -623,10 +624,10 @@ td.group-title {
|
|||
border: none;
|
||||
}
|
||||
.views-ui-dialog .views-offset-top {
|
||||
border-bottom: 1px solid #CCC;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
.views-ui-dialog .views-offset-bottom {
|
||||
border-top: 1px solid #CCC;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
.views-ui-dialog .views-override > * {
|
||||
margin: 0;
|
||||
|
|
286
web/core/modules/views_ui/js/ajax.es6.js
Normal file
286
web/core/modules/views_ui/js/ajax.es6.js
Normal file
|
@ -0,0 +1,286 @@
|
|||
/**
|
||||
* @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 $submitButtons = $form
|
||||
.find('input[type=submit].js-form-submit, button.js-form-submit')
|
||||
.once('views-ajax-submit');
|
||||
$submitButtons.on('click mousedown', function() {
|
||||
this.form.clk = this;
|
||||
});
|
||||
$form.once('views-ajax-submit').each(function() {
|
||||
const $form = $(this);
|
||||
const elementSettings = {
|
||||
url: response.url,
|
||||
event: 'submit',
|
||||
base: $form.attr('id'),
|
||||
element: this,
|
||||
};
|
||||
const ajaxForm = Drupal.ajax(elementSettings);
|
||||
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 displayId = href.substr(11);
|
||||
// Set the form element.
|
||||
$('#views-live-preview #preview-display-id').val(displayId);
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 baseElementSettings = {
|
||||
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 elementSettings = baseElementSettings;
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
// Set the URL to go to the anchor.
|
||||
if ($(this).attr('href')) {
|
||||
elementSettings.url = $(this).attr('href');
|
||||
}
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
|
||||
$('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 elementSettings = baseElementSettings;
|
||||
// Set the URL to go to the anchor.
|
||||
elementSettings.url = $(this).attr('href');
|
||||
if (
|
||||
Drupal.Views.getPath(elementSettings.url).substring(0, 21) !==
|
||||
'admin/structure/views'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
elementSettings.wrapper = 'views-preview-wrapper';
|
||||
elementSettings.method = 'replaceWith';
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
|
||||
// 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 elementSettings = baseElementSettings;
|
||||
// Set the URL to go to the anchor.
|
||||
elementSettings.url = $(this.form).attr('action');
|
||||
if (
|
||||
Drupal.Views.getPath(elementSettings.url).substring(0, 21) !==
|
||||
'admin/structure/views'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
elementSettings.wrapper = 'views-preview-wrapper';
|
||||
elementSettings.method = 'replaceWith';
|
||||
elementSettings.event = 'click';
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
},
|
||||
};
|
||||
})(jQuery, Drupal, drupalSettings);
|
|
@ -1,73 +1,36 @@
|
|||
/**
|
||||
* @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 () {
|
||||
|
||||
var $submitButtons = $form.find('input[type=submit].js-form-submit, button.js-form-submit').once('views-ajax-submit');
|
||||
$submitButtons.on('click mousedown', function () {
|
||||
this.form.clk = this;
|
||||
});
|
||||
$form.once('views-ajax-submit').each(function () {
|
||||
var $form = $(this);
|
||||
var element_settings = {
|
||||
var elementSettings = {
|
||||
url: response.url,
|
||||
event: 'submit',
|
||||
base: $form.attr('id'),
|
||||
element: this
|
||||
};
|
||||
var ajaxForm = Drupal.ajax(element_settings);
|
||||
var ajaxForm = Drupal.ajax(elementSettings);
|
||||
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) {
|
||||
|
@ -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);
|
||||
|
||||
var displayId = href.substr(11);
|
||||
|
||||
$('#views-live-preview #preview-display-id').val(displayId);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
var base_element_settings = {
|
||||
attach: function attach(context, settings) {
|
||||
var baseElementSettings = {
|
||||
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.
|
||||
var elementSettings = baseElementSettings;
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
if ($(this).attr('href')) {
|
||||
element_settings.url = $(this).attr('href');
|
||||
elementSettings.url = $(this).attr('href');
|
||||
}
|
||||
Drupal.ajax(element_settings);
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
|
||||
$('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 elementSettings = baseElementSettings;
|
||||
|
||||
element_settings.wrapper = 'views-preview-wrapper';
|
||||
element_settings.method = 'replaceWith';
|
||||
element_settings.base = $(this).attr('id');
|
||||
element_settings.element = this;
|
||||
Drupal.ajax(element_settings);
|
||||
elementSettings.url = $(this).attr('href');
|
||||
if (Drupal.Views.getPath(elementSettings.url).substring(0, 21) !== 'admin/structure/views') {
|
||||
return true;
|
||||
}
|
||||
|
||||
elementSettings.wrapper = 'views-preview-wrapper';
|
||||
elementSettings.method = 'replaceWith';
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
|
||||
$('div#views-live-preview input[type=submit]').once('views-ajax').each(function (event) {
|
||||
$(this).on('click', function () {
|
||||
this.form.clk = this;
|
||||
return true;
|
||||
});
|
||||
var elementSettings = baseElementSettings;
|
||||
|
||||
// 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;
|
||||
}
|
||||
elementSettings.url = $(this.form).attr('action');
|
||||
if (Drupal.Views.getPath(elementSettings.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);
|
||||
});
|
||||
elementSettings.wrapper = 'views-preview-wrapper';
|
||||
elementSettings.method = 'replaceWith';
|
||||
elementSettings.event = 'click';
|
||||
elementSettings.base = $(this).attr('id');
|
||||
elementSettings.element = this;
|
||||
|
||||
Drupal.ajax(elementSettings);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
})(jQuery, Drupal, drupalSettings);
|
67
web/core/modules/views_ui/js/dialog.views.es6.js
Normal file
67
web/core/modules/views_ui/js/dialog.views.es6.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* @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);
|
|
@ -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);
|
1359
web/core/modules/views_ui/js/views-admin.es6.js
Normal file
1359
web/core/modules/views_ui/js/views-admin.es6.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
57
web/core/modules/views_ui/js/views_ui.listing.es6.js
Normal file
57
web/core/modules/views_ui/js/views_ui.listing.es6.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* @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);
|
|
@ -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);
|
|
@ -8,6 +8,8 @@ use Drupal\views\Views;
|
|||
|
||||
/**
|
||||
* Form builder for the advanced admin settings page.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AdvancedSettingsForm extends ConfigFormBase {
|
||||
|
||||
|
@ -76,7 +78,7 @@ class AdvancedSettingsForm extends ConfigFormBase {
|
|||
'#default_value' => array_filter($config->get('display_extenders')),
|
||||
'#options' => $options,
|
||||
'#type' => 'checkboxes',
|
||||
'#description' => $this->t('Select extensions of the views interface.')
|
||||
'#description' => $this->t('Select extensions of the views interface.'),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -101,7 +103,7 @@ class AdvancedSettingsForm extends ConfigFormBase {
|
|||
*/
|
||||
public function cacheSubmit() {
|
||||
views_invalidate_cache();
|
||||
drupal_set_message($this->t('The cache has been cleared.'));
|
||||
$this->messenger()->addStatus($this->t('The cache has been cleared.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ use Drupal\views\Views;
|
|||
|
||||
/**
|
||||
* Provides a form for adding an item in the Views UI.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class AddHandler extends ViewsFormBase {
|
||||
|
||||
|
@ -176,7 +178,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'];
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\views\Views;
|
|||
|
||||
/**
|
||||
* Displays analysis information for a view.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Analyze extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
/**
|
||||
* Provides a form for configuring an item in the Views UI.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigHandler extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@ use Drupal\views\ViewExecutable;
|
|||
|
||||
/**
|
||||
* Provides a form for configuring extra information for a Views UI item.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigHandlerExtra extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ use Drupal\views\ViewExecutable;
|
|||
|
||||
/**
|
||||
* Provides a form for configuring grouping information for a Views UI handler.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ConfigHandlerGroup extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\views\ViewEntityInterface;
|
|||
|
||||
/**
|
||||
* Provides a form for editing the Views display.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Display extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\views\Views;
|
|||
|
||||
/**
|
||||
* Provides a form for editing the details of a View.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class EditDetails extends ViewsFormBase {
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\views_ui\Form\Ajax;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\views\ViewEntityInterface;
|
||||
|
@ -10,6 +10,8 @@ use Drupal\views\ViewExecutable;
|
|||
|
||||
/**
|
||||
* Provides a rearrange form for Views handlers.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class Rearrange extends ViewsFormBase {
|
||||
|
||||
|
@ -83,7 +85,7 @@ class Rearrange extends ViewsFormBase {
|
|||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
]
|
||||
],
|
||||
],
|
||||
'#tree' => TRUE,
|
||||
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
|
||||
|
@ -124,12 +126,14 @@ class Rearrange extends ViewsFormBase {
|
|||
'#id' => 'views-removed-' . $id,
|
||||
'#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')],
|
||||
'#suffix' => \Drupal::l(new FormattableMarkup('<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'),
|
||||
],
|
||||
])
|
||||
),
|
||||
];
|
||||
|
|
|
@ -8,6 +8,8 @@ use Drupal\views\ViewExecutable;
|
|||
|
||||
/**
|
||||
* Provides a rearrange form for Views filters.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class RearrangeFilter extends ViewsFormBase {
|
||||
|
||||
|
@ -119,7 +121,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',
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace Drupal\views_ui\Form\Ajax;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Displays the display reorder form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ReorderDisplays extends ViewsFormBase {
|
||||
|
||||
|
@ -42,7 +44,7 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
]);
|
||||
$form['view'] = [
|
||||
'#type' => 'value',
|
||||
'#value' => $view
|
||||
'#value' => $view,
|
||||
];
|
||||
|
||||
$displays = $view->get('display');
|
||||
|
@ -66,7 +68,7 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
]
|
||||
],
|
||||
],
|
||||
'#tree' => TRUE,
|
||||
'#prefix' => '<div class="scroll" data-drupal-views-scroll>',
|
||||
|
@ -115,7 +117,7 @@ class ReorderDisplays extends ViewsFormBase {
|
|||
],
|
||||
'link' => [
|
||||
'#type' => 'link',
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => $this->t('Remove')]),
|
||||
'#title' => new FormattableMarkup('<span>@text</span>', ['@text' => $this->t('Remove')]),
|
||||
'#url' => Url::fromRoute('<none>'),
|
||||
'#attributes' => [
|
||||
'id' => 'display-remove-link-' . $id,
|
||||
|
|
|
@ -104,7 +104,9 @@ abstract class ViewsFormBase extends FormBase implements ViewsFormInterface {
|
|||
// Retrieve the first form from the stack without changing the integer keys,
|
||||
// as they're being used for the "2 of 3" progress indicator.
|
||||
reset($view->stack);
|
||||
list($key, $top) = each($view->stack);
|
||||
$key = key($view->stack);
|
||||
$top = current($view->stack);
|
||||
next($view->stack);
|
||||
unset($view->stack[$key]);
|
||||
|
||||
if (array_shift($top) != $identifier) {
|
||||
|
|
|
@ -10,6 +10,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
|
||||
/**
|
||||
* Form builder for the admin display defaults page.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class BasicSettingsForm extends ConfigFormBase {
|
||||
|
||||
|
|
|
@ -5,11 +5,13 @@ namespace Drupal\views_ui\Form;
|
|||
use Drupal\Core\Entity\EntityConfirmFormBase;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\user\SharedTempStoreFactory;
|
||||
use Drupal\Core\TempStore\SharedTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Builds the form to break the lock of an edited view.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class BreakLockForm extends EntityConfirmFormBase {
|
||||
|
||||
|
@ -21,9 +23,9 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* Stores the user tempstore.
|
||||
* Stores the shared tempstore.
|
||||
*
|
||||
* @var \Drupal\user\SharedTempStore
|
||||
* @var \Drupal\Core\TempStore\SharedTempStore
|
||||
*/
|
||||
protected $tempStore;
|
||||
|
||||
|
@ -32,7 +34,7 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The Entity manager.
|
||||
* @param \Drupal\user\SharedTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $temp_store_factory
|
||||
* The factory for the temp store object.
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory) {
|
||||
|
@ -46,7 +48,7 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('entity.manager'),
|
||||
$container->get('user.shared_tempstore')
|
||||
$container->get('tempstore.shared')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,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)]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,7 +110,7 @@ class BreakLockForm extends EntityConfirmFormBase {
|
|||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->tempStore->delete($this->entity->id());
|
||||
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
|
||||
drupal_set_message($this->t('The lock has been broken and you may now edit this view.'));
|
||||
$this->messenger()->addStatus($this->t('The lock has been broken and you may now edit this view.'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ use Drupal\Core\ParamConverter\AdminPathConfigEntityConverter;
|
|||
use Drupal\Core\Routing\AdminContext;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Drupal\Core\ParamConverter\ParamConverterInterface;
|
||||
use Drupal\user\SharedTempStoreFactory;
|
||||
use Drupal\Core\TempStore\SharedTempStoreFactory;
|
||||
use Drupal\views_ui\ViewUI;
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,7 @@ class ViewUIConverter extends AdminPathConfigEntityConverter implements ParamCon
|
|||
/**
|
||||
* Stores the tempstore factory.
|
||||
*
|
||||
* @var \Drupal\user\SharedTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\SharedTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
|
@ -41,7 +41,7 @@ class ViewUIConverter extends AdminPathConfigEntityConverter implements ParamCon
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
|
||||
* The entity manager.
|
||||
* @param \Drupal\user\SharedTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $temp_store_factory
|
||||
* The factory for the temp store object.
|
||||
*/
|
||||
public function __construct(EntityManagerInterface $entity_manager, SharedTempStoreFactory $temp_store_factory, ConfigFactoryInterface $config_factory = NULL, AdminContext $admin_context = NULL) {
|
||||
|
|
|
@ -105,7 +105,13 @@ class PreviewTest extends UITestBase {
|
|||
$this->assertText(t('Query execute time'));
|
||||
$this->assertText(t('View render time'));
|
||||
$this->assertRaw('<strong>Query</strong>');
|
||||
$this->assertText("SELECT views_test_data.name AS views_test_data_name\nFROM \n{views_test_data} views_test_data\nWHERE (views_test_data.id = '100' )");
|
||||
$query_string = <<<SQL
|
||||
SELECT views_test_data.name AS views_test_data_name
|
||||
FROM
|
||||
{views_test_data} views_test_data
|
||||
WHERE (views_test_data.id = '100')
|
||||
SQL;
|
||||
$this->assertEscaped($query_string);
|
||||
|
||||
// Test that the statistics and query are rendered above the preview.
|
||||
$this->assertTrue(strpos($this->getRawContent(), 'views-query-info') < strpos($this->getRawContent(), 'view-test-preview'), 'Statistics shown above the preview.');
|
||||
|
@ -114,6 +120,12 @@ class PreviewTest extends UITestBase {
|
|||
$settings->set('ui.show.sql_query.where', 'below')->save();
|
||||
$this->drupalPostForm(NULL, $edit = ['view_args' => '100'], t('Update preview'));
|
||||
$this->assertTrue(strpos($this->getRawContent(), 'view-test-preview') < strpos($this->getRawContent(), 'views-query-info'), 'Statistics shown below the preview.');
|
||||
|
||||
// Test that the preview title isn't double escaped.
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/test_preview/default/title", $edit = ['title' => 'Double & escaped'], t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$elements = $this->xpath('//div[@id="views-live-preview"]/div[contains(@class, views-query-info)]//td[text()=:text]', [':text' => t('Double & escaped')]);
|
||||
$this->assertEqual(1, count($elements));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,9 @@ use Drupal\views\Tests\ViewTestBase;
|
|||
|
||||
/**
|
||||
* Provides a base class for testing the Views UI.
|
||||
*
|
||||
* @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.x.
|
||||
* Use \Drupal\Tests\views_ui\Functional\UITestBase.
|
||||
*/
|
||||
abstract class UITestBase extends ViewTestBase {
|
||||
|
||||
|
@ -33,8 +36,8 @@ abstract class UITestBase extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
|
@ -48,6 +51,8 @@ abstract class UITestBase extends ViewTestBase {
|
|||
'administer permissions',
|
||||
]);
|
||||
$this->drupalLogin($this->fullAdminUser);
|
||||
|
||||
@trigger_error('\Drupal\views_ui\Tests\UITestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.x. Instead, use \Drupal\Tests\views_ui\Functional\UITestBase', E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,6 +10,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
|
||||
/**
|
||||
* Form controller for the Views edit form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ViewAddForm extends ViewFormBase {
|
||||
|
||||
|
@ -182,12 +184,12 @@ class ViewAddForm extends ViewFormBase {
|
|||
}
|
||||
// @todo Figure out whether it really makes sense to throw and catch exceptions on the wizard.
|
||||
catch (WizardException $e) {
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
$this->messenger()->addError($e->getMessage());
|
||||
$form_state->setRedirect('entity.view.collection');
|
||||
return;
|
||||
}
|
||||
$this->entity->save();
|
||||
drupal_set_message($this->t('The view %name has been saved.', ['%name' => $form_state->getValue('label')]));
|
||||
$this->messenger()->addStatus($this->t('The view %name has been saved.', ['%name' => $form_state->getValue('label')]));
|
||||
$form_state->setRedirectUrl($this->entity->urlInfo('edit-form'));
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ use Drupal\Core\Form\FormStateInterface;
|
|||
|
||||
/**
|
||||
* Form controller for the Views duplicate form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ViewDuplicateForm extends ViewFormBase {
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\views_ui;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
use Drupal\Core\Ajax\HtmlCommand;
|
||||
use Drupal\Core\Ajax\ReplaceCommand;
|
||||
|
@ -11,20 +11,23 @@ use Drupal\Core\Datetime\DateFormatterInterface;
|
|||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\ElementInfoManagerInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\user\SharedTempStoreFactory;
|
||||
use Drupal\Core\TempStore\SharedTempStoreFactory;
|
||||
use Drupal\views\Views;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||
|
||||
/**
|
||||
* Form controller for the Views edit form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ViewEditForm extends ViewFormBase {
|
||||
|
||||
/**
|
||||
* The views temp store.
|
||||
*
|
||||
* @var \Drupal\user\SharedTempStore
|
||||
* @var \Drupal\Core\TempStore\SharedTempStore
|
||||
*/
|
||||
protected $tempStore;
|
||||
|
||||
|
@ -52,7 +55,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
/**
|
||||
* Constructs a new ViewEditForm object.
|
||||
*
|
||||
* @param \Drupal\user\SharedTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\SharedTempStoreFactory $temp_store_factory
|
||||
* The factory for the temp store object.
|
||||
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
|
||||
* The request stack object.
|
||||
|
@ -73,7 +76,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.shared_tempstore'),
|
||||
$container->get('tempstore.shared'),
|
||||
$container->get('request_stack'),
|
||||
$container->get('date.formatter'),
|
||||
$container->get('element_info')
|
||||
|
@ -129,7 +132,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'),
|
||||
];
|
||||
|
@ -162,7 +165,6 @@ class ViewEditForm extends ViewFormBase {
|
|||
],
|
||||
];
|
||||
|
||||
|
||||
$form['displays']['top'] = $this->renderDisplayTop($view);
|
||||
|
||||
// The rest requires a display to be selected.
|
||||
|
@ -262,7 +264,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);
|
||||
|
@ -275,7 +277,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
// Rename display ids if needed.
|
||||
foreach ($executable->displayHandlers as $id => $display) {
|
||||
if (!empty($display->display['new_id']) && empty($display->display['deleted'])) {
|
||||
if (!empty($display->display['new_id']) && $display->display['new_id'] !== $display->display['id'] && empty($display->display['deleted'])) {
|
||||
$new_id = $display->display['new_id'];
|
||||
$display->display['id'] = $new_id;
|
||||
unset($display->display['new_id']);
|
||||
|
@ -290,6 +292,9 @@ class ViewEditForm extends ViewFormBase {
|
|||
'display_id' => $new_id,
|
||||
]);
|
||||
}
|
||||
elseif (isset($display->display['new_id'])) {
|
||||
unset($display->display['new_id']);
|
||||
}
|
||||
}
|
||||
$view->set('display', $displays);
|
||||
|
||||
|
@ -320,7 +325,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
|
||||
$view->save();
|
||||
|
||||
drupal_set_message($this->t('The view %name has been saved.', ['%name' => $view->label()]));
|
||||
$this->messenger()->addStatus($this->t('The view %name has been saved.', ['%name' => $view->label()]));
|
||||
|
||||
// Remove this view from cache so we can edit it properly.
|
||||
$this->tempStore->delete($view->id());
|
||||
|
@ -414,15 +419,25 @@ class ViewEditForm extends ViewFormBase {
|
|||
// path.
|
||||
elseif ($view->status() && $view->getExecutable()->displayHandlers->get($display['id'])->hasPath()) {
|
||||
$path = $view->getExecutable()->displayHandlers->get($display['id'])->getPath();
|
||||
|
||||
if ($path && (strpos($path, '%') === FALSE)) {
|
||||
if (!parse_url($path, PHP_URL_SCHEME)) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$url = Url::fromUserInput('/' . ltrim($path, '/'));
|
||||
// Wrap this in a try/catch as trying to generate links to some
|
||||
// routes may throw a NotAcceptableHttpException if they do not
|
||||
// respond to HTML, such as RESTExports.
|
||||
try {
|
||||
if (!parse_url($path, PHP_URL_SCHEME)) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$url = Url::fromUserInput('/' . ltrim($path, '/'));
|
||||
}
|
||||
else {
|
||||
$url = Url::fromUri("base:$path");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$url = Url::fromUri("base:$path");
|
||||
catch (NotAcceptableHttpException $e) {
|
||||
$url = '/' . $path;
|
||||
}
|
||||
|
||||
$build['top']['actions']['path'] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $this->t('View @display_title', ['@display_title' => $display_title]),
|
||||
|
@ -1083,7 +1098,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
$build['fields'][$id]['#class'][] = Html::cleanCssIdentifier($display['id'] . '-' . $type . '-' . $id);
|
||||
|
||||
if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Aggregation settings')]), new Url('views_ui.form_handler_group', [
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(new FormattableMarkup('<span class="label">@text</span>', ['@text' => $this->t('Aggregation settings')]), new Url('views_ui.form_handler_group', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
|
@ -1093,7 +1108,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
}
|
||||
|
||||
if ($handler->hasExtraOptions()) {
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(SafeMarkup::format('<span class="label">@text</span>', ['@text' => $this->t('Settings')]), new Url('views_ui.form_handler_extra', [
|
||||
$build['fields'][$id]['#settings_links'][] = $this->l(new FormattableMarkup('<span class="label">@text</span>', ['@text' => $this->t('Settings')]), new Url('views_ui.form_handler_extra', [
|
||||
'js' => 'nojs',
|
||||
'view' => $view->id(),
|
||||
'display_id' => $display['id'],
|
||||
|
@ -1132,7 +1147,7 @@ class ViewEditForm extends ViewFormBase {
|
|||
foreach ($contents as $key => $pid) {
|
||||
if ($key != $last) {
|
||||
$operator = $group_info['groups'][$gid] == 'OR' ? $this->t('OR') : $this->t('AND');
|
||||
$store[$pid]['#link'] = SafeMarkup::format('@link <span>@operator</span>', ['@link' => $store[$pid]['#link'], '@operator' => $operator]);
|
||||
$store[$pid]['#link'] = new FormattableMarkup('@link <span>@operator</span>', ['@link' => $store[$pid]['#link'], '@operator' => $operator]);
|
||||
}
|
||||
$build['fields'][$pid] = $store[$pid];
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
|
|||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
|
||||
|
||||
/**
|
||||
* Defines a class to build a listing of view entities.
|
||||
|
@ -177,6 +178,14 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
// ajax.js focuses automatically on the data-drupal-selector element. When
|
||||
// enabling the view again, focusing on the disable link doesn't work, as it
|
||||
// is hidden. We assign data-drupal-selector to every link, so it focuses
|
||||
// on the edit link.
|
||||
foreach ($operations as &$operation) {
|
||||
$operation['attributes']['data-drupal-selector'] = 'views-listing-' . $entity->id();
|
||||
}
|
||||
|
||||
return $operations;
|
||||
}
|
||||
|
||||
|
@ -255,9 +264,17 @@ class ViewListBuilder extends ConfigEntityListBuilder {
|
|||
if ($display->hasPath()) {
|
||||
$path = $display->getPath();
|
||||
if ($view->status() && strpos($path, '%') === FALSE) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
|
||||
// Wrap this in a try/catch as trying to generate links to some
|
||||
// routes may throw a NotAcceptableHttpException if they do not
|
||||
// respond to HTML, such as RESTExports.
|
||||
try {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
// https://www.drupal.org/node/2423913
|
||||
$rendered_path = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
|
||||
}
|
||||
catch (NotAcceptableHttpException $e) {
|
||||
$rendered_path = '/' . $path;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$rendered_path = '/' . $path;
|
||||
|
|
|
@ -7,6 +7,8 @@ use Drupal\Core\Url;
|
|||
|
||||
/**
|
||||
* Form controller for the Views preview form.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class ViewPreviewForm extends ViewFormBase {
|
||||
|
||||
|
@ -75,7 +77,7 @@ class ViewPreviewForm extends ViewFormBase {
|
|||
return [
|
||||
'#attributes' => [
|
||||
'id' => 'preview-submit-wrapper',
|
||||
'class' => ['preview-submit-wrapper']
|
||||
'class' => ['preview-submit-wrapper'],
|
||||
],
|
||||
'button' => [
|
||||
'#type' => 'submit',
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace Drupal\views_ui;
|
|||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Component\Utility\Timer;
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\EventSubscriber\AjaxResponseSubscriber;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\views\Views;
|
||||
|
@ -49,10 +48,10 @@ class ViewUI implements ViewEntityInterface {
|
|||
* If this view is locked for editing.
|
||||
*
|
||||
* If this view is locked it will contain the result of
|
||||
* \Drupal\user\SharedTempStore::getMetadata(). Which can be a stdClass or
|
||||
* \Drupal\Core\TempStore\SharedTempStore::getMetadata(). Which can be a stdClass or
|
||||
* NULL.
|
||||
*
|
||||
* @var stdClass
|
||||
* @var object
|
||||
*/
|
||||
public $lock;
|
||||
|
||||
|
@ -688,7 +687,11 @@ class ViewUI implements ViewEntityInterface {
|
|||
'#template' => "<strong>{% trans 'Title' %}</strong>",
|
||||
],
|
||||
],
|
||||
Xss::filterAdmin($executable->getTitle()),
|
||||
[
|
||||
'data' => [
|
||||
'#markup' => $executable->getTitle(),
|
||||
],
|
||||
],
|
||||
];
|
||||
if (isset($path)) {
|
||||
// @todo Views should expect and store a leading /. See:
|
||||
|
@ -710,7 +713,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
'data' => [
|
||||
'#markup' => $path,
|
||||
],
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
if ($show_stats) {
|
||||
|
@ -787,7 +790,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
else {
|
||||
foreach ($errors as $display_errors) {
|
||||
foreach ($display_errors as $error) {
|
||||
drupal_set_message($error, 'error');
|
||||
\Drupal::messenger()->addError($error);
|
||||
}
|
||||
}
|
||||
$preview = ['#markup' => t('Unable to preview due to validation errors.')];
|
||||
|
@ -852,11 +855,11 @@ class ViewUI implements ViewEntityInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a cached view object in the user tempstore.
|
||||
* Sets a cached view object in the shared tempstore.
|
||||
*/
|
||||
public function cacheSet() {
|
||||
if ($this->isLocked()) {
|
||||
drupal_set_message(t('Changes cannot be made to a locked view.'), 'error');
|
||||
\Drupal::messenger()->addError(t('Changes cannot be made to a locked view.'));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -875,7 +878,7 @@ class ViewUI implements ViewEntityInterface {
|
|||
$executable->default_display = NULL;
|
||||
$executable->query = NULL;
|
||||
$executable->displayHandlers = NULL;
|
||||
\Drupal::service('user.shared_tempstore')->get('views')->set($this->id(), $this);
|
||||
\Drupal::service('tempstore.shared')->get('views')->set($this->id(), $this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,4 +5,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
||||
- drupal:views_ui
|
||||
|
|
|
@ -5,4 +5,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
||||
- drupal:views_ui
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the views analyze system.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class AnalyzeTest extends ViewTestBase {
|
||||
class AnalyzeTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -25,27 +23,18 @@ class AnalyzeTest extends ViewTestBase {
|
|||
*/
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
// Add an admin user will full rights;
|
||||
$this->admin = $this->drupalCreateUser(['administer views']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that analyze works in general.
|
||||
*/
|
||||
public function testAnalyzeBasic() {
|
||||
$this->drupalLogin($this->admin);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
$this->drupalGet('admin/structure/views/view/test_view/edit');
|
||||
$this->assertLink(t('Analyze view'));
|
||||
|
||||
// This redirects the user to the analyze form.
|
||||
$this->clickLink(t('Analyze view'));
|
||||
$this->assertText(t('View analysis'));
|
||||
$this->assertSession()->titleEquals('View analysis | Drupal');
|
||||
|
||||
foreach (['ok', 'warning', 'error'] as $type) {
|
||||
$xpath = $this->xpath('//div[contains(@class, :class)]', [':class' => $type]);
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
@ -34,15 +34,15 @@ class AreaEntityUITest extends UITestBase {
|
|||
$this->drupalGet($view->urlInfo('edit-form'));
|
||||
|
||||
// Add a global NULL argument to the view for testing argument placeholders.
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/argument", ['name[views.null]' => 1], 'Add and configure contextual filters');
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/argument", ['name[views.null]' => TRUE], 'Add and configure contextual filters');
|
||||
$this->drupalPostForm(NULL, [], 'Apply');
|
||||
|
||||
// Configure both the entity_test area header and the block header to
|
||||
// reference the given entities.
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_block]' => 1], 'Add and configure header');
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_block]' => TRUE], 'Add and configure header');
|
||||
$this->drupalPostForm(NULL, ['options[target]' => $block->id()], 'Apply');
|
||||
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_entity_test]' => 1], 'Add and configure header');
|
||||
$this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_entity_test]' => TRUE], 'Add and configure header');
|
||||
$this->drupalPostForm(NULL, ['options[target]' => $entity_test->id()], 'Apply');
|
||||
|
||||
$this->drupalPostForm(NULL, [], 'Save');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the user tempstore cache in the UI.
|
||||
* Tests the shared tempstore cache in the UI.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
|
@ -17,12 +17,12 @@ class CachedDataUITest extends UITestBase {
|
|||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests the user tempstore views data in the UI.
|
||||
* Tests the shared tempstore views data in the UI.
|
||||
*/
|
||||
public function testCacheData() {
|
||||
$views_admin_user_uid = $this->fullAdminUser->id();
|
||||
|
||||
$temp_store = $this->container->get('user.shared_tempstore')->get('views');
|
||||
$temp_store = $this->container->get('tempstore.shared')->get('views');
|
||||
// The view should not be locked.
|
||||
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'The view is not locked.');
|
||||
|
||||
|
@ -40,7 +40,7 @@ class CachedDataUITest extends UITestBase {
|
|||
|
||||
// Cancel the view edit and make sure the cache is deleted.
|
||||
$this->drupalPostForm(NULL, [], t('Cancel'));
|
||||
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'User tempstore data has been removed.');
|
||||
$this->assertEqual($temp_store->getMetadata('test_view'), NULL, 'Shared tempstore data has been removed.');
|
||||
// Test we are redirected to the view listing page.
|
||||
$this->assertUrl('admin/structure/views', [], 'Redirected back to the view listing page.');
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
|
@ -97,8 +97,8 @@ class CustomBooleanTest extends UITestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
$this->{$values['test']}(strpos($output, $values['true']), SafeMarkup::format('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['false']), SafeMarkup::format('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['true']), new FormattableMarkup('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['false']), new FormattableMarkup('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,12 +169,11 @@ class CustomBooleanTest extends UITestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
$this->{$values['test']}(strpos($output, $values['true']), SafeMarkup::format('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['false']), SafeMarkup::format('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['true']), new FormattableMarkup('Expected custom boolean TRUE value %value in output for %type', ['%value' => $values['true'], '%type' => $type]));
|
||||
$this->{$values['test']}(strpos($output, $values['false']), new FormattableMarkup('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
|
||||
|
||||
// Assert that we are using the correct template.
|
||||
$this->setRawContent($output);
|
||||
$this->assertText('llama', 'Loaded the correct views-view-field.html.twig template');
|
||||
$this->assertContains('llama', (string) $output);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
@ -20,11 +20,10 @@ class DefaultViewsTest extends UITestBase {
|
|||
*/
|
||||
public static $testViews = ['test_view_status', 'test_page_display_menu', 'test_page_display_arguments'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
$this->placeBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -228,9 +227,9 @@ class DefaultViewsTest extends UITestBase {
|
|||
* failure. Failure also results in a failed assertion.
|
||||
*/
|
||||
public function clickViewsOperationLink($label, $unique_href_part) {
|
||||
$links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
|
||||
$links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => (string) $label]);
|
||||
foreach ($links as $link_index => $link) {
|
||||
$position = strpos($link['href'], $unique_href_part);
|
||||
$position = strpos($link->getAttribute('href'), $unique_href_part);
|
||||
if ($position !== FALSE) {
|
||||
$index = $link_index;
|
||||
break;
|
||||
|
@ -238,7 +237,7 @@ class DefaultViewsTest extends UITestBase {
|
|||
}
|
||||
$this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', ['@label' => $label, '@part' => $unique_href_part]));
|
||||
if (isset($index)) {
|
||||
return $this->clickLink($label, $index);
|
||||
return $this->clickLink((string) $label, $index);
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -16,6 +16,7 @@ class DisplayAttachmentTest extends UITestBase {
|
|||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
* .
|
||||
*/
|
||||
public static $testViews = ['test_attachment_ui'];
|
||||
|
||||
|
@ -41,7 +42,7 @@ class DisplayAttachmentTest extends UITestBase {
|
|||
$this->assertEscaped('<em>Page</em>');
|
||||
$this->assertNoRaw('<em>Page</em>');
|
||||
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
|
||||
$this->assertEqual($result[0]->attributes()->title, t('Page'));
|
||||
$this->assertEqual($result[0]->getAttribute('title'), t('Page'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView('test_attachment_ui');
|
||||
|
@ -50,7 +51,7 @@ class DisplayAttachmentTest extends UITestBase {
|
|||
|
||||
$this->drupalPostForm($attachment_display_url, ['displays[default]' => 1, 'displays[page_1]' => 1], t('Apply'));
|
||||
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
|
||||
$this->assertEqual($result[0]->attributes()->title, t('Multiple displays'));
|
||||
$this->assertEqual($result[0]->getAttribute('title'), t('Multiple displays'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$view = Views::getView('test_attachment_ui');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -143,6 +143,16 @@ class DisplayCRUDTest extends UITestBase {
|
|||
$this->assertFalse(isset($block_1->display['display_options']['path']));
|
||||
$this->assertEqual($block_1->getOption('title'), $random_title, 'The overridden title option from the display got copied into the duplicate');
|
||||
$this->assertEqual($block_1->getOption('css_class'), $random_css, 'The overridden css_class option from the display got copied into the duplicate');
|
||||
|
||||
// Test duplicating a display after changing the machine name.
|
||||
$view_id = $view->id();
|
||||
$this->drupalPostForm("admin/structure/views/nojs/display/$view_id/page_2/display_id", ['display_id' => 'page_new'], 'Apply');
|
||||
$this->drupalPostForm(NULL, [], 'Duplicate as Block');
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
$view = Views::getView($view_id);
|
||||
$view->initDisplay();
|
||||
$this->assertNotNull($view->displayHandlers->get('page_new'), 'The original display is saved with a changed id');
|
||||
$this->assertNotNull($view->displayHandlers->get('block_2'), 'The duplicate display is saved with new id');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the UI for feed display plugin.
|
||||
|
@ -57,10 +57,9 @@ class DisplayFeedTest extends UITestBase {
|
|||
$result = $this->xpath('//div[@id="edit-displays"]/div');
|
||||
$options = [];
|
||||
foreach ($result as $item) {
|
||||
foreach ($item->input->attributes() as $attribute => $value) {
|
||||
if ($attribute == 'value') {
|
||||
$options[] = (string) $value;
|
||||
}
|
||||
$input_node = $item->find('css', 'input');
|
||||
if ($input_node->hasAttribute('value')) {
|
||||
$options[] = $input_node->getAttribute('value');
|
||||
}
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Core\Menu\MenuTreeParameters;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
|
||||
|
||||
/**
|
||||
* Tests the UI of generic display path plugin.
|
||||
|
@ -12,10 +14,12 @@ use Drupal\menu_link_content\Entity\MenuLinkContent;
|
|||
*/
|
||||
class DisplayPathTest extends UITestBase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
use AssertPageCacheContextsAndTagsTrait;
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->placeBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -158,9 +162,14 @@ class DisplayPathTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/nojs/display/test_page_display_menu/page_5/menu');
|
||||
$this->assertResponse(200);
|
||||
$menu_parent = $this->xpath('//select[@id="edit-menu-parent"]');
|
||||
$menu_options = (array) $menu_parent[0]->option;
|
||||
$menu_options = (array) $menu_parent[0]->findAll('css', 'option');
|
||||
unset($menu_options['@attributes']);
|
||||
|
||||
// Convert array to make the next assertion possible.
|
||||
$menu_options = array_map(function ($element) {
|
||||
return $element->getText();
|
||||
}, $menu_options);
|
||||
|
||||
$this->assertEqual([
|
||||
'<User account menu>',
|
||||
'-- My account',
|
||||
|
@ -199,7 +208,7 @@ class DisplayPathTest extends UITestBase {
|
|||
$edit = [
|
||||
'title[0][value]' => 'Menu title',
|
||||
'link[0][uri]' => '/admin/foo',
|
||||
'menu_parent' => 'admin:system.admin'
|
||||
'menu_parent' => 'admin:system.admin',
|
||||
];
|
||||
$this->drupalPostForm('admin/structure/menu/manage/admin/add', $edit, t('Save'));
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -40,13 +38,6 @@ class DisplayTest extends UITestBase {
|
|||
$this->drupalPostForm(NULL, [], t('Add @display', ['@display' => 'Block']));
|
||||
$this->assertText('Block');
|
||||
$this->assertNoText('Block 2');
|
||||
|
||||
// Views has special form handling in views_ui_form_button_was_clicked()
|
||||
// to be able to change the submit button text via JS, this simulates what
|
||||
// the JS is doing.
|
||||
$this->drupalPostForm(NULL, [], NULL, [], [], NULL, '&op=Block');
|
||||
$this->assertText('Block');
|
||||
$this->assertText('Block 2');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,7 +45,7 @@ class DisplayTest extends UITestBase {
|
|||
*/
|
||||
public function testReorderDisplay() {
|
||||
$view = [
|
||||
'block[create]' => TRUE
|
||||
'block[create]' => TRUE,
|
||||
];
|
||||
$view = $this->randomView($view);
|
||||
|
||||
|
@ -69,7 +60,7 @@ class DisplayTest extends UITestBase {
|
|||
// Put the block display in front of the page display.
|
||||
$edit = [
|
||||
'displays[page_1][weight]' => 2,
|
||||
'displays[block_1][weight]' => 1
|
||||
'displays[block_1][weight]' => 1,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
@ -94,13 +85,13 @@ class DisplayTest extends UITestBase {
|
|||
$this->drupalGet($path_prefix);
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appear after initial adding of a view.');
|
||||
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is visible.');
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is not visible.');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.');
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.');
|
||||
$this->drupalPostForm(NULL, [], 'Disable Page');
|
||||
$this->assertTrue($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.');
|
||||
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is not visible.');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is visible.');
|
||||
$this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.');
|
||||
$this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is visible.');
|
||||
$this->drupalPostForm(NULL, [], 'Enable Page');
|
||||
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appears once the display is enabled again.');
|
||||
}
|
||||
|
@ -145,7 +136,7 @@ class DisplayTest extends UITestBase {
|
|||
// Assert that the expected text is found in each area category.
|
||||
foreach ($areas as $type) {
|
||||
$element = $this->xpath('//div[contains(@class, :class)]/div', [':class' => $type]);
|
||||
$this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', ['@type' => $type]));
|
||||
$this->assertEqual($element[0]->getHtml(), new FormattableMarkup('The selected display type does not use @type plugins', ['@type' => $type]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +151,7 @@ class DisplayTest extends UITestBase {
|
|||
// Test the link text displays 'None' and not 'Block 1'
|
||||
$this->drupalGet($path);
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
|
||||
$this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
|
||||
$this->assertEqual($result[0]->getHtml(), t('None'), 'Make sure that the link option summary shows "None" by default.');
|
||||
|
||||
$this->drupalGet($link_display_path);
|
||||
$this->assertFieldChecked('edit-link-display-0');
|
||||
|
@ -171,7 +162,7 @@ class DisplayTest extends UITestBase {
|
|||
$this->drupalGet($path);
|
||||
|
||||
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
|
||||
$this->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
|
||||
$this->assertEqual($result[0]->getHtml(), 'Page', 'Make sure that the link option summary shows the right linked display.');
|
||||
|
||||
$this->drupalPostForm($link_display_path, ['link_display' => 'custom_url', 'link_url' => 'a-custom-url'], t('Apply'));
|
||||
// The form redirects to the master display.
|
||||
|
@ -186,40 +177,6 @@ class DisplayTest extends UITestBase {
|
|||
$this->assertFieldByName('link_url', 'a-custom-url');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests contextual links on Views page displays.
|
||||
*/
|
||||
public function testPageContextualLinks() {
|
||||
$this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links']));
|
||||
$view = View::load('test_display');
|
||||
$view->enable()->save();
|
||||
$this->container->get('router.builder')->rebuildIfNeeded();
|
||||
|
||||
// When no "main content" block is placed, we find a contextual link
|
||||
// placeholder for editing just the view.
|
||||
$this->drupalGet('test-display');
|
||||
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
|
||||
$this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
|
||||
|
||||
// Get server-rendered contextual links.
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
|
||||
$post = ['ids[0]' => $id];
|
||||
$response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-display']]);
|
||||
$this->assertResponse(200);
|
||||
$json = Json::decode($response);
|
||||
$this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
|
||||
|
||||
// When a "main content" is placed, we still find a contextual link
|
||||
// placeholder for editing just the view (not the main content block).
|
||||
// @see system_block_view_system_main_block_alter()
|
||||
$this->drupalPlaceBlock('system_main_block', ['id' => 'main_content']);
|
||||
$this->drupalGet('test-display');
|
||||
$id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
|
||||
// @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
|
||||
$this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the view status is correctly reflected on the edit form.
|
||||
*/
|
||||
|
@ -227,7 +184,7 @@ class DisplayTest extends UITestBase {
|
|||
$view = $this->randomView();
|
||||
$id = $view['id'];
|
||||
|
||||
// The view should initially have the enabled class on it's form wrapper.
|
||||
// The view should initially have the enabled class on its form wrapper.
|
||||
$this->drupalGet('admin/structure/views/view/' . $id);
|
||||
$elements = $this->xpath('//div[contains(@class, :edit) and contains(@class, :status)]', [':edit' => 'views-edit-view', ':status' => 'enabled']);
|
||||
$this->assertTrue($elements, 'The enabled class was found on the form wrapper');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the UI for view duplicate tool.
|
||||
|
@ -9,10 +9,10 @@ namespace Drupal\views_ui\Tests;
|
|||
*/
|
||||
class DuplicateTest extends UITestBase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
$this->placeBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
|
@ -32,8 +32,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
*/
|
||||
protected $groupFormUiErrors = [];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
|
@ -61,8 +61,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// The first time the filter UI is displayed, the operator and the
|
||||
// value forms should be shown.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
|
||||
$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');
|
||||
|
||||
|
@ -72,8 +72,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
$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', '', 'Operator In exists');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists');
|
||||
$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');
|
||||
|
||||
|
@ -98,8 +98,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
$this->drupalPostForm(NULL, [], t('Hide filter'));
|
||||
|
||||
// After Un-exposing the filter, Operator and Value should be shown again.
|
||||
$this->assertFieldById('edit-options-operator-in', '', 'Operator In exists after hide filter');
|
||||
$this->assertFieldById('edit-options-operator-not-in', '', 'Operator Not In exists after hide filter');
|
||||
$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');
|
||||
|
||||
|
@ -108,7 +108,7 @@ class ExposedFormUITest extends UITestBase {
|
|||
$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', '', 'Make sure a label field is shown');
|
||||
$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'];
|
||||
|
@ -150,8 +150,8 @@ class ExposedFormUITest extends UITestBase {
|
|||
|
||||
// After click on 'Grouped Filters', the standard operator and value should
|
||||
// not be displayed.
|
||||
$this->assertNoFieldById('edit-options-operator-in', '', 'Operator In not exists');
|
||||
$this->assertNoFieldById('edit-options-operator-not-in', '', 'Operator Not In not exists');
|
||||
$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');
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\views\Views;
|
||||
|
@ -39,20 +39,20 @@ class FieldUITest extends UITestBase {
|
|||
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/age';
|
||||
$this->drupalGet($edit_handler_url);
|
||||
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
|
||||
$this->assertEqual((string) $result[0], '{{ age }} == Age');
|
||||
$this->assertEqual($result[0]->getHtml(), '{{ age }} == Age');
|
||||
|
||||
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/id';
|
||||
$this->drupalGet($edit_handler_url);
|
||||
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
|
||||
$this->assertEqual((string) $result[0], '{{ age }} == Age');
|
||||
$this->assertEqual((string) $result[1], '{{ id }} == ID');
|
||||
$this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age');
|
||||
$this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID');
|
||||
|
||||
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
|
||||
$this->drupalGet($edit_handler_url);
|
||||
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
|
||||
$this->assertEqual((string) $result[0], '{{ age }} == Age');
|
||||
$this->assertEqual((string) $result[1], '{{ id }} == ID');
|
||||
$this->assertEqual((string) $result[2], '{{ name }} == Name');
|
||||
$this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age');
|
||||
$this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID');
|
||||
$this->assertEqual(trim($result[2]->getHtml()), '{{ name }} == Name');
|
||||
|
||||
$result = $this->xpath('//details[@id="edit-options-more"]');
|
||||
$this->assertEqual(empty($result), TRUE, "Container 'more' is empty and should not be displayed.");
|
||||
|
@ -71,7 +71,7 @@ class FieldUITest extends UITestBase {
|
|||
|
||||
$edit_handler_url = '/admin/structure/views/ajax/handler-group/test_view/default/field/name';
|
||||
$this->drupalGet($edit_handler_url);
|
||||
$data = Json::decode($this->getRawContent());
|
||||
$data = Json::decode($this->getSession()->getPage()->getContent());
|
||||
$this->assertEqual($data[3]['dialogOptions']['title'], 'Configure aggregation settings for field Views test: Name');
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the boolean filter UI.
|
||||
|
@ -25,7 +25,7 @@ class FilterBooleanWebTest extends UITestBase {
|
|||
|
||||
// Check the field widget label. 'title' should be used as a fallback.
|
||||
$result = $this->cssSelect('#edit-options-value--wrapper legend span');
|
||||
$this->assertEqual((string) $result[0], 'Status');
|
||||
$this->assertEqual($result[0]->getHtml(), 'Status');
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Expose filter'));
|
||||
$this->drupalPostForm(NULL, [], t('Grouped filters'));
|
||||
|
@ -46,11 +46,11 @@ class FilterBooleanWebTest extends UITestBase {
|
|||
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status');
|
||||
|
||||
$result = $this->xpath('//input[@name="options[group_info][group_items][1][value]"]');
|
||||
$this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
|
||||
$this->assertEqual($result[1]->getAttribute('checked'), 'checked');
|
||||
$result = $this->xpath('//input[@name="options[group_info][group_items][2][value]"]');
|
||||
$this->assertEqual((int) $result[2]->attributes()->checked, 'checked');
|
||||
$this->assertEqual($result[2]->getAttribute('checked'), 'checked');
|
||||
$result = $this->xpath('//input[@name="options[group_info][group_items][3][value]"]');
|
||||
$this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
|
||||
$this->assertEqual($result[1]->getAttribute('checked'), 'checked');
|
||||
|
||||
// Test that there is a remove link for each group.
|
||||
$this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
|
||||
|
@ -24,6 +24,12 @@ class FilterNumericWebTest extends UITestBase {
|
|||
* Tests the filter numeric UI.
|
||||
*/
|
||||
public function testFilterNumericUI() {
|
||||
// Add a page display to the test_view to be able to test the filtering.
|
||||
$path = 'test_view-path';
|
||||
$this->drupalPostForm('admin/structure/views/view/test_view/edit', [], 'Add Page');
|
||||
$this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $path], 'Apply');
|
||||
$this->drupalPostForm(NULL, [], t('Save'));
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.age]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Expose filter'));
|
||||
|
@ -52,13 +58,13 @@ class FilterNumericWebTest extends UITestBase {
|
|||
$this->assertConfigSchemaByName('views.view.test_view');
|
||||
|
||||
// Test that the exposed filter works as expected.
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$this->drupalGet('test_view-path');
|
||||
$this->assertText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertText('Ringo');
|
||||
$this->assertText('George');
|
||||
$this->assertText('Meredith');
|
||||
$this->drupalPostForm(NULL, ['age' => '2'], t('Update preview'));
|
||||
$this->drupalPostForm(NULL, ['age' => '2'], 'Apply');
|
||||
$this->assertText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
|
@ -75,13 +81,13 @@ class FilterNumericWebTest extends UITestBase {
|
|||
$this->assertConfigSchemaByName('views.view.test_view');
|
||||
|
||||
// Test that the filter works as expected.
|
||||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$this->drupalGet('test_view-path');
|
||||
$this->assertText('John');
|
||||
$this->assertNoText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
$this->assertNoText('George');
|
||||
$this->assertNoText('Meredith');
|
||||
$this->drupalPostForm(NULL, ['age' => '26'], t('Update preview'));
|
||||
$this->drupalPostForm(NULL, ['age' => '26'], t('Apply'));
|
||||
$this->assertNoText('John');
|
||||
$this->assertText('Paul');
|
||||
$this->assertNoText('Ringo');
|
||||
|
@ -106,7 +112,7 @@ class FilterNumericWebTest extends UITestBase {
|
|||
$this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
|
||||
$this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
|
||||
// Check that the description is shown in the right place.
|
||||
$this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]), 'Description of the exposed filter');
|
||||
$this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]->getText()), 'Description of the exposed filter');
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests for the filters from the UI.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class FilterUITest extends ViewTestBase {
|
||||
class FilterUITest extends UITestBase {
|
||||
|
||||
|
||||
/**
|
||||
|
@ -29,10 +27,9 @@ class FilterUITest extends ViewTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->enableViewsTestModule();
|
||||
}
|
||||
|
||||
/**
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests UI of aggregate functionality..
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
@ -31,10 +31,10 @@ class HandlerTest extends UITestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
$this->placeBlock('page_title_block');
|
||||
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -51,7 +53,7 @@ class HandlerTest extends UITestBase {
|
|||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0
|
||||
'default' => 0,
|
||||
];
|
||||
|
||||
return $schema;
|
||||
|
@ -72,8 +74,8 @@ class HandlerTest extends UITestBase {
|
|||
'relationship' => [
|
||||
'id' => 'standard',
|
||||
'base' => 'users_field_data',
|
||||
'base field' => 'uid'
|
||||
]
|
||||
'base field' => 'uid',
|
||||
],
|
||||
];
|
||||
|
||||
// Create a dummy field with no help text.
|
||||
|
@ -178,14 +180,14 @@ class HandlerTest extends UITestBase {
|
|||
'field_name' => 'field_test',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'label' => 'The giraffe" label'
|
||||
'label' => 'The giraffe" label',
|
||||
])->save();
|
||||
|
||||
FieldConfig::create([
|
||||
'field_name' => 'field_test',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'label' => 'The <em>giraffe"</em> label <script>alert("the return of the xss")</script>'
|
||||
'label' => 'The <em>giraffe"</em> label <script>alert("the return of the xss")</script>',
|
||||
])->save();
|
||||
|
||||
$this->drupalGet('admin/structure/views/nojs/add-handler/content/default/field');
|
||||
|
@ -204,15 +206,15 @@ class HandlerTest extends UITestBase {
|
|||
$href = "admin/structure/views/nojs/handler/test_view_broken/default/$type/id_broken";
|
||||
|
||||
$result = $this->xpath('//a[contains(@href, :href)]', [':href' => $href]);
|
||||
$this->assertEqual(count($result), 1, SafeMarkup::format('Handler (%type) edit link found.', ['%type' => $type]));
|
||||
$this->assertEqual(count($result), 1, new FormattableMarkup('Handler (%type) edit link found.', ['%type' => $type]));
|
||||
|
||||
$text = 'Broken/missing handler';
|
||||
|
||||
$this->assertIdentical((string) $result[0], $text, 'Ensure the broken handler text was found.');
|
||||
$this->assertIdentical($result[0]->getText(), $text, 'Ensure the broken handler text was found.');
|
||||
|
||||
$this->drupalGet($href);
|
||||
$result = $this->xpath('//h1[@class="page-title"]');
|
||||
$this->assertTrue(strpos((string) $result[0], $text) !== FALSE, 'Ensure the broken handler text was found.');
|
||||
$this->assertContains($text, $result[0]->getText(), 'Ensure the broken handler text was found.');
|
||||
|
||||
$original_configuration = [
|
||||
'field' => 'id_broken',
|
||||
|
@ -223,7 +225,7 @@ class HandlerTest extends UITestBase {
|
|||
];
|
||||
|
||||
foreach ($original_configuration as $key => $value) {
|
||||
$this->assertText(SafeMarkup::format('@key: @value', ['@key' => $key, '@value' => $value]));
|
||||
$this->assertText(new FormattableMarkup('@key: @value', ['@key' => $key, '@value' => $value]));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests configuration schema against new views.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class NewViewConfigSchemaTest extends WebTestBase {
|
||||
class NewViewConfigSchemaTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests that displays can be correctly overridden via the user interface.
|
||||
|
@ -9,8 +9,8 @@ namespace Drupal\views_ui\Tests;
|
|||
*/
|
||||
class OverrideDisplaysTest extends UITestBase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Confirm that the view block is available in the block administration UI.
|
||||
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
|
||||
$this->clickLinkPartialName('Place block');
|
||||
$this->clickLink('Place block');
|
||||
$this->assertText($view['label']);
|
||||
|
||||
// Place the block.
|
||||
|
@ -111,7 +111,7 @@ class OverrideDisplaysTest extends UITestBase {
|
|||
|
||||
// Confirm that the block is available in the block administration UI.
|
||||
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
|
||||
$this->clickLinkPartialName('Place block');
|
||||
$this->clickLink('Place block');
|
||||
$this->assertText($view['label']);
|
||||
|
||||
// Put the block into the first sidebar region, and make sure it will not
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\Entity\View;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the redirecting after saving a views.
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
|
@ -1,14 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests existence of the views plugin report.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class ReportTest extends WebTestBase {
|
||||
class ReportTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -24,11 +23,6 @@ class ReportTest extends WebTestBase {
|
|||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the existence of the views plugin report.
|
||||
*/
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewMode;
|
||||
use Drupal\views\Views;
|
||||
|
@ -34,13 +34,13 @@ class RowUITest extends UITestBase {
|
|||
$this->assertFieldByName('row[type]', 'fields', 'The default row plugin selected in the UI should be fields.');
|
||||
|
||||
$edit = [
|
||||
'row[type]' => 'test_row'
|
||||
'row[type]' => 'test_row',
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertFieldByName('row_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
|
||||
$random_name = $this->randomMachineName();
|
||||
$edit = [
|
||||
'row_options[test_option]' => $random_name
|
||||
'row_options[test_option]' => $random_name,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalGet($row_options_url);
|
||||
|
@ -55,20 +55,7 @@ class RowUITest extends UITestBase {
|
|||
$this->assertEqual($row['type'], 'test_row', 'Make sure that the test_row got saved as used row plugin.');
|
||||
$this->assertEqual($row['options']['test_option'], $random_name, 'Make sure that the custom settings field got saved as expected.');
|
||||
|
||||
// Change the row plugin to fields using ajax.
|
||||
// Note: this is the best approximation we can achieve, because we cannot
|
||||
// simulate the 'openDialog' command in
|
||||
// WebTestBase::drupalProcessAjaxResponse(), hence we have to make do.
|
||||
$row_plugin_url_ajax = str_replace('/nojs/', '/ajax/', $row_plugin_url);
|
||||
$ajax_settings = [
|
||||
'accepts' => 'application/vnd.drupal-ajax',
|
||||
'submit' => [
|
||||
'_triggering_element_name' => 'op',
|
||||
'_triggering_element_value' => 'Apply',
|
||||
],
|
||||
'url' => $row_plugin_url_ajax,
|
||||
];
|
||||
$this->drupalPostAjaxForm($row_plugin_url, ['row[type]' => 'fields'], NULL, $row_plugin_url_ajax, [], [], NULL, $ajax_settings);
|
||||
$this->drupalPostForm($row_plugin_url, ['row[type]' => 'fields'], 'Apply');
|
||||
$this->drupalGet($row_plugin_url);
|
||||
$this->assertResponse(200);
|
||||
$this->assertFieldByName('row[type]', 'fields', 'Make sure that the fields got saved as used row plugin.');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests all ui related settings under admin/structure/views/settings.
|
||||
|
@ -19,8 +19,8 @@ class SettingsTest extends UITestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ class SettingsTest extends UITestBase {
|
|||
|
||||
$view['id'] = strtolower($this->randomMachineName());
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
$this->assertFieldById('edit-displays-top-add-display-embed');
|
||||
$this->assertFieldById('edit-displays-top-add-display-embed', NULL);
|
||||
|
||||
$edit = [
|
||||
'ui_show_display_embed' => FALSE,
|
||||
|
@ -116,8 +116,8 @@ class SettingsTest extends UITestBase {
|
|||
$this->drupalPostForm(NULL, [], t('Update preview'));
|
||||
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
|
||||
$this->assertEqual(count($xpath), 1, 'The views sql is shown.');
|
||||
$this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
|
||||
$this->assertTrue(strpos($xpath[0], "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
|
||||
$this->assertFalse(strpos($xpath[0]->getText(), 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
|
||||
$this->assertTrue(strpos($xpath[0]->getText(), "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
|
||||
|
||||
// Test the advanced settings form.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\views\Views;
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -33,13 +33,13 @@ class StyleUITest extends UITestBase {
|
|||
$this->assertFieldByName('style[type]', 'default', 'The default style plugin selected in the UI should be unformatted list.');
|
||||
|
||||
$edit = [
|
||||
'style[type]' => 'test_style'
|
||||
'style[type]' => 'test_style',
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->assertFieldByName('style_options[test_option]', NULL, 'Make sure the custom settings form from the test plugin appears.');
|
||||
$random_name = $this->randomMachineName();
|
||||
$edit = [
|
||||
'style_options[test_option]' => $random_name
|
||||
'style_options[test_option]' => $random_name,
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, t('Apply'));
|
||||
$this->drupalGet($style_options_url);
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\views\Entity\View;
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests that translated strings in views UI don't override original strings.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class TranslatedViewTest extends WebTestBase {
|
||||
class TranslatedViewTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -38,8 +37,8 @@ class TranslatedViewTest extends WebTestBase {
|
|||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$permissions = [
|
||||
'administer site configuration',
|
||||
|
@ -64,7 +63,7 @@ class TranslatedViewTest extends WebTestBase {
|
|||
$translation_url = 'admin/structure/views/view/files/translate/fr/add';
|
||||
$edit_url = 'admin/structure/views/view/files';
|
||||
|
||||
// Check origial string.
|
||||
// Check the original string.
|
||||
$this->drupalGet($edit_url);
|
||||
$this->assertTitle('Files (File) | Drupal');
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\Tests\views\Functional\ViewTestBase;
|
||||
|
||||
/**
|
||||
* Provides a base class for testing the Views UI.
|
||||
*/
|
||||
abstract class UITestBase extends ViewTestBase {
|
||||
|
||||
/**
|
||||
* An admin user with the 'administer views' permission.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
/**
|
||||
* An admin user with administrative permissions for views, blocks, and nodes.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $fullAdminUser;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['node', 'views_ui', 'block', 'taxonomy'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->enableViewsTestModule();
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views']);
|
||||
|
||||
$this->fullAdminUser = $this->drupalCreateUser(['administer views',
|
||||
'administer blocks',
|
||||
'bypass node access',
|
||||
'access user profiles',
|
||||
'view all revisions',
|
||||
'administer permissions',
|
||||
]);
|
||||
$this->drupalLogin($this->fullAdminUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper method which creates a random view.
|
||||
*/
|
||||
public function randomView(array $view = []) {
|
||||
// Create a new view in the UI.
|
||||
$default = [];
|
||||
$default['label'] = $this->randomMachineName(16);
|
||||
$default['id'] = strtolower($this->randomMachineName(16));
|
||||
$default['description'] = $this->randomMachineName(16);
|
||||
$default['page[create]'] = TRUE;
|
||||
$default['page[path]'] = $default['id'];
|
||||
|
||||
$view += $default;
|
||||
|
||||
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function drupalGet($path, array $options = [], array $headers = []) {
|
||||
$url = $this->buildUrl($path, $options);
|
||||
|
||||
// Ensure that each nojs page is accessible via ajax as well.
|
||||
if (strpos($url, '/nojs/') !== FALSE) {
|
||||
$url = preg_replace('|/nojs/|', '/ajax/', $url, 1);
|
||||
$result = $this->drupalGet($url, $options);
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
$this->assertEquals('application/json', $this->getSession()->getResponseHeader('Content-Type'));
|
||||
$this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.');
|
||||
}
|
||||
|
||||
return parent::drupalGet($path, $options, $headers);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,15 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
|
||||
use Drupal\views\Tests\ViewTestBase;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests covering Preview of unsaved Views.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class UnsavedPreviewTest extends ViewTestBase {
|
||||
class UnsavedPreviewTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
|
@ -33,7 +31,7 @@ class UnsavedPreviewTest extends ViewTestBase {
|
|||
/**
|
||||
* Sets up a Drupal site for running functional and integration tests.
|
||||
*/
|
||||
protected function setUp() {
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp(FALSE);
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(['administer views']);
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\views\Entity\View;
|
||||
|
@ -64,13 +64,24 @@ class ViewEditTest extends UITestBase {
|
|||
$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
|
||||
$this->drupalGet('admin/structure/views/ajax/handler/test_view/fake_display_name/filter/title');
|
||||
$this->assertText('Invalid display id fake_display_name');
|
||||
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');
|
||||
|
@ -107,6 +118,8 @@ class ViewEditTest extends UITestBase {
|
|||
* 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',
|
||||
|
@ -117,7 +130,7 @@ class ViewEditTest extends UITestBase {
|
|||
$this->assertResponse(200);
|
||||
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
|
||||
$this->assertNoLinkByHref($langcode_url);
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$this->assertNoLink(t('Content language of view row'));
|
||||
}
|
||||
|
||||
|
@ -134,12 +147,12 @@ class ViewEditTest extends UITestBase {
|
|||
$langcode_url = 'admin/structure/views/nojs/display/' . $view_name . '/' . $display . '/rendering_language';
|
||||
if ($view_name == 'test_view') {
|
||||
$this->assertNoLinkByHref($langcode_url);
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$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);
|
||||
$this->assertNoLink(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$assert_session->linkNotExistsExact(t('@type language selected for page', ['@type' => t('Content')]));
|
||||
$this->assertLink(t('Content language of view row'));
|
||||
}
|
||||
|
||||
|
@ -163,7 +176,7 @@ class ViewEditTest extends UITestBase {
|
|||
$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]->attributes()->{'value'}, $expected_elements[$i]);
|
||||
$this->assertEqual($elements[$i]->getAttribute('value'), $expected_elements[$i]);
|
||||
}
|
||||
|
||||
// Check that the selected values are respected even we they are not
|
||||
|
@ -215,7 +228,7 @@ class ViewEditTest extends UITestBase {
|
|||
$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]->attributes()->{'value'}, $expected_elements[$i]);
|
||||
$this->assertEqual($elements[$i]->getAttribute('value'), $expected_elements[$i]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -11,7 +10,7 @@ use Drupal\views\Views;
|
|||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class ViewsListTest extends WebTestBase {
|
||||
class ViewsListTest extends UITestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -30,8 +29,8 @@ class ViewsListTest extends WebTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('local_actions_block');
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\tour\Tests\TourTestBase;
|
||||
use Drupal\Tests\tour\Functional\TourTestBase;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
||||
/**
|
||||
|
@ -76,7 +76,7 @@ class ViewsUITourTest extends TourTestBase {
|
|||
foreach ($handler_titles as $handler_title) {
|
||||
// Create source string.
|
||||
$source = $this->localeStorage->createString([
|
||||
'source' => $handler_title
|
||||
'source' => $handler_title,
|
||||
]);
|
||||
$source->save();
|
||||
$this->createTranslation($source, $langcode);
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
use Drupal\views\Tests\Wizard\WizardTestBase;
|
||||
use Drupal\Tests\views\Functional\Wizard\WizardTestBase;
|
||||
|
||||
/**
|
||||
* Tests the wizard.
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_ui\Tests;
|
||||
namespace Drupal\Tests\views_ui\Functional;
|
||||
|
||||
/**
|
||||
* Tests the Xss vulnerability.
|
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
use Drupal\simpletest\NodeCreationTrait;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Tests the display UI.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class DisplayTest extends WebDriverTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = [
|
||||
'block',
|
||||
'contextual',
|
||||
'node',
|
||||
'views',
|
||||
'views_ui',
|
||||
'views_test_config',
|
||||
];
|
||||
|
||||
public static $testViews = ['test_content_ajax', 'test_display'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
ViewTestData::createTestViews(self::class, ['views_test_config']);
|
||||
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer site configuration',
|
||||
'administer views',
|
||||
'administer nodes',
|
||||
'access content overview',
|
||||
'access contextual links',
|
||||
]);
|
||||
|
||||
// Disable automatic live preview to make the sequence of calls clearer.
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests adding a display.
|
||||
*/
|
||||
public function testAddDisplay() {
|
||||
$this->drupalGet('admin/structure/views/view/test_content_ajax');
|
||||
$page = $this->getSession()->getPage();
|
||||
|
||||
$page->find('css', '#views-display-menu-tabs .add')->click();
|
||||
|
||||
// Wait for the animation to complete.
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
|
||||
// Add the display.
|
||||
$page->find('css', '#edit-displays-top-add-display-block')->click();
|
||||
|
||||
$element = $page->findById('views-display-menu-tabs')->findLink('Block');
|
||||
$this->assertNotEmpty($element);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests contextual links on Views page displays.
|
||||
*/
|
||||
public function testPageContextualLinks() {
|
||||
$view = View::load('test_display');
|
||||
$view->enable()->save();
|
||||
$this->container->get('router.builder')->rebuildIfNeeded();
|
||||
|
||||
// Create node so the view has content and the contextual area is higher
|
||||
// than 0 pixels.
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
$this->createNode();
|
||||
|
||||
// When no "main content" block is placed, we find a contextual link
|
||||
// placeholder for editing just the view.
|
||||
$this->drupalGet('test-display');
|
||||
$page = $this->getSession()->getPage();
|
||||
$this->assertSession()->assertWaitOnAjaxRequest();
|
||||
|
||||
$selector = '.view-test-display';
|
||||
$this->toggleContextualTriggerVisibility($selector);
|
||||
|
||||
$element = $this->getSession()->getPage()->find('css', $selector);
|
||||
$element->find('css', '.contextual button')->press();
|
||||
|
||||
$contextual_container_id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
|
||||
$contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
|
||||
$this->assertNotEmpty($contextual_container);
|
||||
|
||||
$edit_link = $contextual_container->findLink('Edit view');
|
||||
$this->assertNotEmpty($edit_link);
|
||||
|
||||
// When a "main content" is placed, we still find a contextual link
|
||||
// placeholder for editing just the view (not the main content block).
|
||||
// @see system_block_view_system_main_block_alter()
|
||||
$this->drupalPlaceBlock('system_main_block', ['id' => 'main_content']);
|
||||
$contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
|
||||
$this->assertNotEmpty($contextual_container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles the visibility of a contextual trigger.
|
||||
*
|
||||
* @param string $selector
|
||||
* The selector for the element that contains the contextual Rink.
|
||||
*/
|
||||
protected function toggleContextualTriggerVisibility($selector) {
|
||||
// Hovering over the element itself with should be enough, but does not
|
||||
// work. Manually remove the visually-hidden class.
|
||||
$this->getSession()->executeScript("jQuery('{$selector} .contextual .trigger').toggleClass('visually-hidden');");
|
||||
}
|
||||
|
||||
}
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the View UI filter criteria group dialog.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class FilterCriteriaTest extends JavascriptTestBase {
|
||||
class FilterCriteriaTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the JavaScript filtering of options in add handler form.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class FilterOptionsTest extends JavascriptTestBase {
|
||||
class FilterOptionsTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the JavaScript library caching on consecutive requests.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class LibraryCachingTest extends JavascriptTestBase {
|
||||
class LibraryCachingTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests the JavaScript filtering on the Views listing page.
|
||||
|
@ -10,7 +10,7 @@ use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
|||
* @see core/modules/views_ui/js/views_ui.listing.js
|
||||
* @group views_ui
|
||||
*/
|
||||
class ViewsListingTest extends JavascriptTestBase {
|
||||
class ViewsListingTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -92,6 +92,7 @@ class ViewsListingTest extends JavascriptTestBase {
|
|||
|
||||
// Disable a View and see if it moves to the disabled listing.
|
||||
$enabled_view = $page->find('css', 'tr.views-ui-list-enabled');
|
||||
$view_description = $enabled_view->find('css', '.views-ui-view-name h3')->getText();
|
||||
// Open the dropdown with additional actions.
|
||||
$enabled_view->find('css', 'li.dropbutton-toggle button')->click();
|
||||
$disable_button = $enabled_view->find('css', 'li.disable.dropbutton-action a');
|
||||
|
@ -109,6 +110,18 @@ class ViewsListingTest extends JavascriptTestBase {
|
|||
// Test that one enabled View has been moved to the disabled list.
|
||||
$this->assertCount($enabled_views_count - 1, $enabled_rows);
|
||||
$this->assertCount($disabled_views_count + 1, $disabled_rows);
|
||||
|
||||
// Test that the keyboard focus is on the dropdown button of the View we
|
||||
// just disabled.
|
||||
$this->assertTrue($this->getSession()->evaluateScript("jQuery(document.activeElement).parent().is('li.enable.dropbutton-action')"));
|
||||
$this->assertEquals($view_description, $this->getSession()->evaluateScript("jQuery(document.activeElement).parents('tr').find('h3').text()"));
|
||||
|
||||
// Enable the view again and ensure we have the focus on the edit button.
|
||||
$this->getSession()->evaluateScript('jQuery(document.activeElement).click()');
|
||||
$session->assertWaitOnAjaxRequest();
|
||||
|
||||
$this->assertTrue($this->getSession()->evaluateScript("jQuery(document.activeElement).parent().is('li.edit.dropbutton-action')"));
|
||||
$this->assertEquals($view_description, $this->getSession()->evaluateScript("jQuery(document.activeElement).parents('tr').find('h3').text()"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +131,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;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
|
||||
|
||||
/**
|
||||
* Tests views creation wizard.
|
||||
|
@ -10,7 +10,7 @@ use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
|||
* @see core/modules/views_ui/js/views-admin.js
|
||||
* @group views_ui
|
||||
*/
|
||||
class ViewsWizardTest extends JavascriptTestBase {
|
||||
class ViewsWizardTest extends WebDriverTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -52,7 +52,6 @@ class TagTest extends ViewsKernelTestBase {
|
|||
$this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
|
||||
}
|
||||
|
||||
|
||||
// Make sure that matching by a certain prefix works.
|
||||
$request->query->set('q', 'autocomplete_tag_test_even');
|
||||
$result = $controller->autocompleteTag($request);
|
||||
|
|
|
@ -48,7 +48,7 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
'theme' => 'views_view',
|
||||
'no_ui' => TRUE,
|
||||
'admin' => '',
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'page',
|
||||
|
@ -61,7 +61,7 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
'contextual_links_locations' => ['page'],
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Page admin label',
|
||||
]
|
||||
],
|
||||
],
|
||||
[
|
||||
'embed',
|
||||
|
@ -71,11 +71,10 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
'title' => 'embed',
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Embed admin label',
|
||||
]
|
||||
],
|
||||
],
|
||||
]));
|
||||
|
||||
|
||||
$default_display = $this->getMock('Drupal\views\Plugin\views\display\DefaultDisplay',
|
||||
['initDisplay'],
|
||||
[[], 'default', $display_manager->getDefinition('default')]
|
||||
|
|
|
@ -6,4 +6,4 @@ version: VERSION
|
|||
core: 8.x
|
||||
configure: entity.view.collection
|
||||
dependencies:
|
||||
- views
|
||||
- drupal:views
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
* Provide structure for the administrative interface to Views.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\views\ViewExecutable;
|
||||
|
@ -135,7 +134,7 @@ function views_ui_preprocess_views_view(&$variables) {
|
|||
// Render title for the admin preview.
|
||||
if (!empty($view->live_preview)) {
|
||||
$variables['title'] = [
|
||||
'#markup' => $view->getTitle()
|
||||
'#markup' => $view->getTitle(),
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -156,6 +155,13 @@ function views_ui_preprocess_views_view(&$variables) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK().
|
||||
*/
|
||||
function views_ui_theme_suggestions_views_ui_view_preview_section(array $variables) {
|
||||
return ['views_ui_view_preview_section__' . $variables['section']];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns contextual links for each handler of a certain section.
|
||||
*
|
||||
|
@ -334,8 +340,8 @@ function views_ui_views_analyze(ViewExecutable $view) {
|
|||
* This is often used in the UI to ensure long strings fit.
|
||||
*/
|
||||
function views_ui_truncate($string, $length) {
|
||||
if (Unicode::strlen($string) > $length) {
|
||||
$string = Unicode::substr($string, 0, $length);
|
||||
if (mb_strlen($string) > $length) {
|
||||
$string = mb_substr($string, 0, $length);
|
||||
$string .= '...';
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
services:
|
||||
paramconverter.views_ui:
|
||||
class: Drupal\views_ui\ParamConverter\ViewUIConverter
|
||||
arguments: ['@entity.manager', '@user.shared_tempstore', '@config.factory', '@router.admin_context']
|
||||
arguments: ['@entity.manager', '@tempstore.shared', '@config.factory', '@router.admin_context']
|
||||
tags:
|
||||
- { name: paramconverter, priority: 10 }
|
||||
lazy: true
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* Preprocessors and theme functions for the Views UI.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Render\Element\Checkboxes;
|
||||
|
@ -158,7 +158,7 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
'title' => t('Remove this item'),
|
||||
],
|
||||
]),
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
'#title' => new FormattableMarkup('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
];
|
||||
$remove = [$form['group_items'][$group_id]['remove'], $link];
|
||||
$data = [
|
||||
|
@ -184,7 +184,7 @@ function template_preprocess_views_ui_build_group_filter_form(&$variables) {
|
|||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -286,7 +286,7 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
$remove_link = [
|
||||
'#type' => 'link',
|
||||
'#url' => Url::fromRoute('<none>'),
|
||||
'#title' => SafeMarkup::format('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
'#title' => new FormattableMarkup('<span>@text</span>', ['@text' => t('Remove')]),
|
||||
'#weight' => '1',
|
||||
'#options' => [
|
||||
'attributes' => [
|
||||
|
@ -353,7 +353,7 @@ function template_preprocess_views_ui_rearrange_filter_form(&$variables) {
|
|||
'action' => 'order',
|
||||
'relationship' => 'sibling',
|
||||
'group' => 'weight',
|
||||
]
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -547,10 +547,3 @@ function template_preprocess_views_ui_view_preview_section(&$variables) {
|
|||
$variables['links'] = $build;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK().
|
||||
*/
|
||||
function views_ui_theme_suggestions_views_ui_view_preview_section(array $variables) {
|
||||
return ['views_ui_view_preview_section__' . $variables['section']];
|
||||
}
|
||||
|
|
Reference in a new issue