@apia/execution 4.0.44 → 5.0.0
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/index.d.ts +100 -491
- package/dist/index.js +420 -1818
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/dist/index.js
CHANGED
|
@@ -4,13 +4,49 @@ import xml2js from 'xml2js';
|
|
|
4
4
|
import he from 'he';
|
|
5
5
|
import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
|
|
6
6
|
import QueryString from 'qs';
|
|
7
|
-
import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl,
|
|
7
|
+
import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, shallowEqual as shallowEqual$1, Mutex, noNaN as noNaN$1, getDateFormat, decodeBase64ToUtf8 as decodeBase64ToUtf8$1, encodeStrToBase64Utf8, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
|
|
8
8
|
import { Cell, TableController, Row, FocusControllerPlugin } from '@apia/table2-controller';
|
|
9
|
+
import { UploaderApi as UploaderApi$1, parseFileDefinition } from '@apia/uploader-controller';
|
|
9
10
|
import dayjs from 'dayjs';
|
|
10
11
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
11
12
|
import { MobXTree } from '@apia/tree2-controller';
|
|
12
13
|
import { Scheduler } from '@apia/scheduler-controller';
|
|
13
|
-
|
|
14
|
+
|
|
15
|
+
var __defProp$s = Object.defineProperty;
|
|
16
|
+
var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __publicField$s = (obj, key, value) => {
|
|
18
|
+
__defNormalProp$s(obj, key + "" , value);
|
|
19
|
+
return value;
|
|
20
|
+
};
|
|
21
|
+
class Notification {
|
|
22
|
+
constructor(props) {
|
|
23
|
+
this.props = props;
|
|
24
|
+
__publicField$s(this, "state");
|
|
25
|
+
this.state = props;
|
|
26
|
+
makeObservable(this, { state: observable });
|
|
27
|
+
}
|
|
28
|
+
get icon() {
|
|
29
|
+
return this.state.icon;
|
|
30
|
+
}
|
|
31
|
+
get id() {
|
|
32
|
+
return this.state.id;
|
|
33
|
+
}
|
|
34
|
+
get isOpen() {
|
|
35
|
+
return this.state.isOpen;
|
|
36
|
+
}
|
|
37
|
+
get message() {
|
|
38
|
+
return this.state.message;
|
|
39
|
+
}
|
|
40
|
+
get stackTrace() {
|
|
41
|
+
return this.state.stackTrace;
|
|
42
|
+
}
|
|
43
|
+
get title() {
|
|
44
|
+
return this.state.title;
|
|
45
|
+
}
|
|
46
|
+
get type() {
|
|
47
|
+
return this.state.type;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
14
50
|
|
|
15
51
|
const deepEqual = (a, b) => {
|
|
16
52
|
if (Object.is(a, b))
|
|
@@ -48,42 +84,6 @@ const deepEqual = (a, b) => {
|
|
|
48
84
|
return a === b;
|
|
49
85
|
};
|
|
50
86
|
|
|
51
|
-
var __defProp$t = Object.defineProperty;
|
|
52
|
-
var __defNormalProp$t = (obj, key, value) => key in obj ? __defProp$t(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
53
|
-
var __publicField$t = (obj, key, value) => {
|
|
54
|
-
__defNormalProp$t(obj, key + "" , value);
|
|
55
|
-
return value;
|
|
56
|
-
};
|
|
57
|
-
class Notification {
|
|
58
|
-
constructor(props) {
|
|
59
|
-
this.props = props;
|
|
60
|
-
__publicField$t(this, "state");
|
|
61
|
-
this.state = props;
|
|
62
|
-
makeObservable(this, { state: observable });
|
|
63
|
-
}
|
|
64
|
-
get icon() {
|
|
65
|
-
return this.state.icon;
|
|
66
|
-
}
|
|
67
|
-
get id() {
|
|
68
|
-
return this.state.id;
|
|
69
|
-
}
|
|
70
|
-
get isOpen() {
|
|
71
|
-
return this.state.isOpen;
|
|
72
|
-
}
|
|
73
|
-
get message() {
|
|
74
|
-
return this.state.message;
|
|
75
|
-
}
|
|
76
|
-
get stackTrace() {
|
|
77
|
-
return this.state.stackTrace;
|
|
78
|
-
}
|
|
79
|
-
get title() {
|
|
80
|
-
return this.state.title;
|
|
81
|
-
}
|
|
82
|
-
get type() {
|
|
83
|
-
return this.state.type;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
87
|
class MessageNotification extends Notification {
|
|
88
88
|
close() {
|
|
89
89
|
this.state.isOpen = false;
|
|
@@ -456,7 +456,7 @@ function getDefaultXmlParser(behaveConfig) {
|
|
|
456
456
|
};
|
|
457
457
|
}
|
|
458
458
|
const parseXml = (xml, behaveConfig) => {
|
|
459
|
-
if (typeof xml === "object"
|
|
459
|
+
if (typeof xml === "object") {
|
|
460
460
|
return xml;
|
|
461
461
|
}
|
|
462
462
|
const parser = behaveConfig?.xmlParser ?? getDefaultXmlParser();
|
|
@@ -479,7 +479,7 @@ var ExecutionState = /* @__PURE__ */ ((ExecutionState2) => {
|
|
|
479
479
|
|
|
480
480
|
function dispatchMessage(execution, type, message) {
|
|
481
481
|
const definedType = message.type;
|
|
482
|
-
const actualType = [null, "success", "warning", "error"][definedType || 0];
|
|
482
|
+
const actualType = [null, "success", "warning", "error", "modal"][definedType || 0];
|
|
483
483
|
execution.notifications.add(
|
|
484
484
|
new MessageNotification({
|
|
485
485
|
message: message.text,
|
|
@@ -710,20 +710,20 @@ function makeApiaUrl(execution, props) {
|
|
|
710
710
|
return `${contextWord ? "/" : ""}${contextWord}/${actualAjaxUrl}?${timestamp}${!props?.preventAsXmlParameter ? "asXml=true&" : ""}${props?.queryString ? `${props.queryString}&` : ""}${queryString ? `${queryString}&` : ""}${tabId}`;
|
|
711
711
|
}
|
|
712
712
|
|
|
713
|
-
var __defProp$
|
|
714
|
-
var __defNormalProp$
|
|
715
|
-
var __publicField$
|
|
716
|
-
__defNormalProp$
|
|
713
|
+
var __defProp$r = Object.defineProperty;
|
|
714
|
+
var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
715
|
+
var __publicField$r = (obj, key, value) => {
|
|
716
|
+
__defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
717
717
|
return value;
|
|
718
718
|
};
|
|
719
719
|
class EventEmitter {
|
|
720
720
|
constructor() {
|
|
721
|
-
__publicField$
|
|
721
|
+
__publicField$r(this, "callbacks", {
|
|
722
722
|
on: {},
|
|
723
723
|
once: {}
|
|
724
724
|
});
|
|
725
|
-
__publicField$
|
|
726
|
-
__publicField$
|
|
725
|
+
__publicField$r(this, "enabled", true);
|
|
726
|
+
__publicField$r(this, "debugMode", false);
|
|
727
727
|
}
|
|
728
728
|
debug(enable = true) {
|
|
729
729
|
this.debugMode = enable;
|
|
@@ -789,10 +789,10 @@ class EventEmitter {
|
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
791
|
|
|
792
|
-
var __defProp$
|
|
793
|
-
var __defNormalProp$
|
|
794
|
-
var __publicField$
|
|
795
|
-
__defNormalProp$
|
|
792
|
+
var __defProp$q = Object.defineProperty;
|
|
793
|
+
var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
794
|
+
var __publicField$q = (obj, key, value) => {
|
|
795
|
+
__defNormalProp$q(obj, key + "" , value);
|
|
796
796
|
return value;
|
|
797
797
|
};
|
|
798
798
|
function isSetter(data) {
|
|
@@ -801,7 +801,7 @@ function isSetter(data) {
|
|
|
801
801
|
class StatefulEmitter extends EventEmitter {
|
|
802
802
|
constructor(initialState) {
|
|
803
803
|
super();
|
|
804
|
-
__publicField$
|
|
804
|
+
__publicField$q(this, "state", {});
|
|
805
805
|
this.state = Object.assign({}, initialState);
|
|
806
806
|
}
|
|
807
807
|
emit(event, data) {
|
|
@@ -836,18 +836,18 @@ class StatefulEmitter extends EventEmitter {
|
|
|
836
836
|
}
|
|
837
837
|
}
|
|
838
838
|
|
|
839
|
-
var __defProp$
|
|
840
|
-
var __defNormalProp$
|
|
841
|
-
var __publicField$
|
|
842
|
-
__defNormalProp$
|
|
839
|
+
var __defProp$p = Object.defineProperty;
|
|
840
|
+
var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
841
|
+
var __publicField$p = (obj, key, value) => {
|
|
842
|
+
__defNormalProp$p(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
843
843
|
return value;
|
|
844
844
|
};
|
|
845
845
|
const NullObject = Symbol("NullObject");
|
|
846
846
|
class BouncingEmitter extends StatefulEmitter {
|
|
847
847
|
constructor() {
|
|
848
848
|
super(...arguments);
|
|
849
|
-
__publicField$
|
|
850
|
-
__publicField$
|
|
849
|
+
__publicField$p(this, "bouncingTimeouts", {});
|
|
850
|
+
__publicField$p(this, "defaultTiming", 100);
|
|
851
851
|
/**
|
|
852
852
|
* Throttles a event emit with the warranty that the data will be emitted at most every (timing)ms. Take the following event throttling, where each E is a call to this method and each character represents 20ms:
|
|
853
853
|
*
|
|
@@ -859,8 +859,8 @@ class BouncingEmitter extends StatefulEmitter {
|
|
|
859
859
|
*
|
|
860
860
|
* @param configuration.emitOnStart - Emits an event on the first call to throttle when no pending throttle is stored. **If emitOnStart is true and an only call to throttle is made, it will emit an only event.**
|
|
861
861
|
*/
|
|
862
|
-
__publicField$
|
|
863
|
-
__publicField$
|
|
862
|
+
__publicField$p(this, "throttleData", {});
|
|
863
|
+
__publicField$p(this, "throttleEmittedOnInit", {});
|
|
864
864
|
}
|
|
865
865
|
/**
|
|
866
866
|
* Debounces a event emit with until there is no call to the emit methods by (timing)ms. Take the following event throttling, where each E is a call to this method and each character represents 20ms:
|
|
@@ -990,16 +990,16 @@ function parseFakeJSON$1(str) {
|
|
|
990
990
|
return ret;
|
|
991
991
|
}
|
|
992
992
|
|
|
993
|
-
var __defProp$
|
|
994
|
-
var __defNormalProp$
|
|
995
|
-
var __publicField$
|
|
996
|
-
__defNormalProp$
|
|
993
|
+
var __defProp$o = Object.defineProperty;
|
|
994
|
+
var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
995
|
+
var __publicField$o = (obj, key, value) => {
|
|
996
|
+
__defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
997
997
|
return value;
|
|
998
998
|
};
|
|
999
999
|
class WithProperties {
|
|
1000
1000
|
constructor(initialState) {
|
|
1001
|
-
__publicField$
|
|
1002
|
-
__publicField$
|
|
1001
|
+
__publicField$o(this, "properties", {});
|
|
1002
|
+
__publicField$o(this, "parentGrid", null);
|
|
1003
1003
|
if (initialState) {
|
|
1004
1004
|
this.properties = initialState;
|
|
1005
1005
|
}
|
|
@@ -1193,10 +1193,10 @@ const asyncCreateNewField = async (execution, fld) => {
|
|
|
1193
1193
|
return creator(execution, fld);
|
|
1194
1194
|
};
|
|
1195
1195
|
|
|
1196
|
-
var __defProp$
|
|
1197
|
-
var __defNormalProp$
|
|
1198
|
-
var __publicField$
|
|
1199
|
-
__defNormalProp$
|
|
1196
|
+
var __defProp$n = Object.defineProperty;
|
|
1197
|
+
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1198
|
+
var __publicField$n = (obj, key, value) => {
|
|
1199
|
+
__defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1200
1200
|
return value;
|
|
1201
1201
|
};
|
|
1202
1202
|
var __accessCheck$l = (obj, member, msg) => {
|
|
@@ -1230,9 +1230,9 @@ async function getApiaFunctions(execution) {
|
|
|
1230
1230
|
class Field extends WithProperties {
|
|
1231
1231
|
constructor({ properties, ...definition }) {
|
|
1232
1232
|
super();
|
|
1233
|
-
__publicField$
|
|
1234
|
-
__publicField$
|
|
1235
|
-
__publicField$
|
|
1233
|
+
__publicField$n(this, "form", {});
|
|
1234
|
+
__publicField$n(this, "definition");
|
|
1235
|
+
__publicField$n(this, "state", {
|
|
1236
1236
|
validation: { dirty: false, errorMessage: "", synchronizing: false }
|
|
1237
1237
|
});
|
|
1238
1238
|
__privateAdd$l(this, _hasInited$1, false);
|
|
@@ -1302,8 +1302,15 @@ class Field extends WithProperties {
|
|
|
1302
1302
|
}).text
|
|
1303
1303
|
);
|
|
1304
1304
|
}
|
|
1305
|
+
const evtSrc = await asyncCreateNewField(
|
|
1306
|
+
this.form.execution,
|
|
1307
|
+
this
|
|
1308
|
+
);
|
|
1309
|
+
if (evtSrc.setValue) {
|
|
1310
|
+
evtSrc.setValue = (value) => evtSrc._setValue(value, { fireEvents: false });
|
|
1311
|
+
}
|
|
1305
1312
|
result = await fn(
|
|
1306
|
-
|
|
1313
|
+
evtSrc,
|
|
1307
1314
|
...await this.getScriptEventParams(event.fncParams)
|
|
1308
1315
|
);
|
|
1309
1316
|
if (result === false) {
|
|
@@ -1453,16 +1460,16 @@ class Button extends Field {
|
|
|
1453
1460
|
}
|
|
1454
1461
|
}
|
|
1455
1462
|
|
|
1456
|
-
var __defProp$
|
|
1457
|
-
var __defNormalProp$
|
|
1458
|
-
var __publicField$
|
|
1459
|
-
__defNormalProp$
|
|
1463
|
+
var __defProp$m = Object.defineProperty;
|
|
1464
|
+
var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1465
|
+
var __publicField$m = (obj, key, value) => {
|
|
1466
|
+
__defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1460
1467
|
return value;
|
|
1461
1468
|
};
|
|
1462
1469
|
const _Captcha = class _Captcha extends Field {
|
|
1463
1470
|
constructor(definition) {
|
|
1464
1471
|
super(definition);
|
|
1465
|
-
__publicField$
|
|
1472
|
+
__publicField$m(this, "id", "");
|
|
1466
1473
|
this.state.value = "";
|
|
1467
1474
|
this.properties.name = "__captcha__";
|
|
1468
1475
|
_Captcha.emitter.on("confirm", () => {
|
|
@@ -1513,8 +1520,8 @@ const _Captcha = class _Captcha extends Field {
|
|
|
1513
1520
|
}
|
|
1514
1521
|
}
|
|
1515
1522
|
};
|
|
1516
|
-
__publicField$
|
|
1517
|
-
__publicField$
|
|
1523
|
+
__publicField$m(_Captcha, "emitter", new EventEmitter$1());
|
|
1524
|
+
__publicField$m(_Captcha, "confirmParams", {});
|
|
1518
1525
|
let Captcha = _Captcha;
|
|
1519
1526
|
|
|
1520
1527
|
class TooMuchRetriesException extends Error {
|
|
@@ -1587,10 +1594,10 @@ function isFieldShowAsText(f) {
|
|
|
1587
1594
|
return isTrue(f.properties.disabled) || isTrue(f.getForm().definition.readonly) || isTrue(f.getForm().definition.readOnly) || isTrue(f.properties.inputAsText);
|
|
1588
1595
|
}
|
|
1589
1596
|
|
|
1590
|
-
var __defProp$
|
|
1591
|
-
var __defNormalProp$
|
|
1592
|
-
var __publicField$
|
|
1593
|
-
__defNormalProp$
|
|
1597
|
+
var __defProp$l = Object.defineProperty;
|
|
1598
|
+
var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1599
|
+
var __publicField$l = (obj, key, value) => {
|
|
1600
|
+
__defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1594
1601
|
return value;
|
|
1595
1602
|
};
|
|
1596
1603
|
var __accessCheck$k = (obj, member, msg) => {
|
|
@@ -1631,8 +1638,8 @@ class FieldWithAttribute extends Field {
|
|
|
1631
1638
|
}) {
|
|
1632
1639
|
super(definition);
|
|
1633
1640
|
__privateAdd$k(this, _lastOnChangeValue, null);
|
|
1634
|
-
__publicField$
|
|
1635
|
-
__publicField$
|
|
1641
|
+
__publicField$l(this, "lastSynchronizationValue", null);
|
|
1642
|
+
__publicField$l(this, "attribute");
|
|
1636
1643
|
this.attribute = new Attribute(attId, attName, attLabel, valueType);
|
|
1637
1644
|
this.state.value = value;
|
|
1638
1645
|
this.state.validation = {
|
|
@@ -1777,6 +1784,9 @@ class FieldWithAttribute extends Field {
|
|
|
1777
1784
|
return await syncPromise;
|
|
1778
1785
|
}
|
|
1779
1786
|
hasValue() {
|
|
1787
|
+
return this.getValue() !== "";
|
|
1788
|
+
}
|
|
1789
|
+
isValidValue() {
|
|
1780
1790
|
return !!this.getValue();
|
|
1781
1791
|
}
|
|
1782
1792
|
async validate() {
|
|
@@ -1786,7 +1796,7 @@ class FieldWithAttribute extends Field {
|
|
|
1786
1796
|
return false;
|
|
1787
1797
|
}
|
|
1788
1798
|
}
|
|
1789
|
-
const isValid = isFieldShowAsText(this) || this.
|
|
1799
|
+
const isValid = isFieldShowAsText(this) || this.isValidValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
|
|
1790
1800
|
this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired(this.form.execution);
|
|
1791
1801
|
return !this.state.validation.errorMessage;
|
|
1792
1802
|
}
|
|
@@ -1829,16 +1839,16 @@ class Checkbox extends FieldWithAttribute {
|
|
|
1829
1839
|
}
|
|
1830
1840
|
}
|
|
1831
1841
|
|
|
1832
|
-
var __defProp$
|
|
1833
|
-
var __defNormalProp$
|
|
1834
|
-
var __publicField$
|
|
1835
|
-
__defNormalProp$
|
|
1842
|
+
var __defProp$k = Object.defineProperty;
|
|
1843
|
+
var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1844
|
+
var __publicField$k = (obj, key, value) => {
|
|
1845
|
+
__defNormalProp$k(obj, key + "" , value);
|
|
1836
1846
|
return value;
|
|
1837
1847
|
};
|
|
1838
1848
|
class Translation {
|
|
1839
1849
|
constructor(execution, state) {
|
|
1840
1850
|
this.execution = execution;
|
|
1841
|
-
__publicField$
|
|
1851
|
+
__publicField$k(this, "state");
|
|
1842
1852
|
this.state = {
|
|
1843
1853
|
...state,
|
|
1844
1854
|
hasChanged: false,
|
|
@@ -1903,19 +1913,19 @@ function parseFakeJSON(fakeJSON) {
|
|
|
1903
1913
|
}));
|
|
1904
1914
|
}
|
|
1905
1915
|
|
|
1906
|
-
var __defProp$
|
|
1907
|
-
var __defNormalProp$
|
|
1908
|
-
var __publicField$
|
|
1909
|
-
__defNormalProp$
|
|
1916
|
+
var __defProp$j = Object.defineProperty;
|
|
1917
|
+
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1918
|
+
var __publicField$j = (obj, key, value) => {
|
|
1919
|
+
__defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1910
1920
|
return value;
|
|
1911
1921
|
};
|
|
1912
1922
|
class TranslatableField extends FieldWithAttribute {
|
|
1913
1923
|
constructor(props) {
|
|
1914
1924
|
super(props);
|
|
1915
|
-
__publicField$
|
|
1916
|
-
__publicField$
|
|
1917
|
-
__publicField$
|
|
1918
|
-
__publicField$
|
|
1925
|
+
__publicField$j(this, "translations", /* @__PURE__ */ new Map());
|
|
1926
|
+
__publicField$j(this, "selectedLanguageId", this.getLanguages()[0]?.id);
|
|
1927
|
+
__publicField$j(this, "isTradLoading", false);
|
|
1928
|
+
__publicField$j(this, "definitionTradParsed", {});
|
|
1919
1929
|
makeObservable(this, {
|
|
1920
1930
|
translations: observable,
|
|
1921
1931
|
selectedLanguageId: observable,
|
|
@@ -1925,1670 +1935,166 @@ class TranslatableField extends FieldWithAttribute {
|
|
|
1925
1935
|
extractTrad() {
|
|
1926
1936
|
const tradMap = {};
|
|
1927
1937
|
const regex = /(\d+)\s*:\s*(true|false)/g;
|
|
1928
|
-
let match;
|
|
1929
|
-
while ((match = regex.exec(this.definition.trad ?? "{}")) !== null) {
|
|
1930
|
-
const key = match[1];
|
|
1931
|
-
const value = match[2] === "true";
|
|
1932
|
-
tradMap[key] = value;
|
|
1933
|
-
}
|
|
1934
|
-
this.definitionTradParsed = tradMap;
|
|
1935
|
-
}
|
|
1936
|
-
getLanguages() {
|
|
1937
|
-
return arrayOrArray(parseFakeJSON(this.getForm().definition?.langs ?? ""));
|
|
1938
|
-
}
|
|
1939
|
-
async init(form) {
|
|
1940
|
-
await super.init(form);
|
|
1941
|
-
if (this.getLanguages().length > 0) {
|
|
1942
|
-
this.extractTrad();
|
|
1943
|
-
this.getLanguages().forEach((lang) => {
|
|
1944
|
-
const isTranslated = this.definitionTradParsed[lang.id] ?? false;
|
|
1945
|
-
this.translations.set(
|
|
1946
|
-
lang.id,
|
|
1947
|
-
new Translation(this.form.execution, {
|
|
1948
|
-
id: lang.id,
|
|
1949
|
-
label: lang.label,
|
|
1950
|
-
isTranslated
|
|
1951
|
-
})
|
|
1952
|
-
);
|
|
1953
|
-
});
|
|
1954
|
-
this.selectedLanguageId = this.getLanguages()[0].id;
|
|
1955
|
-
}
|
|
1956
|
-
}
|
|
1957
|
-
cancelTranslations() {
|
|
1958
|
-
this.getTranslations().forEach((c) => {
|
|
1959
|
-
c.reset();
|
|
1960
|
-
});
|
|
1961
|
-
}
|
|
1962
|
-
deleteTranslations() {
|
|
1963
|
-
this.getTranslations().forEach((c) => {
|
|
1964
|
-
c.deleteTranslation();
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
async changeLanguage(langId) {
|
|
1968
|
-
this.selectedLanguageId = langId;
|
|
1969
|
-
this.syncTranslation();
|
|
1970
|
-
}
|
|
1971
|
-
getTranslation(id) {
|
|
1972
|
-
return this.translations.get(id);
|
|
1973
|
-
}
|
|
1974
|
-
getCurrentTranslation() {
|
|
1975
|
-
return this.translations.get(this.selectedLanguageId);
|
|
1976
|
-
}
|
|
1977
|
-
getTranslations() {
|
|
1978
|
-
return this.translations;
|
|
1979
|
-
}
|
|
1980
|
-
submitTranslations() {
|
|
1981
|
-
[...this.getTranslations().values()].filter((c) => c.state.hasChanged).forEach((c) => {
|
|
1982
|
-
c.submitTranslation(
|
|
1983
|
-
c.value,
|
|
1984
|
-
this.getSynchronizeUrl({
|
|
1985
|
-
react: true,
|
|
1986
|
-
preventAsXmlParameter: true,
|
|
1987
|
-
langId: c.langId
|
|
1988
|
-
})
|
|
1989
|
-
);
|
|
1990
|
-
});
|
|
1991
|
-
this.state.validation.errorMessage = null;
|
|
1992
|
-
}
|
|
1993
|
-
async syncTranslation() {
|
|
1994
|
-
const langId = this.selectedLanguageId;
|
|
1995
|
-
this.isTradLoading = true;
|
|
1996
|
-
await this.getTranslation(langId)?.readTranslations(
|
|
1997
|
-
await makeApiaUrl(this.form.execution, {
|
|
1998
|
-
ajaxUrl: "/apia.execution.FormAction.run",
|
|
1999
|
-
action: "getFieldTranslations",
|
|
2000
|
-
frmId: this.getForm().definition.id,
|
|
2001
|
-
frmParent: this.getForm().definition.frmParent,
|
|
2002
|
-
fldId: this.definition.id,
|
|
2003
|
-
attId: this.attribute.id,
|
|
2004
|
-
langId,
|
|
2005
|
-
react: true
|
|
2006
|
-
})
|
|
2007
|
-
);
|
|
2008
|
-
this.isTradLoading = false;
|
|
2009
|
-
}
|
|
2010
|
-
async validate() {
|
|
2011
|
-
const isSuperValid = await super.validate();
|
|
2012
|
-
let isValid = isSuperValid;
|
|
2013
|
-
const canValidate = isSuperValid && this.properties.reqTrad && this.hasValue() && (!this.properties.inputAsText || !this.properties.visibilityHidden || !this.properties.disabled);
|
|
2014
|
-
if (canValidate) {
|
|
2015
|
-
const translations = [...this.getTranslations().values()];
|
|
2016
|
-
const tradNotValidated = translations.find((c) => !c.state.isTranslated);
|
|
2017
|
-
if (tradNotValidated) {
|
|
2018
|
-
this.state.validation.errorMessage = labels.errorTranslateRequired(
|
|
2019
|
-
this.form.execution,
|
|
2020
|
-
tradNotValidated.state.label
|
|
2021
|
-
);
|
|
2022
|
-
isValid = false;
|
|
2023
|
-
} else {
|
|
2024
|
-
this.state.validation.errorMessage = null;
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
|
-
return isValid;
|
|
2028
|
-
}
|
|
2029
|
-
setValue(newValue, options) {
|
|
2030
|
-
if (newValue === "") {
|
|
2031
|
-
this.deleteTranslations();
|
|
2032
|
-
}
|
|
2033
|
-
return super.setValue(newValue, options);
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
class Editor extends TranslatableField {
|
|
2038
|
-
fireEvent(eventName, options) {
|
|
2039
|
-
return super.fireEvent(eventName, options);
|
|
2040
|
-
}
|
|
2041
|
-
hasValue() {
|
|
2042
|
-
return !!String(this.getValue()).trim();
|
|
2043
|
-
}
|
|
2044
|
-
getSynchronizePostConfiguration(value) {
|
|
2045
|
-
const conf = super.getSynchronizePostConfiguration(value);
|
|
2046
|
-
conf.postData.clearValues = "true";
|
|
2047
|
-
return conf;
|
|
2048
|
-
}
|
|
2049
|
-
}
|
|
2050
|
-
|
|
2051
|
-
var __defProp$j = Object.defineProperty;
|
|
2052
|
-
var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2053
|
-
var __publicField$j = (obj, key, value) => {
|
|
2054
|
-
__defNormalProp$j(obj, key + "" , value);
|
|
2055
|
-
return value;
|
|
2056
|
-
};
|
|
2057
|
-
function getFileExtension(fileName) {
|
|
2058
|
-
const parts = fileName.split(".");
|
|
2059
|
-
return parts.length > 1 ? parts.pop().toLowerCase() : "";
|
|
2060
|
-
}
|
|
2061
|
-
const getInitialState = (execution) => Object.freeze({
|
|
2062
|
-
metadata: {
|
|
2063
|
-
metadataArray: [],
|
|
2064
|
-
freeMetadataArray: [],
|
|
2065
|
-
isFreeMetadata: false
|
|
2066
|
-
},
|
|
2067
|
-
fromDirectoryFile: null,
|
|
2068
|
-
docFolder: void 0,
|
|
2069
|
-
docPath: void 0,
|
|
2070
|
-
docExpDate: void 0,
|
|
2071
|
-
description: "",
|
|
2072
|
-
isReadonly: false,
|
|
2073
|
-
permissions: {
|
|
2074
|
-
pools: [],
|
|
2075
|
-
users: getWindow(execution).DOCUMENT_OWNER_PRIVILEGES ? [
|
|
2076
|
-
{
|
|
2077
|
-
canUpdate: true,
|
|
2078
|
-
userId: getWindow(execution).CURRENT_USER_LOGIN,
|
|
2079
|
-
userLogin: getWindow(execution).CURRENT_USER_LOGIN
|
|
2080
|
-
}
|
|
2081
|
-
] : [],
|
|
2082
|
-
allowAllType: getWindow(execution).DOCUMENT_EVERYONE_PERMISSION !== false ? "M" : ""
|
|
2083
|
-
},
|
|
2084
|
-
fileReqError: false
|
|
2085
|
-
});
|
|
2086
|
-
class UploaderModalController {
|
|
2087
|
-
constructor(api, modalConfig, conf) {
|
|
2088
|
-
this.api = api;
|
|
2089
|
-
this.modalConfig = modalConfig;
|
|
2090
|
-
this.conf = conf;
|
|
2091
|
-
__publicField$j(this, "state");
|
|
2092
|
-
makeObservable(this, {
|
|
2093
|
-
state: observable
|
|
2094
|
-
});
|
|
2095
|
-
this.state = getInitialState(api.execution);
|
|
2096
|
-
}
|
|
2097
|
-
get allMetadata() {
|
|
2098
|
-
return [
|
|
2099
|
-
...this.state.metadata.metadataArray,
|
|
2100
|
-
...this.state.metadata.freeMetadataArray
|
|
2101
|
-
];
|
|
2102
|
-
}
|
|
2103
|
-
get allowAllType() {
|
|
2104
|
-
return this.state.permissions.allowAllType;
|
|
2105
|
-
}
|
|
2106
|
-
get description() {
|
|
2107
|
-
return this.state.description;
|
|
2108
|
-
}
|
|
2109
|
-
get docFolder() {
|
|
2110
|
-
return this.state.docFolder;
|
|
2111
|
-
}
|
|
2112
|
-
get docExpDate() {
|
|
2113
|
-
return this.state.docExpDate;
|
|
2114
|
-
}
|
|
2115
|
-
get docTypes() {
|
|
2116
|
-
return this.api.getDocTypes();
|
|
2117
|
-
}
|
|
2118
|
-
get freeMetadata() {
|
|
2119
|
-
return this.state.metadata.freeMetadataArray;
|
|
2120
|
-
}
|
|
2121
|
-
get exitingFiles() {
|
|
2122
|
-
return this.api.getExistingFiles();
|
|
2123
|
-
}
|
|
2124
|
-
get inProgressFiles() {
|
|
2125
|
-
return this.api.getInProgressFiles();
|
|
2126
|
-
}
|
|
2127
|
-
get hiddenFiles() {
|
|
2128
|
-
return this.api.getHiddenFiles();
|
|
2129
|
-
}
|
|
2130
|
-
get progress() {
|
|
2131
|
-
return this.api.getProgress();
|
|
2132
|
-
}
|
|
2133
|
-
get metadata() {
|
|
2134
|
-
return this.state.metadata.metadataArray;
|
|
2135
|
-
}
|
|
2136
|
-
get selectedDocTypeId() {
|
|
2137
|
-
return this.api.getCurrentDocTypeId();
|
|
2138
|
-
}
|
|
2139
|
-
get selectedDocType() {
|
|
2140
|
-
return this.api.getCurrentDocType();
|
|
2141
|
-
}
|
|
2142
|
-
addMetadata() {
|
|
2143
|
-
this.state.metadata.freeMetadataArray.push({
|
|
2144
|
-
free: "Y",
|
|
2145
|
-
id: String(Math.random()),
|
|
2146
|
-
name: "",
|
|
2147
|
-
required: "Y",
|
|
2148
|
-
title: "",
|
|
2149
|
-
type: "S",
|
|
2150
|
-
value: "",
|
|
2151
|
-
errorMessage: "",
|
|
2152
|
-
labelErrorMessage: ""
|
|
2153
|
-
});
|
|
2154
|
-
}
|
|
2155
|
-
addFiles(files) {
|
|
2156
|
-
this.state.fileReqError = false;
|
|
2157
|
-
this.state.isReadonly = false;
|
|
2158
|
-
this.api.saveDroppedFiles(files, this.conf);
|
|
2159
|
-
}
|
|
2160
|
-
addDirectoryFile(file) {
|
|
2161
|
-
this.state.fileReqError = false;
|
|
2162
|
-
this.api.state.inProgressFiles = [];
|
|
2163
|
-
this.state.fromDirectoryFile = file;
|
|
2164
|
-
}
|
|
2165
|
-
async changeDocType(docTypeId) {
|
|
2166
|
-
this.resetMetadata();
|
|
2167
|
-
this.api.setCurrentDocTypeId(docTypeId);
|
|
2168
|
-
this.onChangeExtension();
|
|
2169
|
-
this.api.reloadMetadata({ docTypeId });
|
|
2170
|
-
}
|
|
2171
|
-
clearDirectoryFile() {
|
|
2172
|
-
this.state.fromDirectoryFile = null;
|
|
2173
|
-
this.state.isReadonly = false;
|
|
2174
|
-
}
|
|
2175
|
-
clearFile(name) {
|
|
2176
|
-
this.api.clearFile(name);
|
|
2177
|
-
}
|
|
2178
|
-
clearFiles() {
|
|
2179
|
-
this.api.clearFiles();
|
|
2180
|
-
}
|
|
2181
|
-
clearState() {
|
|
2182
|
-
this.state = getInitialState(this.api.execution);
|
|
2183
|
-
this.api.clearState();
|
|
2184
|
-
}
|
|
2185
|
-
clearPartialState() {
|
|
2186
|
-
if (this.api.state.inProgressFiles.length === 0) {
|
|
2187
|
-
this.state = getInitialState(this.api.execution);
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
onCloseModal() {
|
|
2191
|
-
this.clearState();
|
|
2192
|
-
}
|
|
2193
|
-
async confirm() {
|
|
2194
|
-
let isValid = this.validate();
|
|
2195
|
-
if (isValid)
|
|
2196
|
-
isValid = await this.api.confirmDropModal(this.conf);
|
|
2197
|
-
return isValid;
|
|
2198
|
-
}
|
|
2199
|
-
deleteMetadata(indices) {
|
|
2200
|
-
const deleteSet = new Set(indices);
|
|
2201
|
-
const offset = this.state.metadata.metadataArray.length;
|
|
2202
|
-
this.state.metadata.freeMetadataArray = this.state.metadata.freeMetadataArray.filter(
|
|
2203
|
-
(_, localIndex) => (
|
|
2204
|
-
// conservamos sólo los que NO estén en deleteSet
|
|
2205
|
-
!deleteSet.has(localIndex + offset)
|
|
2206
|
-
)
|
|
2207
|
-
);
|
|
2208
|
-
}
|
|
2209
|
-
deletePermission(item) {
|
|
2210
|
-
if (item && "userId" in item) {
|
|
2211
|
-
this.state.permissions.users = this.state.permissions.users.filter(
|
|
2212
|
-
(c) => c.userId !== item.userId
|
|
2213
|
-
);
|
|
2214
|
-
} else {
|
|
2215
|
-
this.state.permissions.pools = this.state.permissions.pools.filter(
|
|
2216
|
-
(c) => c.poolId !== item.poolId
|
|
2217
|
-
);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
onChangeExtension() {
|
|
2221
|
-
const rawDocExts = this.api.getCurrentDocType()?.docExts || "";
|
|
2222
|
-
let hideFileNames = "";
|
|
2223
|
-
const allowedExtensions = rawDocExts.split(";").map((ext) => ext.trim()).filter((ext) => ext !== "");
|
|
2224
|
-
if (rawDocExts === "") {
|
|
2225
|
-
const allFiles = [...this.inProgressFiles, ...this.hiddenFiles];
|
|
2226
|
-
const dedupedFiles = Array.from(
|
|
2227
|
-
new Map(allFiles.map((file) => [file.name, file])).values()
|
|
2228
|
-
);
|
|
2229
|
-
this.api.state.inProgressFiles = dedupedFiles;
|
|
2230
|
-
this.api.state.hiddenFiles = [];
|
|
2231
|
-
return;
|
|
2232
|
-
}
|
|
2233
|
-
const allowedInProgress = [];
|
|
2234
|
-
const toHide = [];
|
|
2235
|
-
this.inProgressFiles.forEach((file) => {
|
|
2236
|
-
const ext = getFileExtension(file.name);
|
|
2237
|
-
if (allowedExtensions.includes(ext)) {
|
|
2238
|
-
allowedInProgress.push(file);
|
|
2239
|
-
} else {
|
|
2240
|
-
toHide.push(file);
|
|
2241
|
-
hideFileNames += ` ${file.name} `;
|
|
2242
|
-
}
|
|
2243
|
-
});
|
|
2244
|
-
const allowedHidden = [];
|
|
2245
|
-
const stillHidden = [];
|
|
2246
|
-
this.api.state.hiddenFiles.forEach((file) => {
|
|
2247
|
-
const ext = getFileExtension(file.name);
|
|
2248
|
-
if (allowedExtensions.includes(ext)) {
|
|
2249
|
-
allowedHidden.push(file);
|
|
2250
|
-
} else {
|
|
2251
|
-
stillHidden.push(file);
|
|
2252
|
-
}
|
|
2253
|
-
});
|
|
2254
|
-
const combinedInProgress = [...allowedInProgress, ...allowedHidden];
|
|
2255
|
-
const dedupedInProgress = Array.from(
|
|
2256
|
-
new Map(
|
|
2257
|
-
combinedInProgress.map((file) => [file.name, file])
|
|
2258
|
-
).values()
|
|
2259
|
-
);
|
|
2260
|
-
const combinedHidden = [...toHide, ...stillHidden];
|
|
2261
|
-
const dedupedHidden = Array.from(
|
|
2262
|
-
new Map(combinedHidden.map((file) => [file.name, file])).values()
|
|
2263
|
-
);
|
|
2264
|
-
this.api.state.inProgressFiles = dedupedInProgress;
|
|
2265
|
-
this.api.state.hiddenFiles = dedupedHidden;
|
|
2266
|
-
if (hideFileNames)
|
|
2267
|
-
this.api.notify({
|
|
2268
|
-
title: getLabel(this.api.execution, "msgFileWrngExt").text,
|
|
2269
|
-
message: hideFileNames,
|
|
2270
|
-
type: "warning"
|
|
2271
|
-
});
|
|
2272
|
-
}
|
|
2273
|
-
async openModal() {
|
|
2274
|
-
const a = "openUploaderModal";
|
|
2275
|
-
import(
|
|
2276
|
-
/* webpackInclude: /\.tsx?$/ */
|
|
2277
|
-
`/src/static/files/${a}`
|
|
2278
|
-
).then((r) => {
|
|
2279
|
-
r.default(this);
|
|
2280
|
-
});
|
|
2281
|
-
}
|
|
2282
|
-
setDescription(desc) {
|
|
2283
|
-
this.state.description = desc;
|
|
2284
|
-
}
|
|
2285
|
-
async resetMetadata() {
|
|
2286
|
-
this.state.metadata = {
|
|
2287
|
-
freeMetadataArray: [],
|
|
2288
|
-
metadataArray: [],
|
|
2289
|
-
isFreeMetadata: false
|
|
2290
|
-
};
|
|
2291
|
-
}
|
|
2292
|
-
validate() {
|
|
2293
|
-
let isValid = true;
|
|
2294
|
-
this.state.fileReqError = false;
|
|
2295
|
-
if (this.api.getInProgressFiles().length === 0 && !this.state.fromDirectoryFile) {
|
|
2296
|
-
this.state.fileReqError = true;
|
|
2297
|
-
isValid = false;
|
|
2298
|
-
}
|
|
2299
|
-
this.allMetadata.forEach((c) => {
|
|
2300
|
-
if (c.required === "Y") {
|
|
2301
|
-
if (c.name.trim() === "" && c.free === "Y") {
|
|
2302
|
-
c.labelErrorMessage = getLabel(
|
|
2303
|
-
this.api.execution,
|
|
2304
|
-
"msgReqField"
|
|
2305
|
-
).text;
|
|
2306
|
-
isValid = false;
|
|
2307
|
-
}
|
|
2308
|
-
if (c.value.trim() === "") {
|
|
2309
|
-
if (!c.errorMessage)
|
|
2310
|
-
c.errorMessage = getLabel(this.api.execution, "msgReqField").text;
|
|
2311
|
-
isValid = false;
|
|
2312
|
-
}
|
|
2313
|
-
}
|
|
2314
|
-
});
|
|
2315
|
-
return isValid;
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
var __defProp$i = Object.defineProperty;
|
|
2320
|
-
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2321
|
-
var __publicField$i = (obj, key, value) => {
|
|
2322
|
-
__defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2323
|
-
return value;
|
|
2324
|
-
};
|
|
2325
|
-
function returnExactlyTheSame(defaultParameters) {
|
|
2326
|
-
return defaultParameters;
|
|
2327
|
-
}
|
|
2328
|
-
function isOneClickUploadEnabled(execution, oneClickUploadProp) {
|
|
2329
|
-
return !getWindow(execution).avoidOneClickUpload && (getWindow(execution).forceOneClickUpload || oneClickUploadProp || false);
|
|
2330
|
-
}
|
|
2331
|
-
const parseFileDefinition = (execution, fileDefinition, isSignRequired) => {
|
|
2332
|
-
const { lock, isLocked, lockedBy, userLocking, ...file } = fileDefinition;
|
|
2333
|
-
return {
|
|
2334
|
-
...file,
|
|
2335
|
-
isLocked: isLocked === "true" || isLocked === true || toBoolean(lock) || file.locked === true,
|
|
2336
|
-
isLockedByMe: (lockedBy || userLocking) === getWindow(execution).CURRENT_USER_LOGIN,
|
|
2337
|
-
isMarkedToSign: file.markedToSign || toBoolean(file.sign) || isSignRequired,
|
|
2338
|
-
isVirtual: file.virtualDoc ?? false,
|
|
2339
|
-
lockingUser: lockedBy || userLocking
|
|
2340
|
-
};
|
|
2341
|
-
};
|
|
2342
|
-
class UploaderApi extends EventEmitter$1 {
|
|
2343
|
-
constructor(execution, id, type, modalConfig) {
|
|
2344
|
-
super();
|
|
2345
|
-
this.execution = execution;
|
|
2346
|
-
this.id = id;
|
|
2347
|
-
this.type = type;
|
|
2348
|
-
this.modalConfig = modalConfig;
|
|
2349
|
-
__publicField$i(this, "maxFiles", Infinity);
|
|
2350
|
-
__publicField$i(this, "modalController", null);
|
|
2351
|
-
__publicField$i(this, "allowTranslations", false);
|
|
2352
|
-
__publicField$i(this, "langs");
|
|
2353
|
-
__publicField$i(this, "currentConfiguration");
|
|
2354
|
-
__publicField$i(this, "docTypePermittedObjId");
|
|
2355
|
-
__publicField$i(this, "state", {
|
|
2356
|
-
progress: 0,
|
|
2357
|
-
allowedTypes: [],
|
|
2358
|
-
selectedDocTypeId: "1",
|
|
2359
|
-
versioningFile: null,
|
|
2360
|
-
inProgressFiles: [],
|
|
2361
|
-
files: {},
|
|
2362
|
-
selectedFiles: [],
|
|
2363
|
-
hiddenFiles: [],
|
|
2364
|
-
translatedFiles: /* @__PURE__ */ new Map(),
|
|
2365
|
-
hasAllDocTypes: false
|
|
2366
|
-
});
|
|
2367
|
-
__publicField$i(this, "getCheckSignatureParameters", returnExactlyTheSame);
|
|
2368
|
-
__publicField$i(this, "getAjaxUploadFileStatusParameters", returnExactlyTheSame);
|
|
2369
|
-
__publicField$i(this, "getAjaxUploadStartParameters", returnExactlyTheSame);
|
|
2370
|
-
__publicField$i(this, "getConfirmDropModalParameters", returnExactlyTheSame);
|
|
2371
|
-
__publicField$i(this, "getCheckLockDocumentParameters", returnExactlyTheSame);
|
|
2372
|
-
__publicField$i(this, "getCheckWebDavLockParameters", returnExactlyTheSame);
|
|
2373
|
-
__publicField$i(this, "getConfirmDropModalPostdata", returnExactlyTheSame);
|
|
2374
|
-
__publicField$i(this, "getConfirmDropModalMetadataString", ({
|
|
2375
|
-
metadata
|
|
2376
|
-
}) => {
|
|
2377
|
-
return metadata?.filter?.((current) => !!current.value).map((current) => `${current.id}~${current.type}~${current.value}`).join(";") ?? [];
|
|
2378
|
-
});
|
|
2379
|
-
__publicField$i(this, "getConfirmDropModalPermissionsString", ({
|
|
2380
|
-
poolsPermissions,
|
|
2381
|
-
usersPermissions
|
|
2382
|
-
}) => {
|
|
2383
|
-
let returnString = "";
|
|
2384
|
-
poolsPermissions.forEach(
|
|
2385
|
-
(current) => returnString = `${returnString}${returnString.length > 0 ? "&" : ""}docPoolId=${current.poolId}&docPoolName=${current.poolName}&docPermType${current.poolId}=${String(current.canUpdate)}`
|
|
2386
|
-
);
|
|
2387
|
-
usersPermissions.forEach(
|
|
2388
|
-
(current) => returnString = `${returnString}${returnString.length > 0 ? "&" : ""}docUserId=${current.userId}&docUsrLogin=${current.userLogin}&docPermType${current.userId}=${String(current.canUpdate)}`
|
|
2389
|
-
);
|
|
2390
|
-
return returnString;
|
|
2391
|
-
});
|
|
2392
|
-
__publicField$i(this, "getConfirmDropModalAdditionalMetadataString", (additionalMetadata) => {
|
|
2393
|
-
return Object.values(additionalMetadata).filter((current) => !!current?.value).map((current) => `${current.name}~${current.value}`).join(";");
|
|
2394
|
-
});
|
|
2395
|
-
__publicField$i(this, "getDeleteDocumentParameters", returnExactlyTheSame);
|
|
2396
|
-
__publicField$i(this, "getClearTempFilesParameters", returnExactlyTheSame);
|
|
2397
|
-
__publicField$i(this, "getDocumentInfoParameters", returnExactlyTheSame);
|
|
2398
|
-
__publicField$i(this, "getDownloadMultipleDocumentsParameters", returnExactlyTheSame);
|
|
2399
|
-
__publicField$i(this, "getEditDocumentParameters", returnExactlyTheSame);
|
|
2400
|
-
__publicField$i(this, "getLockDocumentParameters", returnExactlyTheSame);
|
|
2401
|
-
__publicField$i(this, "getMarkFileToSignParameters", returnExactlyTheSame);
|
|
2402
|
-
__publicField$i(this, "getProcessDroppedFilesParameters", returnExactlyTheSame);
|
|
2403
|
-
__publicField$i(this, "getProcessDroppedFilesPostdata", returnExactlyTheSame);
|
|
2404
|
-
__publicField$i(this, "getReloadMetadataParameters", returnExactlyTheSame);
|
|
2405
|
-
__publicField$i(this, "getSaveDroppedFilesParameters", returnExactlyTheSame);
|
|
2406
|
-
__publicField$i(this, "parseFileDefinition", (file) => {
|
|
2407
|
-
return {
|
|
2408
|
-
...parseFileDefinition(this.execution, file, false),
|
|
2409
|
-
canEdit: file.canEdit || file.canWrite,
|
|
2410
|
-
canRead: file.canRead
|
|
2411
|
-
};
|
|
2412
|
-
});
|
|
2413
|
-
if (!getWindow(this.execution).fileApi) {
|
|
2414
|
-
getWindow(this.execution).fileApi = {};
|
|
2415
|
-
}
|
|
2416
|
-
getWindow(this.execution).fileApi[this.id] = this;
|
|
2417
|
-
makeObservable(this, {
|
|
2418
|
-
state: observable
|
|
2419
|
-
});
|
|
2420
|
-
this.allowTranslations = type === "E" && !!getWindow(this.execution).DOC_LANGS;
|
|
2421
|
-
this.langs = getWindow(this.execution).DOC_LANGS;
|
|
2422
|
-
try {
|
|
2423
|
-
this.docTypePermittedObjId = type === "E" ? getWindow(this.execution).docTypePerEntId : getWindow(this.execution).docTypePerProId;
|
|
2424
|
-
} catch (e) {
|
|
2425
|
-
console.warn(e);
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
get filesArray() {
|
|
2429
|
-
return Object.values(this.state.files);
|
|
2430
|
-
}
|
|
2431
|
-
async init() {
|
|
2432
|
-
await this.ajaxUploadStart();
|
|
2433
|
-
await this.reloadMetadata({
|
|
2434
|
-
docTypeId: this.state.selectedDocTypeId
|
|
2435
|
-
});
|
|
2436
|
-
await this.loadCurrentDocuments();
|
|
2437
|
-
}
|
|
2438
|
-
async onStartUpload(files) {
|
|
2439
|
-
if (this.modalConfig.oneClickUpload) {
|
|
2440
|
-
await this.saveDroppedFiles(files ?? []);
|
|
2441
|
-
} else {
|
|
2442
|
-
if (files) {
|
|
2443
|
-
const result = await this.saveDroppedFiles(files ?? []);
|
|
2444
|
-
if (!result)
|
|
2445
|
-
return;
|
|
2446
|
-
}
|
|
2447
|
-
this.modalController = new UploaderModalController(
|
|
2448
|
-
this,
|
|
2449
|
-
this.modalConfig
|
|
2450
|
-
);
|
|
2451
|
-
this.modalController.openModal();
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
async onTranslateUpload(conf, files) {
|
|
2455
|
-
if (this.modalConfig.oneClickUpload) {
|
|
2456
|
-
await this.saveDroppedFiles(files ?? [], conf);
|
|
2457
|
-
} else {
|
|
2458
|
-
await this.init();
|
|
2459
|
-
let mustOpen = true;
|
|
2460
|
-
if (files) {
|
|
2461
|
-
const res = await this.saveDroppedFiles(files ?? [], conf);
|
|
2462
|
-
if (!res) {
|
|
2463
|
-
mustOpen = false;
|
|
2464
|
-
}
|
|
2465
|
-
}
|
|
2466
|
-
if (mustOpen) {
|
|
2467
|
-
this.modalController = new UploaderModalController(
|
|
2468
|
-
this,
|
|
2469
|
-
this.modalConfig,
|
|
2470
|
-
conf
|
|
2471
|
-
);
|
|
2472
|
-
this.modalController.openModal();
|
|
2473
|
-
}
|
|
2474
|
-
}
|
|
2475
|
-
}
|
|
2476
|
-
async onVersionUpload(file, conf = { newFiles: [] }) {
|
|
2477
|
-
this.version(file, conf);
|
|
2478
|
-
}
|
|
2479
|
-
async autoLock() {
|
|
2480
|
-
return new Promise((resolve) => {
|
|
2481
|
-
resolve(false);
|
|
2482
|
-
});
|
|
2483
|
-
}
|
|
2484
|
-
notify(notification) {
|
|
2485
|
-
this.execution.notifications.add(new MessageNotification(notification));
|
|
2486
|
-
}
|
|
2487
|
-
getAjaxUrl() {
|
|
2488
|
-
return getWindow(this.execution).URL_REQUEST_AJAX;
|
|
2489
|
-
}
|
|
2490
|
-
getDocTypes() {
|
|
2491
|
-
return this.state.allowedTypes;
|
|
2492
|
-
}
|
|
2493
|
-
getCurrentDocTypeId() {
|
|
2494
|
-
return this.state.selectedDocTypeId;
|
|
2495
|
-
}
|
|
2496
|
-
getCurrentDocType() {
|
|
2497
|
-
return this.state.allowedTypes.find(
|
|
2498
|
-
(c) => c.id === this.state.selectedDocTypeId
|
|
2499
|
-
);
|
|
2500
|
-
}
|
|
2501
|
-
getInProgressFiles() {
|
|
2502
|
-
return this.state.inProgressFiles;
|
|
2503
|
-
}
|
|
2504
|
-
getHiddenFiles() {
|
|
2505
|
-
return this.state.hiddenFiles;
|
|
2506
|
-
}
|
|
2507
|
-
getExistingFiles() {
|
|
2508
|
-
return this.state.files;
|
|
2509
|
-
}
|
|
2510
|
-
getProgress() {
|
|
2511
|
-
return this.state.progress;
|
|
2512
|
-
}
|
|
2513
|
-
getHasAllDocTypes() {
|
|
2514
|
-
return this.state.hasAllDocTypes;
|
|
2515
|
-
}
|
|
2516
|
-
async getDocumentInfo({
|
|
2517
|
-
docId: apiId,
|
|
2518
|
-
downloadDocId: docId
|
|
2519
|
-
}, newElem) {
|
|
2520
|
-
const id = apiId ? this.getDocument(apiId).docId : docId;
|
|
2521
|
-
const result = await post(
|
|
2522
|
-
this.execution,
|
|
2523
|
-
makeApiaUrl(
|
|
2524
|
-
this.execution,
|
|
2525
|
-
this.getDocumentInfoParameters({
|
|
2526
|
-
action: "getDocumentInfo",
|
|
2527
|
-
isAjax: true,
|
|
2528
|
-
docId: id,
|
|
2529
|
-
newElem,
|
|
2530
|
-
prefix: this.type,
|
|
2531
|
-
ajaxUrl: this.getAjaxUrl()
|
|
2532
|
-
})
|
|
2533
|
-
)
|
|
2534
|
-
);
|
|
2535
|
-
if (result?.data) {
|
|
2536
|
-
return result.data;
|
|
2537
|
-
}
|
|
2538
|
-
return null;
|
|
2539
|
-
}
|
|
2540
|
-
/**
|
|
2541
|
-
* This method searches for the provided id in several places:
|
|
2542
|
-
*
|
|
2543
|
-
* If it's found in the current files, returns it.
|
|
2544
|
-
* If not, it searches the provided docId in the translations map of each uploaded file.
|
|
2545
|
-
*/
|
|
2546
|
-
getDocument(docId) {
|
|
2547
|
-
if (this.state.files[docId]) {
|
|
2548
|
-
return this.state.files[docId];
|
|
2549
|
-
} else {
|
|
2550
|
-
for (const map of this.state.translatedFiles.values()) {
|
|
2551
|
-
for (const file of map.values()) {
|
|
2552
|
-
if (file.docId === docId) {
|
|
2553
|
-
return file;
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
return void 0;
|
|
2559
|
-
}
|
|
2560
|
-
updateDocument(docId, newValue) {
|
|
2561
|
-
if (this.state.files[docId]) {
|
|
2562
|
-
this.state.files[docId] = { ...this.getDocument(docId), ...newValue };
|
|
2563
|
-
} else {
|
|
2564
|
-
this.state.translatedFiles.forEach((innerMap) => {
|
|
2565
|
-
innerMap.forEach((doc, langKey) => {
|
|
2566
|
-
if (doc.docId === docId) {
|
|
2567
|
-
innerMap.set(langKey, { ...doc, ...newValue });
|
|
2568
|
-
}
|
|
2569
|
-
});
|
|
2570
|
-
});
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
deleteDocument(docId) {
|
|
2574
|
-
if (this.state.files[docId]) {
|
|
2575
|
-
delete this.state.files[docId];
|
|
2576
|
-
} else {
|
|
2577
|
-
this.state.translatedFiles.forEach((innerMap) => {
|
|
2578
|
-
innerMap.forEach((doc, langKey) => {
|
|
2579
|
-
if (doc.docId === docId) {
|
|
2580
|
-
innerMap.delete(langKey);
|
|
2581
|
-
}
|
|
2582
|
-
});
|
|
2583
|
-
});
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2586
|
-
clearFile(name) {
|
|
2587
|
-
if (this.modalController) {
|
|
2588
|
-
this.modalController.state.isReadonly = false;
|
|
2589
|
-
}
|
|
2590
|
-
this.state.inProgressFiles = this.state.inProgressFiles.filter(
|
|
2591
|
-
(c) => c.name !== name
|
|
2592
|
-
);
|
|
2593
|
-
}
|
|
2594
|
-
clearFiles() {
|
|
2595
|
-
if (this.modalController) {
|
|
2596
|
-
this.modalController.state.isReadonly = false;
|
|
2597
|
-
}
|
|
2598
|
-
this.state.inProgressFiles = [];
|
|
2599
|
-
this.state.versioningFile = null;
|
|
2600
|
-
this.state.hiddenFiles = [];
|
|
2601
|
-
}
|
|
2602
|
-
clearState() {
|
|
2603
|
-
if (this.modalController) {
|
|
2604
|
-
this.modalController.state.isReadonly = false;
|
|
2605
|
-
}
|
|
2606
|
-
this.state.selectedDocTypeId = this.getDocTypes().find(
|
|
2607
|
-
(c) => String(c.id) === "1"
|
|
2608
|
-
) ? "1" : this.getDocTypes()[0]?.id;
|
|
2609
|
-
this.state.inProgressFiles = [];
|
|
2610
|
-
this.state.versioningFile = null;
|
|
2611
|
-
}
|
|
2612
|
-
async checkLockDocument(id, shouldNotifyUnlocked = true) {
|
|
2613
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
2614
|
-
return false;
|
|
2615
|
-
}
|
|
2616
|
-
const file = this.getDocument(id);
|
|
2617
|
-
if (Number(file.docId) < 0)
|
|
2618
|
-
return true;
|
|
2619
|
-
const result = await post(
|
|
2620
|
-
this.execution,
|
|
2621
|
-
makeApiaUrl(
|
|
2622
|
-
this.execution,
|
|
2623
|
-
this.getCheckLockDocumentParameters({
|
|
2624
|
-
action: "checkLockDocument",
|
|
2625
|
-
docId: file.docId,
|
|
2626
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
2627
|
-
prefix: this.type
|
|
2628
|
-
})
|
|
2629
|
-
)
|
|
2630
|
-
);
|
|
2631
|
-
const isLocked = result?.data?.success === "ok";
|
|
2632
|
-
if (!isLocked && result?.data?.usr && result.data.usr !== getWindow(this.execution).CURRENT_USER_LOGIN) {
|
|
2633
|
-
this.notify({
|
|
2634
|
-
message: `${getWindow(this.execution).MSG_DOC_LOCKED_BY_USR.split(".")[0]}: ${result.data.usr}.`,
|
|
2635
|
-
type: "warning"
|
|
2636
|
-
});
|
|
2637
|
-
return result.data.usr;
|
|
2638
|
-
}
|
|
2639
|
-
if (!isLocked && shouldNotifyUnlocked && !await this.autoLock())
|
|
2640
|
-
this.notify({
|
|
2641
|
-
message: getWindow(this.execution).MSG_DOC_MUST_BE_LOCKED,
|
|
2642
|
-
type: "warning"
|
|
2643
|
-
});
|
|
2644
|
-
return isLocked;
|
|
2645
|
-
}
|
|
2646
|
-
setCurrentDocTypeId(docTypeId) {
|
|
2647
|
-
this.state.selectedDocTypeId = docTypeId;
|
|
2648
|
-
}
|
|
2649
|
-
async ajaxUploadStart(newFiles = []) {
|
|
2650
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
2651
|
-
return;
|
|
2652
|
-
}
|
|
2653
|
-
const versioningFile = this.state.versioningFile;
|
|
2654
|
-
const res = await post(
|
|
2655
|
-
this.execution,
|
|
2656
|
-
makeApiaUrl(
|
|
2657
|
-
this.execution,
|
|
2658
|
-
this.getAjaxUploadStartParameters({
|
|
2659
|
-
action: "ajaxUploadStart",
|
|
2660
|
-
isAjax: true,
|
|
2661
|
-
docId: versioningFile?.docId,
|
|
2662
|
-
prefix: this.type,
|
|
2663
|
-
docTypeId: newFiles.length === 1 ? versioningFile?.docTypeId || "1" : "1",
|
|
2664
|
-
newDoc: !versioningFile,
|
|
2665
|
-
useDocTypePermitted: true,
|
|
2666
|
-
docTypePermittedObjType: this.type,
|
|
2667
|
-
docTypePermittedObjId: this.docTypePermittedObjId,
|
|
2668
|
-
ajaxUrl: this.getAjaxUrl()
|
|
2669
|
-
})
|
|
2670
|
-
)
|
|
2671
|
-
);
|
|
2672
|
-
if (res?.data) {
|
|
2673
|
-
const docTypes = arrayOrArray(res?.data?.function?.docTypes?.docType);
|
|
2674
|
-
const hasGeneric = !!docTypes.find((c) => String(c.id) === "1");
|
|
2675
|
-
this.state.allowedTypes = docTypes;
|
|
2676
|
-
this.state.selectedDocTypeId = hasGeneric ? "1" : docTypes[0].id;
|
|
2677
|
-
if (newFiles.length > 0) {
|
|
2678
|
-
await this.saveDroppedFiles(newFiles);
|
|
2679
|
-
}
|
|
2680
|
-
return res?.data?.function.name === "fncDocumentLoadInformation" ? true : false;
|
|
2681
|
-
} else {
|
|
2682
|
-
throw new Error("No files data");
|
|
2683
|
-
}
|
|
2684
|
-
}
|
|
2685
|
-
async reloadMetadata(props, additionalProps) {
|
|
2686
|
-
if (!this.modalController)
|
|
2687
|
-
return;
|
|
2688
|
-
const res = await post(
|
|
2689
|
-
this.execution,
|
|
2690
|
-
makeApiaUrl(
|
|
2691
|
-
this.execution,
|
|
2692
|
-
this.getReloadMetadataParameters({
|
|
2693
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
2694
|
-
action: "reloadMetadata",
|
|
2695
|
-
isAjax: true,
|
|
2696
|
-
docId: props?.docId,
|
|
2697
|
-
docTypeId: props?.docTypeId,
|
|
2698
|
-
metadata: this.getConfirmDropModalMetadataString({
|
|
2699
|
-
metadata: this.modalController?.allMetadata
|
|
2700
|
-
}),
|
|
2701
|
-
prefix: this.type,
|
|
2702
|
-
...additionalProps
|
|
2703
|
-
})
|
|
2704
|
-
)
|
|
2705
|
-
);
|
|
2706
|
-
if (res?.data && props?.docTypeId) {
|
|
2707
|
-
const isFreeMetadata = this.state.allowedTypes.find(
|
|
2708
|
-
(current) => current.id === props.docTypeId
|
|
2709
|
-
)?.free ?? false;
|
|
2710
|
-
this.modalController.state.metadata.metadataArray = arrayOrArray(
|
|
2711
|
-
res.data.metadata
|
|
2712
|
-
);
|
|
2713
|
-
this.modalController.state.metadata.isFreeMetadata = isFreeMetadata;
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
async saveDroppedFiles(unprocessedFiles, conf) {
|
|
2717
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
2718
|
-
return false;
|
|
2719
|
-
}
|
|
2720
|
-
const {
|
|
2721
|
-
langId,
|
|
2722
|
-
strictMode: isConfStrictMode = false,
|
|
2723
|
-
translatingFile
|
|
2724
|
-
} = conf ?? {};
|
|
2725
|
-
const isStrictMode = isConfStrictMode || !!this.state.versioningFile || !!this.modalController?.state.fromDirectoryFile;
|
|
2726
|
-
const docType = this.getCurrentDocTypeId();
|
|
2727
|
-
if (!isStrictMode && !docType) {
|
|
2728
|
-
this.notify({
|
|
2729
|
-
message: `${getWindow(this.execution).LBL_DROP_FILE_DELETED}: ${unprocessedFiles.map((current) => current.name).join(", ")}.`,
|
|
2730
|
-
type: "warning"
|
|
2731
|
-
});
|
|
2732
|
-
return false;
|
|
2733
|
-
}
|
|
2734
|
-
const allowedFiles = this.filterAlreadyUploadedFiles(
|
|
2735
|
-
this.filterByFilesAmountLimit(
|
|
2736
|
-
this.filterAcceptedFiles(
|
|
2737
|
-
this.filterExistingFiles(
|
|
2738
|
-
this.filterVersioningFiles(unprocessedFiles, conf),
|
|
2739
|
-
conf
|
|
2740
|
-
),
|
|
2741
|
-
true,
|
|
2742
|
-
docType
|
|
2743
|
-
)
|
|
2744
|
-
),
|
|
2745
|
-
conf
|
|
2746
|
-
);
|
|
2747
|
-
if (allowedFiles.length > 0) {
|
|
2748
|
-
const formData = new FormData();
|
|
2749
|
-
allowedFiles.forEach(
|
|
2750
|
-
(file) => formData.append("fileRepository", file, file.name)
|
|
2751
|
-
);
|
|
2752
|
-
await post(
|
|
2753
|
-
this.execution,
|
|
2754
|
-
makeApiaUrl(
|
|
2755
|
-
this.execution,
|
|
2756
|
-
this.getSaveDroppedFilesParameters({
|
|
2757
|
-
action: "saveDroppedFiles",
|
|
2758
|
-
docId: this.state.versioningFile?.docId,
|
|
2759
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
2760
|
-
elemType: this.type,
|
|
2761
|
-
elemId: `prmDocumentContainter${this.type}`,
|
|
2762
|
-
frmOut: !this.modalController,
|
|
2763
|
-
docTypeId: this.state.selectedDocTypeId,
|
|
2764
|
-
langId
|
|
2765
|
-
})
|
|
2766
|
-
),
|
|
2767
|
-
{
|
|
2768
|
-
postData: formData,
|
|
2769
|
-
axiosConfig: {
|
|
2770
|
-
onUploadProgress: (ev) => this.state.progress = ev.loaded * 100 / ((ev.total ?? ev.loaded) * 2)
|
|
2771
|
-
}
|
|
2772
|
-
}
|
|
2773
|
-
);
|
|
2774
|
-
const ajaxUploadFileStatusParameters = this.getAjaxUploadFileStatusParameters({
|
|
2775
|
-
action: "ajaxUploadFileStatus",
|
|
2776
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
2777
|
-
delayForDrop: true,
|
|
2778
|
-
isAjax: true,
|
|
2779
|
-
prefix: this.type
|
|
2780
|
-
});
|
|
2781
|
-
let tries = 0;
|
|
2782
|
-
const checkUploadResult = async () => {
|
|
2783
|
-
return new Promise(async (resolve) => {
|
|
2784
|
-
tries += 1;
|
|
2785
|
-
if (tries === 10) {
|
|
2786
|
-
this.notify({
|
|
2787
|
-
message: "Error while checking for uploadFileStatus, too many tries",
|
|
2788
|
-
type: "error"
|
|
2789
|
-
});
|
|
2790
|
-
resolve(false);
|
|
2791
|
-
return;
|
|
2792
|
-
}
|
|
2793
|
-
const response = await post(
|
|
2794
|
-
this.execution,
|
|
2795
|
-
makeApiaUrl(this.execution, ajaxUploadFileStatusParameters)
|
|
2796
|
-
);
|
|
2797
|
-
if (response && response.data) {
|
|
2798
|
-
const hasMessages = arrayOrArray(
|
|
2799
|
-
response.data?.sysMessages?.message ?? response.data?.sysExceptions?.exception ?? response.data?.exceptions?.exception ?? response.data.function.messages?.message
|
|
2800
|
-
).length > 0 || !!response.data.function.dropLastMessage;
|
|
2801
|
-
const uploadMessage = arrayOrArray(
|
|
2802
|
-
response.data.function.messages?.message
|
|
2803
|
-
).find((current) => current.name === "message");
|
|
2804
|
-
if (uploadMessage)
|
|
2805
|
-
this.notify({ message: uploadMessage.label, type: "warning" });
|
|
2806
|
-
const method = response.data?.function.name;
|
|
2807
|
-
this.state.progress = 44;
|
|
2808
|
-
if (hasMessages) {
|
|
2809
|
-
resolve(false);
|
|
2810
|
-
return;
|
|
2811
|
-
}
|
|
2812
|
-
if (method === "fncProceedDocumentProcessing") {
|
|
2813
|
-
resolve(true);
|
|
2814
|
-
return;
|
|
2815
|
-
}
|
|
2816
|
-
if (tries === 10) {
|
|
2817
|
-
resolve(method === "fncProceedDocumentProcessing");
|
|
2818
|
-
}
|
|
2819
|
-
setTimeout(() => {
|
|
2820
|
-
checkUploadResult().then(resolve).catch(() => resolve(false));
|
|
2821
|
-
}, 100);
|
|
2822
|
-
} else {
|
|
2823
|
-
resolve(false);
|
|
2824
|
-
}
|
|
2825
|
-
});
|
|
2826
|
-
};
|
|
2827
|
-
const hasUploadedCorrectly = await checkUploadResult();
|
|
2828
|
-
this.state.progress = 66;
|
|
2829
|
-
if (hasUploadedCorrectly) {
|
|
2830
|
-
const shown = (this.state.inProgressFiles ?? []).map(
|
|
2831
|
-
(file) => file.name
|
|
2832
|
-
);
|
|
2833
|
-
const postData = QueryString.stringify(
|
|
2834
|
-
this.getProcessDroppedFilesPostdata({
|
|
2835
|
-
useDocTypePermitted: true,
|
|
2836
|
-
docTypePermittedObjId: this.docTypePermittedObjId?.toString(),
|
|
2837
|
-
docTypePermittedObjType: this.type,
|
|
2838
|
-
dropped: allowedFiles.map((file) => file.name).concat(shown),
|
|
2839
|
-
shown
|
|
2840
|
-
}),
|
|
2841
|
-
{ arrayFormat: "repeat" }
|
|
2842
|
-
);
|
|
2843
|
-
const secondResult = await post(
|
|
2844
|
-
this.execution,
|
|
2845
|
-
makeApiaUrl(
|
|
2846
|
-
this.execution,
|
|
2847
|
-
this.getProcessDroppedFilesParameters({
|
|
2848
|
-
action: "processDroppedFiles",
|
|
2849
|
-
elemType: this.type,
|
|
2850
|
-
docId: this.state.versioningFile?.docId,
|
|
2851
|
-
frmOut: !this.modalController,
|
|
2852
|
-
ajaxUrl: this.getAjaxUrl()
|
|
2853
|
-
})
|
|
2854
|
-
),
|
|
2855
|
-
{
|
|
2856
|
-
postData: postData.toString()
|
|
2857
|
-
}
|
|
2858
|
-
);
|
|
2859
|
-
this.state.progress = 83;
|
|
2860
|
-
if (secondResult?.data?.function?.principal?.docInfo) {
|
|
2861
|
-
const acceptedByServerFiles = arrayOrArray(
|
|
2862
|
-
secondResult.data.function?.principal?.docInfo
|
|
2863
|
-
);
|
|
2864
|
-
this.state.inProgressFiles = [
|
|
2865
|
-
...this.state.inProgressFiles ?? [],
|
|
2866
|
-
...acceptedByServerFiles.map(
|
|
2867
|
-
(current) => [...this.state.inProgressFiles, ...unprocessedFiles].find(
|
|
2868
|
-
(search) => search.name === current.docInfoName
|
|
2869
|
-
)
|
|
2870
|
-
).filter((current) => !!current)
|
|
2871
|
-
];
|
|
2872
|
-
this.state.progress = 100;
|
|
2873
|
-
if (this.modalController)
|
|
2874
|
-
this.modalController.state.fromDirectoryFile = null;
|
|
2875
|
-
this.notify({
|
|
2876
|
-
type: "success",
|
|
2877
|
-
message: getWindow(this.execution).FILE_UPLOADED_SUCCESSFULLY
|
|
2878
|
-
});
|
|
2879
|
-
if (isOneClickUploadEnabled(
|
|
2880
|
-
this.execution,
|
|
2881
|
-
this.modalConfig.oneClickUpload
|
|
2882
|
-
)) {
|
|
2883
|
-
if (langId && translatingFile)
|
|
2884
|
-
void this.confirmDropModal({ langId, translatingFile });
|
|
2885
|
-
else
|
|
2886
|
-
void this.confirmDropModal();
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
this.state.progress = 100;
|
|
2891
|
-
return true;
|
|
2892
|
-
} else {
|
|
2893
|
-
return false;
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
async checkWebDavLock(docId) {
|
|
2897
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
2898
|
-
return false;
|
|
2899
|
-
}
|
|
2900
|
-
return new Promise((resolve) => {
|
|
2901
|
-
let tries = 10;
|
|
2902
|
-
const checkLockAction = async () => {
|
|
2903
|
-
const isLocked = await post(
|
|
2904
|
-
this.execution,
|
|
2905
|
-
makeApiaUrl(
|
|
2906
|
-
this.execution,
|
|
2907
|
-
this.getCheckWebDavLockParameters({
|
|
2908
|
-
action: "isWebDavDocumentLocked",
|
|
2909
|
-
docId,
|
|
2910
|
-
ajaxUrl: getWindow(this.execution).URL_REQUEST_AJAX
|
|
2911
|
-
})
|
|
2912
|
-
)
|
|
2913
|
-
);
|
|
2914
|
-
if (isLocked?.data?.locked === true || isLocked?.data?.locked === void 0) {
|
|
2915
|
-
if (--tries > 0) {
|
|
2916
|
-
setTimeout(() => void checkLockAction(), 1e3);
|
|
2917
|
-
} else {
|
|
2918
|
-
this.notify({
|
|
2919
|
-
message: getWindow(this.execution).MSG_FAIL_SYNC_DOCUMENT
|
|
2920
|
-
});
|
|
2921
|
-
resolve(false);
|
|
2922
|
-
}
|
|
2923
|
-
} else {
|
|
2924
|
-
resolve(true);
|
|
2925
|
-
}
|
|
2926
|
-
};
|
|
2927
|
-
void checkLockAction();
|
|
2928
|
-
});
|
|
2929
|
-
}
|
|
2930
|
-
async checkSignature(file) {
|
|
2931
|
-
let res = null;
|
|
2932
|
-
if (Number(file.docId) >= 0)
|
|
2933
|
-
res = await get(
|
|
2934
|
-
this.execution,
|
|
2935
|
-
makeApiaUrl(
|
|
2936
|
-
this.execution,
|
|
2937
|
-
this.getCheckSignatureParameters({
|
|
2938
|
-
action: "viewDocSigns",
|
|
2939
|
-
docId: file.docId,
|
|
2940
|
-
lock: false,
|
|
2941
|
-
isAjax: true,
|
|
2942
|
-
prefix: this.type,
|
|
2943
|
-
react: true
|
|
2944
|
-
})
|
|
2945
|
-
)
|
|
2946
|
-
);
|
|
2947
|
-
return res;
|
|
2948
|
-
}
|
|
2949
|
-
async editDocument(id) {
|
|
2950
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
2951
|
-
return;
|
|
2952
|
-
}
|
|
2953
|
-
const file = this.getDocument(id);
|
|
2954
|
-
if (await this.checkLockDocument(file.docId) === true) {
|
|
2955
|
-
const result = await post(
|
|
2956
|
-
this.execution,
|
|
2957
|
-
makeApiaUrl(
|
|
2958
|
-
this.execution,
|
|
2959
|
-
this.getEditDocumentParameters({
|
|
2960
|
-
action: "updateWebDavDocument",
|
|
2961
|
-
docId: file.docId,
|
|
2962
|
-
prefix: this.type,
|
|
2963
|
-
isAjax: true
|
|
2964
|
-
})
|
|
2965
|
-
)
|
|
2966
|
-
);
|
|
2967
|
-
if (result?.data?.folderId) {
|
|
2968
|
-
const sDocumentUrl = `${getWindow(this.execution).WEBDAV_SERVER}${result?.data?.folderId}/${file.docId}/${file.name || file.docName || ""}`;
|
|
2969
|
-
const ProtocolInstallMessage = () => {
|
|
2970
|
-
this.notify({
|
|
2971
|
-
type: "warning",
|
|
2972
|
-
message: getWindow(this.execution).MSG_NO_DOC_EDIT_PROTOCOL,
|
|
2973
|
-
title: getWindow(this.execution).LBL_EDIT
|
|
2974
|
-
});
|
|
2975
|
-
};
|
|
2976
|
-
getWindow(this.execution).avoidLoadEvents = true;
|
|
2977
|
-
getWindow(this.execution).ITHit.WebDAV.Client.DavConstants.ProtocolTimeoutMs = 1e4;
|
|
2978
|
-
await getWindow(this.execution).ITHit.WebDAV.Client.DocManager.DavProtocolEditDocument(
|
|
2979
|
-
sDocumentUrl,
|
|
2980
|
-
getWindow(this.execution).WEBDAV_SERVER,
|
|
2981
|
-
ProtocolInstallMessage,
|
|
2982
|
-
null,
|
|
2983
|
-
"Current",
|
|
2984
|
-
"ApiaWebDavCookie",
|
|
2985
|
-
// Cookie(s) to copy.
|
|
2986
|
-
"",
|
|
2987
|
-
// URL to navigate to if any cookie from the list is not found.
|
|
2988
|
-
"Edit"
|
|
2989
|
-
);
|
|
2990
|
-
}
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
|
-
async downloadVersion(fileId, version) {
|
|
2994
|
-
const file = this.getDocument(fileId);
|
|
2995
|
-
if (!file)
|
|
2996
|
-
return;
|
|
2997
|
-
if (getWindow(this.execution).IN_MONITOR || await this.checkWebDavLock(file.docId))
|
|
2998
|
-
await downloadUrl(
|
|
2999
|
-
makeApiaUrl(this.execution, {
|
|
3000
|
-
action: "downloadDocument",
|
|
3001
|
-
docId: file.downloadDocId,
|
|
3002
|
-
version
|
|
3003
|
-
})
|
|
3004
|
-
);
|
|
3005
|
-
}
|
|
3006
|
-
async downloadDocument(id, version) {
|
|
3007
|
-
const file = this.getDocument(id);
|
|
3008
|
-
if (getWindow(this.execution).IN_MONITOR || await this.checkWebDavLock(file.docId)) {
|
|
3009
|
-
await downloadUrl(
|
|
3010
|
-
makeApiaUrl(this.execution, {
|
|
3011
|
-
action: "downloadDocument",
|
|
3012
|
-
prefix: this.type,
|
|
3013
|
-
docId: file.downloadDocId,
|
|
3014
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
3015
|
-
version
|
|
3016
|
-
})
|
|
3017
|
-
);
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
async ajaxDeleteDocument(id, langId) {
|
|
3021
|
-
const file = this.getDocument(id);
|
|
3022
|
-
const isLocked = await this.checkLockDocument(file.docId);
|
|
3023
|
-
if (isLocked === true) {
|
|
3024
|
-
const result = await post(
|
|
3025
|
-
this.execution,
|
|
3026
|
-
makeApiaUrl(
|
|
3027
|
-
this.execution,
|
|
3028
|
-
this.getDeleteDocumentParameters({
|
|
3029
|
-
action: "ajaxRemoveDocument",
|
|
3030
|
-
docId: file.docId,
|
|
3031
|
-
isAjax: true,
|
|
3032
|
-
prefix: this.type,
|
|
3033
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
3034
|
-
langId
|
|
3035
|
-
})
|
|
3036
|
-
)
|
|
3037
|
-
);
|
|
3038
|
-
if (this.evaluateDeleteDocumentResult(result?.data))
|
|
3039
|
-
this.deleteDocument(id);
|
|
3040
|
-
}
|
|
3041
|
-
}
|
|
3042
|
-
async version(file, conf = { newFiles: [] }) {
|
|
3043
|
-
const checkLock = await this.checkLockDocument(file.docId, true);
|
|
3044
|
-
const isLocked = await this.checkWebDavLock(file.docId);
|
|
3045
|
-
if (!(checkLock === true && isLocked))
|
|
3046
|
-
return;
|
|
3047
|
-
this.state.versioningFile = file;
|
|
3048
|
-
const openVersionModal = () => {
|
|
3049
|
-
if (!this.modalConfig.oneClickUpload) {
|
|
3050
|
-
this.modalController = new UploaderModalController(
|
|
3051
|
-
this,
|
|
3052
|
-
this.modalConfig,
|
|
3053
|
-
{
|
|
3054
|
-
versionFile: file
|
|
3055
|
-
}
|
|
3056
|
-
);
|
|
3057
|
-
this.modalController.openModal();
|
|
3058
|
-
}
|
|
3059
|
-
};
|
|
3060
|
-
if (!conf.newFiles || conf.newFiles.length === 0) {
|
|
3061
|
-
openVersionModal();
|
|
3062
|
-
}
|
|
3063
|
-
await this.ajaxUploadStart();
|
|
3064
|
-
if (file.docTypeId)
|
|
3065
|
-
this.state.selectedDocTypeId = file.docTypeId;
|
|
3066
|
-
await this.versionFileInfo(file);
|
|
3067
|
-
const hasNewFiles = !!(conf.newFiles && conf.newFiles.length > 0);
|
|
3068
|
-
if (hasNewFiles) {
|
|
3069
|
-
const res = await this.saveDroppedFiles(conf.newFiles, {
|
|
3070
|
-
langId: conf.langId,
|
|
3071
|
-
translatingFile: conf.translatingFile,
|
|
3072
|
-
shouldReset: false,
|
|
3073
|
-
strictMode: true
|
|
3074
|
-
});
|
|
3075
|
-
if (res) {
|
|
3076
|
-
openVersionModal();
|
|
3077
|
-
}
|
|
3078
|
-
} else {
|
|
3079
|
-
await this.reloadMetadata({
|
|
3080
|
-
docId: file.docId,
|
|
3081
|
-
docTypeId: file.docTypeId
|
|
3082
|
-
});
|
|
3083
|
-
}
|
|
3084
|
-
}
|
|
3085
|
-
async versionFileInfo(file) {
|
|
3086
|
-
const documentInfo = await this.getDocumentInfo({ docId: file.docId });
|
|
3087
|
-
if (documentInfo?.function) {
|
|
3088
|
-
const {
|
|
3089
|
-
data: { general },
|
|
3090
|
-
metadatas
|
|
3091
|
-
} = documentInfo.function;
|
|
3092
|
-
const isFreeMetadata = this.state.allowedTypes.find((current) => current.id === file.docTypeId)?.free ?? false;
|
|
3093
|
-
if (this.modalController) {
|
|
3094
|
-
this.modalController.state = {
|
|
3095
|
-
description: general.docDesc,
|
|
3096
|
-
docFolder: general.docFolder === "" ? void 0 : Number(general.docFolder),
|
|
3097
|
-
docPath: general.docFolderPath,
|
|
3098
|
-
permissions: {
|
|
3099
|
-
allowAllType: general.docAllPoolPerm,
|
|
3100
|
-
users: arrayOrArray(
|
|
3101
|
-
documentInfo.function.data.permissions?.user
|
|
3102
|
-
).map((current) => {
|
|
3103
|
-
const returnObject = {
|
|
3104
|
-
canUpdate: current.permType === "M",
|
|
3105
|
-
userId: current.id,
|
|
3106
|
-
userLogin: current.name
|
|
3107
|
-
};
|
|
3108
|
-
return returnObject;
|
|
3109
|
-
}),
|
|
3110
|
-
pools: arrayOrArray(
|
|
3111
|
-
documentInfo.function.data.permissions?.pool
|
|
3112
|
-
).map((current) => {
|
|
3113
|
-
const returnObject = {
|
|
3114
|
-
canUpdate: current.permType === "M",
|
|
3115
|
-
poolId: current.id,
|
|
3116
|
-
poolName: current.name
|
|
3117
|
-
};
|
|
3118
|
-
return returnObject;
|
|
3119
|
-
})
|
|
3120
|
-
},
|
|
3121
|
-
docExpDate: general.docExpDate,
|
|
3122
|
-
fileReqError: false,
|
|
3123
|
-
fromDirectoryFile: null,
|
|
3124
|
-
metadata: {
|
|
3125
|
-
metadataArray: arrayOrArray(metadatas?.metadata),
|
|
3126
|
-
freeMetadataArray: [],
|
|
3127
|
-
isFreeMetadata
|
|
3128
|
-
}
|
|
3129
|
-
};
|
|
3130
|
-
}
|
|
3131
|
-
}
|
|
3132
|
-
}
|
|
3133
|
-
async pickFileById(id) {
|
|
3134
|
-
const documentInfo = await this.getDocumentInfo(
|
|
3135
|
-
{ downloadDocId: id },
|
|
3136
|
-
true
|
|
3137
|
-
);
|
|
3138
|
-
if (documentInfo) {
|
|
3139
|
-
const document = documentInfo.function.data.general;
|
|
3140
|
-
const { permissions } = documentInfo.function.data;
|
|
3141
|
-
if (this.modalController) {
|
|
3142
|
-
this.setCurrentDocTypeId(document.docTypeId);
|
|
3143
|
-
this.modalController.addDirectoryFile(document);
|
|
3144
|
-
this.modalController.state.description = document.docDesc;
|
|
3145
|
-
this.modalController.state.docExpDate = document.docExpDate;
|
|
3146
|
-
this.modalController.state.permissions = {
|
|
3147
|
-
pools: arrayOrArray(permissions?.pool).map((c) => {
|
|
3148
|
-
return {
|
|
3149
|
-
poolId: c.id,
|
|
3150
|
-
poolName: c.name,
|
|
3151
|
-
canUpdate: c.permType === "M"
|
|
3152
|
-
};
|
|
3153
|
-
}),
|
|
3154
|
-
users: [
|
|
3155
|
-
...arrayOrArray(permissions?.user).map((c) => {
|
|
3156
|
-
return {
|
|
3157
|
-
userId: c.id,
|
|
3158
|
-
userLogin: c.name,
|
|
3159
|
-
canUpdate: c.permType === "M"
|
|
3160
|
-
};
|
|
3161
|
-
})
|
|
3162
|
-
],
|
|
3163
|
-
allowAllType: document.docAllPoolPerm
|
|
3164
|
-
};
|
|
3165
|
-
this.modalController.changeDocType(document.docTypeId);
|
|
3166
|
-
this.modalController.state.isReadonly = !documentInfo.function.currentUsrPems.usrCanModify;
|
|
3167
|
-
}
|
|
3168
|
-
void this.reloadMetadata(
|
|
3169
|
-
{ docId: document.docId, docTypeId: document.docTypeId },
|
|
3170
|
-
{
|
|
3171
|
-
docReuse: true
|
|
3172
|
-
}
|
|
3173
|
-
);
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
async markFileToSign(id, langId) {
|
|
3177
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
3178
|
-
return;
|
|
3179
|
-
}
|
|
3180
|
-
const file = this.getDocument(id);
|
|
3181
|
-
if (await this.checkLockDocument(file.docId) === true) {
|
|
3182
|
-
const marked = await post(
|
|
3183
|
-
this.execution,
|
|
3184
|
-
makeApiaUrl(
|
|
3185
|
-
this.execution,
|
|
3186
|
-
this.getMarkFileToSignParameters({
|
|
3187
|
-
action: "markDocTosign",
|
|
3188
|
-
docId: file.docId,
|
|
3189
|
-
isAjax: true,
|
|
3190
|
-
prefix: this.type,
|
|
3191
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
3192
|
-
langId
|
|
3193
|
-
})
|
|
3194
|
-
)
|
|
3195
|
-
);
|
|
3196
|
-
if (marked?.data?.markedToSign !== void 0) {
|
|
3197
|
-
if (this.state.files[id]) {
|
|
3198
|
-
this.state.files[id].markedToSign = marked.data.markedToSign;
|
|
3199
|
-
} else {
|
|
3200
|
-
this.state.translatedFiles.forEach((innerMap) => {
|
|
3201
|
-
innerMap.forEach((doc, langKey) => {
|
|
3202
|
-
if (doc.docId === id) {
|
|
3203
|
-
innerMap.set(langKey, {
|
|
3204
|
-
...doc,
|
|
3205
|
-
markedToSign: marked?.data?.markedToSign ?? false
|
|
3206
|
-
});
|
|
3207
|
-
}
|
|
3208
|
-
});
|
|
3209
|
-
});
|
|
3210
|
-
}
|
|
3211
|
-
}
|
|
3212
|
-
}
|
|
3213
|
-
}
|
|
3214
|
-
/**
|
|
3215
|
-
* Por el momento realiza la descarga de todos los archivos
|
|
3216
|
-
* que estén subidos.
|
|
3217
|
-
*/
|
|
3218
|
-
downloadMultipleDocuments() {
|
|
3219
|
-
const files = this.filesArray;
|
|
3220
|
-
if (files.length === 0)
|
|
3221
|
-
return;
|
|
3222
|
-
const docIds = this.state.selectedFiles;
|
|
3223
|
-
const selectedFiles = files.filter(
|
|
3224
|
-
(current) => docIds.find((search) => search === current.docId)
|
|
3225
|
-
);
|
|
3226
|
-
const ids = (selectedFiles.length > 0 ? selectedFiles : files).map((current) => current.downloadDocId).join("-");
|
|
3227
|
-
void downloadUrl(
|
|
3228
|
-
makeApiaUrl(
|
|
3229
|
-
this.execution,
|
|
3230
|
-
this.getDownloadMultipleDocumentsParameters({
|
|
3231
|
-
action: "multipleDownload",
|
|
3232
|
-
docId: ids,
|
|
3233
|
-
prefix: this.type
|
|
3234
|
-
})
|
|
3235
|
-
),
|
|
3236
|
-
"documents.zip"
|
|
3237
|
-
);
|
|
3238
|
-
}
|
|
3239
|
-
async confirmDropModal(conf) {
|
|
3240
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
3241
|
-
return false;
|
|
3242
|
-
}
|
|
3243
|
-
const { langId, translatingFile } = conf ?? {};
|
|
3244
|
-
const cmbDocType = this.state.selectedDocTypeId;
|
|
3245
|
-
const fromDirectoryFile = this.modalController?.state.fromDirectoryFile;
|
|
3246
|
-
const docDesc = this.modalController?.description ?? "";
|
|
3247
|
-
const docAllowAllType = this.modalConfig.oneClickUpload ? "M" : this.modalController?.allowAllType ?? "";
|
|
3248
|
-
const docFolder = this.modalController?.docFolder;
|
|
3249
|
-
const docExpDate = this.modalController?.docExpDate;
|
|
3250
|
-
const metadata = this.modalController?.metadata ?? [];
|
|
3251
|
-
const freeMetadata = this.modalController?.freeMetadata ?? [];
|
|
3252
|
-
const poolsPermissions = this.modalController?.state.permissions.pools ?? [];
|
|
3253
|
-
const usersPermissions = this.modalController?.state.permissions.users ?? [];
|
|
3254
|
-
let postData = QueryString.stringify(
|
|
3255
|
-
this.getConfirmDropModalPostdata({
|
|
3256
|
-
cmbDocType,
|
|
3257
|
-
docDesc,
|
|
3258
|
-
docAllowAllType,
|
|
3259
|
-
pe: this.docTypePermittedObjId?.toString(),
|
|
3260
|
-
dropped: this.state.inProgressFiles.map((file) => file.name),
|
|
3261
|
-
txtLangId: langId,
|
|
3262
|
-
txtLangGroup: translatingFile?.docLangGroup,
|
|
3263
|
-
docFolder
|
|
3264
|
-
}),
|
|
3265
|
-
{ arrayFormat: "repeat" }
|
|
3266
|
-
);
|
|
3267
|
-
postData = `${postData}${postData.length > 0 ? "&" : ""}${this.getConfirmDropModalPermissionsString({
|
|
3268
|
-
poolsPermissions,
|
|
3269
|
-
usersPermissions
|
|
3270
|
-
})}&txtFreeMetadata=${this.getConfirmDropModalAdditionalMetadataString(
|
|
3271
|
-
freeMetadata
|
|
3272
|
-
)}&txtMetadata=${this.getConfirmDropModalMetadataString({
|
|
3273
|
-
metadata: Object.values(metadata || {})
|
|
3274
|
-
})}&docExpDate=${docExpDate ?? ""}`;
|
|
3275
|
-
const result = await post(
|
|
3276
|
-
this.execution,
|
|
3277
|
-
makeApiaUrl(
|
|
3278
|
-
this.execution,
|
|
3279
|
-
this.getConfirmDropModalParameters({
|
|
3280
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
3281
|
-
docId: fromDirectoryFile ? fromDirectoryFile.docId : this.state.versioningFile?.docId,
|
|
3282
|
-
action: fromDirectoryFile ? "associateExistingFile" : "confirmDropModal",
|
|
3283
|
-
elemType: this.type,
|
|
3284
|
-
fromForm: true,
|
|
3285
|
-
...fromDirectoryFile ? {
|
|
3286
|
-
docId: fromDirectoryFile.docId,
|
|
3287
|
-
fromReuse: true,
|
|
3288
|
-
uploadDocument: false
|
|
3289
|
-
} : null
|
|
3290
|
-
})
|
|
3291
|
-
),
|
|
3292
|
-
{
|
|
3293
|
-
postData: postData.toString()
|
|
3294
|
-
}
|
|
3295
|
-
);
|
|
3296
|
-
if (result?.data?.function) {
|
|
3297
|
-
const currentFiles = { ...this.state.files };
|
|
3298
|
-
const versioningFile = this.state.versioningFile;
|
|
3299
|
-
if (versioningFile && versioningFile.name) {
|
|
3300
|
-
delete currentFiles[versioningFile.name];
|
|
3301
|
-
}
|
|
3302
|
-
const newFiles = arrayOrArray(
|
|
3303
|
-
result.data.function.general
|
|
3304
|
-
).map(
|
|
3305
|
-
(current) => this.parseFileDefinition({
|
|
3306
|
-
...current,
|
|
3307
|
-
canWrite: true,
|
|
3308
|
-
canRead: true,
|
|
3309
|
-
canEdit: true
|
|
3310
|
-
})
|
|
3311
|
-
).filter((current) => !currentFiles[current.docId]).reduce((acc, current) => ({ ...acc, [current.docId]: current }), {});
|
|
3312
|
-
if (langId && translatingFile) {
|
|
3313
|
-
const firstFile = Object.values(newFiles)[0];
|
|
3314
|
-
this.setTranslationFile(firstFile, translatingFile.docId, langId);
|
|
3315
|
-
} else {
|
|
3316
|
-
this.state.files = { ...currentFiles, ...newFiles };
|
|
3317
|
-
}
|
|
3318
|
-
this.clearFiles();
|
|
3319
|
-
this.emit("fileUploaded", null);
|
|
3320
|
-
return true;
|
|
3321
|
-
}
|
|
3322
|
-
return false;
|
|
3323
|
-
}
|
|
3324
|
-
async loadCurrentDocuments() {
|
|
3325
|
-
const result = await post(
|
|
3326
|
-
this.execution,
|
|
3327
|
-
makeApiaUrl(this.execution, {
|
|
3328
|
-
ajaxUrl: this.getAjaxUrl(),
|
|
3329
|
-
action: "ajaxLoadCurrent",
|
|
3330
|
-
isAjax: true,
|
|
3331
|
-
readOnly: getWindow(this.execution).IS_READONLY,
|
|
3332
|
-
allowLock: true,
|
|
3333
|
-
allowSign: true,
|
|
3334
|
-
allowMultiple: true,
|
|
3335
|
-
prefix: this.type
|
|
3336
|
-
}),
|
|
3337
|
-
{}
|
|
3338
|
-
);
|
|
3339
|
-
if (result && result.data) {
|
|
3340
|
-
const currentConfiguration = arrayOrArray(result.data.function.messages.message).reduce(
|
|
3341
|
-
(prev, { name, label }) => ({ ...prev, [name]: Boolean(label) }),
|
|
3342
|
-
{}
|
|
3343
|
-
);
|
|
3344
|
-
const currentFiles = result.data.function.general ? arrayOrArray(result.data.function.general).map(
|
|
3345
|
-
this.parseFileDefinition
|
|
3346
|
-
) : [];
|
|
3347
|
-
this.currentConfiguration = currentConfiguration;
|
|
3348
|
-
const nonTranslationFiles = [];
|
|
3349
|
-
const translationFiles = [];
|
|
3350
|
-
currentFiles.forEach((current) => {
|
|
3351
|
-
if (current.docLang === void 0)
|
|
3352
|
-
nonTranslationFiles.push(current);
|
|
3353
|
-
else
|
|
3354
|
-
translationFiles.push(current);
|
|
3355
|
-
});
|
|
3356
|
-
nonTranslationFiles.forEach((c) => {
|
|
3357
|
-
this.state.files[c.docId] = c;
|
|
3358
|
-
});
|
|
3359
|
-
translationFiles.forEach((current) => {
|
|
3360
|
-
const originalFile = nonTranslationFiles.find(
|
|
3361
|
-
(search) => search.docLangGroup === current.docLangGroup
|
|
3362
|
-
);
|
|
3363
|
-
if (originalFile && current.docLang !== void 0) {
|
|
3364
|
-
this.setTranslationFile(
|
|
3365
|
-
current,
|
|
3366
|
-
originalFile.docId,
|
|
3367
|
-
Number(current.docLang)
|
|
3368
|
-
);
|
|
3369
|
-
} else
|
|
3370
|
-
console.warn(
|
|
3371
|
-
`The following file is translated but has no orignal file`,
|
|
3372
|
-
current,
|
|
3373
|
-
nonTranslationFiles
|
|
3374
|
-
);
|
|
3375
|
-
});
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
async lockDocument(id) {
|
|
3379
|
-
if (getWindow(this.execution).IN_MONITOR) {
|
|
3380
|
-
return;
|
|
3381
|
-
}
|
|
3382
|
-
const file = this.getDocument(id);
|
|
3383
|
-
if (file.markedToSign) {
|
|
3384
|
-
this.notify({
|
|
3385
|
-
message: getWindow(this.execution).CANT_UNLOCK_MARKED_TO_SIGN,
|
|
3386
|
-
type: "warning"
|
|
3387
|
-
});
|
|
3388
|
-
return;
|
|
3389
|
-
}
|
|
3390
|
-
if (!file.isLocked || !file.isLockedByMe) {
|
|
3391
|
-
const isLocked = await this.checkLockDocument(file.docId, false);
|
|
3392
|
-
this.updateDocument(
|
|
3393
|
-
id,
|
|
3394
|
-
typeof isLocked === "string" ? this.parseFileDefinition({
|
|
3395
|
-
...file,
|
|
3396
|
-
userLocking: isLocked,
|
|
3397
|
-
lock: true,
|
|
3398
|
-
isLocked: true,
|
|
3399
|
-
lockedBy: isLocked
|
|
3400
|
-
}) : { ...file, isLocked }
|
|
3401
|
-
);
|
|
1938
|
+
let match;
|
|
1939
|
+
while ((match = regex.exec(this.definition.trad ?? "{}")) !== null) {
|
|
1940
|
+
const key = match[1];
|
|
1941
|
+
const value = match[2] === "true";
|
|
1942
|
+
tradMap[key] = value;
|
|
3402
1943
|
}
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
this.updateDocument(
|
|
3421
|
-
resultFile.docId,
|
|
3422
|
-
this.parseFileDefinition({
|
|
3423
|
-
...file,
|
|
3424
|
-
...resultFile,
|
|
3425
|
-
isLocked: resultFile.locked
|
|
1944
|
+
this.definitionTradParsed = tradMap;
|
|
1945
|
+
}
|
|
1946
|
+
getLanguages() {
|
|
1947
|
+
return arrayOrArray(parseFakeJSON(this.getForm().definition?.langs ?? ""));
|
|
1948
|
+
}
|
|
1949
|
+
async init(form) {
|
|
1950
|
+
await super.init(form);
|
|
1951
|
+
if (this.getLanguages().length > 0) {
|
|
1952
|
+
this.extractTrad();
|
|
1953
|
+
this.getLanguages().forEach((lang) => {
|
|
1954
|
+
const isTranslated = this.definitionTradParsed[lang.id] ?? false;
|
|
1955
|
+
this.translations.set(
|
|
1956
|
+
lang.id,
|
|
1957
|
+
new Translation(this.form.execution, {
|
|
1958
|
+
id: lang.id,
|
|
1959
|
+
label: lang.label,
|
|
1960
|
+
isTranslated
|
|
3426
1961
|
})
|
|
3427
1962
|
);
|
|
1963
|
+
});
|
|
1964
|
+
this.selectedLanguageId = this.getLanguages()[0].id;
|
|
3428
1965
|
}
|
|
3429
1966
|
}
|
|
3430
|
-
|
|
3431
|
-
|
|
1967
|
+
cancelTranslations() {
|
|
1968
|
+
this.getTranslations().forEach((c) => {
|
|
1969
|
+
c.reset();
|
|
1970
|
+
});
|
|
3432
1971
|
}
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
}
|
|
3437
|
-
this.state.translatedFiles.get(docId)?.set(langId, file);
|
|
1972
|
+
deleteTranslations() {
|
|
1973
|
+
this.getTranslations().forEach((c) => {
|
|
1974
|
+
c.deleteTranslation();
|
|
1975
|
+
});
|
|
3438
1976
|
}
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
return files;
|
|
3443
|
-
const uploadedFiles = Object.values(this.state.files).filter(
|
|
3444
|
-
(file) => Number(file.docId) > 0
|
|
3445
|
-
);
|
|
3446
|
-
const existingFiles = [];
|
|
3447
|
-
const nonExistingFiles = [];
|
|
3448
|
-
if (conf?.langId) {
|
|
3449
|
-
const docId = conf.translatingFile?.docId ?? Infinity;
|
|
3450
|
-
const translationsMap = this.state.translatedFiles.get(String(docId));
|
|
3451
|
-
const alreadyUploadedToTranslationsFile = translationsMap ? Array.from(translationsMap.values()).find(
|
|
3452
|
-
(current) => (current.docName || current.name) === files[0]?.name
|
|
3453
|
-
) : void 0;
|
|
3454
|
-
if (alreadyUploadedToTranslationsFile)
|
|
3455
|
-
existingFiles.push(files[0]);
|
|
3456
|
-
} else
|
|
3457
|
-
files.forEach((file) => {
|
|
3458
|
-
if (uploadedFiles.find((search) => search.docName === file.name)) {
|
|
3459
|
-
existingFiles.push(file);
|
|
3460
|
-
} else
|
|
3461
|
-
nonExistingFiles.push(file);
|
|
3462
|
-
});
|
|
3463
|
-
if (existingFiles.length > 0) {
|
|
3464
|
-
void this.notify({
|
|
3465
|
-
message: `${getWindow(this.execution).LBL_DROP_FILE_REPEATED}: ${existingFiles.map((current) => current.name).join(", ")}`,
|
|
3466
|
-
type: "warning"
|
|
3467
|
-
});
|
|
3468
|
-
return nonExistingFiles;
|
|
3469
|
-
}
|
|
3470
|
-
return files;
|
|
1977
|
+
async changeLanguage(langId) {
|
|
1978
|
+
this.selectedLanguageId = langId;
|
|
1979
|
+
this.syncTranslation();
|
|
3471
1980
|
}
|
|
3472
|
-
|
|
3473
|
-
return
|
|
3474
|
-
|
|
3475
|
-
|
|
1981
|
+
getTranslation(id) {
|
|
1982
|
+
return this.translations.get(id);
|
|
1983
|
+
}
|
|
1984
|
+
getCurrentTranslation() {
|
|
1985
|
+
return this.translations.get(this.selectedLanguageId);
|
|
1986
|
+
}
|
|
1987
|
+
getTranslations() {
|
|
1988
|
+
return this.translations;
|
|
1989
|
+
}
|
|
1990
|
+
submitTranslations() {
|
|
1991
|
+
[...this.getTranslations().values()].filter((c) => c.state.hasChanged).forEach((c) => {
|
|
1992
|
+
c.submitTranslation(
|
|
1993
|
+
c.value,
|
|
1994
|
+
this.getSynchronizeUrl({
|
|
1995
|
+
react: true,
|
|
1996
|
+
preventAsXmlParameter: true,
|
|
1997
|
+
langId: c.langId
|
|
1998
|
+
})
|
|
1999
|
+
);
|
|
2000
|
+
});
|
|
2001
|
+
this.state.validation.errorMessage = null;
|
|
2002
|
+
}
|
|
2003
|
+
async syncTranslation() {
|
|
2004
|
+
const langId = this.selectedLanguageId;
|
|
2005
|
+
this.isTradLoading = true;
|
|
2006
|
+
await this.getTranslation(langId)?.readTranslations(
|
|
2007
|
+
await makeApiaUrl(this.form.execution, {
|
|
2008
|
+
ajaxUrl: "/apia.execution.FormAction.run",
|
|
2009
|
+
action: "getFieldTranslations",
|
|
2010
|
+
frmId: this.getForm().definition.id,
|
|
2011
|
+
frmParent: this.getForm().definition.frmParent,
|
|
2012
|
+
fldId: this.definition.id,
|
|
2013
|
+
attId: this.attribute.id,
|
|
2014
|
+
langId,
|
|
2015
|
+
react: true
|
|
2016
|
+
})
|
|
3476
2017
|
);
|
|
2018
|
+
this.isTradLoading = false;
|
|
3477
2019
|
}
|
|
3478
|
-
|
|
3479
|
-
const
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
if (
|
|
3483
|
-
const
|
|
3484
|
-
const
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
return true;
|
|
3494
|
-
})) {
|
|
3495
|
-
isAllowed = false;
|
|
3496
|
-
notAllowedFilesBecauseOfExtension.push(currentFile);
|
|
3497
|
-
}
|
|
3498
|
-
if (isAllowed && !docTypes.find((currentDocType) => {
|
|
3499
|
-
if (Number(currentDocType.maxSize) < currentFile.size) {
|
|
3500
|
-
maxSize = Number(currentDocType.maxSize);
|
|
3501
|
-
return false;
|
|
3502
|
-
}
|
|
3503
|
-
return true;
|
|
3504
|
-
})) {
|
|
3505
|
-
notAllowedFilesBecauseOfSize.push(currentFile);
|
|
3506
|
-
isAllowed = false;
|
|
3507
|
-
}
|
|
3508
|
-
if (!isAllowed)
|
|
3509
|
-
return false;
|
|
3510
|
-
return true;
|
|
3511
|
-
});
|
|
3512
|
-
if (shouldNotify) {
|
|
3513
|
-
let errorMessage = "";
|
|
3514
|
-
if (notAllowedFilesBecauseOfExtension.length > 0) {
|
|
3515
|
-
const filesNames = notAllowedFilesBecauseOfExtension.reduce(
|
|
3516
|
-
(accumulated, current) => {
|
|
3517
|
-
if (accumulated.length === 0)
|
|
3518
|
-
return current.name;
|
|
3519
|
-
return `${accumulated}, ${current.name}`;
|
|
3520
|
-
},
|
|
3521
|
-
""
|
|
3522
|
-
);
|
|
3523
|
-
errorMessage = `<strong>${getWindow(this.execution).FILES_WRONG_EXT}</strong><br />${filesNames}`;
|
|
3524
|
-
}
|
|
3525
|
-
if (notAllowedFilesBecauseOfSize.length > 0) {
|
|
3526
|
-
const filesNames = notAllowedFilesBecauseOfSize.reduce(
|
|
3527
|
-
(accumulated, current) => {
|
|
3528
|
-
if (accumulated.length === 0)
|
|
3529
|
-
return current.name;
|
|
3530
|
-
return `${accumulated}, ${current.name}`;
|
|
3531
|
-
},
|
|
3532
|
-
""
|
|
3533
|
-
);
|
|
3534
|
-
if (errorMessage.length > 0)
|
|
3535
|
-
errorMessage = `${errorMessage} <br /><br />`;
|
|
3536
|
-
errorMessage = `${errorMessage}${formatMessage(
|
|
3537
|
-
getWindow(this.execution).FILES_TOO_BIG,
|
|
3538
|
-
{
|
|
3539
|
-
TOK1: `<br />${filesNames}`,
|
|
3540
|
-
TOK2: `${parseAsSize(maxSize)}`
|
|
3541
|
-
}
|
|
3542
|
-
)}`;
|
|
3543
|
-
}
|
|
3544
|
-
if (errorMessage.length > 0)
|
|
3545
|
-
this.notify({
|
|
3546
|
-
message: errorMessage,
|
|
3547
|
-
type: "warning"
|
|
3548
|
-
});
|
|
2020
|
+
async validate() {
|
|
2021
|
+
const isSuperValid = await super.validate();
|
|
2022
|
+
let isValid = isSuperValid;
|
|
2023
|
+
const canValidate = isSuperValid && this.properties.reqTrad && this.hasValue() && (!this.properties.inputAsText || !this.properties.visibilityHidden || !this.properties.disabled);
|
|
2024
|
+
if (canValidate) {
|
|
2025
|
+
const translations = [...this.getTranslations().values()];
|
|
2026
|
+
const tradNotValidated = translations.find((c) => !c.state.isTranslated);
|
|
2027
|
+
if (tradNotValidated) {
|
|
2028
|
+
this.state.validation.errorMessage = labels.errorTranslateRequired(
|
|
2029
|
+
this.form.execution,
|
|
2030
|
+
tradNotValidated.state.label
|
|
2031
|
+
);
|
|
2032
|
+
isValid = false;
|
|
2033
|
+
} else {
|
|
2034
|
+
this.state.validation.errorMessage = null;
|
|
3549
2035
|
}
|
|
3550
|
-
return allowedFiles;
|
|
3551
2036
|
}
|
|
3552
|
-
return
|
|
2037
|
+
return isValid;
|
|
3553
2038
|
}
|
|
3554
|
-
|
|
3555
|
-
if (
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
(current) => Number(current.docId) < 0
|
|
3560
|
-
);
|
|
3561
|
-
let alreadyIncludedFileNames = "";
|
|
3562
|
-
const filteredFiles = files.filter((current) => {
|
|
3563
|
-
const isIncluded = currentFiles.findIndex((search) => search.name === current.name) !== -1 || alreadyUploadedFiles.findIndex(
|
|
3564
|
-
(search) => search.docName === current.name
|
|
3565
|
-
) !== -1;
|
|
3566
|
-
if (isIncluded)
|
|
3567
|
-
alreadyIncludedFileNames = `${alreadyIncludedFileNames}${alreadyIncludedFileNames.length > 0 ? ", " : ""}${current.name}`;
|
|
3568
|
-
return !isIncluded;
|
|
3569
|
-
});
|
|
3570
|
-
if (alreadyIncludedFileNames.length > 0)
|
|
3571
|
-
this.notify({
|
|
3572
|
-
message: `${getWindow(this.execution).LBL_DROP_FILE_REPEATED}: ${alreadyIncludedFileNames}`,
|
|
3573
|
-
type: "warning"
|
|
3574
|
-
});
|
|
3575
|
-
return filteredFiles;
|
|
2039
|
+
setValue(newValue, options) {
|
|
2040
|
+
if (newValue === "") {
|
|
2041
|
+
this.deleteTranslations();
|
|
2042
|
+
}
|
|
2043
|
+
return super.setValue(newValue, options);
|
|
3576
2044
|
}
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
2045
|
+
}
|
|
2046
|
+
|
|
2047
|
+
class Editor extends TranslatableField {
|
|
2048
|
+
fireEvent(eventName, options) {
|
|
2049
|
+
return super.fireEvent(eventName, options);
|
|
2050
|
+
}
|
|
2051
|
+
isValidValue() {
|
|
2052
|
+
return !!String(this.getValue()).trim();
|
|
2053
|
+
}
|
|
2054
|
+
getSynchronizePostConfiguration(value) {
|
|
2055
|
+
const conf = super.getSynchronizePostConfiguration(value);
|
|
2056
|
+
conf.postData.clearValues = "true";
|
|
2057
|
+
return conf;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
var __defProp$i = Object.defineProperty;
|
|
2062
|
+
var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2063
|
+
var __publicField$i = (obj, key, value) => {
|
|
2064
|
+
__defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2065
|
+
return value;
|
|
2066
|
+
};
|
|
2067
|
+
class UploaderApi extends UploaderApi$1 {
|
|
2068
|
+
constructor(execution, id, type, modalConfig) {
|
|
2069
|
+
super({
|
|
2070
|
+
id,
|
|
2071
|
+
modalConfig: { ...modalConfig, renderers: execution.renderers },
|
|
2072
|
+
context: {
|
|
2073
|
+
allowTranslation: type === "E" && !!getWindow(execution).DOC_LANGS,
|
|
2074
|
+
CONTEXT: getWindow(execution).CONTEXT,
|
|
2075
|
+
currentUserLogin: getWindow(execution).CURRENT_USER_LOGIN,
|
|
2076
|
+
docLangs: getWindow(execution).DOC_LANGS,
|
|
2077
|
+
everyoneCanUpdate: getWindow(execution).DOCUMENT_EVERYONE_PERMISSION !== false,
|
|
2078
|
+
IN_MONITOR: getWindow(execution).IN_MONITOR,
|
|
2079
|
+
ITHit: getWindow(execution).ITHit,
|
|
2080
|
+
killSession: () => execution.kill(),
|
|
2081
|
+
labels: getWindow(execution).labels,
|
|
2082
|
+
notify: (n) => execution.notifications.add(new MessageNotification(n)),
|
|
2083
|
+
openModal: () => execution.environment.openUploaderModal?.(this.modalController),
|
|
2084
|
+
ownerCanUpdate: getWindow(execution).DOCUMENT_OWNER_PRIVILEGES,
|
|
2085
|
+
readonly: false,
|
|
2086
|
+
TAB_ID_REQUEST: getWindow(execution).TAB_ID_REQUEST,
|
|
2087
|
+
URL_REQUEST_AJAX: getWindow(execution).URL_REQUEST_AJAX,
|
|
2088
|
+
WEBDAV_SERVER: getWindow(execution).WEBDAV_SERVER
|
|
3588
2089
|
}
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
2090
|
+
});
|
|
2091
|
+
this.execution = execution;
|
|
2092
|
+
this.type = type;
|
|
2093
|
+
__publicField$i(this, "docTypePermittedObjId");
|
|
2094
|
+
__publicField$i(this, "getCheckLockDocumentParameters", (defaultParameters) => {
|
|
2095
|
+
return this.addPrefix(defaultParameters);
|
|
2096
|
+
});
|
|
2097
|
+
this.docTypePermittedObjId = type === "E" ? getWindow(execution).docTypePerEntId : getWindow(execution).docTypePerProId;
|
|
3592
2098
|
}
|
|
3593
2099
|
getLoadFileSystemStructureTree() {
|
|
3594
2100
|
return {
|
|
@@ -3604,6 +2110,70 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
3604
2110
|
docTypePermittedObjType: this.type
|
|
3605
2111
|
};
|
|
3606
2112
|
}
|
|
2113
|
+
getAjaxUploadStartParameters(defaultParameters) {
|
|
2114
|
+
return {
|
|
2115
|
+
...defaultParameters,
|
|
2116
|
+
prefix: this.type,
|
|
2117
|
+
useDocTypePermitted: true,
|
|
2118
|
+
docTypePermittedObjType: this.type,
|
|
2119
|
+
docTypePermittedObjId: this.docTypePermittedObjId
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
addPrefix(defaultParameters) {
|
|
2123
|
+
return { ...defaultParameters, prefix: this.type };
|
|
2124
|
+
}
|
|
2125
|
+
getDocumentInfoParameters(defaultParameters) {
|
|
2126
|
+
return this.addPrefix(defaultParameters);
|
|
2127
|
+
}
|
|
2128
|
+
getReloadMetadataParameters(defaultParameters) {
|
|
2129
|
+
return this.addPrefix(defaultParameters);
|
|
2130
|
+
}
|
|
2131
|
+
getSaveDroppedFilesParameters(defaultParameters) {
|
|
2132
|
+
return {
|
|
2133
|
+
...defaultParameters,
|
|
2134
|
+
elemType: this.type,
|
|
2135
|
+
elemId: `prmDocumentContainter${this.type}`
|
|
2136
|
+
};
|
|
2137
|
+
}
|
|
2138
|
+
getAjaxUploadFileStatusParameters(defaultParameters) {
|
|
2139
|
+
return this.addPrefix(defaultParameters);
|
|
2140
|
+
}
|
|
2141
|
+
getMarkFileToSignParameters(defaultParameters) {
|
|
2142
|
+
return this.addPrefix(defaultParameters);
|
|
2143
|
+
}
|
|
2144
|
+
getProcessDroppedFilesPostdata(defaultParameters) {
|
|
2145
|
+
return {
|
|
2146
|
+
...defaultParameters,
|
|
2147
|
+
useDocTypePermitted: true,
|
|
2148
|
+
docTypePermittedObjId: this.docTypePermittedObjId?.toString(),
|
|
2149
|
+
docTypePermittedObjType: this.type
|
|
2150
|
+
};
|
|
2151
|
+
}
|
|
2152
|
+
getProcessDroppedFilesParameters(defaultParameters) {
|
|
2153
|
+
return { ...defaultParameters, elemType: this.type };
|
|
2154
|
+
}
|
|
2155
|
+
getConfirmDropModalParameters(defaultParameters) {
|
|
2156
|
+
return { ...defaultParameters, elemType: this.type };
|
|
2157
|
+
}
|
|
2158
|
+
getConfirmDropModalPostdata(defaultParameters) {
|
|
2159
|
+
return {
|
|
2160
|
+
...defaultParameters,
|
|
2161
|
+
elemType: this.type,
|
|
2162
|
+
pe: this.docTypePermittedObjId?.toString()
|
|
2163
|
+
};
|
|
2164
|
+
}
|
|
2165
|
+
getCheckWebDavLockParameters(defaultParameters) {
|
|
2166
|
+
return this.addPrefix(defaultParameters);
|
|
2167
|
+
}
|
|
2168
|
+
getDownloadMultipleDocumentsParameters(defaultParameters) {
|
|
2169
|
+
return this.addPrefix(defaultParameters);
|
|
2170
|
+
}
|
|
2171
|
+
getLoadCurrentDocumentsParameters(defaultParameters) {
|
|
2172
|
+
return this.addPrefix(defaultParameters);
|
|
2173
|
+
}
|
|
2174
|
+
getDeleteDocumentParameters(defaultParameters) {
|
|
2175
|
+
return this.addPrefix(defaultParameters);
|
|
2176
|
+
}
|
|
3607
2177
|
}
|
|
3608
2178
|
|
|
3609
2179
|
var __defProp$h = Object.defineProperty;
|
|
@@ -3622,28 +2192,8 @@ class FormsUploader extends UploaderApi {
|
|
|
3622
2192
|
);
|
|
3623
2193
|
this.execution = execution;
|
|
3624
2194
|
this.type = type;
|
|
3625
|
-
this.modalConfig = modalConfig;
|
|
3626
2195
|
this.field = field;
|
|
3627
2196
|
__publicField$h(this, "isEditionMode");
|
|
3628
|
-
__publicField$h(this, "getAjaxUploadFileStatusParameters", (defaultParameters) => {
|
|
3629
|
-
return {
|
|
3630
|
-
...defaultParameters,
|
|
3631
|
-
forceDocTypeId: this.field.properties.docType,
|
|
3632
|
-
...this.getFormParameters()
|
|
3633
|
-
};
|
|
3634
|
-
});
|
|
3635
|
-
__publicField$h(this, "getAjaxUploadStartParameters", ({
|
|
3636
|
-
useDocTypePermitted,
|
|
3637
|
-
docTypePermittedObjType,
|
|
3638
|
-
docTypePermittedObjId,
|
|
3639
|
-
...defaultParameters
|
|
3640
|
-
}) => {
|
|
3641
|
-
return {
|
|
3642
|
-
...defaultParameters,
|
|
3643
|
-
forceDocTypeId: this.field.properties.docType,
|
|
3644
|
-
...this.getFormParameters()
|
|
3645
|
-
};
|
|
3646
|
-
});
|
|
3647
2197
|
__publicField$h(this, "getCheckLockDocumentParameters", ({
|
|
3648
2198
|
prefix,
|
|
3649
2199
|
...parameters
|
|
@@ -3674,15 +2224,6 @@ class FormsUploader extends UploaderApi {
|
|
|
3674
2224
|
index
|
|
3675
2225
|
};
|
|
3676
2226
|
});
|
|
3677
|
-
__publicField$h(this, "getConfirmDropModalParameters", (defaultParameters) => {
|
|
3678
|
-
const { frmParent } = this.getFormParameters();
|
|
3679
|
-
return {
|
|
3680
|
-
...defaultParameters,
|
|
3681
|
-
elemType: frmParent,
|
|
3682
|
-
forceDocTypeId: this.field.properties.docType,
|
|
3683
|
-
...this.getFormParameters()
|
|
3684
|
-
};
|
|
3685
|
-
});
|
|
3686
2227
|
__publicField$h(this, "getConfirmDropModalPostdata", ({
|
|
3687
2228
|
pe,
|
|
3688
2229
|
...parameters
|
|
@@ -3704,12 +2245,6 @@ class FormsUploader extends UploaderApi {
|
|
|
3704
2245
|
...rest
|
|
3705
2246
|
};
|
|
3706
2247
|
});
|
|
3707
|
-
__publicField$h(this, "getDocumentInfoParameters", (parameters) => {
|
|
3708
|
-
return {
|
|
3709
|
-
...parameters,
|
|
3710
|
-
ajaxUrl: getWindow(this.execution).URL_REQUEST_AJAX
|
|
3711
|
-
};
|
|
3712
|
-
});
|
|
3713
2248
|
__publicField$h(this, "getEditDocumentParameters", ({ action, docId }) => {
|
|
3714
2249
|
const { prefix, editionMode, ...rest } = this.getFormParameters();
|
|
3715
2250
|
return {
|
|
@@ -3748,7 +2283,7 @@ class FormsUploader extends UploaderApi {
|
|
|
3748
2283
|
...defaultParameters
|
|
3749
2284
|
}) => {
|
|
3750
2285
|
return {
|
|
3751
|
-
...defaultParameters,
|
|
2286
|
+
...super.getMarkFileToSignParameters(defaultParameters),
|
|
3752
2287
|
action: "sign",
|
|
3753
2288
|
fldId: this.field.definition.id,
|
|
3754
2289
|
...this.getFormParameters()
|
|
@@ -3769,30 +2304,15 @@ class FormsUploader extends UploaderApi {
|
|
|
3769
2304
|
docTypePermittedObjType,
|
|
3770
2305
|
...parameters
|
|
3771
2306
|
}) => {
|
|
3772
|
-
return { ...parameters, editionMode: this.getFormParameters().editionMode };
|
|
3773
|
-
});
|
|
3774
|
-
__publicField$h(this, "getReloadMetadataParameters", (defaultParameters) => {
|
|
3775
|
-
return {
|
|
3776
|
-
...defaultParameters,
|
|
3777
|
-
...getWindow(this.execution).IS_EDIT_GRID ? { editionMode: true } : null,
|
|
3778
|
-
...this.getFormParameters()
|
|
3779
|
-
};
|
|
3780
|
-
});
|
|
3781
|
-
__publicField$h(this, "getSaveDroppedFilesParameters", (defaultParameters) => {
|
|
3782
|
-
const elemId = this.elemId();
|
|
3783
|
-
const { prefix, ...rest } = this.getFormParameters();
|
|
3784
2307
|
return {
|
|
3785
|
-
...
|
|
3786
|
-
|
|
3787
|
-
elemType: elemId,
|
|
3788
|
-
elemId,
|
|
3789
|
-
...rest
|
|
2308
|
+
...super.getProcessDroppedFilesParameters(parameters),
|
|
2309
|
+
editionMode: this.getFormParameters().editionMode
|
|
3790
2310
|
};
|
|
3791
2311
|
});
|
|
3792
2312
|
__publicField$h(this, "parseFileDefinition", (file) => {
|
|
3793
2313
|
return {
|
|
3794
2314
|
...parseFileDefinition(
|
|
3795
|
-
this.
|
|
2315
|
+
this.context,
|
|
3796
2316
|
file,
|
|
3797
2317
|
this.field.properties.reqSign || false
|
|
3798
2318
|
),
|
|
@@ -3809,6 +2329,9 @@ class FormsUploader extends UploaderApi {
|
|
|
3809
2329
|
elemId() {
|
|
3810
2330
|
return `dropUpprDiv${this.field.getForm().definition.frmParent}_${this.field.getForm().definition.id}_${this.field.definition.id}_${this.index()}${getWindow(this.execution).IS_EDIT_GRID_MODAL ? "_true_Mdl" : ""}`;
|
|
3811
2331
|
}
|
|
2332
|
+
buildModalController(conf) {
|
|
2333
|
+
return super.buildModalController(conf);
|
|
2334
|
+
}
|
|
3812
2335
|
filterByFilesAmountLimit(files) {
|
|
3813
2336
|
const inProgressFiles = this.state.inProgressFiles;
|
|
3814
2337
|
if (inProgressFiles.length === 1 && files.length)
|
|
@@ -3849,6 +2372,58 @@ class FormsUploader extends UploaderApi {
|
|
|
3849
2372
|
}
|
|
3850
2373
|
};
|
|
3851
2374
|
}
|
|
2375
|
+
getAjaxUploadFileStatusParameters(defaultParameters) {
|
|
2376
|
+
return {
|
|
2377
|
+
...super.getAjaxUploadFileStatusParameters(defaultParameters),
|
|
2378
|
+
forceDocTypeId: this.field.properties.docType,
|
|
2379
|
+
...this.getFormParameters()
|
|
2380
|
+
};
|
|
2381
|
+
}
|
|
2382
|
+
getAjaxUploadStartParameters({
|
|
2383
|
+
useDocTypePermitted,
|
|
2384
|
+
docTypePermittedObjType,
|
|
2385
|
+
docTypePermittedObjId,
|
|
2386
|
+
...defaultParameters
|
|
2387
|
+
}) {
|
|
2388
|
+
return {
|
|
2389
|
+
...super.getAjaxUploadStartParameters(defaultParameters),
|
|
2390
|
+
forceDocTypeId: this.field.properties.docType,
|
|
2391
|
+
...this.getFormParameters()
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
getConfirmDropModalParameters(defaultParameters) {
|
|
2395
|
+
const { frmParent } = this.getFormParameters();
|
|
2396
|
+
return {
|
|
2397
|
+
...super.getConfirmDropModalParameters(defaultParameters),
|
|
2398
|
+
elemType: frmParent,
|
|
2399
|
+
forceDocTypeId: this.field.properties.docType,
|
|
2400
|
+
...this.getFormParameters()
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
2403
|
+
getDocumentInfoParameters(parameters) {
|
|
2404
|
+
return {
|
|
2405
|
+
...super.getDocumentInfoParameters(parameters),
|
|
2406
|
+
ajaxUrl: getWindow(this.execution).URL_REQUEST_AJAX
|
|
2407
|
+
};
|
|
2408
|
+
}
|
|
2409
|
+
getReloadMetadataParameters(defaultParameters) {
|
|
2410
|
+
return {
|
|
2411
|
+
...super.getReloadMetadataParameters(defaultParameters),
|
|
2412
|
+
...getWindow(this.execution).IS_EDIT_GRID ? { editionMode: true } : null,
|
|
2413
|
+
...this.getFormParameters()
|
|
2414
|
+
};
|
|
2415
|
+
}
|
|
2416
|
+
getSaveDroppedFilesParameters(defaultParameters) {
|
|
2417
|
+
const elemId = this.elemId();
|
|
2418
|
+
const { prefix, ...rest } = this.getFormParameters();
|
|
2419
|
+
return {
|
|
2420
|
+
...super.getSaveDroppedFilesParameters(defaultParameters),
|
|
2421
|
+
fromFormElem: true,
|
|
2422
|
+
elemType: elemId,
|
|
2423
|
+
elemId,
|
|
2424
|
+
...rest
|
|
2425
|
+
};
|
|
2426
|
+
}
|
|
3852
2427
|
async downloadVersion(fileId, version) {
|
|
3853
2428
|
const file = this.getDocument(fileId);
|
|
3854
2429
|
if (!file)
|
|
@@ -4724,12 +3299,15 @@ class Grid extends Field {
|
|
|
4724
3299
|
}
|
|
4725
3300
|
refreshColumnsVisibilities() {
|
|
4726
3301
|
const shownColumns = /* @__PURE__ */ new Set();
|
|
3302
|
+
this.tableController.head.rows[0]?.cells.forEach((c) => {
|
|
3303
|
+
shownColumns.add(c.getState("colName"));
|
|
3304
|
+
});
|
|
4727
3305
|
for (let i = 0; i < this.tableController.body.rows[0]?.cells.length || 0; i++) {
|
|
4728
3306
|
for (const row of this.tableController.body.rows) {
|
|
4729
3307
|
const cell = row.cells[i];
|
|
4730
3308
|
const field = cell.getState("properties")?.field;
|
|
4731
|
-
if (
|
|
4732
|
-
shownColumns.
|
|
3309
|
+
if (field && (field.properties.visibilityHidden || field instanceof Hidden)) {
|
|
3310
|
+
shownColumns.delete(cell.getState("colName"));
|
|
4733
3311
|
break;
|
|
4734
3312
|
}
|
|
4735
3313
|
}
|
|
@@ -5430,7 +4008,7 @@ class Input extends TranslatableField {
|
|
|
5430
4008
|
return false;
|
|
5431
4009
|
return super.validate();
|
|
5432
4010
|
}
|
|
5433
|
-
|
|
4011
|
+
isValidValue() {
|
|
5434
4012
|
return !!String(this.getValue()).trim();
|
|
5435
4013
|
}
|
|
5436
4014
|
}
|
|
@@ -5478,7 +4056,7 @@ class Multiple extends FieldWithAttribute {
|
|
|
5478
4056
|
}
|
|
5479
4057
|
|
|
5480
4058
|
class Password extends FieldWithAttribute {
|
|
5481
|
-
|
|
4059
|
+
isValidValue() {
|
|
5482
4060
|
return !!String(this.getValue()).trim();
|
|
5483
4061
|
}
|
|
5484
4062
|
}
|
|
@@ -5535,7 +4113,7 @@ class Select extends FieldWithAttribute {
|
|
|
5535
4113
|
}
|
|
5536
4114
|
|
|
5537
4115
|
class Textarea extends TranslatableField {
|
|
5538
|
-
|
|
4116
|
+
isValidValue() {
|
|
5539
4117
|
return !!String(this.getValue()).trim();
|
|
5540
4118
|
}
|
|
5541
4119
|
getSynchronizePostConfiguration(value) {
|
|
@@ -5644,6 +4222,9 @@ class Tree extends FieldWithAttribute {
|
|
|
5644
4222
|
arrayOrArray(this.properties.possibleValue)
|
|
5645
4223
|
);
|
|
5646
4224
|
}
|
|
4225
|
+
isValidValue() {
|
|
4226
|
+
return this.state.value.length > 0;
|
|
4227
|
+
}
|
|
5647
4228
|
async setValue(newValue, options) {
|
|
5648
4229
|
const res = await super.setValue(newValue, options);
|
|
5649
4230
|
if (res) {
|
|
@@ -6804,7 +5385,6 @@ class GridField extends ApiaField {
|
|
|
6804
5385
|
__privateAdd$6(this, _mutex, new Mutex());
|
|
6805
5386
|
__privateSet$6(this, _execution$2, execution);
|
|
6806
5387
|
__privateSet$6(this, _field$2, field);
|
|
6807
|
-
__privateSet$6(this, _execution$2, execution);
|
|
6808
5388
|
}
|
|
6809
5389
|
async addRow() {
|
|
6810
5390
|
try {
|
|
@@ -8706,6 +7286,7 @@ function buildPoolSelection(execution, status, poolForm) {
|
|
|
8706
7286
|
function buildPathSelection(execution, status, form) {
|
|
8707
7287
|
const modal = new ShowPathSelection(form, async function(result) {
|
|
8708
7288
|
if (result.confirmed) {
|
|
7289
|
+
const unLock = execution.lock();
|
|
8709
7290
|
const pathSelectionResult = await axios.post(
|
|
8710
7291
|
makeApiaUrl(execution, {
|
|
8711
7292
|
action: "confirmPath",
|
|
@@ -8717,6 +7298,8 @@ function buildPathSelection(execution, status, form) {
|
|
|
8717
7298
|
const parsedRes = parseXMLRequestResponse(
|
|
8718
7299
|
pathSelectionResult
|
|
8719
7300
|
);
|
|
7301
|
+
if (parsedRes)
|
|
7302
|
+
unLock();
|
|
8720
7303
|
if (parsedRes?.groupSelection) {
|
|
8721
7304
|
return buildPoolSelection(execution, status, parsedRes.load.form);
|
|
8722
7305
|
} else if (parsedRes?.actions?.action?.toDo === "functionTimedCall") {
|
|
@@ -8852,7 +7435,8 @@ async function defaultConfirm$1(execution, status) {
|
|
|
8852
7435
|
if (key === "value" && typeof value === "string") {
|
|
8853
7436
|
return value;
|
|
8854
7437
|
}
|
|
8855
|
-
|
|
7438
|
+
const parsed = processStringObj(value, key);
|
|
7439
|
+
return parsed;
|
|
8856
7440
|
};
|
|
8857
7441
|
const baseOptions = getDefaultXmlParserOptions();
|
|
8858
7442
|
baseOptions.attrValueProcessors = [
|
|
@@ -8861,10 +7445,22 @@ async function defaultConfirm$1(execution, status) {
|
|
|
8861
7445
|
processAjaxEventResponse
|
|
8862
7446
|
];
|
|
8863
7447
|
const parser = new xml2js.Parser(baseOptions);
|
|
8864
|
-
|
|
7448
|
+
let objJS = null;
|
|
7449
|
+
parser.parseString(
|
|
8865
7450
|
xml,
|
|
8866
|
-
|
|
7451
|
+
(err, result) => {
|
|
7452
|
+
if (err) {
|
|
7453
|
+
console.warn("Error Parsing XML data", err);
|
|
7454
|
+
objJS = err;
|
|
7455
|
+
} else {
|
|
7456
|
+
if (result?.code === "-1" && result.exceptions) {
|
|
7457
|
+
throw new InvalidSessionException();
|
|
7458
|
+
}
|
|
7459
|
+
objJS = result;
|
|
7460
|
+
}
|
|
7461
|
+
}
|
|
8867
7462
|
);
|
|
7463
|
+
return objJS;
|
|
8868
7464
|
}
|
|
8869
7465
|
}
|
|
8870
7466
|
);
|
|
@@ -9224,13 +7820,14 @@ const unescapeMarkup = (str) => {
|
|
|
9224
7820
|
return "";
|
|
9225
7821
|
};
|
|
9226
7822
|
class Execution extends EventEmitter$1 {
|
|
9227
|
-
constructor(environment) {
|
|
7823
|
+
constructor(environment, renderers) {
|
|
9228
7824
|
super();
|
|
9229
7825
|
this.environment = environment;
|
|
7826
|
+
this.renderers = renderers;
|
|
9230
7827
|
__publicField(this, "fieldsMapping");
|
|
9231
|
-
__publicField(this, "entity"
|
|
9232
|
-
__publicField(this, "process"
|
|
9233
|
-
__publicField(this, "observations"
|
|
7828
|
+
__publicField(this, "entity");
|
|
7829
|
+
__publicField(this, "process");
|
|
7830
|
+
__publicField(this, "observations");
|
|
9234
7831
|
__publicField(this, "executedOnLoadEvents", false);
|
|
9235
7832
|
__publicField(this, "executionConfig", null);
|
|
9236
7833
|
__publicField(this, "_steps", []);
|
|
@@ -9289,6 +7886,11 @@ class Execution extends EventEmitter$1 {
|
|
|
9289
7886
|
this.fieldsMapping = { ...defaultFieldsMap, ...environment.fieldsMapping };
|
|
9290
7887
|
this.notifications = new Notifications(this);
|
|
9291
7888
|
makeObservable(this, { state: observable });
|
|
7889
|
+
setTimeout(() => {
|
|
7890
|
+
this.entity = new Entity(this);
|
|
7891
|
+
this.process = new Process(this);
|
|
7892
|
+
this.observations = new Observations(this);
|
|
7893
|
+
}, 0);
|
|
9292
7894
|
}
|
|
9293
7895
|
addPendingPromise(promise) {
|
|
9294
7896
|
this._pendingPromises.add(promise);
|
|
@@ -9774,5 +8376,5 @@ class Execution extends EventEmitter$1 {
|
|
|
9774
8376
|
}
|
|
9775
8377
|
}
|
|
9776
8378
|
|
|
9777
|
-
export { ActionsController, AdditionalCell, ApiaAttribute, ApiaField, ApiaFieldWithAttribute, ApiaForm, ApiaFunctions, BouncingEmitter, Button, ButtonField, Captcha, CaptchaField, CheckField, Checkbox, CustomComponent, GridField as DataGridField, Editor, EditorField, EventEmitter, Execution, ExecutionState, Field, FieldWithAttribute, File, FileUploaderField, FlowModal$1 as FlowModal, Form, FormsUploader, Grid, GridCell, GridField, GridPaginated, HeaderCell, Hidden, HiddenField, IProperty, Image, ImageField, Input, InputField, InvalidSessionException, Label, Link, LinkField, MessageNotification, ModalInput, ModalInputField, Multiple, MultipleField, Notifications, Password, PasswordField, Radio, RadioField, SchedulerField, Select, SelectField, ShowConfirmMessage, ShowPathSelection, ShowPoolSelection, ShowSign$1 as ShowSign, ShowSignSelection$1 as ShowSignSelection, StatefulEmitter, StatusNotification, AreaField as TextAreaField, TextField, Textarea, Title, TranslatableField, Translation, Tree, TreeField, UploaderApi,
|
|
8379
|
+
export { ActionsController, AdditionalCell, ApiaAttribute, ApiaField, ApiaFieldWithAttribute, ApiaForm, ApiaFunctions, BouncingEmitter, Button, ButtonField, Captcha, CaptchaField, CheckField, Checkbox, CustomComponent, GridField as DataGridField, Editor, EditorField, EventEmitter, Execution, ExecutionState, Field, FieldWithAttribute, File, FileUploaderField, FlowModal$1 as FlowModal, Form, FormsUploader, Grid, GridCell, GridField, GridPaginated, HeaderCell, Hidden, HiddenField, IProperty, Image, ImageField, Input, InputField, InvalidSessionException, Label, Link, LinkField, MessageNotification, ModalInput, ModalInputField, Multiple, MultipleField, Notification, Notifications, Password, PasswordField, Radio, RadioField, SchedulerField, Select, SelectField, ShowConfirmMessage, ShowPathSelection, ShowPoolSelection, ShowSign$1 as ShowSign, ShowSignSelection$1 as ShowSignSelection, StatefulEmitter, StatusNotification, AreaField as TextAreaField, TextField, Textarea, Title, TranslatableField, Translation, Tree, TreeField, UploaderApi, createNewField, deepEqual, get, getLabel, isHtmlResponse, isJsonResponse, isXmlResponse, makeApiaUrl, parseFakeJSON$1 as parseFakeJSON, parseSuccessfulResponse, parseXml, post, shallowEqual };
|
|
9778
8380
|
//# sourceMappingURL=index.js.map
|