relateditems .pattern-relateditems-result-browse links broken on non-site rootPath

Open
#795 2 comments 0 reactions 1 assignee View on GitHub

@seanupton is already working on this.

Since Aug 16, 2017.

Assessment

This issue has not been assessed yet.

Description

01 type: bug

If you set anything other than the site root as the rootPath (e.g. a navroot/subsite) in options for the relateditems pattern, the path passed to the AJAX catalog query will be incorrect. This leads to missing results in browse mode everywhere outside of the rootPath.

To duplicate (using mockup master), something like the following:

  • Site's nav root is at /mysite/my-navroot-folder -- so...
  • rootPath could be set to /mysite/my-navroot-folder in my pattern options
    • I use a subclass of the server-side widget to inject this, but that seems a trivial detail.
  • site root is /mysite
  • A folder "animals" exists at /mysite/my-navroot-folder/animals
  • Clicking the .pattern-relateditems-browse-results link for "animals" will lead to erroneous path:
    • /mysite/my-navroot-folder/my-navroot-folder/animals is passed to @@getVocbaulary catalog query as path, and of course, this path always yields zero results/brains.
    • This is in part because the rootPath and the currentPath are concatenated without some sort of normalization to their respective relationship to the site root's path.

There is really no way that a non-site-root rootPath works at present. I would like to address this, but a fix is a bit elusive, because:

  • Some of this hides behind the abstractions of Select2.
  • There is no clear way I understand yet in JavaScript to ascertain the site-root-path in a Plone 5 site (without possibly making an AJAX call).
  • We cannot always assume that a duplicated path fragment like my-navroot-folder/my-navroot-folder is accidental, in the general case. This is the easiest way to generalize to most situations, but it does not solve all possible navroot path choices, and possibly incurs some unwanted technical debt as a workaround.

@thet any thoughts?

Dominant language
JavaScript
Stars
57
Forks
103
Avg merge
10h 25m
Merged PRs (30d)
18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from plone/mockup

All issues in plone/mockup

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.