lostcarpark / conclar

ConClár Programme Guide in ReactJS
MIT License
11 stars 12 forks source link

Can't do AND in tag filter #144

Closed aJanuary closed 5 months ago

aJanuary commented 5 months ago

For the last couple of Eastercon's, as well as topic tags like art, science, writing, fantasy, etc., have had tags like online, in person, no catch-up available and sign up required.

A natural query to want to use the filters to answer is "show me all the fantasy items that are available online". However, the current tag filter only does an OR. If I check fantasy and online, it shows me anything that is fantasy OR online, rather than fantasy AND online.

aJanuary commented 5 months ago

I don't want to see the filter form get any more complicated. Support for arbitrary ORs and ANDs in the query would make it very difficult to use.

My proposal is to add the concept of "tag groups". Each tag would belong to a tag group:

Topic:

Location:

Catch-up:

The tags within a group are ORed together, and then each tag group is ANDed together. For example:

I'm undecided how, if at all, tag groups should be displayed in the UI. I think maybe just ordering by tag group, and then alphabetically within tag groups. So the dropdown would list:

Tag groups could be alphabetical by name, or the order of the tag groups could be defined in the program json. Some flourishes that could be added to the UI include a horizontal line separating tag groups, and having headings for the tag groups. But I think those are probably unnecessary and messy. I think (hope) the concept of tag groups is natural enough that people don't need it explained why writing, fantasy, online shows online writing or fantasy items.

Tag groups would need to be defined somehow in the program json. The tags array could be changed from an array of strings to an array of string or object. If it is a string, it gets added to an implicit "unknown" tag group. If it is an object, it has tag and group attributes.

{
  "id": "item1",
  ...
  "tags": [
    "a raw tag",
    "this still works",
    "these are added to the unknown tag group"
  ]
}, {
  "id": "item2",
  ...
  "tags": [
    { "tag": "science", "group": "topic" },
    { "tag": "online", "group": "location" }
  ]
}, {
  "id": "item3",
  ...
  "tags": [
    "I guess you could mix raw tags",
    { "tag": "and explicitly grouped tags", "group": "the group" },
    "but no one would in practice"
  ]
}

Finding somewhere to add an explicit ordering of the tag groups is difficult with the current structure. (This is why I tend to steer away from arrays as the root objects for json. It makes it difficult to add other types of things in the future) So maybe groups are just ordered alphabetically in the UI.

A consideration is how to handle the same tag belonging to multiple groups. If I have:

{
  "id": "item4",
  ...
  "tags": [
    { "tag": "cool tag", "group": "group 1" },
    { "tag": "cool tag", "group": "group 2" },
  ]
}

a) Do we show cool tag twice in the tag filter dropdown? Do we make any effort to visually distinguish the two? b) Do we show cool tag twice in the tag list on the item? Do we make any effort to distinguish the two? c) Or do we error, saying the tags are invalid?

My current inclination is to say we just show them twice in both places, without making any extra effort to visually distinguish them, and if someone is foolish enough to have duplicate tag names, that's kinda their fault.

An alternative presentation is that, instead of smooshing it all into the tags filter, each tag group gets it's own dropdown list in the filter form. My concern here is that already for a hybrid event list Eastercon we have 4 tag groups, so we'd end up with 7 input boxes in the filter form.

mcdemarco commented 5 months ago

It's already possible to group tags (into separate dropdowns/categories) via the JSON data, and the search over different dropdowns is treated as an AND. See the docs directory for details of the formatting. This option also existed in KonOpas and is possible using either data format.

aJanuary commented 5 months ago

Doh, I can't believe I missed that in the docs! Thanks.