Commit 258b9a31 authored by Dries's avatar Dries

Issue #2149599 by Wim Leers: Fix minor bugs and minor coding standards...

Issue #2149599 by Wim Leers: Fix minor bugs and minor coding standards violations in edit.module, discovered by backporting.
parent 7d36579d
......@@ -13,7 +13,7 @@
};
/**
* Registers a resize hanlder on the window.
* Registers a resize handler on the window.
*/
Drupal.behaviors.drupalDisplace = {
attach: function () {
......
/**
* @file
* Icons for contextual module.
* Icons for edit module.
*/
.edit .icon {
......
/**
* @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 @@ public function attachments(Request $request) {
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 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
$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 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
*
* @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 @@ public static function getInfo() {
);
}
public function setUp() {
protected function setUp() {
parent::setUp();
$type = $this->drupalCreateContentType(array(
......
......@@ -32,7 +32,7 @@ public static function getInfo() {
);
}
public function setUp() {
protected function setUp() {
parent::setUp();
// Create a text format.
......@@ -79,7 +79,7 @@ public function testUserWithoutPermission() {
// 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 @@ public function testUserWithPermission() {
// 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 @@ public static function getInfo() {
);
}
public function setUp() {
protected function setUp() {
parent::setUp();
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
......
......@@ -54,7 +54,7 @@ public static function getInfo() {
);
}
public function setUp() {
protected function setUp() {
parent::setUp();
$this->editorManager = $this->container->get('plugin.manager.edit.editor');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment