Bug 41562

Summary: Introduce the concept of "stores" for regular javascript
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: TemplatesAssignee: Jonathan Druart <jonathan.druart>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: dcook
Version: Main   
Hardware: All   
OS: All   
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:
Bug Depends on:    
Bug Blocks: 41563, 41568    
Attachments: Bug 41562: Introduce "stores" for regular javascript
Bug 41562: Introduce "stores" for regular javascript

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.