$form['value']['#options'] = [
      1 => $this->t('Flagged'),
      0 => $this->t('Not flagged'),
      // @todo Find out what in the hell filter type ALL is supposed to do.
      // 'All' => t('All'),
    ];

Haha... 'All' is there for the use case when this filter is exposed, and there are other exposed filters too, so you can combine them or not.

For example, if your filters are 'flagged' and 'published', the 'All' option allows you to show 'published' and 'unpublished' along with combinations such as 'flagged and published' or 'unflagged and unpublished'.

Comments

joachim created an issue. See original summary.

morbus iff’s picture

I believe the only reason to uncomment this line would be for defining the DEFAULT setting.

Currently, with it commented in -dev, if I define a single exposed filter that is NOT required, then "-Any-" will show up in the rendered select box. Selecting "-Any-" will show me all (entities, in my case nodes) regardless of whether they have been flagged or not. However, it doesn't appear that I can ever set "-Any-" as the default value (unless I switch over to a Grouped filter and force it there).

If I uncomment the line, however, I'll see "Any" show up as a "Status" and if I select that in the exposed filter, then it will be the default option in the rendered UI. Which, in the long run, feels like the right default choice for an exposed filter (if I'm new to a site and go to a View with this filter defaulting to "Flagged", I'll see no content at all, which would be hella confusing).

Whether this is the RIGHT way to add "All" (or "Any"), I'm not entirely sure.

grimreaper’s picture

Status: Active » Needs review
StatusFileSize
new1.57 KB

Hello,

I encountered the same need to have multiple exposed filters on a view with a flag relationship and I don't want the view filtered by default.

Here is a patch that uncomment the lines.

Thanks for the review.

Status: Needs review » Needs work

The last submitted patch, 3: flag-all_option-2813503-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

grimreaper’s picture

Status: Needs work » Needs review

Yeah!!! Failing code sniffer tests on untouched parts of the file...

berdir’s picture

Status: Needs review » Needs work

The coding errors are just for information that's not why it fails. It fails because there are test fails and a patch can't be committed when tests fail.

grimreaper’s picture

Ok. My bad.

I was focused on the "codesniffer_fixes.patch Interdiff of automated coding standards fixes only." of the error message I haven't seen it before.

grimreaper’s picture

After some tests using simplytest.me:

  • On Drupal 8.3.6: dev version of flag: OK
  • On Drupal 8.3.6: dev version of flag + patch from comment 3: OK
  • On Drupal 8.4.x: dev version of flag: KO

The errors do not come from the patch, I will try to fix the tests.

grimreaper’s picture

It seems that the issue is known and the work is in progress in #2898502: Convert/Modernise FlagContextualLinksTest.

grimreaper’s picture

Status: Needs work » Needs review

Blocker issue as been fixed. Setting back to needs review.

Status: Needs review » Needs work

The last submitted patch, 3: flag-all_option-2813503-3.patch, failed testing. View results

socketwench’s picture

Issue tags: +Needs reroll

Needs a reroll. :-(

grimreaper’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new1.66 KB

Here is a rerolled patch.

socketwench’s picture

Status: Needs review » Reviewed & tested by the community

Much better. ^_^

  • socketwench committed 361f6fa on 8.x-4.x authored by Grimreaper
    Issue #2813503 by Grimreaper, joachim, socketwench, Morbus Iff, Berdir:...
socketwench’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.