Bug 41562 - Introduce the concept of "stores" for regular javascript
Summary: Introduce the concept of "stores" for regular javascript
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 41563 41568
  Show dependency treegraph
 
Reported: 2026-01-09 13:22 UTC by Jonathan Druart
Modified: 2026-01-13 22:26 UTC (History)
1 user (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 41562: Introduce "stores" for regular javascript (6.84 KB, patch)
2026-01-09 13:24 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 41562: Introduce "stores" for regular javascript (6.89 KB, patch)
2026-01-12 16:35 UTC, Owen Leonard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2026-01-09 13:22:56 UTC
For follow-up bug reports we will have the need to store syspref's values and permissions.

It seems a good idea to have a "store" to share the permissions and system preferences' values we need for the current page. Several "script" tag can coexist and define their own permissions or sysprefs.
Comment 1 Jonathan Druart 2026-01-09 13:24:51 UTC
Created attachment 191062 [details] [review]
Bug 41562: Introduce "stores" for regular javascript

We already have "Stores" in Vue, here we are going to use a shared
object to store permissions and sysrepfs

For follow-up bug reports we will have the need to store syspref's
values and permissions.

It seems a good idea to have a "store" to share the permissions and
system preferences' values we need for the current page. Several
"script" tag can coexist and define their own permissions or sysprefs.

Added on its own bug for reusability purpose.

Test plan:
Test follow-up bug reports ;)
Comment 2 Owen Leonard 2026-01-12 16:35:39 UTC
Created attachment 191289 [details] [review]
Bug 41562: Introduce "stores" for regular javascript

We already have "Stores" in Vue, here we are going to use a shared
object to store permissions and sysrepfs

For follow-up bug reports we will have the need to store syspref's
values and permissions.

It seems a good idea to have a "store" to share the permissions and
system preferences' values we need for the current page. Several
"script" tag can coexist and define their own permissions or sysprefs.

Added on its own bug for reusability purpose.

Test plan:
Test follow-up bug reports ;)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 3 David Cook 2026-01-12 23:43:49 UTC
I like the idea, but should we be namespacing these more?
Comment 4 Jonathan Druart 2026-01-13 09:19:54 UTC
(In reply to David Cook from comment #3)
> I like the idea, but should we be namespacing these more?

Can you detail what you suggest exactly please?
Comment 5 David Cook 2026-01-13 22:26:47 UTC
(In reply to Jonathan Druart from comment #4)
> (In reply to David Cook from comment #3)
> > I like the idea, but should we be namespacing these more?
> 
> Can you detail what you suggest exactly please?

Oh yeah my bad. I just mean putting it under something like window.Koha.permissions and window.Koha.prefs. 

Of course, as I say that, I know we haven't been great about the use of window.Koha and window.KOHA in the past. 

In the Koha code, I see Koha.i18n, Koha.frameworkPlugins, KOHA.coce, KOHA.browser, KOHA.LocalCover, KOHA.Preferences, KOHA.AJAX... I imagine some are used globally while others are only used locally on a single page...

Maybe something like window.Koha.global.permissions / window.Koha.global.prefs.

I'm not sure. It's just got a thought to avoid collisions with other Javascript and to make it clear that it's Koha code specifically.