Problem/Motivation

Source plugins have a getFilterDefinitions() method, the base implementation of which calls $this->getCategories() to produce a list of categories as one of the filters.

The Svelte code also makes an AJAX request to the backend, which...calls getCategories() on the source plugin. Since the categories are available up front when the Svelte app loads, this request is completely pointless, makes the code more confusing, and necessitates an extra route and method of EnabledSourceHandler which is not ultimately needed.

Proposed resolution

Remove EnabledSourceHandler::getCategories() entirely, and the route which calls it. Then refactor the MultipleChoiceFilter component in the Svelte code so that it uses a set of categories passed to it from drupalSettings. This will allow us to remove three of the most perplexing writables in the Svelte app (categoryCheckedTrack, moduleCategoryFilter, and moduleCategoryVocabularies).

As part of this issue, we'll also need to make sure that categories are internally cached by the source plugins (they are currently cached in a non-volatile way by EnabledSourceHandler, but I think it's probably fine to have them in a regular volatile cache).

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

phenaproxima created an issue. See original summary.

phenaproxima’s picture

Title: Project Browser makes a pointless API request for categories » [PP-1] Project Browser makes a pointless API request for categories
Status: Active » Postponed

Postponing on #3495112: Export a coherent set of information about a particular Project Browser instance in drupalSettings, since it'll be a lot easier to do this once that one is in.

phenaproxima’s picture

Issue summary: View changes

phenaproxima’s picture

The one behavior change that this seems to cause is that, when you select categories, they are shown (in the "selected categories" area) in the order that you clicked them, rather than some other arbitrary order. I'm not sure why my changes in this MR caused this, but to me, this is a sensible user experience, so I'm adjusting the tests to conform to the new behavior.

phenaproxima’s picture

Closed #3501453: Only return categories for the current source being displayed as a duplicate of this. I'll need a maintainer to transfer credit for @fjgarlin, @iamdroid, and @gprtskh.

fjgarlin credited gprtskh.

fjgarlin credited iamdroid.

fjgarlin’s picture

Credit transfer.

phenaproxima’s picture

Issue summary: View changes
chrisfromredfin’s picture

Status: Postponed » Needs review
phenaproxima’s picture

Title: [PP-1] Project Browser makes a pointless API request for categories » Project Browser makes a pointless API request for categories
phenaproxima’s picture

chrisfromredfin’s picture

Status: Needs review » Fixed

ok, let's keep slicing away at these old mechanisms!

🔪

Status: Fixed » Closed (fixed)

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