@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/iife/af.common.js
CHANGED
|
@@ -184,6 +184,43 @@ var af;
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
+
// src/localStorage.ts
|
|
188
|
+
function getLocalKey(key) {
|
|
189
|
+
return [af?.article?.id || "", "common", key].join(".");
|
|
190
|
+
}
|
|
191
|
+
var LocalStorage = class {
|
|
192
|
+
isPersisted = () => true;
|
|
193
|
+
getLocalStorageKey(key, global) {
|
|
194
|
+
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
195
|
+
}
|
|
196
|
+
get(key, defaultValue, global) {
|
|
197
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
198
|
+
const value = localStorage.getItem(lsKey);
|
|
199
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
200
|
+
}
|
|
201
|
+
set(key, value, global) {
|
|
202
|
+
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
203
|
+
}
|
|
204
|
+
remove(key, global) {
|
|
205
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
206
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
207
|
+
localStorage.removeItem(lsKey);
|
|
208
|
+
return true;
|
|
209
|
+
} else {
|
|
210
|
+
return false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
clear() {
|
|
214
|
+
const baseKey = getLocalKey("");
|
|
215
|
+
for (let key in localStorage) {
|
|
216
|
+
if (key.slice(0, baseKey.length) === baseKey) {
|
|
217
|
+
localStorage.removeItem(key);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
var localStorage_default = new LocalStorage();
|
|
223
|
+
|
|
187
224
|
// src/date.ts
|
|
188
225
|
function toLocalISODate(date) {
|
|
189
226
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
@@ -429,45 +466,6 @@ var af;
|
|
|
429
466
|
return localized;
|
|
430
467
|
}
|
|
431
468
|
|
|
432
|
-
// src/localStorage.ts
|
|
433
|
-
function getLocalKey(key) {
|
|
434
|
-
return [af?.article?.id || "", "common", key].join(".");
|
|
435
|
-
}
|
|
436
|
-
var LocalStorage = class {
|
|
437
|
-
isPersisted() {
|
|
438
|
-
return true;
|
|
439
|
-
}
|
|
440
|
-
getLocalStorageKey(key, global) {
|
|
441
|
-
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
442
|
-
}
|
|
443
|
-
get(key, defaultValue, global) {
|
|
444
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
445
|
-
const value = localStorage.getItem(lsKey);
|
|
446
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
447
|
-
}
|
|
448
|
-
set(key, value, global) {
|
|
449
|
-
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
450
|
-
}
|
|
451
|
-
remove(key, global) {
|
|
452
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
453
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
454
|
-
localStorage.removeItem(lsKey);
|
|
455
|
-
return true;
|
|
456
|
-
} else {
|
|
457
|
-
return false;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
clear() {
|
|
461
|
-
const baseKey = getLocalKey("");
|
|
462
|
-
for (let key in localStorage) {
|
|
463
|
-
if (key.slice(0, baseKey.length) === baseKey) {
|
|
464
|
-
localStorage.removeItem(key);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
};
|
|
469
|
-
var localStorage_default = new LocalStorage();
|
|
470
|
-
|
|
471
469
|
// src/logActivity.ts
|
|
472
470
|
async function logActivity(activity, parameters, timeElapsed = 0) {
|
|
473
471
|
try {
|
|
@@ -547,7 +545,11 @@ var af;
|
|
|
547
545
|
dialog.addEventListener("close", resolve, { once: true });
|
|
548
546
|
});
|
|
549
547
|
}
|
|
550
|
-
|
|
548
|
+
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
549
|
+
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
550
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
551
|
+
return await alertDialogPromiseMap.get(id);
|
|
552
|
+
}
|
|
551
553
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
552
554
|
if (!$template)
|
|
553
555
|
throw Error("No alert dialog template found");
|
|
@@ -557,7 +559,12 @@ var af;
|
|
|
557
559
|
if (!$dialog || !$content || !$menu)
|
|
558
560
|
throw Error("Invalid alert dialog template");
|
|
559
561
|
if (className) {
|
|
560
|
-
$dialog
|
|
562
|
+
className.split(/\s+/).forEach((className2) => $dialog?.classList.add(className2));
|
|
563
|
+
}
|
|
564
|
+
if (title) {
|
|
565
|
+
let $header = document.createElement("header");
|
|
566
|
+
$header.append(title);
|
|
567
|
+
$content.parentNode?.insertBefore($header, $content);
|
|
561
568
|
}
|
|
562
569
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
563
570
|
for (let { label, value, primary } of buttons) {
|
|
@@ -573,39 +580,48 @@ var af;
|
|
|
573
580
|
}
|
|
574
581
|
document.body.appendChild($dialog);
|
|
575
582
|
$dialog.showModal();
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
583
|
+
let dialogPromise = waitForDialog($dialog).then(() => {
|
|
584
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
585
|
+
alertDialogPromiseMap.delete(id);
|
|
586
|
+
}
|
|
587
|
+
}).then(() => {
|
|
588
|
+
let result = $dialog?.returnValue || "cancel";
|
|
589
|
+
if ($dialog)
|
|
590
|
+
document.body.removeChild($dialog);
|
|
591
|
+
return result;
|
|
592
|
+
});
|
|
593
|
+
if (id) {
|
|
594
|
+
alertDialogPromiseMap.set(id, dialogPromise);
|
|
595
|
+
}
|
|
596
|
+
return await dialogPromise;
|
|
580
597
|
}
|
|
581
598
|
var ConfirmButtons = /* @__PURE__ */ ((ConfirmButtons2) => {
|
|
582
599
|
ConfirmButtons2[ConfirmButtons2["YesNo"] = 0] = "YesNo";
|
|
583
600
|
ConfirmButtons2[ConfirmButtons2["OkCancel"] = 1] = "OkCancel";
|
|
584
601
|
return ConfirmButtons2;
|
|
585
602
|
})(ConfirmButtons || {});
|
|
586
|
-
async function confirm(prompt,
|
|
587
|
-
let buttons =
|
|
603
|
+
async function confirm(prompt, options = {}) {
|
|
604
|
+
let { buttons: optionButtons = 0 /* YesNo */, title } = options;
|
|
605
|
+
let buttons = optionButtons === 1 /* OkCancel */ ? [
|
|
606
|
+
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
607
|
+
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
608
|
+
] : [
|
|
588
609
|
{ label: getLocalizedString("Yes"), value: "yes", primary: true },
|
|
589
610
|
{ label: getLocalizedString("No"), value: "no" }
|
|
590
611
|
];
|
|
591
|
-
|
|
592
|
-
buttons = [
|
|
593
|
-
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
594
|
-
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
595
|
-
];
|
|
596
|
-
}
|
|
597
|
-
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm" });
|
|
612
|
+
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm", title });
|
|
598
613
|
return result === "yes";
|
|
599
614
|
}
|
|
600
|
-
async function alert(prompt) {
|
|
615
|
+
async function alert(prompt, options = {}) {
|
|
601
616
|
await openAlertDialog({
|
|
602
617
|
content: prompt,
|
|
603
618
|
className: "alert-dialog-alert",
|
|
604
|
-
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
|
|
619
|
+
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }],
|
|
620
|
+
...options
|
|
605
621
|
});
|
|
606
622
|
}
|
|
607
623
|
|
|
608
624
|
// src/index.ts
|
|
609
|
-
var version = "2.7.
|
|
625
|
+
var version = "2.7.3";
|
|
610
626
|
return __toCommonJS(src_exports);
|
|
611
627
|
})();
|
|
@@ -206,6 +206,46 @@ af.common = (() => {
|
|
|
206
206
|
});
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
+
// src/localStorage.ts
|
|
210
|
+
function getLocalKey(key) {
|
|
211
|
+
var _a2;
|
|
212
|
+
return [((_a2 = af == null ? void 0 : af.article) == null ? void 0 : _a2.id) || "", "common", key].join(".");
|
|
213
|
+
}
|
|
214
|
+
var LocalStorage = class {
|
|
215
|
+
constructor() {
|
|
216
|
+
__publicField(this, "isPersisted", () => true);
|
|
217
|
+
}
|
|
218
|
+
getLocalStorageKey(key, global) {
|
|
219
|
+
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
220
|
+
}
|
|
221
|
+
get(key, defaultValue, global) {
|
|
222
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
223
|
+
const value = localStorage.getItem(lsKey);
|
|
224
|
+
return value !== null ? JSON.parse(value) : defaultValue;
|
|
225
|
+
}
|
|
226
|
+
set(key, value, global) {
|
|
227
|
+
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
228
|
+
}
|
|
229
|
+
remove(key, global) {
|
|
230
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
231
|
+
if (localStorage.getItem(lsKey) !== null) {
|
|
232
|
+
localStorage.removeItem(lsKey);
|
|
233
|
+
return true;
|
|
234
|
+
} else {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
clear() {
|
|
239
|
+
const baseKey = getLocalKey("");
|
|
240
|
+
for (let key in localStorage) {
|
|
241
|
+
if (key.slice(0, baseKey.length) === baseKey) {
|
|
242
|
+
localStorage.removeItem(key);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
var localStorage_default = new LocalStorage();
|
|
248
|
+
|
|
209
249
|
// src/date.ts
|
|
210
250
|
function toLocalISODate(date) {
|
|
211
251
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
@@ -453,46 +493,6 @@ af.common = (() => {
|
|
|
453
493
|
return localized;
|
|
454
494
|
}
|
|
455
495
|
|
|
456
|
-
// src/localStorage.ts
|
|
457
|
-
function getLocalKey(key) {
|
|
458
|
-
var _a2;
|
|
459
|
-
return [((_a2 = af == null ? void 0 : af.article) == null ? void 0 : _a2.id) || "", "common", key].join(".");
|
|
460
|
-
}
|
|
461
|
-
var LocalStorage = class {
|
|
462
|
-
isPersisted() {
|
|
463
|
-
return true;
|
|
464
|
-
}
|
|
465
|
-
getLocalStorageKey(key, global) {
|
|
466
|
-
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
467
|
-
}
|
|
468
|
-
get(key, defaultValue, global) {
|
|
469
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
470
|
-
const value = localStorage.getItem(lsKey);
|
|
471
|
-
return value !== null ? JSON.parse(value) : defaultValue;
|
|
472
|
-
}
|
|
473
|
-
set(key, value, global) {
|
|
474
|
-
localStorage.setItem(this.getLocalStorageKey(key, global), JSON.stringify(value));
|
|
475
|
-
}
|
|
476
|
-
remove(key, global) {
|
|
477
|
-
const lsKey = this.getLocalStorageKey(key, global);
|
|
478
|
-
if (localStorage.getItem(lsKey) !== null) {
|
|
479
|
-
localStorage.removeItem(lsKey);
|
|
480
|
-
return true;
|
|
481
|
-
} else {
|
|
482
|
-
return false;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
clear() {
|
|
486
|
-
const baseKey = getLocalKey("");
|
|
487
|
-
for (let key in localStorage) {
|
|
488
|
-
if (key.slice(0, baseKey.length) === baseKey) {
|
|
489
|
-
localStorage.removeItem(key);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
};
|
|
494
|
-
var localStorage_default = new LocalStorage();
|
|
495
|
-
|
|
496
496
|
// src/logActivity.ts
|
|
497
497
|
async function logActivity(activity, parameters, timeElapsed = 0) {
|
|
498
498
|
var _a2;
|
|
@@ -573,8 +573,12 @@ af.common = (() => {
|
|
|
573
573
|
dialog.addEventListener("close", resolve, { once: true });
|
|
574
574
|
});
|
|
575
575
|
}
|
|
576
|
-
|
|
577
|
-
|
|
576
|
+
var alertDialogPromiseMap = /* @__PURE__ */ new Map();
|
|
577
|
+
async function openAlertDialog({ buttons, content, className, id, title }) {
|
|
578
|
+
var _a2, _b;
|
|
579
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
580
|
+
return await alertDialogPromiseMap.get(id);
|
|
581
|
+
}
|
|
578
582
|
let $template = document.querySelector("#AlertDialogTemplate");
|
|
579
583
|
if (!$template)
|
|
580
584
|
throw Error("No alert dialog template found");
|
|
@@ -584,7 +588,12 @@ af.common = (() => {
|
|
|
584
588
|
if (!$dialog || !$content || !$menu)
|
|
585
589
|
throw Error("Invalid alert dialog template");
|
|
586
590
|
if (className) {
|
|
587
|
-
$dialog.classList.add(
|
|
591
|
+
className.split(/\s+/).forEach((className2) => $dialog == null ? void 0 : $dialog.classList.add(className2));
|
|
592
|
+
}
|
|
593
|
+
if (title) {
|
|
594
|
+
let $header = document.createElement("header");
|
|
595
|
+
$header.append(title);
|
|
596
|
+
(_b = $content.parentNode) == null ? void 0 : _b.insertBefore($header, $content);
|
|
588
597
|
}
|
|
589
598
|
$content.appendChild(typeof content === "string" ? document.createTextNode(content) : content);
|
|
590
599
|
for (let { label, value, primary } of buttons) {
|
|
@@ -600,39 +609,47 @@ af.common = (() => {
|
|
|
600
609
|
}
|
|
601
610
|
document.body.appendChild($dialog);
|
|
602
611
|
$dialog.showModal();
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
612
|
+
let dialogPromise = waitForDialog($dialog).then(() => {
|
|
613
|
+
if (id && alertDialogPromiseMap.has(id)) {
|
|
614
|
+
alertDialogPromiseMap.delete(id);
|
|
615
|
+
}
|
|
616
|
+
}).then(() => {
|
|
617
|
+
let result = ($dialog == null ? void 0 : $dialog.returnValue) || "cancel";
|
|
618
|
+
if ($dialog)
|
|
619
|
+
document.body.removeChild($dialog);
|
|
620
|
+
return result;
|
|
621
|
+
});
|
|
622
|
+
if (id) {
|
|
623
|
+
alertDialogPromiseMap.set(id, dialogPromise);
|
|
624
|
+
}
|
|
625
|
+
return await dialogPromise;
|
|
607
626
|
}
|
|
608
627
|
var ConfirmButtons = /* @__PURE__ */ ((ConfirmButtons2) => {
|
|
609
628
|
ConfirmButtons2[ConfirmButtons2["YesNo"] = 0] = "YesNo";
|
|
610
629
|
ConfirmButtons2[ConfirmButtons2["OkCancel"] = 1] = "OkCancel";
|
|
611
630
|
return ConfirmButtons2;
|
|
612
631
|
})(ConfirmButtons || {});
|
|
613
|
-
async function confirm(prompt,
|
|
614
|
-
let buttons =
|
|
632
|
+
async function confirm(prompt, options = {}) {
|
|
633
|
+
let { buttons: optionButtons = 0 /* YesNo */, title } = options;
|
|
634
|
+
let buttons = optionButtons === 1 /* OkCancel */ ? [
|
|
635
|
+
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
636
|
+
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
637
|
+
] : [
|
|
615
638
|
{ label: getLocalizedString("Yes"), value: "yes", primary: true },
|
|
616
639
|
{ label: getLocalizedString("No"), value: "no" }
|
|
617
640
|
];
|
|
618
|
-
|
|
619
|
-
buttons = [
|
|
620
|
-
{ label: getLocalizedString("OK"), value: "yes", primary: true },
|
|
621
|
-
{ label: getLocalizedString("Cancel"), value: "no" }
|
|
622
|
-
];
|
|
623
|
-
}
|
|
624
|
-
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm" });
|
|
641
|
+
let result = await openAlertDialog({ content: prompt, buttons, className: "alert-dialog-confirm", title });
|
|
625
642
|
return result === "yes";
|
|
626
643
|
}
|
|
627
|
-
async function alert(prompt) {
|
|
628
|
-
await openAlertDialog({
|
|
644
|
+
async function alert(prompt, options = {}) {
|
|
645
|
+
await openAlertDialog(__spreadValues({
|
|
629
646
|
content: prompt,
|
|
630
647
|
className: "alert-dialog-alert",
|
|
631
648
|
buttons: [{ label: getLocalizedString("OK"), value: "ok", primary: true }]
|
|
632
|
-
});
|
|
649
|
+
}, options));
|
|
633
650
|
}
|
|
634
651
|
|
|
635
652
|
// src/index.ts
|
|
636
|
-
var version = "2.7.
|
|
653
|
+
var version = "2.7.3";
|
|
637
654
|
return __toCommonJS(src_exports);
|
|
638
655
|
})();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var af=af||{};af.common=(()=>{var
|
|
1
|
+
var af=af||{};af.common=(()=>{var v=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames,U=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable;var E=(e,t,r)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,A=(e,t)=>{for(var r in t||(t={}))M.call(t,r)&&E(e,r,t[r]);if(U)for(var r of U(t))oe.call(t,r)&&E(e,r,t[r]);return e};var ie=(e,t)=>{for(var r in t)v(e,r,{get:t[r],enumerable:!0})},ae=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ne(t))!M.call(e,o)&&o!==r&&v(e,o,{get:()=>t[o],enumerable:!(n=re(t,o))||n.enumerable});return e};var le=e=>ae(v({},"__esModule",{value:!0}),e);var l=(e,t,r)=>(E(e,typeof t!="symbol"?t+"":t,r),r);var pe={};ie(pe,{ConfirmButtons:()=>P,SessionHandler:()=>g,UserSession:()=>D,alert:()=>Q,confirm:()=>G,downloadBlob:()=>I,downloadRequest:()=>F,expose:()=>R,getLocalizedString:()=>f,getSettings:()=>Y,getUserImage:()=>$,has:()=>y,invariant:()=>u,localStorage:()=>k,localize:()=>V,logActivity:()=>C,mitt:()=>L,openAlertDialog:()=>z,saveSettings:()=>W,startActivity:()=>Z,toLocalISODate:()=>B,toLocalISODateTime:()=>O,version:()=>de,waitForDialog:()=>H});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 q;(q=window.window)==null||q.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 _(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var T=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,r){return r?["common",t].join("."):_(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=_("");for(let r in localStorage)r.slice(0,t.length)===t&&localStorage.removeItem(r)}},k=new T;function B(e){return e?O(e).substring(0,10):null}function m(e){return String(e).padStart(2,"0")}function O(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 I(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 F(e,{fileName:t,signal:r,onProgress:n}){var a;function o(s){typeof n=="function"&&n(A({},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(h){function c(){return d.read().then(function(x){if(x.done){h.close();return}return i+=x.value.length,o({bytesReceived:i,status:"downloading"}),h.enqueue(x.value),c()})}return c()}});s=new Response(w)}catch(d){}let p=await s.blob();o({bytesReceived:i,status:"downloaded"}),await I(p,t),o({bytesReceived:i,status:"completed"})}catch(s){r!=null&&r.aborted?o({status:"cancelled"}):o({error:s.message,status:"error"})}}function y(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var se=/^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 j(e){var t=e.toString().match(se);return u(t,"Unable to parse function!"),{name:t[1],args:t[2].split(","),body:t[3]}}function K(){}K.prototype=Object.create(null);var J=K;function N(e,t){if(typeof e=="object"){if(typeof t=="string"){let r=t.split(".");return N(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 J;return r}}}function R(e,t,r={}){if(Array.isArray(t))for(let n of t){let{name:o}=j(n);u(o,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),R(e,n)}else{let n,o;if(typeof t=="function"&&(n=j(t).name),typeof e=="string"){let i=e.split(".");n||(n=i[i.length-1],i=i.slice(0,i.length-1)),o=N(window,i)}else n&&(typeof e=="object"||typeof e=="function")?o=e:u(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");y(o,n)&&(r==null?void 0:r.overwrite)!==!0?console.warn([e,n].join(".")+" is already defined!"):o[n]=t}}var ce={xs:64,sm:128,md:256,lg:512,xl:void 0};function $(e,t,r,n="xs"){if(e&&typeof e=="object")return $(e.primKey,e.login,e.hash,e.size);if(!e||!r)return"";let o=ce[n];return`/api/data/blob/EmployeesLookup/${e}/Image/${encodeURIComponent(t!=null?t:"")}${t?".":""}${encodeURIComponent(r)}.jpg${o?`?width=${o}`:""}`}async function ue(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(!y(af.article.i18n,e)){af.article.i18n[e]=e;let n=ue(e).then(o=>(af.article.i18n[e]=o,o));if(t)return n}return af.article.i18n[e]}else return e}function V(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 C(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 Z(e,t){let r=performance.now();return()=>C(e,t,performance.now()-r)}function X(e){return`${e||af.article.id}.${af.userSession.login}`}function Y(e,t){if(!(af!=null&&af.userSession))return null;let r=X(t),n=JSON.parse(localStorage.getItem(r)||"{}");return e?n[e]||null:n}function W(e,t,r){if(!(af!=null&&af.userSession))return;let n=X(r),o=JSON.parse(localStorage.getItem(n)||"{}");typeof t<"u"?o[e]=t:o=e,localStorage.setItem(n,JSON.stringify(o))}var fe=`
|
|
2
2
|
<dialog class="alert-dialog">
|
|
3
3
|
<form method="dialog">
|
|
4
4
|
<article></article>
|
|
@@ -7,5 +7,5 @@ var af=af||{};af.common=(()=>{var b=Object.defineProperty;var G=Object.getOwnPro
|
|
|
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=fe,document.body.append(e)}function H(e){return new Promise(t=>{e.addEventListener("close",t,{once:!0})})}var S=new Map;async function z({buttons:e,content:t,className:r,id:n,title:o}){var w,h;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),(h=s.parentNode)==null||h.insertBefore(c,s)}s.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:c,value:x,primary:ee}of e){let te=document.createElement("li"),b=document.createElement("button");b.value=x,ee&&b.classList.add("primary"),b.textContent=c,te.appendChild(b),p.appendChild(b)}document.body.appendChild(a),a.showModal();let d=H(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 P=(r=>(r[r.YesNo=0]="YesNo",r[r.OkCancel=1]="OkCancel",r))(P||{});async function G(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 z({content:e,buttons:o,className:"alert-dialog-confirm",title:n})==="yes"}async function Q(e,t={}){await z(A({content:e,className:"alert-dialog-alert",buttons:[{label:f("OK"),value:"ok",primary:!0}]},t))}var de="2.7.3";return le(pe);})();
|
|
11
11
|
//# sourceMappingURL=af.common.legacy.min.js.map
|