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).
Issue fork project_browser-3502399
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
Comment #2
phenaproximaPostponing 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.
Comment #3
phenaproximaComment #5
phenaproximaThe 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.
Comment #6
phenaproximaClosed #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.
Comment #9
fjgarlin commentedCredit transfer.
Comment #10
phenaproximaComment #11
chrisfromredfinComment #12
phenaproximaComment #13
phenaproximaComment #15
chrisfromredfinok, let's keep slicing away at these old mechanisms!
🔪