diff --git a/core/modules/views_ui/css/views_ui.admin.css b/core/modules/views_ui/css/views_ui.admin.css index 8374577..05b2d9a 100644 --- a/core/modules/views_ui/css/views_ui.admin.css +++ b/core/modules/views_ui/css/views_ui.admin.css @@ -101,7 +101,6 @@ * The attachment details section, its tabs for each section and the buttons * to add a new section */ - .views-displays { clear: both; } diff --git a/core/modules/views_ui/css/views_ui.admin.theme.css b/core/modules/views_ui/css/views_ui.admin.theme.css index bdb962b..4330290 100644 --- a/core/modules/views_ui/css/views_ui.admin.theme.css +++ b/core/modules/views_ui/css/views_ui.admin.theme.css @@ -423,11 +423,10 @@ td.group-title { .views-displays { border: 1px solid #ccc; + padding-bottom: 36px; } -.views-display-top, -#edit-controls, -.form-edit .form-actions { +.views-display-top { background-color: #e1e2dc; border-bottom: 1px solid #ccc; padding: 8px 8px 8px; /* LTR */ @@ -437,17 +436,6 @@ td.group-title { padding: 8px 8px 8px; } -.form-edit .form-actions { - border-left: 1px solid #ccc; - border-right: 1px solid #ccc; - margin-top: 0; -} - -#edit-controls { - margin: -12px -12px 0 -12px; - padding: 12px 12px 12px; -} - .views-display-top .secondary { margin-right: 18em; /* LTR */ } @@ -478,6 +466,15 @@ td.group-title { max-width: 180px; } +.form-edit .form-actions { + background-color: #e1e2dc; + border-right: 1px solid #ccc; + border-bottom: 1px solid #ccc; + border-left: 1px solid #ccc; + margin-top: 0; + padding: 8px 12px; +} + /* @end */ /* @group Attachment details tabs @@ -607,7 +604,7 @@ td.group-title { /* @group Attachment details */ #edit-display-settings { - margin: 12px; + margin: 12px 12px 0 12px } @@ -651,6 +648,7 @@ td.group-title { * * The auto-preview checkbox line. */ + #views-ui-preview-form .form-type-checkbox { margin-top: 2px; margin-left: 2px; /* LTR */ @@ -663,35 +661,24 @@ td.group-title { #views-ui-preview-form .form-type-textfield, #views-ui-preview-form .form-actions { margin-top: 5px; } -#views-ui-preview-form h2.title { - display: inline; -} -#views-ui-preview-form #edit-controls .arguments-preview { +#views-ui-preview-form .arguments-preview { font-size: 1em; - margin: 0 0.75em; } #views-ui-preview-form .arguments-preview, #views-ui-preview-form .form-type-textfield { - margin-left: 14px; /* LTR */ + margin-left: 10px; /* LTR */ } [dir="rtl"] #views-ui-preview-form .arguments-preview, [dir="rtl"] #views-ui-preview-form .form-type-textfield { margin-left: 0; - margin-right: 14px; + margin-right: 10px; } #views-ui-preview-form .form-type-textfield label { display: inline-block; float: left; /* LTR */ -} -#views-ui-preview-form #edit-controls .form-type-textfield label, -#views-ui-preview-form #edit-controls .form-type-textfield input { - display: inline-block; - float: left; -} -#views-ui-preview-form #edit-controls .form-type-textfield label { font-weight: normal; height: 6ex; margin-right: 0.75em; /* LTR */ @@ -702,40 +689,19 @@ td.group-title { margin-right: 0.2em; } -#views-ui-preview-form #edit-controls .form-type-textfield input { - max-width: 380px; -} - .form-item-live-preview, -.form-item-view-args { - display: inline-block; -} - -.form-item.form-item-view-args { - max-width: 43em; -} - -.form-item.form-item-view-args label { +.form-item-view-args, +#preview-submit-wrapper { display: inline-block; - float: left; } -.form-item.form-item-view-args .description { - float: right; -} - -.form-item.form-item-live-preview { - float: right; - margin: 0; +.form-item-live-preview, +#preview-submit-wrapper { vertical-align: top; } -#preview-args { - float: right; -} - @media screen and (min-width:45em) { /* 720px */ - #views-ui-preview-form #edit-controls .form-type-textfield .description { + #views-ui-preview-form .form-type-textfield .description { white-space: nowrap; } } @@ -849,46 +815,6 @@ td.group-title { margin-bottom: 15px; } -/* @group Preview - * - * The preview controls and the preview pane - */ - -#edit-displays-preview-controls .details-wrapper > * { - float: left; -} - -#edit-displays-preview-controls .details-wrapper > .form-item { - margin-top: 0.3333em; -} - -#edit-displays-preview-controls .form-submit { - display: inline-block; - margin-right: 1em; -} - -#edit-displays-preview-controls .form-type-textfield { - margin-left: 1em; - position: relative; -} - -#edit-displays-preview-controls .form-type-textfield label { - border-left: 1px solid #999; - padding-left: 1em; - position: absolute; -} - -#edit-displays-preview-controls .form-type-textfield label:after { - content: ":"; -} - -#edit-displays-preview-controls .form-type-textfield label ~ * { - margin-left: 105px; -} - -/* @end */ - - /* @group Modal dialog box * * The contents of the popup dialog on the views edit form. @@ -1096,7 +1022,21 @@ td.group-title { border: 1px solid #ccc; } -#views-ui-preview-form { +.view-preview-form { + position: relative; +} +.view-preview-form__title { + background-color: #e1e2dc; + border-bottom: 1px solid #ccc; + margin-top: 0; + padding: 8px 12px; +} +.view-preview-form .form-item-live-preview { + position: absolute; + right: 12px; + top: 3px; +} +#views-live-preview { padding: 12px; } diff --git a/core/modules/views_ui/src/Tests/PreviewTest.php b/core/modules/views_ui/src/Tests/PreviewTest.php index 45742d1..fd37343 100644 --- a/core/modules/views_ui/src/Tests/PreviewTest.php +++ b/core/modules/views_ui/src/Tests/PreviewTest.php @@ -32,12 +32,12 @@ protected function testPreviewContextual() { $this->drupalGet('admin/structure/views/view/test_preview/edit'); $this->assertResponse(200); - $this->drupalPostForm(NULL, $edit = array(), t('Preview')); + $this->drupalPostForm(NULL, $edit = array(), t('Update preview')); $elements = $this->xpath('//div[@id="views-live-preview"]//ul[contains(@class, :ul-class)]/li[contains(@class, :li-class)]', array(':ul-class' => 'contextual-links', ':li-class' => 'filter-add')); $this->assertEqual(count($elements), 1, 'The contextual link to add a new field is shown.'); - $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Preview')); + $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview')); // Test that area text and exposed filters are present and rendered. $this->assertFieldByName('id', NULL, 'ID exposed filter field found.'); @@ -53,19 +53,19 @@ function testPreviewUI() { $this->drupalGet('admin/structure/views/view/test_preview/edit'); $this->assertResponse(200); - $this->drupalPostForm(NULL, $edit = array(), t('Preview')); + $this->drupalPostForm(NULL, $edit = array(), t('Update preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 5); // Filter just the first result. - $this->drupalPostForm(NULL, $edit = array('view_args' => '1'), t('Preview')); + $this->drupalPostForm(NULL, $edit = array('view_args' => '1'), t('Update preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 1); // Filter for no results. - $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Preview')); + $this->drupalPostForm(NULL, $edit = array('view_args' => '100'), t('Update preview')); $elements = $this->xpath('//div[@class = "view-content"]/div[contains(@class, views-row)]'); $this->assertEqual(count($elements), 0); @@ -227,7 +227,7 @@ public function testPreviewAdditionalInfo() { */ protected function getPreviewAJAX($view_name, $panel_id, $row_count) { $this->drupalGet('admin/structure/views/view/' . $view_name . '/preview/' . $panel_id); - $result = $this->drupalPostAjaxForm(NULL, array(), array('op' => t('Preview'))); + $result = $this->drupalPostAjaxForm(NULL, array(), array('op' => t('Update preview'))); $this->assertPreviewAJAX($result, $row_count); } diff --git a/core/modules/views_ui/src/Tests/SettingsTest.php b/core/modules/views_ui/src/Tests/SettingsTest.php index d610531..77bf0a0 100644 --- a/core/modules/views_ui/src/Tests/SettingsTest.php +++ b/core/modules/views_ui/src/Tests/SettingsTest.php @@ -98,7 +98,7 @@ function testEditUI() { $view['id'] = strtolower($this->randomMachineName()); $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $this->drupalPostForm(NULL, array(), t('Preview')); + $this->drupalPostForm(NULL, array(), t('Update preview')); $xpath = $this->xpath('//div[@class="views-query-info"]/pre'); $this->assertEqual(count($xpath), 0, 'The views sql is hidden.'); @@ -110,7 +110,7 @@ function testEditUI() { $view['id'] = strtolower($this->randomMachineName()); $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit')); - $this->drupalPostForm(NULL, array(), t('Preview')); + $this->drupalPostForm(NULL, array(), t('Update preview')); $xpath = $this->xpath('//div[@class="views-query-info"]//pre'); $this->assertEqual(count($xpath), 1, 'The views sql is shown.'); $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.'); diff --git a/core/modules/views_ui/src/ViewPreviewForm.php b/core/modules/views_ui/src/ViewPreviewForm.php index 7f3e3d1..af97e15 100644 --- a/core/modules/views_ui/src/ViewPreviewForm.php +++ b/core/modules/views_ui/src/ViewPreviewForm.php @@ -7,7 +7,6 @@ namespace Drupal\views_ui; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; @@ -26,13 +25,6 @@ public function form(array $form, FormStateInterface $form_state) { $form['#suffix'] = ''; $form['#id'] = 'views-ui-preview-form'; - $form['controls'] = array( - '#type' => 'container', - ); - $form['controls']['title'] = array( - '#markup' => '

' . t('Preview') . '

', - ); - // Reset the cache of IDs. Drupal rather aggressively prevents ID // duplication but this causes it to remember IDs that are no longer even // being used. @@ -43,23 +35,28 @@ public function form(array $form, FormStateInterface $form_state) { $form['controls']['#attributes'] = array('class' => array('clearfix')); - // Add the arguments textfield - $form['view_args'] = array( - '#type' => 'textfield', - '#title' => $this->t('Apply contextual filters:'), - '#description' => $this->t('For multiple filters, separate values with a "/". Example: %example', array('%example' => '40/12/10')), - '#id' => 'preview-args', + $form['controls']['title'] = array( + '#prefix' => '

', + '#markup' => $this->t('Preview'), + '#suffix' => '

', ); // Add a checkbox controlling whether or not this display auto-previews. $form['controls']['live_preview'] = array( '#type' => 'checkbox', - '#weight' => 110, '#id' => 'edit-displays-live-preview', '#title' => $this->t('Auto preview'), '#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'), ); + // Add the arguments textfield + $form['controls']['view_args'] = array( + '#type' => 'textfield', + '#title' => $this->t('Preview with contextual filters:'), + '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), + '#id' => 'preview-args', + ); + $args = array(); if (!$form_state->isValueEmpty('view_args')) { $args = explode('/', $form_state->getValue('view_args')); @@ -68,7 +65,7 @@ public function form(array $form, FormStateInterface $form_state) { $user_input = $form_state->getUserInput(); if ($form_state->get('show_preview') || !empty($user_input['js'])) { $form['preview'] = array( - '#weight' => 1000, + '#weight' => 110, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), '#markup' => $view->renderPreview($this->displayID, $args), @@ -92,7 +89,7 @@ protected function actions(array $form, FormStateInterface $form_state) { ), 'button' => array( '#type' => 'submit', - '#value' => $this->t('Preview'), + '#value' => $this->t('Update preview'), '#attributes' => array('class' => array('arguments-preview')), '#submit' => array('::submitPreview'), '#id' => 'preview-submit', @@ -108,17 +105,6 @@ protected function actions(array $form, FormStateInterface $form_state) { } /** - * {@inheritdoc} - */ - public function buildForm(array $form, FormStateInterface $form_state, $display_id = NULL) { - $form = parent::buildForm($form, $form_state); - - $form['controls']['actions'] = $form['actions']; - unset($form['actions']); - return $form; - } - - /** * Form submission handler for the Preview button. */ public function submitPreview($form, FormStateInterface $form_state) {