updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -48,7 +48,7 @@
|
||||
font-size: 1em;
|
||||
}
|
||||
.quickedit .icon-pencil {
|
||||
margin-left: .5em;
|
||||
margin-left: 0.5em;
|
||||
padding-left: 1.5em;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
}
|
||||
.quickedit-editing.quickedit-validation-error,
|
||||
.quickedit-form.quickedit-validation-error {
|
||||
box-shadow: 0 0 0px 1px #ee8b74, 0 0 0 2px #fa2209;
|
||||
box-shadow: 0 0 0 1px #ee8b74, 0 0 0 2px #fa2209;
|
||||
}
|
||||
.quickedit-editing.quickedit-editor-is-popup {
|
||||
box-shadow: none;
|
||||
@@ -45,7 +45,7 @@
|
||||
margin: 0;
|
||||
}
|
||||
.quickedit-form .form-wrapper {
|
||||
margin: .5em;
|
||||
margin: 0.5em;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,35 +55,35 @@
|
||||
opacity: 0;
|
||||
}
|
||||
.quickedit-animate-default {
|
||||
-webkit-transition: all .4s ease;
|
||||
transition: all .4s ease;
|
||||
-webkit-transition: all 0.4s ease;
|
||||
transition: all 0.4s ease;
|
||||
}
|
||||
.quickedit-animate-slow {
|
||||
-webkit-transition: all .6s ease;
|
||||
transition: all .6s ease;
|
||||
-webkit-transition: all 0.6s ease;
|
||||
transition: all 0.6s ease;
|
||||
}
|
||||
.quickedit-animate-delay-veryfast {
|
||||
-webkit-transition-delay: .05s;
|
||||
transition-delay: .05s;
|
||||
-webkit-transition-delay: 0.05s;
|
||||
transition-delay: 0.05s;
|
||||
}
|
||||
.quickedit-animate-delay-fast {
|
||||
-webkit-transition-delay: .2s;
|
||||
transition-delay: .2s;
|
||||
-webkit-transition-delay: 0.2s;
|
||||
transition-delay: 0.2s;
|
||||
}
|
||||
.quickedit-animate-disable-width {
|
||||
-webkit-transition: width 0s;
|
||||
transition: width 0s;
|
||||
}
|
||||
.quickedit-animate-only-visibility {
|
||||
-webkit-transition: opacity .2s ease;
|
||||
transition: opacity .2s ease;
|
||||
-webkit-transition: opacity 0.2s ease;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
/**
|
||||
* In-place editors that don't use a popup.
|
||||
*/
|
||||
.quickedit-validation-errors .messages.error {
|
||||
box-shadow: 0 0 1px 1px red, 0 0 3px 3px rgba(153, 153, 153, .5);
|
||||
box-shadow: 0 0 1px 1px red, 0 0 3px 3px rgba(153, 153, 153, 0.5);
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@
|
||||
}
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-content {
|
||||
background-image: -webkit-linear-gradient(top, #fff, #e4e4e4);
|
||||
background-image: linear-gradient(to bottom, #fff, #e4e4e4);
|
||||
background-image: linear-gradient(to bottom, #fff, #e4e4e4);
|
||||
box-sizing: border-box;
|
||||
color: black;
|
||||
padding: 0.1667em;
|
||||
@@ -121,7 +121,7 @@
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-pointer {
|
||||
background-color: #e4e4e4;
|
||||
bottom: 2px;
|
||||
box-shadow: 0 0 0 1px #818181, 0px 0px 0 4px rgba(150, 150, 150, 0.5);
|
||||
box-shadow: 0 0 0 1px #818181, 0 0 0 4px rgba(150, 150, 150, 0.5);
|
||||
display: block;
|
||||
height: 16px;
|
||||
left: 18px; /* LTR */
|
||||
@@ -142,7 +142,7 @@
|
||||
}
|
||||
.quickedit-toolbar-container > .quickedit-toolbar-lining {
|
||||
bottom: 7px;
|
||||
box-shadow: 0 0 0 1px #818181, 0px 3px 0px 1px rgba(150, 150, 150, 0.5);
|
||||
box-shadow: 0 0 0 1px #818181, 0 3px 0 1px rgba(150, 150, 150, 0.5);
|
||||
display: block;
|
||||
left: 0;
|
||||
position: absolute;
|
||||
@@ -208,8 +208,8 @@
|
||||
margin: 0;
|
||||
opacity: 1;
|
||||
padding: 0.345em;
|
||||
-webkit-transition: opacity .1s ease;
|
||||
transition: opacity .1s ease;
|
||||
-webkit-transition: opacity 0.1s ease;
|
||||
transition: opacity 0.1s ease;
|
||||
}
|
||||
.quickedit-button[aria-hidden="true"] {
|
||||
visibility: hidden;
|
||||
@@ -237,7 +237,7 @@
|
||||
color: white;
|
||||
background-color: #50a0e9;
|
||||
background-image: -webkit-linear-gradient(top, #50a0e9, #4481dc);
|
||||
background-image: linear-gradient(to bottom, #50a0e9, #4481dc);
|
||||
background-image: linear-gradient(to bottom, #50a0e9, #4481dc);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.quickedit-button.action-save:hover,
|
||||
|
||||
@@ -92,13 +92,14 @@
|
||||
const fieldModel = this.fieldModel;
|
||||
|
||||
// Generate a DOM-compatible ID for the form container DOM element.
|
||||
const id = `quickedit-form-for-${fieldModel.id.replace(/[\/\[\]]/g, '_')}`;
|
||||
const id = `quickedit-form-for-${fieldModel.id.replace(/[/[\]]/g, '_')}`;
|
||||
|
||||
// Render form container.
|
||||
const $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
|
||||
const $formContainer = $(Drupal.theme('quickeditFormContainer', {
|
||||
id,
|
||||
loadingMsg: Drupal.t('Loading…'),
|
||||
}));
|
||||
this.$formContainer = $formContainer;
|
||||
$formContainer
|
||||
.find('.quickedit-form')
|
||||
.addClass('quickedit-editable quickedit-highlighted quickedit-editing')
|
||||
@@ -194,7 +195,7 @@
|
||||
}
|
||||
|
||||
// Create an AJAX object for the form associated with the field.
|
||||
var formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving({
|
||||
let formSaveAjax = Drupal.quickedit.util.form.ajaxifySaving({
|
||||
nocssjs: false,
|
||||
other_view_modes: fieldModel.findOtherViewModes(),
|
||||
}, $submit);
|
||||
|
||||
@@ -57,12 +57,13 @@
|
||||
loadForm: function loadForm() {
|
||||
var fieldModel = this.fieldModel;
|
||||
|
||||
var id = 'quickedit-form-for-' + fieldModel.id.replace(/[\/\[\]]/g, '_');
|
||||
var id = 'quickedit-form-for-' + fieldModel.id.replace(/[/[\]]/g, '_');
|
||||
|
||||
var $formContainer = this.$formContainer = $(Drupal.theme('quickeditFormContainer', {
|
||||
var $formContainer = $(Drupal.theme('quickeditFormContainer', {
|
||||
id: id,
|
||||
loadingMsg: Drupal.t('Loading…')
|
||||
}));
|
||||
this.$formContainer = $formContainer;
|
||||
$formContainer.find('.quickedit-form').addClass('quickedit-editable quickedit-highlighted quickedit-editing').attr('role', 'dialog');
|
||||
|
||||
if (this.$el.css('display') === 'inline') {
|
||||
|
||||
@@ -27,14 +27,9 @@
|
||||
|
||||
// Store the original value of this field. Necessary for reverting
|
||||
// changes.
|
||||
let $textElement;
|
||||
const $fieldItems = this.$el.find('.quickedit-field');
|
||||
if ($fieldItems.length) {
|
||||
$textElement = this.$textElement = $fieldItems.eq(0);
|
||||
}
|
||||
else {
|
||||
$textElement = this.$textElement = this.$el;
|
||||
}
|
||||
const $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
|
||||
this.$textElement = $textElement;
|
||||
editorModel.set('originalValue', $.trim(this.$textElement.text()));
|
||||
|
||||
// Sets the state to 'changed' whenever the value changes.
|
||||
|
||||
@@ -15,13 +15,9 @@
|
||||
var editorModel = this.model;
|
||||
var fieldModel = this.fieldModel;
|
||||
|
||||
var $textElement = void 0;
|
||||
var $fieldItems = this.$el.find('.quickedit-field');
|
||||
if ($fieldItems.length) {
|
||||
$textElement = this.$textElement = $fieldItems.eq(0);
|
||||
} else {
|
||||
$textElement = this.$textElement = this.$el;
|
||||
}
|
||||
var $textElement = $fieldItems.length ? $fieldItems.eq(0) : this.$el;
|
||||
this.$textElement = $textElement;
|
||||
editorModel.set('originalValue', $.trim(this.$textElement.text()));
|
||||
|
||||
var previousText = editorModel.get('originalValue');
|
||||
|
||||
@@ -189,9 +189,9 @@
|
||||
this.set('isActive', true);
|
||||
break;
|
||||
|
||||
case 'committing':
|
||||
case 'committing': {
|
||||
// The user indicated they want to save the entity.
|
||||
var fields = this.get('fields');
|
||||
const fields = this.get('fields');
|
||||
// For fields that are in an active state, transition them to
|
||||
// candidate.
|
||||
fields.chain()
|
||||
@@ -207,9 +207,10 @@
|
||||
fieldModel.set('state', 'saving');
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'deactivating':
|
||||
var changedFields = this.get('fields')
|
||||
case 'deactivating': {
|
||||
const changedFields = this.get('fields')
|
||||
.filter(fieldModel => _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length);
|
||||
// If the entity contains unconfirmed or unsaved changes, return the
|
||||
// entity to an opened state and ask the user if they would like to
|
||||
@@ -250,6 +251,7 @@
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'closing':
|
||||
// Set all fields to the 'inactive' state.
|
||||
@@ -364,7 +366,7 @@
|
||||
}
|
||||
break;
|
||||
|
||||
case 'committing':
|
||||
case 'committing': {
|
||||
// If the field save returned a validation error, set the state of the
|
||||
// entity back to 'opened'.
|
||||
if (fieldState === 'invalid') {
|
||||
@@ -380,7 +382,7 @@
|
||||
|
||||
// Attempt to save the entity. If the entity's fields are not yet all
|
||||
// in a ready state, the save will not be processed.
|
||||
var options = {
|
||||
const options = {
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates,
|
||||
};
|
||||
if (entityModel.set('isCommitting', true, options)) {
|
||||
@@ -404,6 +406,7 @@
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'deactivating':
|
||||
// When setting the entity to 'closing', require that all fieldModels
|
||||
|
||||
@@ -69,48 +69,52 @@
|
||||
break;
|
||||
|
||||
case 'committing':
|
||||
var fields = this.get('fields');
|
||||
{
|
||||
var fields = this.get('fields');
|
||||
|
||||
fields.chain().filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['active']).length;
|
||||
}).each(function (fieldModel) {
|
||||
fieldModel.set('state', 'candidate');
|
||||
});
|
||||
fields.chain().filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['active']).length;
|
||||
}).each(function (fieldModel) {
|
||||
fieldModel.set('state', 'candidate');
|
||||
});
|
||||
|
||||
fields.chain().filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length;
|
||||
}).each(function (fieldModel) {
|
||||
fieldModel.set('state', 'saving');
|
||||
});
|
||||
break;
|
||||
fields.chain().filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], Drupal.quickedit.app.changedFieldStates).length;
|
||||
}).each(function (fieldModel) {
|
||||
fieldModel.set('state', 'saving');
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'deactivating':
|
||||
var changedFields = this.get('fields').filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length;
|
||||
});
|
||||
|
||||
if ((changedFields.length || this.get('fieldsInTempStore').length) && !options.saved && !options.confirmed) {
|
||||
this.set('state', 'opened', { confirming: true });
|
||||
|
||||
_.defer(function () {
|
||||
Drupal.quickedit.app.confirmEntityDeactivation(entityModel);
|
||||
});
|
||||
} else {
|
||||
var invalidFields = this.get('fields').filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['invalid']).length;
|
||||
{
|
||||
var changedFields = this.get('fields').filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['changed', 'invalid']).length;
|
||||
});
|
||||
|
||||
entityModel.set('reload', this.get('fieldsInTempStore').length || invalidFields.length);
|
||||
if ((changedFields.length || this.get('fieldsInTempStore').length) && !options.saved && !options.confirmed) {
|
||||
this.set('state', 'opened', { confirming: true });
|
||||
|
||||
entityModel.get('fields').each(function (fieldModel) {
|
||||
if (_.intersection([fieldModel.get('state')], ['candidate', 'highlighted']).length) {
|
||||
fieldModel.trigger('change:state', fieldModel, fieldModel.get('state'), options);
|
||||
} else {
|
||||
fieldModel.set('state', 'candidate', options);
|
||||
}
|
||||
});
|
||||
_.defer(function () {
|
||||
Drupal.quickedit.app.confirmEntityDeactivation(entityModel);
|
||||
});
|
||||
} else {
|
||||
var invalidFields = this.get('fields').filter(function (fieldModel) {
|
||||
return _.intersection([fieldModel.get('state')], ['invalid']).length;
|
||||
});
|
||||
|
||||
entityModel.set('reload', this.get('fieldsInTempStore').length || invalidFields.length);
|
||||
|
||||
entityModel.get('fields').each(function (fieldModel) {
|
||||
if (_.intersection([fieldModel.get('state')], ['candidate', 'highlighted']).length) {
|
||||
fieldModel.trigger('change:state', fieldModel, fieldModel.get('state'), options);
|
||||
} else {
|
||||
fieldModel.set('state', 'candidate', options);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'closing':
|
||||
options.reason = 'stop';
|
||||
@@ -166,37 +170,39 @@
|
||||
break;
|
||||
|
||||
case 'committing':
|
||||
if (fieldState === 'invalid') {
|
||||
_.defer(function () {
|
||||
entityModel.set('state', 'opened', { reason: 'invalid' });
|
||||
});
|
||||
} else {
|
||||
this._updateInTempStoreAttributes(entityModel, fieldModel);
|
||||
{
|
||||
if (fieldState === 'invalid') {
|
||||
_.defer(function () {
|
||||
entityModel.set('state', 'opened', { reason: 'invalid' });
|
||||
});
|
||||
} else {
|
||||
this._updateInTempStoreAttributes(entityModel, fieldModel);
|
||||
}
|
||||
|
||||
var options = {
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates
|
||||
};
|
||||
if (entityModel.set('isCommitting', true, options)) {
|
||||
entityModel.save({
|
||||
success: function success() {
|
||||
entityModel.set({
|
||||
state: 'deactivating',
|
||||
isCommitting: false
|
||||
}, { saved: true });
|
||||
},
|
||||
error: function error() {
|
||||
entityModel.set('isCommitting', false);
|
||||
|
||||
entityModel.set('state', 'opened', { reason: 'networkerror' });
|
||||
|
||||
var message = Drupal.t('Your changes to <q>@entity-title</q> could not be saved, either due to a website problem or a network connection problem.<br>Please try again.', { '@entity-title': entityModel.get('label') });
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var options = {
|
||||
'accept-field-states': Drupal.quickedit.app.readyFieldStates
|
||||
};
|
||||
if (entityModel.set('isCommitting', true, options)) {
|
||||
entityModel.save({
|
||||
success: function success() {
|
||||
entityModel.set({
|
||||
state: 'deactivating',
|
||||
isCommitting: false
|
||||
}, { saved: true });
|
||||
},
|
||||
error: function error() {
|
||||
entityModel.set('isCommitting', false);
|
||||
|
||||
entityModel.set('state', 'opened', { reason: 'networkerror' });
|
||||
|
||||
var message = Drupal.t('Your changes to <q>@entity-title</q> could not be saved, either due to a website problem or a network connection problem.<br>Please try again.', { '@entity-title': entityModel.get('label') });
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deactivating':
|
||||
_.defer(function () {
|
||||
entityModel.set('state', 'closing', {
|
||||
|
||||
@@ -218,15 +218,8 @@
|
||||
// different view mode).
|
||||
.where({ logicalFieldID: currentField.get('logicalFieldID') })
|
||||
.forEach((field) => {
|
||||
// Ignore the current field.
|
||||
if (field === currentField) {
|
||||
|
||||
}
|
||||
// Also ignore other fields with the same view mode.
|
||||
else if (field.get('fieldID') === currentField.get('fieldID')) {
|
||||
|
||||
}
|
||||
else {
|
||||
// Ignore the current field and other fields with the same view mode.
|
||||
if (field !== currentField && field.get('fieldID') !== currentField.get('fieldID')) {
|
||||
otherViewModes.push(field.getViewMode());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -72,9 +72,9 @@
|
||||
var currentField = this;
|
||||
var otherViewModes = [];
|
||||
Drupal.quickedit.collections.fields.where({ logicalFieldID: currentField.get('logicalFieldID') }).forEach(function (field) {
|
||||
if (field === currentField) {} else if (field.get('fieldID') === currentField.get('fieldID')) {} else {
|
||||
otherViewModes.push(field.getViewMode());
|
||||
}
|
||||
if (field !== currentField && field.get('fieldID') !== currentField.get('fieldID')) {
|
||||
otherViewModes.push(field.getViewMode());
|
||||
}
|
||||
});
|
||||
return otherViewModes;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@
|
||||
// If there are no elements returned from `entityElementSelector`
|
||||
// throw an error. Check the browser console for this message.
|
||||
if (!$entityElement.length) {
|
||||
throw `Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="${fieldID}"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="${entityID}"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes.`;
|
||||
throw new Error(`Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="${fieldID}"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="${entityID}"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes.`);
|
||||
}
|
||||
let entityElement = $(fieldElement).closest($entityElement);
|
||||
|
||||
|
||||
@@ -162,7 +162,7 @@
|
||||
var $entityElement = $(entityElementSelector);
|
||||
|
||||
if (!$entityElement.length) {
|
||||
throw 'Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="' + fieldID + '"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="' + entityID + '"]. This is typically caused by the theme\'s template for this entity type forgetting to print the attributes.';
|
||||
throw new Error('Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id="' + fieldID + '"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id="' + entityID + '"]. This is typically caused by the theme\'s template for this entity type forgetting to print the attributes.');
|
||||
}
|
||||
var entityElement = $(fieldElement).closest($entityElement);
|
||||
|
||||
|
||||
@@ -144,14 +144,10 @@
|
||||
// Attributes.
|
||||
const attributes = [];
|
||||
const attrMap = settings.buttons[i].attributes || {};
|
||||
for (const attr in attrMap) {
|
||||
if (attrMap.hasOwnProperty(attr)) {
|
||||
attributes.push(attr + ((attrMap[attr]) ? `="${attrMap[attr]}"` : ''));
|
||||
}
|
||||
}
|
||||
html += `<button type="${button.type}" class="${button.classes}"` + ` ${attributes.join(' ')}>`;
|
||||
html += button.label;
|
||||
html += '</button>';
|
||||
Object.keys(attrMap).forEach((attr) => {
|
||||
attributes.push(attr + ((attrMap[attr]) ? `="${attrMap[attr]}"` : ''));
|
||||
});
|
||||
html += `<button type="${button.type}" class="${button.classes}" ${attributes.join(' ')}>${button.label}</button>`;
|
||||
}
|
||||
return html;
|
||||
};
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
|
||||
Drupal.theme.quickeditButtons = function (settings) {
|
||||
var html = '';
|
||||
for (var i = 0; i < settings.buttons.length; i++) {
|
||||
|
||||
var _loop = function _loop(i) {
|
||||
var button = settings.buttons[i];
|
||||
if (!button.hasOwnProperty('type')) {
|
||||
button.type = 'button';
|
||||
@@ -61,14 +62,14 @@
|
||||
|
||||
var attributes = [];
|
||||
var attrMap = settings.buttons[i].attributes || {};
|
||||
for (var attr in attrMap) {
|
||||
if (attrMap.hasOwnProperty(attr)) {
|
||||
attributes.push(attr + (attrMap[attr] ? '="' + attrMap[attr] + '"' : ''));
|
||||
}
|
||||
}
|
||||
html += '<button type="' + button.type + '" class="' + button.classes + '"' + (' ' + attributes.join(' ') + '>');
|
||||
html += button.label;
|
||||
html += '</button>';
|
||||
Object.keys(attrMap).forEach(function (attr) {
|
||||
attributes.push(attr + (attrMap[attr] ? '="' + attrMap[attr] + '"' : ''));
|
||||
});
|
||||
html += '<button type="' + button.type + '" class="' + button.classes + '" ' + attributes.join(' ') + '>' + button.label + '</button>';
|
||||
};
|
||||
|
||||
for (var i = 0; i < settings.buttons.length; i++) {
|
||||
_loop(i);
|
||||
}
|
||||
return html;
|
||||
};
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
*/
|
||||
Drupal.quickedit.util.networkErrorModal = function (title, message) {
|
||||
const $message = $(`<div>${message}</div>`);
|
||||
var networkErrorModal = Drupal.dialog($message.get(0), {
|
||||
const networkErrorModal = Drupal.dialog($message.get(0), {
|
||||
title,
|
||||
dialogClass: 'quickedit-network-error',
|
||||
buttons: [
|
||||
@@ -181,11 +181,11 @@
|
||||
* The HTTP status code.
|
||||
*/
|
||||
success(response, status) {
|
||||
for (const i in response) {
|
||||
if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) {
|
||||
Object.keys(response || {}).forEach((i) => {
|
||||
if (response[i].command && this.commands[response[i].command]) {
|
||||
this.commands[response[i].command](this, response[i], status);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
base: $submit.attr('id'),
|
||||
element: $submit[0],
|
||||
|
||||
@@ -85,11 +85,13 @@
|
||||
},
|
||||
|
||||
success: function success(response, status) {
|
||||
for (var i in response) {
|
||||
if (response.hasOwnProperty(i) && response[i].command && this.commands[response[i].command]) {
|
||||
this.commands[response[i].command](this, response[i], status);
|
||||
var _this = this;
|
||||
|
||||
Object.keys(response || {}).forEach(function (i) {
|
||||
if (response[i].command && _this.commands[response[i].command]) {
|
||||
_this.commands[response[i].command](_this, response[i], status);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
base: $submit.attr('id'),
|
||||
|
||||
@@ -231,11 +231,9 @@
|
||||
if (context && context.reason === 'mouseleave') {
|
||||
accept = false;
|
||||
}
|
||||
else {
|
||||
// Check whether the transition has been confirmed?
|
||||
if (context && context.confirmed) {
|
||||
accept = true;
|
||||
}
|
||||
// Check whether the transition has been confirmed?
|
||||
else if (context && context.confirmed) {
|
||||
accept = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,11 +121,9 @@
|
||||
} else if ((from === 'changed' || from === 'invalid') && to === 'candidate') {
|
||||
if (context && context.reason === 'mouseleave') {
|
||||
accept = false;
|
||||
} else {
|
||||
if (context && context.confirmed) {
|
||||
} else if (context && context.confirmed) {
|
||||
accept = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,13 +118,13 @@
|
||||
// visible yet.
|
||||
break;
|
||||
|
||||
case 'activating':
|
||||
case 'activating': {
|
||||
// The user has indicated he wants to do in-place editing: if
|
||||
// something needs to be loaded (CSS/JavaScript/server data/…), then
|
||||
// do so at this stage, and once the in-place editor is ready,
|
||||
// set the 'active' state. A "loading" indicator will be shown in the
|
||||
// UI for as long as the field remains in this state.
|
||||
var loadDependencies = function (callback) {
|
||||
const loadDependencies = function (callback) {
|
||||
// Do the loading here.
|
||||
callback();
|
||||
};
|
||||
@@ -132,6 +132,7 @@
|
||||
fieldModel.set('state', 'active');
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'active':
|
||||
// The user can now actually use the in-place editor.
|
||||
@@ -184,7 +185,7 @@
|
||||
save() {
|
||||
const fieldModel = this.fieldModel;
|
||||
const editorModel = this.model;
|
||||
const backstageId = `quickedit_backstage-${this.fieldModel.id.replace(/[\/\[\]\_\s]/g, '-')}`;
|
||||
const backstageId = `quickedit_backstage-${this.fieldModel.id.replace(/[/[\]_\s]/g, '-')}`;
|
||||
|
||||
function fillAndSubmitForm(value) {
|
||||
const $form = $(`#${backstageId}`).find('form');
|
||||
|
||||
@@ -38,13 +38,15 @@
|
||||
break;
|
||||
|
||||
case 'activating':
|
||||
var loadDependencies = function loadDependencies(callback) {
|
||||
callback();
|
||||
};
|
||||
loadDependencies(function () {
|
||||
fieldModel.set('state', 'active');
|
||||
});
|
||||
break;
|
||||
{
|
||||
var loadDependencies = function loadDependencies(callback) {
|
||||
callback();
|
||||
};
|
||||
loadDependencies(function () {
|
||||
fieldModel.set('state', 'active');
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'active':
|
||||
break;
|
||||
@@ -71,7 +73,7 @@
|
||||
save: function save() {
|
||||
var fieldModel = this.fieldModel;
|
||||
var editorModel = this.model;
|
||||
var backstageId = 'quickedit_backstage-' + this.fieldModel.id.replace(/[\/\[\]\_\s]/g, '-');
|
||||
var backstageId = 'quickedit_backstage-' + this.fieldModel.id.replace(/[/[\]_\s]/g, '-');
|
||||
|
||||
function fillAndSubmitForm(value) {
|
||||
var $form = $('#' + backstageId).find('form');
|
||||
|
||||
@@ -230,10 +230,10 @@
|
||||
delay = 250;
|
||||
break;
|
||||
|
||||
default:
|
||||
var fieldModels = this.model.get('fields').models;
|
||||
var topMostPosition = 1000000;
|
||||
var topMostField = null;
|
||||
default: {
|
||||
const fieldModels = this.model.get('fields').models;
|
||||
let topMostPosition = 1000000;
|
||||
let topMostField = null;
|
||||
// Position against the topmost field.
|
||||
for (let i = 0; i < fieldModels.length; i++) {
|
||||
const pos = fieldModels[i].get('el').getBoundingClientRect().top;
|
||||
@@ -245,6 +245,7 @@
|
||||
of = topMostField.get('el');
|
||||
delay = 50;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Prepare to check the next possible element to position against.
|
||||
check++;
|
||||
@@ -295,7 +296,7 @@
|
||||
suggested.top = fenceTop;
|
||||
}
|
||||
else if ((suggested.top + toolbarHeight) > (fenceTop + fenceHeight)) {
|
||||
suggested.top = fenceTop + fenceHeight - toolbarHeight;
|
||||
suggested.top = (fenceTop + fenceHeight) - toolbarHeight;
|
||||
}
|
||||
// Position the toolbar.
|
||||
info.element.element.css({
|
||||
|
||||
@@ -142,20 +142,22 @@
|
||||
break;
|
||||
|
||||
default:
|
||||
var fieldModels = this.model.get('fields').models;
|
||||
var topMostPosition = 1000000;
|
||||
var topMostField = null;
|
||||
{
|
||||
var fieldModels = this.model.get('fields').models;
|
||||
var topMostPosition = 1000000;
|
||||
var topMostField = null;
|
||||
|
||||
for (var i = 0; i < fieldModels.length; i++) {
|
||||
var pos = fieldModels[i].get('el').getBoundingClientRect().top;
|
||||
if (pos < topMostPosition) {
|
||||
topMostPosition = pos;
|
||||
topMostField = fieldModels[i];
|
||||
for (var i = 0; i < fieldModels.length; i++) {
|
||||
var pos = fieldModels[i].get('el').getBoundingClientRect().top;
|
||||
if (pos < topMostPosition) {
|
||||
topMostPosition = pos;
|
||||
topMostField = fieldModels[i];
|
||||
}
|
||||
}
|
||||
of = topMostField.get('el');
|
||||
delay = 50;
|
||||
break;
|
||||
}
|
||||
of = topMostField.get('el');
|
||||
delay = 50;
|
||||
break;
|
||||
}
|
||||
|
||||
check++;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
this.$root = this.$el;
|
||||
|
||||
// Generate a DOM-compatible ID for the form container DOM element.
|
||||
this._id = `quickedit-toolbar-for-${this.model.id.replace(/[\/\[\]]/g, '_')}`;
|
||||
this._id = `quickedit-toolbar-for-${this.model.id.replace(/[/[\]]/g, '_')}`;
|
||||
|
||||
this.listenTo(this.model, 'change:state', this.stateChange);
|
||||
},
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
this.$root = this.$el;
|
||||
|
||||
this._id = 'quickedit-toolbar-for-' + this.model.id.replace(/[\/\[\]]/g, '_');
|
||||
this._id = 'quickedit-toolbar-for-' + this.model.id.replace(/[/[\]]/g, '_');
|
||||
|
||||
this.listenTo(this.model, 'change:state', this.stateChange);
|
||||
},
|
||||
|
||||
@@ -9,8 +9,8 @@ dependencies:
|
||||
- field
|
||||
- filter
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457825
|
||||
|
||||
@@ -130,10 +130,10 @@ function quickedit_preprocess_page_title(&$variables) {
|
||||
function quickedit_preprocess_field(&$variables) {
|
||||
$variables['#cache']['contexts'][] = 'user.permissions';
|
||||
$element = $variables['element'];
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$entity = $element['#object'];
|
||||
|
||||
if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) {
|
||||
if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !$entity->isLatestRevision()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,8 +157,9 @@ function quickedit_preprocess_field(&$variables) {
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$build['#cache']['contexts'][] = 'user.permissions';
|
||||
if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) {
|
||||
if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !$entity->isLatestRevision()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -174,22 +175,14 @@ function quickedit_entity_view_alter(&$build, EntityInterface $entity, EntityVie
|
||||
* @return bool
|
||||
* TRUE if the loaded entity is the latest revision, FALSE otherwise.
|
||||
*
|
||||
* @todo Remove this method once better support for pending revisions is added
|
||||
* to core https://www.drupal.org/node/2784201.
|
||||
* @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use
|
||||
* \Drupal\Core\Entity\RevisionableInterface::isLatestRevision() instead.
|
||||
* As internal API, _quickedit_entity_is_latest_revision() may also be removed
|
||||
* in a minor release.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
function _quickedit_entity_is_latest_revision(ContentEntityInterface $entity) {
|
||||
if (!$entity->getEntityType()->isRevisionable() || $entity->isNew()) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$latest_revision = \Drupal::entityTypeManager()
|
||||
->getStorage($entity->getEntityTypeId())
|
||||
->getQuery()
|
||||
->latestRevision()
|
||||
->condition($entity->getEntityType()->getKey('id'), $entity->id())
|
||||
->execute();
|
||||
|
||||
return !empty($latest_revision) && $entity->getLoadedRevisionId() == key($latest_revision) ? TRUE : FALSE;
|
||||
@trigger_error('_quickedit_entity_is_latest_revision() is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use \Drupal\Core\Entity\RevisionableInterface::isLatestRevision() instead. As internal API, _quickedit_entity_is_latest_revision() may also be removed in a minor release.', E_USER_DEPRECATED);
|
||||
return $entity->isLatestRevision();
|
||||
}
|
||||
|
||||
@@ -10,19 +10,21 @@ use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Drupal\Core\Entity\Entity\EntityFormDisplay;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
|
||||
/**
|
||||
* Builds and process a form for editing a single entity field.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class QuickEditFieldForm extends FormBase {
|
||||
|
||||
/**
|
||||
* Stores the tempstore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
@@ -50,7 +52,7 @@ class QuickEditFieldForm extends FormBase {
|
||||
/**
|
||||
* Constructs a new EditFieldForm.
|
||||
*
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The tempstore factory.
|
||||
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
|
||||
* The module handler.
|
||||
@@ -71,7 +73,7 @@ class QuickEditFieldForm extends FormBase {
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.private_tempstore'),
|
||||
$container->get('tempstore.private'),
|
||||
$container->get('module_handler'),
|
||||
$container->get('entity.manager')->getStorage('node_type'),
|
||||
$container->get('typed_data_manager')->getValidator()
|
||||
@@ -114,6 +116,10 @@ class QuickEditFieldForm extends FormBase {
|
||||
'#attributes' => ['class' => ['quickedit-form-submit']],
|
||||
];
|
||||
|
||||
// Use the non-inline form error display for Quick Edit forms, because in
|
||||
// this case the errors are already near the form element.
|
||||
$form['#disable_inline_form_errors'] = TRUE;
|
||||
|
||||
// Simplify it for optimal in-place use.
|
||||
$this->simplify($form, $form_state);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Drupal\quickedit;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Render\RendererInterface;
|
||||
use Drupal\user\PrivateTempStoreFactory;
|
||||
use Drupal\Core\TempStore\PrivateTempStoreFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
@@ -25,7 +25,7 @@ class QuickEditController extends ControllerBase {
|
||||
/**
|
||||
* The PrivateTempStore factory.
|
||||
*
|
||||
* @var \Drupal\user\PrivateTempStoreFactory
|
||||
* @var \Drupal\Core\TempStore\PrivateTempStoreFactory
|
||||
*/
|
||||
protected $tempStoreFactory;
|
||||
|
||||
@@ -53,7 +53,7 @@ class QuickEditController extends ControllerBase {
|
||||
/**
|
||||
* Constructs a new QuickEditController.
|
||||
*
|
||||
* @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
|
||||
* @param \Drupal\Core\TempStore\PrivateTempStoreFactory $temp_store_factory
|
||||
* The PrivateTempStore factory.
|
||||
* @param \Drupal\quickedit\MetadataGeneratorInterface $metadata_generator
|
||||
* The in-place editing metadata generator.
|
||||
@@ -74,7 +74,7 @@ class QuickEditController extends ControllerBase {
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('user.private_tempstore'),
|
||||
$container->get('tempstore.private'),
|
||||
$container->get('quickedit.metadata.generator'),
|
||||
$container->get('quickedit.editor.selector'),
|
||||
$container->get('renderer')
|
||||
|
||||
@@ -5,8 +5,8 @@ description: 'Support module for the Quick Edit module tests.'
|
||||
package: Testing
|
||||
# version: VERSION
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457825
|
||||
|
||||
Reference in New Issue
Block a user