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