Commit 959df8db authored by alexpott's avatar alexpott

Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and defaults to...

Issue #2834316 by Berdir, claudiu.cristea: Node preview shows and defaults to "Default" instead of "Full" view mode
parent b8447123
...@@ -85,9 +85,11 @@ public function buildForm(array $form, FormStateInterface $form_state, EntityInt ...@@ -85,9 +85,11 @@ public function buildForm(array $form, FormStateInterface $form_state, EntityInt
'#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options, '#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options,
); );
$view_mode_options = $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle()); // Always show full as an option, even if the display is not enabled.
$view_mode_options = ['full' => $this->t('Full')] + $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
// Unset view modes that are not used in the front end. // Unset view modes that are not used in the front end.
unset($view_mode_options['default']);
unset($view_mode_options['rss']); unset($view_mode_options['rss']);
unset($view_mode_options['search_index']); unset($view_mode_options['search_index']);
......
...@@ -265,7 +265,7 @@ public function preview(array $form, FormStateInterface $form_state) { ...@@ -265,7 +265,7 @@ public function preview(array $form, FormStateInterface $form_state) {
$route_parameters = [ $route_parameters = [
'node_preview' => $this->entity->uuid(), 'node_preview' => $this->entity->uuid(),
'view_mode_id' => 'default', 'view_mode_id' => 'full',
]; ];
$options = []; $options = [];
......
...@@ -196,7 +196,7 @@ function testPagePreview() { ...@@ -196,7 +196,7 @@ function testPagePreview() {
->save(); ->save();
$view_mode_edit = array('view_mode' => 'teaser'); $view_mode_edit = array('view_mode' => 'teaser');
$this->drupalPostForm('node/preview/' . $uuid . '/default', $view_mode_edit, t('Switch')); $this->drupalPostForm('node/preview/' . $uuid . '/full', $view_mode_edit, t('Switch'));
$this->assertRaw('view-mode-teaser', 'View mode teaser class found.'); $this->assertRaw('view-mode-teaser', 'View mode teaser class found.');
$this->assertNoText($edit[$body_key], 'Body not displayed.'); $this->assertNoText($edit[$body_key], 'Body not displayed.');
...@@ -298,7 +298,7 @@ function testPagePreview() { ...@@ -298,7 +298,7 @@ function testPagePreview() {
// original destination, if set. // original destination, if set.
$destination = 'node'; $destination = 'node';
$this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview'), ['query' => ['destination' => $destination]]); $this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview'), ['query' => ['destination' => $destination]]);
$parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'default']; $parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'];
$options = ['absolute' => TRUE, 'query' => ['destination' => $destination]]; $options = ['absolute' => TRUE, 'query' => ['destination' => $destination]];
$this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, $options)); $this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, $options));
$this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch')); $this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch'));
...@@ -308,7 +308,7 @@ function testPagePreview() { ...@@ -308,7 +308,7 @@ function testPagePreview() {
// Check that preview page works as expected without a destination set. // Check that preview page works as expected without a destination set.
$this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview')); $this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview'));
$parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'default']; $parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'];
$this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, ['absolute' => TRUE])); $this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, ['absolute' => TRUE]));
$this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch')); $this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch'));
$this->clickLink(t('Back to content editing')); $this->clickLink(t('Back to content editing'));
...@@ -442,7 +442,7 @@ function testPagePreviewWithRevisions() { ...@@ -442,7 +442,7 @@ function testPagePreviewWithRevisions() {
/** @var \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver */ /** @var \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver */
$controller_resolver = \Drupal::service('controller_resolver'); $controller_resolver = \Drupal::service('controller_resolver');
$node_preview_controller = $controller_resolver->getControllerFromDefinition('\Drupal\node\Controller\NodePreviewController::view'); $node_preview_controller = $controller_resolver->getControllerFromDefinition('\Drupal\node\Controller\NodePreviewController::view');
$node_preview_controller($node, 'default'); $node_preview_controller($node, 'full');
} }
/** /**
...@@ -463,7 +463,7 @@ public function testSimultaneousPreview() { ...@@ -463,7 +463,7 @@ public function testSimultaneousPreview() {
$edit2 = array($title_key => 'Another page title'); $edit2 = array($title_key => 'Another page title');
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit2, t('Preview')); $this->drupalPostForm('node/' . $node->id() . '/edit', $edit2, t('Preview'));
$this->assertUrl(\Drupal::url('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'default'], ['absolute' => TRUE])); $this->assertUrl(\Drupal::url('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'], ['absolute' => TRUE]));
$this->assertText($edit2[$title_key]); $this->assertText($edit2[$title_key]);
} }
......
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