Issue #2475483 by Arla, alexpott, Berdir, jeroen.b: Cannot quickedit an image or date field
parent
72fb794d90
commit
0c80f49b90
|
@ -14,7 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
|||
* Implements the class resolver interface supporting class names and services.
|
||||
*/
|
||||
class ClassResolver implements ClassResolverInterface, ContainerAwareInterface {
|
||||
|
||||
use DependencySerializationTrait;
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
|
|
|
@ -11,6 +11,7 @@ use Drupal\Component\Plugin\Exception\PluginException;
|
|||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\Core\DependencyInjection\ClassResolverInterface;
|
||||
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
|
||||
use Drupal\Core\Extension\ModuleHandlerInterface;
|
||||
use Drupal\Core\Plugin\DefaultPluginManager;
|
||||
use Drupal\Core\TypedData\Validation\ExecutionContextFactory;
|
||||
|
@ -24,6 +25,7 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
|
|||
* Manages data type plugins.
|
||||
*/
|
||||
class TypedDataManager extends DefaultPluginManager {
|
||||
use DependencySerializationTrait;
|
||||
|
||||
/**
|
||||
* The validator used for validating typed data.
|
||||
|
|
|
@ -10,6 +10,9 @@ namespace Drupal\quickedit\Tests;
|
|||
use Drupal\Component\Serialization\Json;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\block_content\Entity\BlockContent;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
@ -27,7 +30,13 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual', 'quickedit', 'filter', 'node');
|
||||
public static $modules = array(
|
||||
'contextual',
|
||||
'quickedit',
|
||||
'filter',
|
||||
'node',
|
||||
'image',
|
||||
);
|
||||
|
||||
/**
|
||||
* An user with permissions to create and edit articles.
|
||||
|
@ -527,4 +536,44 @@ class QuickEditLoadingTest extends WebTestBase {
|
|||
$this->drupalGet('');
|
||||
$this->assertRaw('data-quickedit-entity-id="block_content/1"');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that Quick Edit can handle an image field.
|
||||
*/
|
||||
public function testImageField() {
|
||||
// Add an image field to the content type.
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => 'field_image',
|
||||
'type' => 'image',
|
||||
'entity_type' => 'node',
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'field_name' => 'field_image',
|
||||
'field_type' => 'image',
|
||||
'label' => t('Image'),
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
])->save();
|
||||
entity_get_form_display('node', 'article', 'default')
|
||||
->setComponent('field_image', [
|
||||
'type' => 'image_image',
|
||||
])
|
||||
->save();
|
||||
|
||||
// Add an image to the node.
|
||||
$this->drupalLogin($this->editorUser);
|
||||
$image = $this->drupalGetTestFiles('image')[0];
|
||||
$this->drupalPostForm('node/1/edit', [
|
||||
'files[field_image_0]' => $image->uri,
|
||||
], t('Upload'));
|
||||
$this->drupalPostForm(NULL, [
|
||||
'field_image[0][alt]' => 'Vivamus aliquet elit',
|
||||
], t('Save'));
|
||||
|
||||
// The image field form should load normally.
|
||||
$response = $this->drupalPost('quickedit/form/node/1/field_image/en/full', 'application/vnd.drupal-ajax', ['nocssjs' => 'true'] + $this->getAjaxPageStatePostData());
|
||||
$this->assertResponse(200);
|
||||
$ajax_commands = Json::decode($response);
|
||||
$this->assertIdentical('<form ', Unicode::substr($ajax_commands[0]['data'], 0, 6), 'The quickeditFieldForm command contains a form.');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue