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>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2026-01-09 11:21:18 +01:00 committed by Lucas Gass
parent fdf9fcfee4
commit b708776eb0
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
9 changed files with 53 additions and 0 deletions

View File

@ -47,6 +47,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
[% IF ( login ) %]
[% Asset.css("css/login.css") | $raw %]

View File

@ -18,6 +18,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
<style id="antiClickjack">
body {
display: none !important;

View File

@ -0,0 +1,23 @@
(function () {
const permissions = (window.permissions = window.permissions || {});
window.addPermissions = function (perms) {
for (const key in perms) {
if (Object.prototype.hasOwnProperty.call(perms, key)) {
permissions[key] = perms[key];
}
}
};
})();
(function () {
const prefs = (window.prefs = window.prefs || {});
window.addPrefs = function (sysprefs) {
for (const key in sysprefs) {
if (Object.prototype.hasOwnProperty.call(sysprefs, key)) {
prefs[key] = sysprefs[key];
}
}
};
})();

View File

@ -83,6 +83,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
[% Asset.css("lib/fontawesome/css/fontawesome.min.css") | $raw %]
[% Asset.css("lib/fontawesome/css/brands.min.css") | $raw %]

View File

@ -79,6 +79,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
</head>
<body id="sci_main" class="sci">
<div id="wrapper">

View File

@ -49,6 +49,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
</head>
<body id="sco_help" class="sco">
<div id="wrapper">

View File

@ -31,6 +31,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
[% Asset.js("lib/jquery/jquery-3.6.0.min.js") | $raw %]
[% Asset.js("lib/jquery/jquery-migrate-3.3.2.min.js") | $raw %]
[% Asset.js("lib/fontfaceobserver/fontfaceobserver.min.js") | $raw %]

View File

@ -60,6 +60,7 @@
[% END %]
[% Asset.js('js/Gettext.js') | $raw %]
[% Asset.js('js/i18n.js') | $raw %]
[% Asset.js('js/stores.js') | $raw %]
</head>
<body id="sco_main" class="sco">
<div id="wrapper">

View File

@ -0,0 +1,23 @@
(function () {
const permissions = (window.permissions = window.permissions || {});
window.addPermissions = function (perms) {
for (const key in perms) {
if (Object.prototype.hasOwnProperty.call(perms, key)) {
permissions[key] = perms[key];
}
}
};
})();
(function () {
const prefs = (window.prefs = window.prefs || {});
window.addPrefs = function (sysprefs) {
for (const key in sysprefs) {
if (Object.prototype.hasOwnProperty.call(sysprefs, key)) {
prefs[key] = sysprefs[key];
}
}
};
})();