Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -31,7 +31,7 @@
|
|||
// Store the original value of this field. Necessary for reverting
|
||||
// changes.
|
||||
var $textElement;
|
||||
var $fieldItems = this.$el.find('.field__item');
|
||||
var $fieldItems = this.$el.find('.quickedit-field');
|
||||
if ($fieldItems.length) {
|
||||
$textElement = this.$textElement = $fieldItems.eq(0);
|
||||
}
|
||||
|
|
|
@ -410,7 +410,7 @@
|
|||
entityModel.set('state', 'opened', {reason: 'networkerror'});
|
||||
// Show a modal to inform the user of the network error.
|
||||
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('Sorry!'), message);
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -369,9 +369,11 @@
|
|||
var entityElement = $(fieldElement).closest(entityElementSelector);
|
||||
// In the case of a full entity view page, the entity title is rendered
|
||||
// outside of "the entity DOM node": it's rendered as the page title. So in
|
||||
// this case, we must find the entity in the mandatory "content" region.
|
||||
// this case, we find the lowest common parent element (deepest in the tree)
|
||||
// and consider that the entity element.
|
||||
if (entityElement.length === 0) {
|
||||
entityElement = $('.region-content').find(entityElementSelector);
|
||||
var $lowestCommonParent = $(entityElementSelector).parents().has(fieldElement).first();
|
||||
entityElement = $lowestCommonParent.find(entityElementSelector);
|
||||
}
|
||||
var entityInstanceID = entityElement
|
||||
.get(0)
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
// Show a modal to inform the user of the network error.
|
||||
var fieldLabel = Drupal.quickedit.metadata.get(fieldID, 'label');
|
||||
var message = Drupal.t('Could not load the form for <q>@field-label</q>, either due to a website problem or a network connection problem.<br>Please try again.', {'@field-label': fieldLabel});
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Sorry!'), message);
|
||||
Drupal.quickedit.util.networkErrorModal(Drupal.t('Network problem!'), message);
|
||||
|
||||
// Change the state back to "candidate", to allow the user to start
|
||||
// in-place editing of the field again.
|
||||
|
|
|
@ -22,12 +22,12 @@ function quickedit_help($route_name, RouteMatchInterface $route_match) {
|
|||
switch ($route_name) {
|
||||
case 'help.page.quickedit':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Quick Edit module allows users with the <a href="!quickedit_permission">Access in-place editing</a> and <a href="!contextual_permission">Use contextual links</a> permissions to edit field content without visiting a separate page. For more information, see the <a href="!handbook_url">online documentation for the Quick Edit module</a>.', array('!handbook_url' => 'https://www.drupal.org/documentation/modules/edit', '!quickedit_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-quickedit')), '!contextual_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-contextual')))) . '</p>';
|
||||
$output .= '<p>' . t('The Quick Edit module allows users with the <a href=":quickedit_permission">Access in-place editing</a> and <a href=":contextual_permission">Use contextual links</a> permissions to edit field content without visiting a separate page. For more information, see the <a href=":handbook_url">online documentation for the Quick Edit module</a>.', array(':handbook_url' => 'https://www.drupal.org/documentation/modules/edit', ':quickedit_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-quickedit')), ':contextual_permission' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-contextual')))) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Editing content in-place') . '</dt>';
|
||||
$output .= '<dd>';
|
||||
$output .= '<p>' . t('To edit content in place, you need to activate quick edit mode for a content item. Activate quick edit mode by choosing Quick edit from the contextual links for an area displaying the content (see the <a href="!contextual">Contextual Links module help</a> for more information about how to use contextual links).', array('!contextual' => \Drupal::url('help.page', array('name' => 'contextual')))) . '</p>';
|
||||
$output .= '<p>' . t('To edit content in place, you need to activate quick edit mode for a content item. Activate quick edit mode by choosing Quick edit from the contextual links for an area displaying the content (see the <a href=":contextual">Contextual Links module help</a> for more information about how to use contextual links).', array(':contextual' => \Drupal::url('help.page', array('name' => 'contextual')))) . '</p>';
|
||||
$output .= '<p>' . t('Once quick edit mode is activated, you will be able to edit the individual fields of your content. In the default theme, with a JavaScript-enabled browser and a mouse, the output of different fields in your content is outlined in blue, a pop-up gives the field name as you hover over the field output, and clicking on a field activates the editor. Closing the pop-up window ends quick edit mode.') . '</p>';
|
||||
$output .= '</dd>';
|
||||
$output .= '</dl>';
|
||||
|
@ -113,6 +113,13 @@ function quickedit_field_formatter_info_alter(&$info) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for the page title template.
|
||||
*/
|
||||
function quickedit_preprocess_page_title(&$variables) {
|
||||
$variables['title_attributes']['class'][] = 'js-quickedit-page-title';
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for field templates.
|
||||
*/
|
||||
|
@ -130,10 +137,9 @@ function quickedit_preprocess_field(&$variables) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Fields that are not part of the entity (i.e. dynamically injected "pseudo
|
||||
// fields") and computed fields are not editable.
|
||||
// Fields that are computed fields are not editable.
|
||||
$definition = $entity->getFieldDefinition($element['#field_name']);
|
||||
if ($definition && !$definition->isComputed()) {
|
||||
if (!$definition->isComputed()) {
|
||||
$variables['attributes']['data-quickedit-field-id'] = $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\quickedit\Ajax\BaseCommand.
|
||||
*/
|
||||
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\CommandInterface;
|
||||
|
||||
/**
|
||||
* Base command that only exists to simplify Quick Edit's actual AJAX commands.
|
||||
*/
|
||||
class BaseCommand implements CommandInterface {
|
||||
|
||||
/**
|
||||
* The name of the command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* The data to pass on to the client side.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $data;
|
||||
|
||||
/**
|
||||
* Constructs a BaseCommand object.
|
||||
*
|
||||
* @param string $command
|
||||
* The name of the command.
|
||||
* @param string $data
|
||||
* The data to pass on to the client side.
|
||||
*/
|
||||
public function __construct($command, $data) {
|
||||
$this->command = $command;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render() {
|
||||
return array(
|
||||
'command' => $this->command,
|
||||
'data' => $this->data,
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\BaseCommand;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate the entity was loaded from PrivateTempStore and
|
||||
* saved into the database.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\BaseCommand;
|
||||
|
||||
/**
|
||||
* AJAX command for passing a rendered field form to Quick Edit's JavaScript
|
||||
* app.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\BaseCommand;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate a field was saved into PrivateTempStore without
|
||||
* validation errors and pass the rerendered field to Quick Edit's JavaScript
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
namespace Drupal\quickedit\Ajax;
|
||||
|
||||
use Drupal\Core\Ajax\BaseCommand;
|
||||
|
||||
/**
|
||||
* AJAX command to indicate a field form was attempted to be saved but failed
|
||||
* validation and pass the validation errors.
|
||||
|
|
|
@ -36,7 +36,7 @@ interface EditorSelectorInterface {
|
|||
* @return array
|
||||
* An array of attachments, for use with #attached.
|
||||
*
|
||||
* @see drupal_process_attached()
|
||||
* @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
|
||||
*/
|
||||
public function getEditorAttachments(array $editor_ids);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ interface InPlaceEditorInterface extends PluginInspectionInterface {
|
|||
* @return array
|
||||
* An array of attachments, for use with #attached.
|
||||
*
|
||||
* @see drupal_process_attached()
|
||||
* @see \Drupal\Core\Render\AttachmentsResponseProcessorInterface::processAttachments()
|
||||
*/
|
||||
public function getAttachments();
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ class QuickEditController extends ControllerBase {
|
|||
* The view mode the field should be rerendered in. Either an Entity Display
|
||||
* view mode ID, or a custom one. See hook_quickedit_render_field().
|
||||
*
|
||||
* @return \Drupal\Component\Utility\SafeStringInterface
|
||||
* @return \Drupal\Component\Render\MarkupInterface
|
||||
* Rendered HTML.
|
||||
*
|
||||
* @see hook_quickedit_render_field()
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\quickedit\EditorSelector;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +42,7 @@ class EditorSelectionTest extends QuickEditTestBase {
|
|||
*/
|
||||
protected function getSelectedEditor($entity_id, $field_name, $view_mode = 'default') {
|
||||
$entity = entity_load('entity_test', $entity_id, TRUE);
|
||||
$items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name);
|
||||
$items = $entity->get($field_name);
|
||||
$options = entity_get_display('entity_test', 'entity_test', $view_mode)->getComponent($field_name);
|
||||
return $this->editorSelector->getEditor($options['type'], $items);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\quickedit\Tests;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\quickedit\EditorSelector;
|
||||
use Drupal\quickedit\MetadataGenerator;
|
||||
use Drupal\quickedit\Plugin\InPlaceEditorManager;
|
||||
|
@ -101,7 +100,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
|
|||
$entity = entity_load('entity_test', $entity->id());
|
||||
|
||||
// Verify metadata for field 1.
|
||||
$items_1 = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_1_name);
|
||||
$items_1 = $entity->get($field_1_name);
|
||||
$metadata_1 = $this->metadataGenerator->generateFieldMetadata($items_1, 'default');
|
||||
$expected_1 = array(
|
||||
'access' => TRUE,
|
||||
|
@ -111,7 +110,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
|
|||
$this->assertEqual($expected_1, $metadata_1, 'The correct metadata is generated for the first field.');
|
||||
|
||||
// Verify metadata for field 2.
|
||||
$items_2 = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_2_name);
|
||||
$items_2 = $entity->get($field_2_name);
|
||||
$metadata_2 = $this->metadataGenerator->generateFieldMetadata($items_2, 'default');
|
||||
$expected_2 = array(
|
||||
'access' => TRUE,
|
||||
|
@ -169,7 +168,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
|
|||
$entity = entity_load('entity_test', $entity->id());
|
||||
|
||||
// Verify metadata.
|
||||
$items = $entity->getTranslation(LanguageInterface::LANGCODE_NOT_SPECIFIED)->get($field_name);
|
||||
$items = $entity->get($field_name);
|
||||
$metadata = $this->metadataGenerator->generateFieldMetadata($items, 'default');
|
||||
$expected = array(
|
||||
'access' => TRUE,
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\quickedit\Tests;
|
|||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\entity_reference\Tests\EntityReferenceTestTrait;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
|
|
|
@ -396,20 +396,6 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Quick Edit doesn't make pseudo fields or computed fields
|
||||
* editable.
|
||||
*/
|
||||
public function testPseudoFields() {
|
||||
\Drupal::service('module_installer')->install(array('quickedit_test'));
|
||||
|
||||
$this->drupalLogin($this->authorUser);
|
||||
$this->drupalGet('node/1');
|
||||
|
||||
// Check that the data- attribute is not added.
|
||||
$this->assertNoRaw('data-quickedit-field-id="node/1/quickedit_test_pseudo_field/en/default"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Quick Edit doesn't make fields rendered with display options
|
||||
* editable.
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract class QuickEditTestBase extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'entity_test', 'field', 'field_test', 'filter', 'user', 'text', 'quickedit', 'entity_reference');
|
||||
public static $modules = ['system', 'entity_test', 'field', 'field_test', 'filter', 'user', 'text', 'quickedit'];
|
||||
|
||||
/**
|
||||
* Bag of created fields.
|
||||
|
|
|
@ -9,35 +9,6 @@ use Drupal\Core\Entity\EntityInterface;
|
|||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function quickedit_test_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'article') {
|
||||
$build['pseudo'] = array(
|
||||
'#theme' => 'field',
|
||||
'#title' => 'My pseudo field',
|
||||
'#field_name' => 'quickedit_test_pseudo_field',
|
||||
'#label_display' => 'Label',
|
||||
'#entity_type' => $entity->getEntityTypeId(),
|
||||
'#bundle' => $entity->bundle(),
|
||||
'#language' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
|
||||
'#field_type' => 'pseudo',
|
||||
'#view_mode' => 'default',
|
||||
'#object' => $entity,
|
||||
'#access' => TRUE,
|
||||
'#items' => array(
|
||||
0 => array(
|
||||
'value' => 'pseudo field',
|
||||
),
|
||||
),
|
||||
0 => array(
|
||||
'#markup' => 'pseudo field',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_quickedit_render_field().
|
||||
*/
|
||||
|
|
|
@ -34,7 +34,9 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
$this->editAccessCheck = new EditEntityFieldAccessCheck();
|
||||
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class)->reveal();
|
||||
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
|
||||
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
|
||||
$cache_contexts_manager->reveal();
|
||||
$container = new Container();
|
||||
$container->set('cache_contexts_manager', $cache_contexts_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
|
Reference in a new issue