Issue #2149599 by Wim Leers: Fix minor bugs and minor coding standards violations in edit.module, discovered by backporting.
parent
7d36579df3
commit
258b9a310c
|
@ -13,7 +13,7 @@
|
|||
};
|
||||
|
||||
/**
|
||||
* Registers a resize hanlder on the window.
|
||||
* Registers a resize handler on the window.
|
||||
*/
|
||||
Drupal.behaviors.drupalDisplace = {
|
||||
attach: function () {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @file
|
||||
* Icons for contextual module.
|
||||
* Icons for edit module.
|
||||
*/
|
||||
|
||||
.edit .icon {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @file
|
||||
* Styling for contextual module.
|
||||
* Styling for edit module.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* but before they are cached. Hence any alterations will be cached.
|
||||
*
|
||||
* @param array &$editors
|
||||
* An array of informations on existing in-place editors, as collected by the
|
||||
* An array of metadata on existing in-place editors, as collected by the
|
||||
* annotation discovery mechanism.
|
||||
*
|
||||
* @see \Drupal\edit\Annotation\InPlaceEditor
|
||||
|
@ -72,7 +72,7 @@ function hook_edit_editor_alter(&$editors) {
|
|||
function hook_edit_render_field(Drupal\Core\Entity\EntityInterface $entity, $field_name, $view_mode_id, $langcode) {
|
||||
return array(
|
||||
'#prefix' => '<div class="example-markup">',
|
||||
'field' => field_view_field($entity, $field_name),
|
||||
'field' => field_view_field($entity, $field_name, $view_mode_id, $langcode),
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ function edit_library_info() {
|
|||
'js' => array(
|
||||
// Core.
|
||||
$path . '/js/edit.js' => $options,
|
||||
$path . '/js/util.js' => $options,
|
||||
// Models.
|
||||
$path . '/js/models/AppModel.js' => $options,
|
||||
$path . '/js/models/EntityModel.js' => $options,
|
||||
|
@ -90,7 +91,6 @@ function edit_library_info() {
|
|||
$path . '/js/views/FieldToolbarView.js' => $options,
|
||||
$path . '/js/views/EditorView.js' => $options,
|
||||
// Other.
|
||||
$path . '/js/util.js' => $options,
|
||||
$path . '/js/theme.js' => $options,
|
||||
),
|
||||
'css' => array(
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
* @file
|
||||
* contentEditable-based in-place editor for plain text content.
|
||||
*/
|
||||
|
||||
(function ($, _, Drupal) {
|
||||
|
||||
"use strict";
|
||||
|
@ -60,7 +61,7 @@ Drupal.edit.editors.plain_text = Drupal.edit.EditorView.extend({
|
|||
break;
|
||||
case 'candidate':
|
||||
if (from !== 'inactive') {
|
||||
this.$textElement.removeAttr('contentEditable');
|
||||
this.$textElement.removeAttr('contenteditable');
|
||||
}
|
||||
if (from === 'invalid') {
|
||||
this.removeValidationErrors();
|
||||
|
@ -76,7 +77,7 @@ Drupal.edit.editors.plain_text = Drupal.edit.EditorView.extend({
|
|||
});
|
||||
break;
|
||||
case 'active':
|
||||
this.$textElement.attr('contentEditable', 'true');
|
||||
this.$textElement.attr('contenteditable', 'true');
|
||||
break;
|
||||
case 'changed':
|
||||
break;
|
||||
|
|
|
@ -207,8 +207,8 @@ class EditController extends ContainerAware implements ContainerInjectionInterfa
|
|||
public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view_mode_id, Request $request) {
|
||||
$response = new AjaxResponse();
|
||||
|
||||
// Replace entity with tempstore copy if available and not resetting, init
|
||||
// tempstore copy otherwise.
|
||||
// Replace entity with TempStore copy if available and not resetting, init
|
||||
// TempStore copy otherwise.
|
||||
$tempstore_entity = $this->tempStoreFactory->get('edit')->get($entity->uuid());
|
||||
if ($tempstore_entity && $request->request->get('reset') !== 'true') {
|
||||
$entity = $tempstore_entity;
|
||||
|
@ -229,8 +229,8 @@ class EditController extends ContainerAware implements ContainerInjectionInterfa
|
|||
$form = drupal_build_form($form_object->getFormId(), $form_state);
|
||||
|
||||
if (!empty($form_state['executed'])) {
|
||||
// The form submission saved the entity in tempstore. Return the
|
||||
// updated view of the field from the tempstore copy.
|
||||
// The form submission saved the entity in TempStore. Return the
|
||||
// updated view of the field from the TempStore copy.
|
||||
$entity = $this->tempStoreFactory->get('edit')->get($entity->uuid());
|
||||
|
||||
// Render the field. If the view mode ID is not an Entity Display view
|
||||
|
@ -280,10 +280,13 @@ class EditController extends ContainerAware implements ContainerInjectionInterfa
|
|||
*
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity being edited.
|
||||
*
|
||||
* @return \Drupal\Core\Ajax\AjaxResponse
|
||||
* The Ajax response.
|
||||
*/
|
||||
public function entitySave(EntityInterface $entity) {
|
||||
// Take the entity from tempstore and save in entity storage. fieldForm()
|
||||
// ensures that the tempstore copy exists ahead.
|
||||
// Take the entity from TempStore and save in entity storage. fieldForm()
|
||||
// ensures that the TempStore copy exists ahead.
|
||||
$tempstore = $this->tempStoreFactory->get('edit');
|
||||
$tempstore->get($entity->uuid())->save();
|
||||
$tempstore->delete($entity->uuid());
|
||||
|
|
|
@ -66,7 +66,7 @@ class EditAutocompleteTermTest extends WebTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$type = $this->drupalCreateContentType(array(
|
||||
|
|
|
@ -32,7 +32,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create a text format.
|
||||
|
@ -79,7 +79,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
// Library and in-place editors.
|
||||
$settings = $this->drupalGetSettings();
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/edit.js']), 'Edit library not loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/createjs/editingWidgets/formwidget.js']), "'form' in-place editor not loaded.");
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
|
||||
// HTML annotation must always exist (to not break the render cache).
|
||||
$this->assertRaw('data-edit-entity-id="node/1"');
|
||||
|
@ -135,7 +135,7 @@ class EditLoadingTest extends WebTestBase {
|
|||
// Library and in-place editors.
|
||||
$settings = $this->drupalGetSettings();
|
||||
$this->assertTrue(isset($settings['ajaxPageState']['js']['core/modules/edit/js/edit.js']), 'Edit library loaded.');
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/createjs/editingWidgets/formwidget.js']), "'form' in-place editor not loaded.");
|
||||
$this->assertFalse(isset($settings['ajaxPageState']['js']['core/modules/edit/js/editors/formEditor.js']), "'form' in-place editor not loaded.");
|
||||
|
||||
// HTML annotation must always exist (to not break the render cache).
|
||||
$this->assertRaw('data-edit-entity-id="node/1"');
|
||||
|
|
|
@ -24,7 +24,7 @@ class EditTestBase extends DrupalUnitTestBase {
|
|||
/**
|
||||
* Sets the default field storage backend for fields created during tests.
|
||||
*/
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', 'variable');
|
||||
|
|
|
@ -37,7 +37,7 @@ class EditorSelectionTest extends EditTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
|
|
|
@ -54,7 +54,7 @@ class MetadataGeneratorTest extends EditTestBase {
|
|||
);
|
||||
}
|
||||
|
||||
public function setUp() {
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
|
||||
|
|
Loading…
Reference in New Issue