Problem/Motivation

Currently, if you have a view with an exposed filter, and you expose the operator for it, the label is hard-coded to "Operator". The only way to change it is to implement a hook form alter, which is not accessible to site builders, and will likely break if the configuration for the view changes.

An example use case for this would be when you have multiple operators exposed, and would like to have the labels be more explicit as to which one is is for which filter, so that the users can clearly identify them.

Proposed resolution

When a filter has Expose this filter to visitors, to allow them to change it and Expose operator enabled, display a new "Operator label" text field to configure the label for the Operator select element on the exposed filters form.

This will make it configurable via the UI so that site builders can configure it, and export it with the rest of the view.

This would work exactly how the Label for filters currently works. What ever text is configured will be used as the label for the operator select element.

Remaining tasks

  • Write patch
  • Write update path
  • Write update path test
  • Write test for the new setting
  • Review
  • Accessibility review
  • Commit

User interface changes

A new textfield element is added to the configure filter form, which displays only when both Expose this filter to visitors, to allow them to change it and Expose operator are enabled.

Configure filter form before

Configure filter form before

Configure filter form after

Configure filter form after

Exposed filter form before

Exposed filter form before

Exposed filter form after

Exposed filter form after

API changes

None.

Data model changes

New views data type schema operator_label.

Release notes snippet

Views exposed filters that also expose the operator are now able to configure the label for the operator.

CommentFileSizeAuthor
#61 3120627-nr-bot.txt144 bytesneeds-review-queue-bot
#60 Screenshot from 2022-12-15 15-25-59.png120.29 KBgaurav-mathur
#60 Screenshot from 2022-12-15 15-15-26.png136.39 KBgaurav-mathur
#60 Screenshot from 2022-12-15 15-13-47.png127.99 KBgaurav-mathur
#52 3120627-52.with-2625136-btwn-op.png87.47 KBdww
#51 3120627-51.with-2625136.png79 KBdww
#51 3120627-51.without-2625136.png68 KBdww
#49 Form-After.png78.07 KBmanuel garcia
#48 View-After.png30.88 KBmanuel garcia
#48 View-Before.png29.95 KBmanuel garcia
#48 Form-After.png71.28 KBmanuel garcia
#48 Form-Before.png78.23 KBmanuel garcia
#45 3120627-45.patch54.7 KBmanuel garcia
#45 interdiff-3120627-41-45.txt819 bytesmanuel garcia
#41 3120627-41.patch54.7 KBmanuel garcia
#37 diff-3120627-31-37.txt10.64 KBmanuel garcia
#37 3120627-37.patch54.69 KBmanuel garcia
#35 interdiff_27-35.txt3.24 KBneslee canil pinto
#35 3120627-35.patch54.86 KBneslee canil pinto
#31 3120627-31.patch53.57 KBmanuel garcia
#31 interdiff-3120627-27-31.txt3.12 KBmanuel garcia
#27 3120627-27.patch52.86 KBmanuel garcia
#27 interdiff-3120627-25-27.txt862 bytesmanuel garcia
#25 3120627-25.patch51.99 KBmanuel garcia
#25 interdiff-3120627-22-25.txt31.84 KBmanuel garcia
#22 3120627-22.patch21.28 KBmanuel garcia
#22 interdiff-3120627-20-22.txt8.05 KBmanuel garcia
#20 3120627-20.patch20.18 KBmanuel garcia
#18 3120627-18.patch20.07 KBmanuel garcia
#18 interdiff-3120627-14-18.txt12.8 KBmanuel garcia
#14 3120627-14.patch12.62 KBmanuel garcia
#14 interdiff-3120627-12-14.txt5.49 KBmanuel garcia
#12 3120627-12.patch7.13 KBmanuel garcia
#12 interdiff-3120627-9-12.txt1.19 KBmanuel garcia
#9 3120627-9.patch7.19 KBmanuel garcia
#9 interdiff-3120627-6-9.txt2.75 KBmanuel garcia
#6 3120627-6.patch6.85 KBmanuel garcia
#6 interdiff-3120627-2-6.txt4.23 KBmanuel garcia
#3 Exposed_Filter_View.png34.35 KBabhisekmazumdar
#2 3120627-2.patch3.56 KBmanuel garcia
image4144.png71.28 KBmanuel garcia

Issue fork drupal-3120627

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Manuel Garcia created an issue. See original summary.

manuel garcia’s picture

Status: Active » Needs review
StatusFileSize
new3.56 KB

Here is a working patch as well as the (untested) upgrade path, which should serve as a good starting point.

abhisekmazumdar’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new34.35 KB

Hi @Manuel Garcia this will be a good option for customization.

I applied the patch and It works flawlessly. Thanks for the patch.

abhisekmazumdar’s picture

dww’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Generally +1 to this feature. It's always hard to justify adding yet more settings to the Views UI. ;) But this does seem like the sort of thing that folks want/need to customize (I certainly have), and forcing them to use hook_form_alter() for it is a burden.

However, the RTBC is premature. At the bare minimum, we need a test of the new feature. We should probably also have a test for the post_update function (thanks for adding that!).

I'll closely review the rest of the patch later (time permitting).

Thanks,
-Derek

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new4.23 KB
new6.85 KB

Thank you @abhisekmazumdar and @dww for having a look at this, I'm very pleased to see there is interest in doing this.

I agree its still early for RTBC, but thanks for that @abhisekmazumdar - I'm glad it's already working :)

I had a go at the upgrade path test, which for now I have not been able to get to pass locally:

  • If I manually enter something in the Operator label via the UI and save the view, then the configuration shows the operator_label in it.
  • If I run the upgrade path, then the configuration does not show the operator_label in it.

So to me the test is actually catching a valid bug in the upgrade path. The post update function does look correct to me though, so perhaps its something else we're missing?

Status: Needs review » Needs work

The last submitted patch, 6: 3120627-6.patch, failed testing. View results

andyf’s picture

  1. +++ b/core/modules/views/views.post_update.php
    @@ -436,3 +436,29 @@ function views_post_update_remove_core_key(&$sandbox = NULL) {
    +  \Drupal::classResolver(ConfigEntityUpdater::class)->update($sandbox, 'view', function ($view) {
    +    /** @var \Drupal\views\ViewEntityInterface $view */
    

    Nit: you can use a type declaration on the closure parameter to have the language enforce it.

  2. +++ b/core/modules/views/views.post_update.php
    @@ -436,3 +436,29 @@ function views_post_update_remove_core_key(&$sandbox = NULL) {
    +          $view->set("display.$display_name.display_options.filters.$filter_name", $filter);
    

    I don't think you can set nested values in this way on the config entity itself; that's provided by \Drupal\Core\Config\ConfigBase::set(), ie you can use it with config returned from the config factory.

Thanks!

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new2.75 KB
new7.19 KB

Thanks @AndyF for the review

re #8.1 - Cleaner that way, thanks!
re #8.2 - I'm not entirely sure I understand, but I based this on views_post_update_limit_operator_defaults which does something very similar, so I assume it is the correct way to do it?

Cleaning up a bit the update path test etc in this patch, as well as #8.1

Update should test still fail.

Status: Needs review » Needs work

The last submitted patch, 9: 3120627-9.patch, failed testing. View results

andyf’s picture

Thanks @Manuel Garcia!

I based this on views_post_update_limit_operator_defaults which does something very similar, so I assume it is the correct way to do it?

Ooh, er yeah, good point! I've done a little digging, and I actually wonder if that update really works. I commented out the following line locally from views_post_update_limit_operator_defaults() and yet \Drupal\Tests\views\Functional\Update\LimitOperatorsDefaultsTest::testViewsPostUpdateLimitOperatorsDefaultValues() still passes, so I wonder if that's just a bad model to be copying?

$view->set("display.$display_name.display_options.filters.$filter_name", $filter);

FWIW I made the attached little script and it seems that test2() and test3() successfully update the view.

function test(string $view_name) {
  $config_entity = View::load($view_name);

  foreach ($config_entity->get('display') as $display_name => &$display) {
    if (!isset($display['display_options']['filters'])) {
      continue;
    }

    foreach ($display['display_options']['filters'] as $filter_name => $filter) {
      if (!isset($filter['expose']['operator_label'])) {
        $filter['expose']['operator_label'] = t('Operator');
        $config_entity->set("display.$display_name.display_options.filters.$filter_name", $filter);
      }
    }
  }
  $config_entity->save();
}

function test2(string $view_name) {
  $config_object = \Drupal::configFactory()->getEditable('views.view.' . $view_name);
  foreach ($config_object->get('display') as $display_name => &$display) {
    if (!isset($display['display_options']['filters'])) {
      continue;
    }

    foreach ($display['display_options']['filters'] as $filter_name => $filter) {
      if (!isset($filter['expose']['operator_label'])) {
        $filter['expose']['operator_label'] = t('Operator');
        $config_object->set("display.$display_name.display_options.filters.$filter_name", $filter);
      }
    }
  }
  $config_object->save();
}

function test3(string $view_name) {
  $config_entity = View::load($view_name);

  $displays = $config_entity->get('display');
  foreach ($displays as $display_name => &$display) {
    if (!isset($display['display_options']['filters'])) {
      continue;
    }

    foreach ($display['display_options']['filters'] as $filter_name => $filter) {
      if (!isset($filter['expose']['operator_label'])) {
        $display['display_options']['filters'][$filter_name]['expose']['operator_label'] = t('Operator');
      }
    }
  }
  $config_entity->set('display', $displays);
  $config_entity->save();
}

test('content');
test2('block_content');
test3('comment');

Thanks

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new1.19 KB
new7.13 KB

Thanks @AndyF again for the info. Finally figured it out, I looked at other post update functions updating views in core (for example content_moderation_post_update_views_field_plugin_id) and noticed that they were doing it differently, so I followed their pattern and now is working as expected.

So yay for tests. Also views_post_update_limit_operator_defaults is indeed incorrect, and we should fix it.

This should come back green, next step is add test coverage for the feature itself.

manuel garcia’s picture

Issue summary: View changes
Status: Needs review » Needs work

Setting to needs work for adding test coverage to the new option.

manuel garcia’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.49 KB
new12.62 KB

Here is the test. I spent a bit of time trying to figure out where it would make the most sense to have it, and in the end I decided for \Drupal\Tests\views\Functional\Plugin\ExposedFormTest. Happy to move it around if it should go somewhere else though :)

manuel garcia’s picture

Issue summary: View changes
neslee canil pinto’s picture

Status: Needs review » Reviewed & tested by the community

@Manuel, #14 applied cleanly and works has required. Moving to RTBC.

dww’s picture

Status: Reviewed & tested by the community » Needs work

Mostly looks good, thanks! A few nits, and a few concerns of real substance:

  1. +++ b/core/modules/views/tests/fixtures/update/exposed-operators-labels.php
    @@ -0,0 +1,19 @@
    +/**
    + * @file
    + * Test fixture.
    + */
    

    One could complain this doesn't really tell us much. ;)

  2. +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
    @@ -357,6 +363,40 @@ public function testExposedSortAndItemsPerPage() {
    +    $this->assertText($default_operator_label);
    ...
    +    $this->assertText($new_operator_label);
    

    Raw assertText() always makes me nervous, since there's a chance we'll get false positives if that text appears anywhere else on the page for any other reason. I always prefer more targeted assertions if possible. E.g. an xpath that finds exactly the label we're expecting...

  3. +++ b/core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php
    @@ -357,6 +363,40 @@ public function testExposedSortAndItemsPerPage() {
    +    // Assert the Operator label field is displayed with the default value.
    +    $this->drupalLogin($this->rootUser);
    +    $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_operator_label/default/filter/type');
    +    $assert_session->fieldValueEquals('options[expose][operator_label]', $default_operator_label);
    +
    +    // Change it to a different value and ensure the form saves correctly.
    +    $this->submitForm([
    +      'options[expose][operator_label]' => $new_operator_label,
    +    ], 'Apply');
    +    $assert_session->statusCodeEquals(200);
    +    // Save the view itself.
    +    $this->submitForm([], 'Save');
    +    // Assert the Operator label field is displayed with the new value.
    +    $this->drupalGet('admin/structure/views/nojs/handler/test_exposed_operator_label/default/filter/type');
    +    $assert_session->fieldValueEquals('options[expose][operator_label]', $new_operator_label);
    

    I guess all this is okay. It's mostly testing that the Views UI works, not that this feature works. ;) Many (most?) views tests directly twiddle the view config. E.g. something like this:

        $view = Views::getView('test_display_feed');
        $display = &$view->storage->getDisplay('feed_2');
        $display['display_options']['row']['options']['link_field'] = 'nid';
        $view->save();
    

    I don't feel super strongly about it, and what's here is more test coverage (which is almost always welcome), but it's also sort of out-of-scope testing, and perhaps duplicate (sort of) with existing tests (#CitationNeeded). /shrug

  4. +++ b/core/modules/views/tests/src/Functional/Update/OperatorLabelsDefaultsTest.php
    @@ -0,0 +1,59 @@
    + * Tests the upgrade path for the operator labels feature.
    

    s/upgrade/update/

  5. +++ b/core/modules/views/tests/src/Functional/Update/OperatorLabelsDefaultsTest.php
    @@ -0,0 +1,59 @@
    +   * Tests that default settings for limit operators are present.
    

    Copy/paste error, that's not what this test is testing.

  6. +++ b/core/modules/views/tests/src/Functional/Update/OperatorLabelsDefaultsTest.php
    @@ -0,0 +1,59 @@
    +  public function testViewsPostUpdateOperatorLabelsDefaultValues() {
    +    // Load and initialize our test view.
    +    $view = View::load('test_exposed_filters');
    

    This test is now depending on the fact that core/modules/views/tests/fixtures/update/views.view.test_exposed_filters.yml does *not* define the new 'operator_label' key. Someone might regenerate that view for other tests (e.g. tests that the view was originally added for, etc). Seems a bit fragile and dangerous to go this route. We should either:

    A) Add some comments to views.view.test_exposed_filters.yml explaining that this test now depends on this fact so that it's less likely someone will accidentally "fix" the view in the future, breaking this test's assumptions.

    B) (Probably safer): Add another default view specifically for this test, something like "views.view.test_exposed_operator_label_update.yml" or something that explains it's a legacy view to test the update path. Then there's no chance someone will "fix" it, since it'll be a dedicated view only used by this test.

  7. +++ b/core/modules/views/views.post_update.php
    @@ -436,3 +437,28 @@ function views_post_update_remove_core_key(&$sandbox = NULL) {
    +    foreach ($displays as $display_name => &$display) {
    

    Doesn't look like we ever directly modify $display, so I don't think we want to iterate with references here. Unless PHP is weird and the fact that we're getting references to $filter below requires references here, too. Would be curious if this works with just $display...

Thanks,
-Derek

p.s. Re: #14: Yeah, that seems like a reasonable spot for where to put this test. The layout of Views tests is a bit weird (some make sense, some do not), so it's not easy to make good decisions based on prior art. But +1 to your choice of \Drupal\Tests\views\Functional\Plugin\ExposedFormTest. Since this feature is entirely UI-centric, I think we're going to need Functional tests for it (lots of Views can be tested via Kernel tests, which are preferred if possible, but not for this), and since it's about the exposed form, we should keep it close to the other tests for that functionality.

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new12.8 KB
new20.07 KB

Thanks @dww for the excellent review!

Re #17:

  1. I agree, added some more information there.
  2. Good point, pays to be more specific here, asserting the actual label element's text now.
  3. Yeah its probably out of scope of this test... I moved to updating the view configuration directly. It cuts testExposedOperatorLabel()'s execution time by ~25% on my machine which is always a good thing :)
  4. Fixed.
  5. Oops, Fixed.
  6. Yeah you're right... I was being lazy there for no good reason really :) - Providing a new view for this test as it should be now.
  7. The update test fails with with Failed asserting that an array has the key 'operator_label'. if we don't do &$display... I think it makes sense, since we are altering the filter inside the display array, then $view->set('display', $displays);. I checked how we're doing it elsewhere out of curiosity, and we're doing something similar on views_post_update_entity_link_url(), views_post_update_filter_placeholder_text() and views_post_update_cleanup_duplicate_views_data(), so I suppose it should be safe.

p.s. Glad the test is in the right place in \Drupal\Tests\views\Functional\Plugin\ExposedFormTes :)

dww’s picture

Status: Needs review » Needs work

Thanks! Looking really close. Sorry I didn't notice these before, but a few more minor nits/concerns:

  1. +++ b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    @@ -0,0 +1,271 @@
    +      filters:
    +        status:
    +          value: '1'
    +          table: node_field_data
    +          field: status
    +          plugin_id: boolean
    +          entity_type: node
    +          entity_field: status
    +          id: status
    +          expose:
    +            operator: ''
    +          group: 1
    

    Do we want the test to ensure that the operator label is set on this (non-exposed) filter, too? If not, maybe we don't want it in this view at all? Or maybe we want to change the post_update to ignore non-exposed filters? TBD.

  2. +++ b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    @@ -0,0 +1,271 @@
    +      sorts:
    +        created:
    +          id: created
    +          table: node_field_data
    +          field: created
    +          order: DESC
    +          entity_type: node
    +          entity_field: created
    +          plugin_id: date
    +          relationship: none
    +          group_type: group
    +          admin_label: ''
    +          exposed: false
    +          expose:
    +            label: ''
    +          granularity: second
    

    This is irrelevant to the test, and should probably be removed.

manuel garcia’s picture

StatusFileSize
new20.18 KB

Thanks @dww for the review, valid points.

First, patch needed a reroll due to #2989745: views_update_8500() inlines configuration changes instead of this being done on config save for bc - I had a look at the changes introduced there, and they seem very related to what we're doing here, does that mean we should change our views_post_update_set_operator_label_defaults() function as well? @see ViewsConfigUpdater::processOperatorDefaultsHandler()

manuel garcia’s picture

Status: Needs work » Needs review
manuel garcia’s picture

StatusFileSize
new8.05 KB
new21.28 KB

Re #19.1:
I played around a bit and noticed that the expose configuration is included in the view no matter if the filter is exposed or not. So in my opinion we should be adding the default value for the new configuration to every filter. I have updated the update test to reflect that.

Re #19.2:
I agree, removed it.

Also in this patch:

The last submitted patch, 20: 3120627-20.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 22: 3120627-22.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new31.84 KB
new51.99 KB

Updating all the views...

dww’s picture

Status: Needs review » Needs work

Re: #22
19.1: Sounds good, thanks!
19.2: 👍
Also.2: Seems like the right thing, yeah. I need to read #2989745: views_update_8500() inlines configuration changes instead of this being done on config save for bc
Also.2: /shrug. Generally test views don't need complete config, only the config for the stuff they care about. The point of this fixture is a known pre-update starting point. But whatever, I don't care much either way. This is fine as-is.

Re: #25: Oh right, good point about updating all the default views that core ships. ;)

A few final concerns before I can sign off on this. I'd fix these myself, but then I couldn't RTBC, so I have to set NW:

  1. +++ b/core/modules/views/tests/fixtures/update/exposed-operators-labels.php
    @@ -0,0 +1,21 @@
    diff --git a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    
    diff --git a/core/profiles/demo_umami/config/install/views.view.featured_articles.yml b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    similarity index 69%
    
    similarity index 69%
    copy from core/profiles/demo_umami/config/install/views.view.featured_articles.yml
    
    copy from core/profiles/demo_umami/config/install/views.view.featured_articles.yml
    copy to core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    

    Something about the git diff settings here are confusing git into thinking your new view is a copy of the demu_umami view, which is making this patch hard to review. What if you do git diff -C95% or something? Then it shouldn't consider this a similar file to be copied and will list the new thing as a whole new file (which should be a lot easier to review/read).

  2. +++ b/core/modules/views/views.post_update.php
    @@ -10,6 +10,7 @@
    +use Drupal\views\ViewEntityInterface;
    

    Now unused. https://www.drupal.org/pift-ci-job/1641713 shows:

    /var/lib/drupalci/workspace/jenkins-drupal_patches-41128/source/core/modules/views/views.post_update.php ✗ 1 more
    line 13	Unused use statement
    
  3. +++ b/core/modules/views/views.post_update.php
    @@ -396,3 +397,14 @@ function views_post_update_field_names_for_multivalue_fields(&$sandbox = NULL) {
    + * Define default operator label values on all exposed filters.
    

    Not just 'all exposed filters' anymore...

Thanks/sorry!
-Derek

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new862 bytes
new52.86 KB

Thanks @dww again for the review!

Re #26.1 Wow first time I'm seeing this very strange, I checked and I couldn't find a way to configure the default value for --find-copies though...
In any case, I used git diff -C95% for this patch which has done the trick, so thanks for that.

Re #26.2 Oops, good catch, fixed.

Re #26.3 Yup, fixed.

dww’s picture

Status: Needs review » Reviewed & tested by the community

Sweet, thanks! I can't find anything else to complain about. 😉 Let's see what the core committers think. 🤞

lendude’s picture

Nice. Big patch but the actual change is quite small.

+++ b/core/modules/views/src/ViewsConfigUpdater.php
@@ -21,6 +22,8 @@
@@ -249,6 +252,10 @@ protected function processOperatorDefaultsHandler(array &$handler, $handler_type
         $handler['expose']['operator_list'] = [];
         $changed = TRUE;
       }
+      if (!isset($handler['expose']['operator_label'])) {
+        $handler['expose']['operator_label'] = $this->t('Operator');
+        $changed = TRUE;
+      }
     }
 

Interesting. Weaving this into the config update for a different issue will make this helper class VERY hard to clean up let alone ever remove. The hope would be that we can clean/remove this once all the associated update hooks have been removed, but weaving updates into each other would make this very hard to track.

I think we would need to give this its own method that is tightly coupled to the update hook, but this is new ground, so not sure how others feel.

dww’s picture

Status: Reviewed & tested by the community » Needs work

@Lendude re: #29: 👍Now that I've read commit 663762f38d from #2989745: views_update_8500() inlines configuration changes instead of this being done on config save for bc, a separate protected method for this is probably more true to the design intentions of ViewsConfigUpdater, and will indeed make it easier to untangle later. Thanks for raising that.

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new3.12 KB
new53.57 KB

Thanks @Lendude for having a look and rising that issue, makes sense. Let's see if I am understanding this class correctly... is this what you meant?

lendude’s picture

@Manuel Garcia yeah that looks great.

This will make it easier to remove the right things in D10. Since all these updates are probably going away in D10, I don't think it is a big deal right now, but when we start adding more updates to this in D9 (some of which might be removed in D11) we want do have the right pattern for this set so we can just remove methods and not have to refactor the whole class to find code that is still relevant.

We might want to think about adding some @see comments to that class to make it clearer which method is coupled to which update hook, but that is way out of scope here :)

dww’s picture

Status: Needs review » Reviewed & tested by the community

Yup, #31 definitely addresses #29/#30. Back to RTBC.

Thanks!
-Derek

dww’s picture

Status: Reviewed & tested by the community » Needs work

Eek, whoops, was looking at the interdiff, not the patch. You forgot the git diff -C95% so the weird diff returned. Would you be willing to re-roll for that?

Sorry/thanks!
-Derek

neslee canil pinto’s picture

Status: Needs work » Needs review
StatusFileSize
new54.86 KB
new3.24 KB

Rerolled the patch and added interdiff

dww’s picture

Status: Needs review » Needs work

Thanks for the re-roll, @Neslee Canil Pinto. I haven't fully verified the re-roll, but a few concerns with the interdiff you posted:

  1. +++ b/core/modules/views/src/ViewsConfigUpdater.php
    @@ -113,6 +113,9 @@
    @@ -215,7 +218,7 @@
    
    @@ -215,7 +218,7 @@
       }
     
       /**
    -   * Add additional settings to the entity link field.
    +   * Add additional settings to filters operators.
        *
        * @param \Drupal\views\ViewEntityInterface $view
        *   The View to update.
    

    Not sure what this has to do with this issue. Seems like an out-of-scope (but legit) documentation fix for an existing comment that's wrong?

  2. +++ b/core/modules/views/src/ViewsConfigUpdater.php
    @@ -252,6 +270,26 @@
    diff -u b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    
    diff -u b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    --- b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    
    --- b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    +++ b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    
    +++ b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    +++ b/core/modules/views/tests/fixtures/update/views.view.test_exposed_operator_label_update.yml
    @@ -59,8 +59,8 @@
    
    @@ -59,8 +59,8 @@
                 offset: false
                 offset_label: Offset
               tags:
    -            previous: ‹‹
    -            next: ››
    +            previous: ‹‹
    +            next: ››
           style:
             type: default
           row:
    

    This shouldn't be here, either, I don't think...

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new54.69 KB
new10.64 KB

OK here is a reroll of the patch on #31 using git diff -C95%. The interdiff on #31 is still valid.

Re #36.1 I introduced this change on #31 - the change was to remove what seems to be a copy paste error. That description is on needsEntityLinkUrlUpdate which was probably copy/pasted to create needsOperatorDefaultsUpdate and then forgotten to update it. I thought I'd fix it here as I'd feel silly opening a new issue just for this. Happy to remove it though :)

dww’s picture

Status: Needs review » Reviewed & tested by the community

Re-reviewed #37. LGTM. I dunno about #36.1. I tend to prefer Just Fix It Already(tm), but core committers tend to get really set on scope management. I guess we'll see what happens. 😉🤞Hopefully we can leave it as-is, but maybe we'll have to split that out to a trivial follow-up. /shrug

Thanks!
-Derek

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs usability review

Nice work on this feature! I think it could use a usability review.

The latest patch also doesn't apply to 9.1.x, so it needs a reroll.

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new54.7 KB

Rerolled, three-way merge did the trick.

Status: Needs review » Needs work

The last submitted patch, 41: 3120627-41.patch, failed testing. View results

dww’s picture

https://www.drupal.org/pift-ci-job/1672597 is indeed a legit failure. Looks like perhaps the test is relying on an update fixture that's now gone in D9?

dww’s picture

Re: UX review, added this to the agenda for #3131774: Drupal Usability Meeting 2020-05-05

manuel garcia’s picture

Status: Needs work » Needs review
StatusFileSize
new819 bytes
new54.7 KB

Indeed valid fail, updating the fixture that the test uses here.

Thanks @dww for adding this to the usability meeting agenda!

dww’s picture

Interdiff looks great. Bot is now happy. RTBC once the UX review is satisfied.

Thanks!
-Derek

benjifisher’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

We discussed this issue at the #3131774: Drupal Usability Meeting 2020-05-05.

Making the operator name configurable seems like a good idea. I guess the usability issue is whether it is clear what the new "Operator label" text field affects.

Before giving a usability review, we would like to see some further updates to the issue summary, so I am setting the status to NW for that.

  • In the Proposed Resolution, give more detail about how the feature will work.
  • Under User interface changes, add a screenshot showing how this affects the filter when the view is displayed.

Besides adding the highlighted text field, the patch seems to move the "Expose operator" checkbox from the first column to the second. That puts it closer to the additional controls that are unhidden when it is selected, which is a good thing. But it should be called out in the issue summary, either as I have just described it or with a "before" screenshot.

The screenshot shows "Operator for content type" in the new textfield, and the list of options has the label "Your momma". Are these two supposed to match? If so, please describe and/or illustrate that in the issue summary. Please also come up with a more useful example. If the two are supposed to match, have you considered keeping the default label: that is, "Operator (Your momma)" instead of just "Your momma"?

Looking at this screenshot reminds us how crowded the Views UI can get. Personally, I wonder if it would improve things if the "Expose operator" checkbox and the additional controls that it enables were put inside a fieldset. Both of these are out of scope for the current issue, but worth keeping in mind.

If you can update the summary, then I will do my best to review it promptly.

manuel garcia’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new78.23 KB
new71.28 KB
new29.95 KB
new30.88 KB

Thank you so much for having a look at this @benjifisher !

Re: #47:

Besides adding the highlighted text field, the patch seems to move the "Expose operator" checkbox from the first column to the second. That puts it closer to the additional controls that are unhidden when it is selected, which is a good thing. But it should be called out in the issue summary, either as I have just described it or with a "before" screenshot.

The patch does nothing of this sort, the "Expose operator" checkbox is already in the first column without the patch, at least if using Firefox.

The screenshot shows "Operator for content type" in the new textfield, and the list of options has the label "Your momma". Are these two supposed to match? If so, please describe and/or illustrate that in the issue summary. Please also come up with a more useful example. If the two are supposed to match, have you considered keeping the default label: that is, "Operator (Your momma)" instead of just "Your momma"?

I'm not sure which screenshot you're referring to, but whatever the user inputs into the text field when configuring the view will be what the select element label will have. It works exactly like the field label. I have added an example use case to the IS Problem/Motivation section.

Updated the IS to clarify as much as I could. I also added before / after screenshots to both the configuration form and the exposed filter form to make it easier to review. Let me know if you need anything else :)

manuel garcia’s picture

Issue summary: View changes
StatusFileSize
new78.07 KB

Argh messed up one of the screenshots, here is the good one.

dww’s picture

Sweet, thanks @Manuel Garcia. Summary looks great. Removing that tag.

Also adding #2625136: Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements as related, since both of these issues are dealing with the UI of the views exposed filter form. Even the 'After' screenshots here are still kinda whack, which is why we desperately need to fix #2625136, too. ;)

dww’s picture

@benjifisher Asked for screenshots where both this and #2625136: Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements are applied. Glad they asked! ;) I forgot that #2625136 is doing this anytime there's an exposed operator:

$form[$operator]['#title_display'] = 'invisible';

;) It visually hides the label for the operator (although leaves it for assistive tech), because the whole filter (label, operator, value(s)) is now wrapped in a fieldset (see below). Therefore, that bug fix potentially renders this feature request obsolete. :/ Whoops!

I added 2 exposed time filters to the /admin/content view on a local test site, both with exposed operators. Here's just #3120627:

Screenshot of a view with 2 exposed filters that expose an operator, with only patch #3120627-45 applied.

Better than just "Operator" for both (raw core), but still confusing and weird.

Here's what you see once you apply #2625136-129:

Screenshot of a view with 2 exposed filters that expose an operator, with both patch #3120627-45 and #2625136-129 applied.

Now that there's a labeled fieldset for the whole filter, we probably don't need a custom label for the operator at all.

Some possible paths forward:

A) Close this as "won't fix" in favor of #2625136. :(

B) Postpone this on #2625136, and once that's landed, modify this feature so that it can peacefully co-exist:

B.1) Add a 'Display operator label' checkbox (defaults to false to keep the 'invisible' behavior above) but that you can enable if you still want a custom operator label in there for something.

B.2) Change this feature so the default value is an empty string (for 'invisible') but if folks fill in a value, the code that's setting 'invisible' from #2625136 doesn't fire. Would probably want to change the label for the setting, and add a description.

C) Other?

Thanks/sorry,
-Derek

dww’s picture

StatusFileSize
new87.47 KB

This is really a screenshot for #2625136, but here's the same view once you select an operator that requires 2 values (e.g. 'Is between'):

dww’s picture

Title: Make views exposed filter operator labels configurable » [PP-1] Make views exposed filter operator labels configurable
Status: Needs review » Postponed
Issue tags: -Needs usability review

Per @benjifisher in Slack, formally postponing this on #2625136: Fix label visibility and add wrapper container for exposed numeric/date filters with multiple form elements. Once that lands, we can decide what to do with this feature.

Thanks/sorry,
-Derek

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damienmckenna’s picture

Status: Postponed » Needs review

#2625136 was committed, so reopening this.

gaurav-mathur’s picture

i refer some screenshot after use of exposed filter and changment in operator lable on drupal 10.1.x.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new144 bytes

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

sokru’s picture

Title: [PP-1] Make views exposed filter operator labels configurable » Make views exposed filter operator labels configurable
Issue tags: +Needs reroll

I don't think its postponed by anything, but needs a reroll.

mrinalini9 made their first commit to this issue’s fork.

xjm’s picture

Amending attribution.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.