visual-framework / vf-wp

WordPress theme and plugins for Visual Framework integration
3 stars 6 forks source link

BUG/ENHANCEMENT - EMBL term picker should only match last child #271

Open khawkins98 opened 4 years ago

khawkins98 commented 4 years ago

The EMBL Taxonomy picker currently matches any term or its parent, resulting in false positives.

That is:

Screen Shot 2020-05-05 at 17 47 11

In this case the term I wanted was only second on the list, but sometimes it's much further down.

This results in many false positives in the picker.

Possible solutions

A: Only match last child

It would be best if the picker can only match on the last child term. Having worked with other JS pickers, I know this can be tricky.

B: Only show term + UUID (easier?)

A simpler approach might be to not show the parents in the picker, just the term.

This might be an issue if we have similar but different terms (as we won't see the term parents). If we do go for just showing the child term (no parents) it would be good if we also expose the UUID.

khawkins98 commented 4 years ago

It might turn out that Option B is better as we have a multi-parent hierarchy where a term would show many times, likely confusing editors.

Perhaps we should discuss at standup.

dbushell commented 4 years ago

Hmm interesting problem! Thoughts below.

A)

The tags picker is handled entirely by the WordPress taxonomy (and re-implementing this would be a recipe for disaster). Meaning A) would be practically unfeasable. We could try hacking into the JavaScript and see if we can monkey patch but I suspect that'd be a waste of an afternoon.

We could hide the default tag picker. Then use ACF to build a custom picker, allowing us a little more control over which terms appear (and how).

B)

We can rename the terms anything, i.e. remove the parent hierachy.

However, within the WordPress taxonomy the terms represent more than just a single EMBL term. They represent the hierarchy with their parents.

So for example these four WP terms:

  1. What > EMBL.org Sitemap taxonomy > Locations > EMBL Heidelberg > Typas Group
  2. What > Research Clusters > Genome Biology > Typas Group
  3. Where > Sites > EMBL Heidelberg > Typas Group
  4. Where > Sites > People directory > Nassos Typas > Typas Group

Each represent a hierarchy of 4–5 EBML terms.

So if we remove the parents from the name we have Typas Group appear four times with no context.

The parent hierarchy does appear in the WP API for post tags:

"embl_taxonomy_terms": [
  {
    "uuid": "a:5:{i:0;s:36:\"302cfdf7-365b-462a-be65-82c7b783ebf7\";i:1;s:36:\"747fd49a-cc4c-4f89-975b-8920db22e7e9\";i:2;s:36:\"0bbc7167-1725-4509-bda3-43373f648244\";i:3;s:36:\"f36a2275-0292-4ddf-9784-9f9f681915f8\";i:4;s:36:\"94ddaf2b-18a5-4239-9017-bb23f22f3e9f\";}",
    "name": ["Typas Group"],
    "slug": "what-embl-org-sitemap-taxonomy-locations-embl-heidelberg-typas-group"
  },
  {
    "uuid": "a:4:{i:0;s:36:\"302cfdf7-365b-462a-be65-82c7b783ebf7\";i:1;s:36:\"165a2927-951d-45b9-b756-59e11fba6c66\";i:2;s:36:\"082f4fa0-b2d2-4505-9033-3ad7deda83a7\";i:3;s:36:\"94ddaf2b-18a5-4239-9017-bb23f22f3e9f\";}",
    "name": ["Typas Group"],
    "slug": "what-research-clusters-genome-biology-typas-group"
  }
]

So I suppose we need to figure out where we are picking terms in WordPress and whether context matters. If context doesn't matter we can use ACF to provide a filtered list of terms with no parent.

Right now the taxonomy plugin doesn't actually store Typas Group as a term on its own. I forget why, maybe the API it's pulling from doesn't either.

dbushell commented 4 years ago

Also I don't know why that uuid is a serialised PHP array, that seems like a bug since there is no reason why we can't encode as a JSON array. To avoid breaking anything a real array under a different key...

khawkins98 commented 4 years ago

I can imagine a situation "in the future" where we might want to show the entire ancestry -- it's theoretical though.

I suppose the best hope is to:

  1. See if we can cheat with some CSS to make the picker taller (and/or wider)
  2. Investigate if ACF has a magic bullet?

I think doing Option 1 would buy enough time, if the ACF investigation would be a distraction.

khawkins98 commented 3 years ago

Blocked by https://gitlab.ebi.ac.uk/emblorg/backlog/-/issues/327