From 458f5bee7bb4f2715530d56068301b5897c363b3 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Mon, 5 Oct 2015 21:54:38 +0100 Subject: [PATCH] Issue #2409639 by k4v, madhavvyas, katzilla, tstoeckler, hexabinaer, dawehner: Hide empty details containers --- .../views/src/Plugin/views/HandlerBase.php | 2 ++ .../views/src/Plugin/views/PluginBase.php | 1 - .../src/Plugin/views/argument/ManyToOne.php | 6 +++--- .../src/Plugin/views/argument/NullArgument.php | 2 +- .../Plugin/views/argument/NumericArgument.php | 4 ++-- .../src/Plugin/views/argument/StringArgument.php | 16 ++++++++-------- core/modules/views_ui/src/Tests/FieldUITest.php | 3 +++ 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/core/modules/views/src/Plugin/views/HandlerBase.php b/core/modules/views/src/Plugin/views/HandlerBase.php index 5f9842fd1a1b..47e0c13c7d1f 100644 --- a/core/modules/views/src/Plugin/views/HandlerBase.php +++ b/core/modules/views/src/Plugin/views/HandlerBase.php @@ -305,7 +305,9 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#type' => 'details', '#title' => $this->t('More'), '#weight' => 200, + '#optional' => TRUE, ); + // Allow to alter the default values brought into the form. // @todo Do we really want to keep this hook. $this->getModuleHandler()->alter('views_handler_options', $this->options, $this->view); diff --git a/core/modules/views/src/Plugin/views/PluginBase.php b/core/modules/views/src/Plugin/views/PluginBase.php index cf00382376ef..d84496995ed6 100644 --- a/core/modules/views/src/Plugin/views/PluginBase.php +++ b/core/modules/views/src/Plugin/views/PluginBase.php @@ -483,7 +483,6 @@ public static function preRenderAddFieldsetMarkup(array $form) { unset($form[$key]); } } - return $form; } diff --git a/core/modules/views/src/Plugin/views/argument/ManyToOne.php b/core/modules/views/src/Plugin/views/argument/ManyToOne.php index 781ea80bb973..7c6367ad882d 100644 --- a/core/modules/views/src/Plugin/views/argument/ManyToOne.php +++ b/core/modules/views/src/Plugin/views/argument/ManyToOne.php @@ -72,7 +72,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Allow multiple values'), '#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'), '#default_value' => !empty($this->options['break_phrase']), - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['add_table'] = array( @@ -80,14 +80,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Allow multiple filter values to work together'), '#description' => $this->t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'), '#default_value' => !empty($this->options['add_table']), - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['require_value'] = array( '#type' => 'checkbox', '#title' => $this->t('Do not display items with no value in summary'), '#default_value' => !empty($this->options['require_value']), - '#fieldset' => 'more', + '#group' => 'options][more', ); $this->helper->buildOptionsForm($form, $form_state); diff --git a/core/modules/views/src/Plugin/views/argument/NullArgument.php b/core/modules/views/src/Plugin/views/argument/NullArgument.php index d21ce521f57e..9d654fe513dc 100644 --- a/core/modules/views/src/Plugin/views/argument/NullArgument.php +++ b/core/modules/views/src/Plugin/views/argument/NullArgument.php @@ -35,7 +35,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Fail basic validation if any argument is given'), '#default_value' => !empty($this->options['must_not_be']), '#description' => $this->t('By checking this field, you can use this to make sure views with more arguments than necessary fail validation.'), - '#fieldset' => 'more', + '#group' => 'options][more', ); unset($form['exception']); diff --git a/core/modules/views/src/Plugin/views/argument/NumericArgument.php b/core/modules/views/src/Plugin/views/argument/NumericArgument.php index 799d5cbeaf3c..02e58f098211 100644 --- a/core/modules/views/src/Plugin/views/argument/NumericArgument.php +++ b/core/modules/views/src/Plugin/views/argument/NumericArgument.php @@ -49,7 +49,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Allow multiple values'), '#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'), '#default_value' => !empty($this->options['break_phrase']), - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['not'] = array( @@ -57,7 +57,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Exclude'), '#description' => $this->t('If selected, the numbers entered for the filter will be excluded rather than limiting the view.'), '#default_value' => !empty($this->options['not']), - '#fieldset' => 'more', + '#group' => 'options][more', ); } diff --git a/core/modules/views/src/Plugin/views/argument/StringArgument.php b/core/modules/views/src/Plugin/views/argument/StringArgument.php index 8acd795f8203..409f10de1330 100644 --- a/core/modules/views/src/Plugin/views/argument/StringArgument.php +++ b/core/modules/views/src/Plugin/views/argument/StringArgument.php @@ -65,7 +65,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Glossary mode'), '#description' => $this->t('Glossary mode applies a limit to the number of characters used in the filter value, which allows the summary view to act as a glossary.'), '#default_value' => $this->options['glossary'], - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['limit'] = array( @@ -78,7 +78,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { ':input[name="options[glossary]"]' => array('checked' => TRUE), ), ), - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['case'] = array( @@ -93,7 +93,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'ucwords' => $this->t('Capitalize each word'), ), '#default_value' => $this->options['case'], - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['path_case'] = array( @@ -108,14 +108,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'ucwords' => $this->t('Capitalize each word'), ), '#default_value' => $this->options['path_case'], - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['transform_dash'] = array( '#type' => 'checkbox', '#title' => $this->t('Transform spaces to dashes in URL'), '#default_value' => $this->options['transform_dash'], - '#fieldset' => 'more', + '#group' => 'options][more', ); if (!empty($this->definition['many to one'])) { @@ -124,14 +124,14 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Allow multiple filter values to work together'), '#description' => $this->t('If selected, multiple instances of this filter can work together, as though multiple values were supplied to the same filter. This setting is not compatible with the "Reduce duplicates" setting.'), '#default_value' => !empty($this->options['add_table']), - '#fieldset' => 'more', + '#group' => 'options][more', ); $form['require_value'] = array( '#type' => 'checkbox', '#title' => $this->t('Do not display items with no value in summary'), '#default_value' => !empty($this->options['require_value']), - '#fieldset' => 'more', + '#group' => 'options][more', ); } @@ -141,7 +141,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { '#title' => $this->t('Allow multiple values'), '#description' => $this->t('If selected, users can enter multiple values in the form of 1+2+3 (for OR) or 1,2,3 (for AND).'), '#default_value' => !empty($this->options['break_phrase']), - '#fieldset' => 'more', + '#group' => 'options][more', ); } diff --git a/core/modules/views_ui/src/Tests/FieldUITest.php b/core/modules/views_ui/src/Tests/FieldUITest.php index ff0e382b0391..b6018f7f964c 100644 --- a/core/modules/views_ui/src/Tests/FieldUITest.php +++ b/core/modules/views_ui/src/Tests/FieldUITest.php @@ -57,6 +57,9 @@ public function testFieldUI() { $this->assertEqual((string) $result[0], '{{ age }} == Age'); $this->assertEqual((string) $result[1], '{{ id }} == ID'); $this->assertEqual((string) $result[2], '{{ name }} == Name'); + + $result = $this->xpath('//details[@id="edit-options-more"]'); + $this->assertEqual(empty($result), true, "Container 'more' is empty and should not be displayed."); } /** -- GitLab