@olenbetong/appframe-core 2.7.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +73 -57
- package/dist/esm/af.common.legacy.js +77 -60
- package/dist/esm/af.common.legacy.min.js +2 -2
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +2 -2
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +73 -57
- package/dist/iife/af.common.legacy.js +77 -60
- package/dist/iife/af.common.legacy.min.js +2 -2
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +2 -2
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/alert.d.ts +12 -3
- package/es/alert.js +38 -16
- package/es/index.d.ts +8 -2
- package/es/index.js +3 -2
- package/es/localStorage.d.ts +1 -1
- package/es/localStorage.js +2 -2
- package/package.json +2 -2
- package/src/alert.ts +57 -20
- package/src/index.ts +8 -2
- package/src/localStorage.ts +1 -3
package/dist/esm/af.common.js
CHANGED
|
@@ -135,6 +135,43 @@ if (true) {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
// src/localStorage.ts
|
|
139
|
+
function getLocalKey(key) {
|
|
140
|
+
return [af?.article?.id || "", "common", key].join(".");
|
|
141
|
+
}
|
|
142
|
+
var LocalStorage = class {
|
|
143
|
+
isPersisted = () => true;
|
|
144
|
+
getLocalStorageKey(key, global) {
|
|
145
|
+
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
146
|
+
}
|
|
147
|
+
get(key, defaultValue, global) {
|
|
148
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
149
|
+
const value = localStorage.getItem(lsKey);
|
|
150
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
151
|
+
}
|
|
152
|
+
set(key, value, global) {
|
|
153
|
+
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
154
|
+
}
|
|
155
|
+
remove(key, global) {
|
|
156
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
157
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
158
|
+
localStorage.removeItem(lsKey);
|
|
159
|
+
return true;
|
|
160
|
+
} else {
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
clear() {
|
|
165
|
+
const baseKey = getLocalKey("");
|
|
166
|
+
for (let key in localStorage) {
|
|
167
|
+
if (key.slice(0, baseKey.length) === baseKey) {
|
|
168
|
+
localStorage.removeItem(key);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
var localStorage_default = new LocalStorage();
|
|
174
|
+
|
|
138
175
|
// src/date.ts
|
|
139
176
|
function toLocalISODate(date) {
|
|
140
177
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
@@ -380,45 +417,6 @@ function localize(stringParts, ...args) {
|
|
|
380
417
|
return localized;
|
|
381
418
|
}
|
|
382
419
|
|
|
383
|
-
// src/localStorage.ts
|
|
384
|
-
function getLocalKey(key) {
|
|
385
|
-
return [af?.article?.id || "", "common", key].join(".");
|
|
386
|
-
}
|
|
387
|
-
var LocalStorage = class {
|
|
388
|
-
isPersisted() {
|
|
389
|
-
return true;
|
|
390
|
-
}
|
|
391
|
-
getLocalStorageKey(key, global) {
|
|
392
|
-
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
393
|
-
}
|
|
394
|
-
get(key, defaultValue, global) {
|
|
395
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
396
|
-
const value = localStorage.getItem(lsKey);
|
|
397
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
398
|
-
}
|
|
399
|
-
set(key, value, global) {
|
|
400
|
-
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
401
|
-
}
|
|
402
|
-
remove(key, global) {
|
|
403
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
404
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
405
|
-
localStorage.removeItem(lsKey);
|
|
406
|
-
return true;
|
|
407
|
-
} else {
|
|
408
|
-
return false;
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
clear() {
|
|
412
|
-
const baseKey = getLocalKey("");
|
|
413
|
-
for (let key in localStorage) {
|
|
414
|
-
if (key.slice(0, baseKey.length) === baseKey) {
|
|
415
|
-
localStorage.removeItem(key);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
};
|
|
420
|
-
var localStorage_default = new LocalStorage();
|
|
421
|
-
|
|
422
420
|
// src/logActivity.ts
|
|
423
421
|
async function logActivity(activity, parameters, timeElapsed = 0) {
|
|
424
422
|
try {
|
|
@@ -498,7 +496,11 @@ function waitForDialog(dialog) {
|
|
|
498
496
|
dialog.addEventListener("close", resolve, { once: true });
|
|
499
497
|
});
|
|
500
498
|
}
|
|
501
|
-
|
|
499
|
+
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
500
|
+
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
501
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
502
|
+
return await alertDialogPromiseMap.get(id);
|
|
503
|
+
}
|
|
502
504
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
503
505
|
if (!$template)
|
|
504
506
|
throw Error("No alert dialog template found");
|
|
@@ -508,7 +510,12 @@ async function openAlertDialog({ buttons, content, className }) {
|
|
|
508
510
|
if (!$dialog || !$content || !$menu)
|
|
509
511
|
throw Error("Invalid alert dialog template");
|
|
510
512
|
if (className) {
|
|
511
|
-
$dialog
|
|
513
|
+
className.split(/\s+/).forEach((className2) => $dialog?.classList.add(className2));
|
|
514
|
+
}
|
|
515
|
+
if (title) {
|
|
516
|
+
let $header = document.createElement("header");
|
|
517
|
+
$header.append(title);
|
|
518
|
+
$content.parentNode?.insertBefore($header, $content);
|
|
512
519
|
}
|
|
513
520
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
514
521
|
for (let { label, value, primary } of buttons) {
|
|
@@ -524,40 +531,49 @@ async function openAlertDialog({ buttons, content, className }) {
|
|
|
524
531
|
}
|
|
525
532
|
document.body.appendChild($dialog);
|
|
526
533
|
$dialog.showModal();
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
534
|
+
let dialogPromise = waitForDialog($dialog).then(() => {
|
|
535
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
536
|
+
alertDialogPromiseMap.delete(id);
|
|
537
|
+
}
|
|
538
|
+
}).then(() => {
|
|
539
|
+
let result = $dialog?.returnValue || "cancel";
|
|
540
|
+
if ($dialog)
|
|
541
|
+
document.body.removeChild($dialog);
|
|
542
|
+
return result;
|
|
543
|
+
});
|
|
544
|
+
if (id) {
|
|
545
|
+
alertDialogPromiseMap.set(id, dialogPromise);
|
|
546
|
+
}
|
|
547
|
+
return await dialogPromise;
|
|
531
548
|
}
|
|
532
549
|
var ConfirmButtons = /* @__PURE__ */ ((ConfirmButtons2) => {
|
|
533
550
|
ConfirmButtons2[ConfirmButtons2["YesNo"] = 0] = "YesNo";
|
|
534
551
|
ConfirmButtons2[ConfirmButtons2["OkCancel"] = 1] = "OkCancel";
|
|
535
552
|
return ConfirmButtons2;
|
|
536
553
|
})(ConfirmButtons || {});
|
|
537
|
-
async function confirm(prompt,
|
|
538
|
-
let buttons =
|
|
554
|
+
async function confirm(prompt, options = {}) {
|
|
555
|
+
let { buttons: optionButtons = 0 /* YesNo */, title } = options;
|
|
556
|
+
let buttons = optionButtons === 1 /* OkCancel */ ? [
|
|
557
|
+
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
558
|
+
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
559
|
+
] : [
|
|
539
560
|
{ label: getLocalizedString("Yes"), value: "yes", primary: true },
|
|
540
561
|
{ label: getLocalizedString("No"), value: "no" }
|
|
541
562
|
];
|
|
542
|
-
|
|
543
|
-
buttons = [
|
|
544
|
-
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
545
|
-
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
546
|
-
];
|
|
547
|
-
}
|
|
548
|
-
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm" });
|
|
563
|
+
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm", title });
|
|
549
564
|
return result === "yes";
|
|
550
565
|
}
|
|
551
|
-
async function alert(prompt) {
|
|
566
|
+
async function alert(prompt, options = {}) {
|
|
552
567
|
await openAlertDialog({
|
|
553
568
|
content: prompt,
|
|
554
569
|
className: "alert-dialog-alert",
|
|
555
|
-
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
|
|
570
|
+
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }],
|
|
571
|
+
...options
|
|
556
572
|
});
|
|
557
573
|
}
|
|
558
574
|
|
|
559
575
|
// src/index.ts
|
|
560
|
-
var version = "2.7.
|
|
576
|
+
var version = "2.7.3";
|
|
561
577
|
export {
|
|
562
578
|
ConfirmButtons,
|
|
563
579
|
SessionHandler,
|
|
@@ -160,6 +160,46 @@ if (true) {
|
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
// src/localStorage.ts
|
|
164
|
+
function getLocalKey(key) {
|
|
165
|
+
var _a2;
|
|
166
|
+
return [((_a2 = af == null ? void 0 : af.article) == null ? void 0 : _a2.id) || "", "common", key].join(".");
|
|
167
|
+
}
|
|
168
|
+
var LocalStorage = class {
|
|
169
|
+
constructor() {
|
|
170
|
+
__publicField(this, "isPersisted", () => true);
|
|
171
|
+
}
|
|
172
|
+
getLocalStorageKey(key, global) {
|
|
173
|
+
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
174
|
+
}
|
|
175
|
+
get(key, defaultValue, global) {
|
|
176
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
177
|
+
const value = localStorage.getItem(lsKey);
|
|
178
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
179
|
+
}
|
|
180
|
+
set(key, value, global) {
|
|
181
|
+
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
182
|
+
}
|
|
183
|
+
remove(key, global) {
|
|
184
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
185
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
186
|
+
localStorage.removeItem(lsKey);
|
|
187
|
+
return true;
|
|
188
|
+
} else {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
clear() {
|
|
193
|
+
const baseKey = getLocalKey("");
|
|
194
|
+
for (let key in localStorage) {
|
|
195
|
+
if (key.slice(0, baseKey.length) === baseKey) {
|
|
196
|
+
localStorage.removeItem(key);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var localStorage_default = new LocalStorage();
|
|
202
|
+
|
|
163
203
|
// src/date.ts
|
|
164
204
|
function toLocalISODate(date) {
|
|
165
205
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
@@ -407,46 +447,6 @@ function localize(stringParts, ...args) {
|
|
|
407
447
|
return localized;
|
|
408
448
|
}
|
|
409
449
|
|
|
410
|
-
// src/localStorage.ts
|
|
411
|
-
function getLocalKey(key) {
|
|
412
|
-
var _a2;
|
|
413
|
-
return [((_a2 = af == null ? void 0 : af.article) == null ? void 0 : _a2.id) || "", "common", key].join(".");
|
|
414
|
-
}
|
|
415
|
-
var LocalStorage = class {
|
|
416
|
-
isPersisted() {
|
|
417
|
-
return true;
|
|
418
|
-
}
|
|
419
|
-
getLocalStorageKey(key, global) {
|
|
420
|
-
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
421
|
-
}
|
|
422
|
-
get(key, defaultValue, global) {
|
|
423
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
424
|
-
const value = localStorage.getItem(lsKey);
|
|
425
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
426
|
-
}
|
|
427
|
-
set(key, value, global) {
|
|
428
|
-
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
429
|
-
}
|
|
430
|
-
remove(key, global) {
|
|
431
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
432
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
433
|
-
localStorage.removeItem(lsKey);
|
|
434
|
-
return true;
|
|
435
|
-
} else {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
clear() {
|
|
440
|
-
const baseKey = getLocalKey("");
|
|
441
|
-
for (let key in localStorage) {
|
|
442
|
-
if (key.slice(0, baseKey.length) === baseKey) {
|
|
443
|
-
localStorage.removeItem(key);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
var localStorage_default = new LocalStorage();
|
|
449
|
-
|
|
450
450
|
// src/logActivity.ts
|
|
451
451
|
async function logActivity(activity, parameters, timeElapsed = 0) {
|
|
452
452
|
var _a2;
|
|
@@ -527,8 +527,12 @@ function waitForDialog(dialog) {
|
|
|
527
527
|
dialog.addEventListener("close", resolve, { once: true });
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
|
-
|
|
531
|
-
|
|
530
|
+
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
531
|
+
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
532
|
+
var _a2, _b;
|
|
533
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
534
|
+
return await alertDialogPromiseMap.get(id);
|
|
535
|
+
}
|
|
532
536
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
533
537
|
if (!$template)
|
|
534
538
|
throw Error("No alert dialog template found");
|
|
@@ -538,7 +542,12 @@ async function openAlertDialog({ buttons, content, className }) {
|
|
|
538
542
|
if (!$dialog || !$content || !$menu)
|
|
539
543
|
throw Error("Invalid alert dialog template");
|
|
540
544
|
if (className) {
|
|
541
|
-
$dialog.classList.add(
|
|
545
|
+
className.split(/\s+/).forEach((className2) => $dialog == null ? void 0 : $dialog.classList.add(className2));
|
|
546
|
+
}
|
|
547
|
+
if (title) {
|
|
548
|
+
let $header = document.createElement("header");
|
|
549
|
+
$header.append(title);
|
|
550
|
+
(_b = $content.parentNode) == null ? void 0 : _b.insertBefore($header, $content);
|
|
542
551
|
}
|
|
543
552
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
544
553
|
for (let { label, value, primary } of buttons) {
|
|
@@ -554,40 +563,48 @@ async function openAlertDialog({ buttons, content, className }) {
|
|
|
554
563
|
}
|
|
555
564
|
document.body.appendChild($dialog);
|
|
556
565
|
$dialog.showModal();
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
566
|
+
let dialogPromise = waitForDialog($dialog).then(() => {
|
|
567
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
568
|
+
alertDialogPromiseMap.delete(id);
|
|
569
|
+
}
|
|
570
|
+
}).then(() => {
|
|
571
|
+
let result = ($dialog == null ? void 0 : $dialog.returnValue) || "cancel";
|
|
572
|
+
if ($dialog)
|
|
573
|
+
document.body.removeChild($dialog);
|
|
574
|
+
return result;
|
|
575
|
+
});
|
|
576
|
+
if (id) {
|
|
577
|
+
alertDialogPromiseMap.set(id, dialogPromise);
|
|
578
|
+
}
|
|
579
|
+
return await dialogPromise;
|
|
561
580
|
}
|
|
562
581
|
var ConfirmButtons = /* @__PURE__ */ ((ConfirmButtons2) => {
|
|
563
582
|
ConfirmButtons2[ConfirmButtons2["YesNo"] = 0] = "YesNo";
|
|
564
583
|
ConfirmButtons2[ConfirmButtons2["OkCancel"] = 1] = "OkCancel";
|
|
565
584
|
return ConfirmButtons2;
|
|
566
585
|
})(ConfirmButtons || {});
|
|
567
|
-
async function confirm(prompt,
|
|
568
|
-
let buttons =
|
|
586
|
+
async function confirm(prompt, options = {}) {
|
|
587
|
+
let { buttons: optionButtons = 0 /* YesNo */, title } = options;
|
|
588
|
+
let buttons = optionButtons === 1 /* OkCancel */ ? [
|
|
589
|
+
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
590
|
+
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
591
|
+
] : [
|
|
569
592
|
{ label: getLocalizedString("Yes"), value: "yes", primary: true },
|
|
570
593
|
{ label: getLocalizedString("No"), value: "no" }
|
|
571
594
|
];
|
|
572
|
-
|
|
573
|
-
buttons = [
|
|
574
|
-
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
575
|
-
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
576
|
-
];
|
|
577
|
-
}
|
|
578
|
-
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm" });
|
|
595
|
+
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm", title });
|
|
579
596
|
return result === "yes";
|
|
580
597
|
}
|
|
581
|
-
async function alert(prompt) {
|
|
582
|
-
await openAlertDialog({
|
|
598
|
+
async function alert(prompt, options = {}) {
|
|
599
|
+
await openAlertDialog(__spreadValues({
|
|
583
600
|
content: prompt,
|
|
584
601
|
className: "alert-dialog-alert",
|
|
585
602
|
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
|
|
586
|
-
});
|
|
603
|
+
}, options));
|
|
587
604
|
}
|
|
588
605
|
|
|
589
606
|
// src/index.ts
|
|
590
|
-
var version = "2.7.
|
|
607
|
+
var version = "2.7.3";
|
|
591
608
|
export {
|
|
592
609
|
ConfirmButtons,
|
|
593
610
|
SessionHandler,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var K=Object.defineProperty;var j=Object.getOwnPropertySymbols;var J=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var A=(e,t,r)=>t in e?K(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))J.call(t,r)&&A(e,r,t[r]);if(j)for(var r of j(t))V.call(t,r)&&A(e,r,t[r]);return e};var l=(e,t,r)=>(A(e,typeof t!="symbol"?t+"":t,r),r);function L(e){return{all:e=e||new Map,on:function(t,r){var n=e.get(t);n?n.push(r):e.set(t,[r])},off:function(t,r){var n=e.get(t);n&&(r?n.splice(n.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var n=e.get(t);n&&n.slice().map(function(o){o(r)}),(n=e.get("*"))&&n.slice().map(function(o){o(t,r)})}}}var g=class{constructor(){l(this,"eventHandler",L())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,r){try{let n=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t==null||t(),i()};this.eventHandler.on("onAuthenticated",a)}),o=document.querySelector("dialog.session-expired-dialog");if(o)await n;else{o=document.createElement("dialog"),o.className="session-expired-dialog",o.style.display="flex",o.style.padding="0",o.style.left="50%",o.style.transform="translateX(-50%)";let i="/login?ReturnUrl=%2fapi/sessionexpired/remove";r!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",o.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${i}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(o),o.showModal(),await n,o.remove()}}catch(n){window.location.href=`/login?ReturnUrl=${encodeURIComponent(window.location.pathname)}${encodeURIComponent(window.location.search)}`}}attachEvent(t,r){return this.eventHandler.on(t,r)}detachEvent(t,r){return this.eventHandler.off(t,r)}};var D=class extends g{constructor(r){super();l(this,"amDesignator","a.m.");l(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);l(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);l(this,"decimalSeparator",".");l(this,"domain","OB");l(this,"email");l(this,"formats");l(this,"groupSeparator",null);l(this,"integratedSecurity",!1);l(this,"isDeveloper",!1);l(this,"login","");l(this,"loginType");l(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);l(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);l(this,"name");l(this,"pmDesignator","p.m.");l(this,"shortDateFormat","dd.MM.yyyy");l(this,"culture","en-GB");l(this,"uiculture","en-GB");this.formats={},Object.assign(this,r)}};var N;(N=window.window)==null||N.addEventListener("error",e=>{var t,r,n,o,i,a,s;try{let p={error:(n=(r=(t=e.error)==null?void 0:t.message)!=null?r:e.message)!=null?n:null,file:e.filename,line:(o=e.lineno)!=null?o:0,column:(i=e.colno)!=null?i:0,stack:(s=(a=e.error)==null?void 0:a.stack)!=null?s:null};fetch("/data/Logger/LogError",{body:JSON.stringify(p),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(p){}});function R(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var I=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,r){return r?["common",t].join("."):R(t)}get(t,r,n){let o=this.getLocalStorageKey(t,n),i=localStorage.getItem(o);return i!==null?JSON.parse(i):r}set(t,r,n){localStorage.setItem(this.getLocalStorageKey(t,n),JSON.stringify(r))}remove(t,r){let n=this.getLocalStorageKey(t,r);return localStorage.getItem(n)!==null?(localStorage.removeItem(n),!0):!1}clear(){let t=R("");for(let r in localStorage)r.slice(0,t.length)===t&&localStorage.removeItem(r)}},Z=new I;function X(e){return e?$(e).substring(0,10):null}function m(e){return String(e).padStart(2,"0")}function $(e){return e?`${e.getFullYear()}-${m(e.getMonth()+1)}-${m(e.getDate())}T${m(e.getHours())}:${m(e.getMinutes())}:${m(e.getSeconds())}.${m(e.getMilliseconds())}`:null}function z(e,t){return new Promise(function(r,n){try{let o=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=o,i.append(a),a.click(),i.removeChild(a),setTimeout(function(){URL.revokeObjectURL(o),r()},250)}catch(o){n(o)}})}function u(e,t){if(e)return;let r=typeof t=="function"?t():t;throw new Error(r!=null?r:"Invariant failed")}async function Y(e,{fileName:t,signal:r,onProgress:n}){var a;function o(s){typeof n=="function"&&n(v({},s))}let i=0;o({status:"requested"});try{let s=await fetch(e);if(!s.ok||!s.body){if((a=s.headers.get("content-type"))!=null&&a.includes("application/json")){let d=await s.json();u(!d.error,d.error)}throw new Error(`${s.status} ${s.statusText}`)}try{let d=s.body.getReader(),w=new ReadableStream({start:function(y){function c(){return d.read().then(function(h){if(h.done){y.close();return}return i+=h.value.length,o({bytesReceived:i,status:"downloading"}),y.enqueue(h.value),c()})}return c()}});s=new Response(w)}catch(d){}let p=await s.blob();o({bytesReceived:i,status:"downloaded"}),await z(p,t),o({bytesReceived:i,status:"completed"})}catch(s){r!=null&&r.aborted?o({status:"cancelled"}):o({error:s.message,status:"error"})}}function b(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var W=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function E(e){var t=e.toString().match(W);return u(t,"Unable to parse function!"),{name:t[1],args:t[2].split(","),body:t[3]}}function C(){}C.prototype=Object.create(null);var H=C;function T(e,t){if(typeof e=="object"){if(typeof t=="string"){let r=t.split(".");return T(e,r)}else if(Array.isArray(t)){let r=e;for(let n=0;n<t.length;n++)r=r[t[n]]=r[t[n]]||new H;return r}}}function P(e,t,r={}){if(Array.isArray(t))for(let n of t){let{name:o}=E(n);u(o,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),P(e,n)}else{let n,o;if(typeof t=="function"&&(n=E(t).name),typeof e=="string"){let i=e.split(".");n||(n=i[i.length-1],i=i.slice(0,i.length-1)),o=T(window,i)}else n&&(typeof e=="object"||typeof e=="function")?o=e:u(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");b(o,n)&&(r==null?void 0:r.overwrite)!==!0?console.warn([e,n].join(".")+" is already defined!"):o[n]=t}}var G={xs:64,sm:128,md:256,lg:512,xl:void 0};function U(e,t,r,n="xs"){if(e&&typeof e=="object")return U(e.primKey,e.login,e.hash,e.size);if(!e||!r)return"";let o=G[n];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t!=null?t:"")}${t?".":""}${encodeURIComponent(r)}.jpg${o?`?width=${o}`:""}`}async function Q(e){try{let t=await fetch(`/api/user/localize/new/${af.article.id}`,{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function f(e,t){var r;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((r=af==null?void 0:af.article)==null?void 0:r.i18n)!==void 0){if(!b(af.article.i18n,e)){af.article.i18n[e]=e;let n=Q(e).then(o=>(af.article.i18n[e]=o,o));if(t)return n}return af.article.i18n[e]}else return e}function ee(e,...t){u(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let r=e.map((o,i)=>i===e.length-1?o:`${o}$${i}`).join(""),n=f(r);return t.forEach((o,i)=>{n=n.replace("$"+i,o)}),n}async function M(e,t,r=0){var n;try{let o=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:r,action:e,parameters:t}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!o.ok)if((n=o.headers.get("Content-Type"))!=null&&n.includes("application/json")){let i=await o.json();console.error(i.error)}else console.error(`${o.status} ${o.statusText}`)}catch(o){}}function te(e,t){let r=performance.now();return()=>M(e,t,performance.now()-r)}function q(e){return`${e||af.article.id}.${af.userSession.login}`}function re(e,t){if(!(af!=null&&af.userSession))return null;let r=q(t),n=JSON.parse(localStorage.getItem(r)||"{}");return e?n[e]||null:n}function ne(e,t,r){if(!(af!=null&&af.userSession))return;let n=q(r),o=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?o[e]=t:o=e,localStorage.setItem(n,JSON.stringify(o))}var oe=`
|
|
2
2
|
<dialog class="alert-dialog">
|
|
3
3
|
<form method="dialog">
|
|
4
4
|
<article></article>
|
|
@@ -7,5 +7,5 @@ var _=Object.defineProperty;var T=Object.getOwnPropertySymbols;var k=Object.prot
|
|
|
7
7
|
</footer>
|
|
8
8
|
</form>
|
|
9
9
|
</dialog>
|
|
10
|
-
`;if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=
|
|
10
|
+
`;if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=oe,document.body.append(e)}function _(e){return new Promise(t=>{e.addEventListener("close",t,{once:!0})})}var S=new Map;async function O({buttons:e,content:t,className:r,id:n,title:o}){var w,y;if(n&&S.has(n))return await S.get(n);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(w=i.content.firstElementChild)==null?void 0:w.cloneNode(!0),s=a==null?void 0:a.querySelector("article"),p=a==null?void 0:a.querySelector("footer menu");if(!a||!s||!p)throw Error("Invalid alert dialog template");if(r&&r.split(/\s+/).forEach(c=>a==null?void 0:a.classList.add(c)),o){let c=document.createElement("header");c.append(o),(y=s.parentNode)==null||y.insertBefore(c,s)}s.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:c,value:h,primary:B}of e){let F=document.createElement("li"),x=document.createElement("button");x.value=h,B&&x.classList.add("primary"),x.textContent=c,F.appendChild(x),p.appendChild(x)}document.body.appendChild(a),a.showModal();let d=_(a).then(()=>{n&&S.has(n)&&S.delete(n)}).then(()=>{let c=(a==null?void 0:a.returnValue)||"cancel";return a&&document.body.removeChild(a),c});return n&&S.set(n,d),await d}var k=(r=>(r[r.YesNo=0]="YesNo",r[r.OkCancel=1]="OkCancel",r))(k||{});async function ie(e,t={}){let{buttons:r=0,title:n}=t,o=r===1?[{label:f("OK"),value:"yes",primary:!0},{label:f("Cancel"),value:"no"}]:[{label:f("Yes"),value:"yes",primary:!0},{label:f("No"),value:"no"}];return await O({content:e,buttons:o,className:"alert-dialog-confirm",title:n})==="yes"}async function ae(e,t={}){await O(v({content:e,className:"alert-dialog-alert",buttons:[{label:f("OK"),value:"ok",primary:!0}]},t))}var We="2.7.3";export{k as ConfirmButtons,g as SessionHandler,D as UserSession,ae as alert,ie as confirm,z as downloadBlob,Y as downloadRequest,P as expose,f as getLocalizedString,re as getSettings,U as getUserImage,b as has,u as invariant,Z as localStorage,ee as localize,M as logActivity,L as mitt,O as openAlertDialog,ne as saveSettings,te as startActivity,X as toLocalISODate,$ as toLocalISODateTime,We as version,_ as waitForDialog};
|
|
11
11
|
//# sourceMappingURL=af.common.legacy.min.js.map
|