Netlify-cms: Add a "Group by" dropdown selector in the folder collection view

Created on 16 Apr 2020  路  9Comments  路  Source: netlify/netlify-cms

Is your feature request related to a problem? Please describe.
Given an example "scholars" folder collection with taxonomies "cohort" and "country" (grouped by Markdown frontmatter values), if I want to browse scholars by cohort, I can't easily do that in the folder view.

Describe the solution you'd like
Ideally there would be a dropdown "Group by" right next to "Sort by" in the collections list view. The selected dropdown value would then be used to group items in the list, like so:

Screenshot 2020-04-16 at 17 30 16

Describe alternatives you've considered

  1. I could search for "2019" in the global search box, but that would return any post from any collection containing that term.
  2. I could also sort by cohort and then view scholars sequentially (and potentially change the "summary" collection config variable to show their cohort in the listing), but that creates cognitive overload.
  3. I could split the collection up into different collections with the "filter" collection config variable, but my understanding is that this creates separate collections, which is undesired for a use case like the above.

Additional context

ux good first issue feature

Most helpful comment

Hi,
I would like to work on that issue.
If you have a good place to start, any advice or direction is welcome 馃槃
@erezrokah

All 9 comments

Excellent feature request!

@erezrokah is it possible to work on it?

Thanks @MohamedBechir, I've already assigned you to https://github.com/netlify/netlify-cms/issues/3640. Let's keep this one open for grabs 馃槃

As suggested, posting this potential feature for validation Multiple Filters with different categories
The idea is almost the same since the filter will be "grouped by".

Thank you @erezrokah 馃槃

Hi,
I would like to work on that issue.
If you have a good place to start, any advice or direction is welcome 馃槃
@erezrokah

Hi @KancerEzeroglu, I think we could start by configuration only groups and as a second iteration infer groups automatically.
You can mode this after https://www.netlifycms.org/docs/configuration-options/#view_filters if you think that makes sense.

Hi,

I will start to add a new configuration for groups.
In the config file, it will look like that:

view_groups:
      - label: "Date"
        field: date
      - label: 'Country'
        field: country

If you add this attribute in your config file, then we'll show a 'group by' filter.
And the user can group items as she/he wanted.

Assume you added these posts:

postA:
 date: 01.01.2020
 country: USA
postB
 date: 01.01.2020
 country: USA
postC:
 date: 01.01.2021
 country: USA
postD
 date: 01.03.2020
 country: Netherlands

When you group by Country you will see these posts as below:

--- Country: USA ---
postA
postB
postC
--- Country: Netherlands ---
postD

Whereas when you group by the date, you will see this:

--- Date: 01.01.2020 ---
postA
postB
--- Date: 01.03.2020 ---
postD
--- Date: 01.01.2021 ---
postC

As you see, this is a date group and it groups by day, not year. I don't know how can we provide a configuration for a year group. WDYT @erezrokah ?

As you see, this is a date group and it groups by day, not year. I don't know how can we provide a configuration for a year group. WDYT @erezrokah ?

Maybe we can add an optional pattern to extract the value e.g.

view_groups:
      - label: "Year"
        field: date
        pattern: "\\d{4}$"

WDYT?

@erezrokah it makes sense theoretically. I'm working on that.

Was this page helpful?
0 / 5 - 0 ratings