specify global origin of data in window builder
This commit is contained in:
parent
1d96acc37a
commit
a10a14893a
2 changed files with 20 additions and 19 deletions
|
@ -4,6 +4,7 @@ Window and window content management */
|
|||
import texts from "../../mapping/read.js";
|
||||
import net from "/scripts/utils/net.js";
|
||||
import Window from "../window.js";
|
||||
import {global} from "/scripts/secretariat.js";
|
||||
|
||||
export default class windowman {
|
||||
static new(URL, height, width) {
|
||||
|
@ -46,7 +47,7 @@ export default class windowman {
|
|||
logging.error(err.name, err.message, err.stack, true, [source]);
|
||||
|
||||
// Stop loading the page when an error has occured; it's not going to work!
|
||||
if ((await secretariat.read(`debug`, -1) != null) ? await secretariat.read(`debug`, -1) : true) {
|
||||
if ((await secretariat.global.read(`debug`, -1) != null) ? await secretariat.global.read(`debug`, -1) : true) {
|
||||
window.close();
|
||||
};
|
||||
};
|
||||
|
@ -226,12 +227,12 @@ export default class windowman {
|
|||
(document.querySelectorAll(`.sidenav`)).forEach(function (sidebar_element) {
|
||||
if (sidebar_element.getAttribute(`name`)) {
|
||||
document.querySelector(`[works-sidebar="${sidebar_element.getAttribute(`name`)}"]`)
|
||||
.addEventListener(`click`, function () {
|
||||
.addEventListener(`click`, () => {
|
||||
M.Sidenav.getInstance(sidebar_element).open();
|
||||
});
|
||||
} else if (document.querySelector(`[data-action="ui,open,navbar"]`)) {
|
||||
document.querySelector(`[data-action="ui,open,navbar"]`).forEach(function (button_element) {
|
||||
button_element.addEventListener(`click`, function() {
|
||||
button_element.addEventListener(`click`, () => {
|
||||
M.Sidenav.getInstance(sidebar).open();
|
||||
});
|
||||
});
|
||||
|
@ -270,7 +271,7 @@ export default class windowman {
|
|||
let data = {};
|
||||
data[`source`] = input_element.getAttribute(`data-store`);
|
||||
// data[`origin`] = (input_element.hasAttribute(`data-store-location`)) ? parseInt(input_element.getAttribute(`data-store-location`)) : -1
|
||||
data[`value`] = secretariat.read(data[`source`]);
|
||||
data[`value`] = secretariat.global.read(data[`source`]);
|
||||
|
||||
data[`value`].then(async function(value) {
|
||||
switch (input_element.getAttribute(`type`).toLowerCase()) {
|
||||
|
@ -315,7 +316,7 @@ export default class windowman {
|
|||
UI_item[`source`] = this.getAttribute(`data-store`);
|
||||
UI_item[`value`] = this.checked;
|
||||
UI_item[`store`] = (this.hasAttribute(`data-store-location`)) ? parseInt(this.getAttribute(`data-store-location`)) : -1;
|
||||
secretariat.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]);
|
||||
secretariat.global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]);
|
||||
};
|
||||
break;
|
||||
default:
|
||||
|
@ -337,7 +338,7 @@ export default class windowman {
|
|||
: parseInt(this.value)
|
||||
: this.value;
|
||||
UI_item[`store`] = (this.hasAttribute(`data-store-location`)) ? parseInt(this.getAttribute(`data-store-location`)) : -1;
|
||||
secretariat.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]);
|
||||
secretariat.global.write(UI_item[`source`], UI_item[`value`], UI_item[`store`]);
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
@ -351,7 +352,7 @@ export default class windowman {
|
|||
*/
|
||||
async function updates() {
|
||||
// Get the storage data.
|
||||
let storage_data = await secretariat.read();
|
||||
let storage_data = await secretariat.global.read();
|
||||
|
||||
async function enable() {
|
||||
let input_elements = document.querySelectorAll("[data-enable]");
|
||||
|
@ -360,10 +361,10 @@ export default class windowman {
|
|||
input_elements.forEach(async (input_element) => {
|
||||
if (input_element.getAttribute("data-enable")) {
|
||||
// Enable the element.
|
||||
input_element.disabled = ((await secretariat.read(input_element.getAttribute("data-enable"))) != null
|
||||
? (typeof (await secretariat.read(input_element.getAttribute("data-enable")))).includes(`obj`)
|
||||
? (Object.keys(await secretariat.read(input_element.getAttribute("data-enable")))).length <= 0
|
||||
: !(!!(await secretariat.read(input_element.getAttribute("data-enable"))))
|
||||
input_element.disabled = ((await secretariat.global.read(input_element.getAttribute("data-enable"))) != null
|
||||
? (typeof (await secretariat.global.read(input_element.getAttribute("data-enable")))).includes(`obj`)
|
||||
? (Object.keys(await secretariat.global.read(input_element.getAttribute("data-enable")))).length <= 0
|
||||
: !(!!(await secretariat.global.read(input_element.getAttribute("data-enable"))))
|
||||
: true);
|
||||
(input_element.disabled) ? input_element.classList.add(`disabled`) : input_element.classList.remove(`disabled`);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import {read, write, search, observe} from "/scripts/secretariat.js";
|
||||
import {global, observe} from "/scripts/secretariat.js";
|
||||
import logging from "/scripts/logging.js"
|
||||
import texts from "/scripts/mapping/read.js";
|
||||
|
||||
|
@ -114,7 +114,7 @@ export default class UI {
|
|||
var DATA = {};
|
||||
|
||||
DATA[`target`] = ((ELEMENT.getAttribute(`data-result-store`).split(`,`))[0] == ``) ? [...(ELEMENT.getAttribute(`data-result-store`).split(`,`).slice(1)), ...[NAME]] : [...AREA, ...[NAME], ...(ELEMENT.getAttribute(`data-result-store`).split(`,`))];
|
||||
DATA[`value`] = ((Object.keys(ITEM).includes(ELEMENT.getAttribute(`data-result-store`))) ? ITEM[ELEMENT.getAttribute(`data-result-store`)] : await read(DATA[`target`], (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1));
|
||||
DATA[`value`] = ((Object.keys(ITEM).includes(ELEMENT.getAttribute(`data-result-store`))) ? ITEM[ELEMENT.getAttribute(`data-result-store`)] : await global.read(DATA[`target`], (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1));
|
||||
|
||||
switch (ELEMENT[`type`]) {
|
||||
case `checkbox`:
|
||||
|
@ -122,7 +122,7 @@ export default class UI {
|
|||
|
||||
ELEMENT[`function`] = function() {
|
||||
DATA[`target`] = ((ELEMENT.getAttribute(`data-result-store`).split(`,`))[0] == ``) ? [...(ELEMENT.getAttribute(`data-result-store`).split(`,`).slice(1)), ...[NAME]] : [...AREA, ...[NAME], ...(ELEMENT.getAttribute(`data-result-store`).split(`,`))];
|
||||
write(DATA[`target`], ELEMENT.checked, (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
globa.write(DATA[`target`], ELEMENT.checked, (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
};
|
||||
break;
|
||||
default:
|
||||
|
@ -133,7 +133,7 @@ export default class UI {
|
|||
try {
|
||||
DATA[`target`] = ((ELEMENT.getAttribute(`data-result-store`).split(`,`))[0] == ``) ? [...(ELEMENT.getAttribute(`data-result-store`).split(`,`).slice(1)), ...[NAME]] : [...AREA, ...[NAME], ...(ELEMENT.getAttribute(`data-result-store`).split(`,`))];
|
||||
DATA[`value`] = JSON.parse(ELEMENT.value.trim());
|
||||
write(DATA[`target`], DATA[`value`], (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
globa.write(DATA[`target`], DATA[`value`], (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
} catch(err) {
|
||||
// The JSON isn't valid.
|
||||
logging.error(err.name, texts.localized(`JSON_parse_error`), err.stack, false);
|
||||
|
@ -144,7 +144,7 @@ export default class UI {
|
|||
|
||||
ELEMENT[`function`] = function() {
|
||||
DATA[`target`] = ((ELEMENT.getAttribute(`data-result-store`).split(`,`))[0] == ``) ? [...(ELEMENT.getAttribute(`data-result-store`).split(`,`).slice(1)), ...[NAME]] : [...AREA, ...[NAME], ...(ELEMENT.getAttribute(`data-result-store`).split(`,`))];
|
||||
write(DATA[`target`], ELEMENT.value.trim(), (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
globa.write(DATA[`target`], ELEMENT.value.trim(), (ELEMENT.hasAttribute(`data-store-location`)) ? parseInt(ELEMENT.getAttribute(`data-store-location`)) : -1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -162,7 +162,7 @@ export default class UI {
|
|||
: ITEM[ELEMENT.getAttribute(`data-result-content`)])
|
||||
: ((ITEM[ELEMENT.getAttribute(`data-result-store`)])
|
||||
? (ITEM[ELEMENT.getAttribute(`data-result-store`)])
|
||||
: null) /*read(((ITEM[(ELEMENT.getAttribute(`data-result-store`).split(`,`))])[ITEM])));*/
|
||||
: null) /*global.read(((ITEM[(ELEMENT.getAttribute(`data-result-store`).split(`,`))])[ITEM])));*/
|
||||
}
|
||||
} else {
|
||||
if (ELEMENT.getAttribute(`data-result-store`) && ELEMENT.type) {
|
||||
|
@ -212,9 +212,9 @@ export default class UI {
|
|||
.getAttribute(`data-results-filters`)
|
||||
.split(`,`);
|
||||
}
|
||||
SEARCH[element.getAttribute(`data-result`)][`results`] = await search(element.getAttribute(`data-result`), SEARCH[element.getAttribute(`data-result`)][`criteria`], SEARCH[element.getAttribute(`data-result`)][`additional criteria`]);
|
||||
SEARCH[element.getAttribute(`data-result`)][`results`] = await global.search(element.getAttribute(`data-result`), SEARCH[element.getAttribute(`data-result`)][`criteria`], SEARCH[element.getAttribute(`data-result`)][`additional criteria`]);
|
||||
} else {
|
||||
SEARCH[element.getAttribute(`data-result`)][`results`] = await read(element.getAttribute(`data-result`));
|
||||
SEARCH[element.getAttribute(`data-result`)][`results`] = await global.read(element.getAttribute(`data-result`));
|
||||
};
|
||||
|
||||
display(element.getAttribute(`data-result`), SEARCH[element.getAttribute(`data-result`)][`results`], `name`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue