@apia/execution 4.0.20 → 4.0.25
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 +34 -16
- package/dist/index.js +204 -99
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ import he from 'he';
|
|
|
4
4
|
import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
|
|
5
5
|
import QueryString from 'qs';
|
|
6
6
|
import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, addBoundary, formatMessage, parseAsSize, Mutex, awaitTime, noNaN as noNaN$1, getDateFormat, freezeDeep, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
|
|
7
|
+
import axios from 'axios';
|
|
7
8
|
import { Cell, TableController, Row, FocusControllerPlugin } from '@apia/table2-controller';
|
|
8
9
|
import dayjs from 'dayjs';
|
|
9
10
|
import { MobXTree } from '@apia/tree2-controller';
|
|
10
|
-
import axios from 'axios';
|
|
11
11
|
|
|
12
12
|
const deepEqual = (a, b) => {
|
|
13
13
|
if (Object.is(a, b))
|
|
@@ -879,12 +879,61 @@ const labels = {
|
|
|
879
879
|
errorConfirmationFailed: () => "Error al confirmar",
|
|
880
880
|
errorRegexNotValidated: () => "La expresi\xF3n regular no fue validada.",
|
|
881
881
|
errorCouldNotSync: () => "No se pudo sincronizar",
|
|
882
|
-
errorFieldRequired: () =>
|
|
882
|
+
errorFieldRequired: (execution) => getLabel(execution, "msgReqField").text,
|
|
883
883
|
errorTranslateRequired: (execution, lang) => getLabel(execution, "lblReqLang", { text: { TOK1: lang } }).text,
|
|
884
884
|
errorLoadForms: () => "Error al inicializar los formularios, contacte al administrador.",
|
|
885
885
|
errorOnEvent: (eventName, className) => window.SERVER_MODE ? "Error al ejecutar la clase de negocios, contacte al administrador." : `Error on event ${eventName}, className ${className}`
|
|
886
886
|
};
|
|
887
887
|
|
|
888
|
+
const parseBoolean = (val) => {
|
|
889
|
+
if (typeof val === "string") {
|
|
890
|
+
if (/^(?:true|T|t|1|1,00)$/i.test(val))
|
|
891
|
+
return true;
|
|
892
|
+
if (/^(?:false|F|f|0|0,00|null)$/i.test(val))
|
|
893
|
+
return false;
|
|
894
|
+
}
|
|
895
|
+
return false;
|
|
896
|
+
};
|
|
897
|
+
|
|
898
|
+
const valueParsers = [
|
|
899
|
+
(key, value, next) => {
|
|
900
|
+
if (BoolProps.indexOf(key) === -1 && NumProps.indexOf(key) === -1) {
|
|
901
|
+
return next();
|
|
902
|
+
} else if (typeof value === "number") {
|
|
903
|
+
return next();
|
|
904
|
+
} else if (BoolProps.indexOf(key) !== -1) {
|
|
905
|
+
return { key, value: parseBoolean(value) };
|
|
906
|
+
} else if (NumProps.indexOf(key) !== -1) {
|
|
907
|
+
return { key, value: parseInt(value || "", 10) };
|
|
908
|
+
}
|
|
909
|
+
next();
|
|
910
|
+
}
|
|
911
|
+
];
|
|
912
|
+
function parseFakeJSON$1(str) {
|
|
913
|
+
if (!str) {
|
|
914
|
+
return {};
|
|
915
|
+
}
|
|
916
|
+
if (typeof str === "object") {
|
|
917
|
+
return str;
|
|
918
|
+
}
|
|
919
|
+
const res = new Function(`const form = ${str}; return form;`)();
|
|
920
|
+
const ret = {};
|
|
921
|
+
for (const [key, value] of Object.entries(res)) {
|
|
922
|
+
for (const p of valueParsers) {
|
|
923
|
+
let next = false;
|
|
924
|
+
const t = p(key, value, () => {
|
|
925
|
+
next = true;
|
|
926
|
+
});
|
|
927
|
+
if (!next && t) {
|
|
928
|
+
ret[t.key] = t.value;
|
|
929
|
+
} else {
|
|
930
|
+
ret[key] = value;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
return ret;
|
|
935
|
+
}
|
|
936
|
+
|
|
888
937
|
var __defProp$n = Object.defineProperty;
|
|
889
938
|
var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
890
939
|
var __publicField$n = (obj, key, value) => {
|
|
@@ -1352,7 +1401,9 @@ const _Captcha = class _Captcha extends Field$1 {
|
|
|
1352
1401
|
async validate() {
|
|
1353
1402
|
this.id = this.getCaptchaId();
|
|
1354
1403
|
if (this.state.value === "" && !this.getForm().definition.readOnly) {
|
|
1355
|
-
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
1404
|
+
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
1405
|
+
this.form.execution
|
|
1406
|
+
);
|
|
1356
1407
|
return false;
|
|
1357
1408
|
} else {
|
|
1358
1409
|
this.state.validation.errorMessage = "";
|
|
@@ -1604,6 +1655,9 @@ class FieldWithAttribute extends Field$1 {
|
|
|
1604
1655
|
}
|
|
1605
1656
|
return false;
|
|
1606
1657
|
}
|
|
1658
|
+
hasValue() {
|
|
1659
|
+
return this.getValue() !== "";
|
|
1660
|
+
}
|
|
1607
1661
|
isValidValue() {
|
|
1608
1662
|
return !!this.getValue();
|
|
1609
1663
|
}
|
|
@@ -1615,7 +1669,7 @@ class FieldWithAttribute extends Field$1 {
|
|
|
1615
1669
|
}
|
|
1616
1670
|
}
|
|
1617
1671
|
const isValid = isFieldShowAsText(this) || this.isValidValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
|
|
1618
|
-
this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired();
|
|
1672
|
+
this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired(this.form.execution);
|
|
1619
1673
|
return !this.state.validation.errorMessage;
|
|
1620
1674
|
}
|
|
1621
1675
|
setError(err) {
|
|
@@ -1688,8 +1742,8 @@ class Translation {
|
|
|
1688
1742
|
this.execution,
|
|
1689
1743
|
url
|
|
1690
1744
|
);
|
|
1691
|
-
const newValue = result?.data?.values?.value
|
|
1692
|
-
this.state.tempValue = newValue !== "null" ? result?.data?.values?.value
|
|
1745
|
+
const newValue = result?.data?.values?.value;
|
|
1746
|
+
this.state.tempValue = newValue !== "null" ? result?.data?.values?.value ?? "" : "";
|
|
1693
1747
|
this.state.remoteValue = this.state.tempValue;
|
|
1694
1748
|
}
|
|
1695
1749
|
}
|
|
@@ -1721,7 +1775,7 @@ class Translation {
|
|
|
1721
1775
|
}
|
|
1722
1776
|
}
|
|
1723
1777
|
|
|
1724
|
-
function parseFakeJSON
|
|
1778
|
+
function parseFakeJSON(fakeJSON) {
|
|
1725
1779
|
return [...fakeJSON.matchAll(/(\d+): '?([^']+)'?/g)].map(([, k, v]) => ({
|
|
1726
1780
|
id: k,
|
|
1727
1781
|
label: v
|
|
@@ -1759,7 +1813,7 @@ class TranslatableField extends FieldWithAttribute {
|
|
|
1759
1813
|
this.definitionTradParsed = tradMap;
|
|
1760
1814
|
}
|
|
1761
1815
|
getLanguages() {
|
|
1762
|
-
return arrayOrArray(parseFakeJSON
|
|
1816
|
+
return arrayOrArray(parseFakeJSON(this.getForm().definition?.langs ?? ""));
|
|
1763
1817
|
}
|
|
1764
1818
|
async init(form) {
|
|
1765
1819
|
await super.init(form);
|
|
@@ -1829,7 +1883,8 @@ class TranslatableField extends FieldWithAttribute {
|
|
|
1829
1883
|
async validate() {
|
|
1830
1884
|
const isSuperValid = await super.validate();
|
|
1831
1885
|
let isValid = isSuperValid;
|
|
1832
|
-
|
|
1886
|
+
const canValidate = isSuperValid && this.properties.reqTrad && this.hasValue() && (!this.properties.inputAsText || !this.properties.visibilityHidden || !this.properties.disabled);
|
|
1887
|
+
if (canValidate) {
|
|
1833
1888
|
const translations = [...this.getTranslations().values()];
|
|
1834
1889
|
const tradNotValidated = translations.find((c) => !c.state.isTranslated);
|
|
1835
1890
|
if (tradNotValidated) {
|
|
@@ -1855,55 +1910,6 @@ class Editor extends TranslatableField {
|
|
|
1855
1910
|
}
|
|
1856
1911
|
}
|
|
1857
1912
|
|
|
1858
|
-
const parseBoolean = (val) => {
|
|
1859
|
-
if (typeof val === "string") {
|
|
1860
|
-
if (/^(?:true|T|t|1|1,00)$/i.test(val))
|
|
1861
|
-
return true;
|
|
1862
|
-
if (/^(?:false|F|f|0|0,00|null)$/i.test(val))
|
|
1863
|
-
return false;
|
|
1864
|
-
}
|
|
1865
|
-
return false;
|
|
1866
|
-
};
|
|
1867
|
-
|
|
1868
|
-
const valueParsers = [
|
|
1869
|
-
(key, value, next) => {
|
|
1870
|
-
if (BoolProps.indexOf(key) === -1 && NumProps.indexOf(key) === -1) {
|
|
1871
|
-
return next();
|
|
1872
|
-
} else if (typeof value === "number") {
|
|
1873
|
-
return next();
|
|
1874
|
-
} else if (BoolProps.indexOf(key) !== -1) {
|
|
1875
|
-
return { key, value: parseBoolean(value) };
|
|
1876
|
-
} else if (NumProps.indexOf(key) !== -1) {
|
|
1877
|
-
return { key, value: parseInt(value || "", 10) };
|
|
1878
|
-
}
|
|
1879
|
-
next();
|
|
1880
|
-
}
|
|
1881
|
-
];
|
|
1882
|
-
function parseFakeJSON(str) {
|
|
1883
|
-
if (!str) {
|
|
1884
|
-
return {};
|
|
1885
|
-
}
|
|
1886
|
-
if (typeof str === "object") {
|
|
1887
|
-
return str;
|
|
1888
|
-
}
|
|
1889
|
-
const res = new Function(`const form = ${str}; return form;`)();
|
|
1890
|
-
const ret = {};
|
|
1891
|
-
for (const [key, value] of Object.entries(res)) {
|
|
1892
|
-
for (const p of valueParsers) {
|
|
1893
|
-
let next = false;
|
|
1894
|
-
const t = p(key, value, () => {
|
|
1895
|
-
next = true;
|
|
1896
|
-
});
|
|
1897
|
-
if (!next && t) {
|
|
1898
|
-
ret[t.key] = t.value;
|
|
1899
|
-
} else {
|
|
1900
|
-
ret[key] = value;
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
return ret;
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
1913
|
var __defProp$h = Object.defineProperty;
|
|
1908
1914
|
var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1909
1915
|
var __publicField$h = (obj, key, value) => {
|
|
@@ -2008,7 +2014,7 @@ class UploaderModalController {
|
|
|
2008
2014
|
}
|
|
2009
2015
|
addFiles(files) {
|
|
2010
2016
|
this.state.fileReqError = false;
|
|
2011
|
-
this.api.saveDroppedFiles(files);
|
|
2017
|
+
this.api.saveDroppedFiles(files, this.conf);
|
|
2012
2018
|
}
|
|
2013
2019
|
addDirectoryFile(file) {
|
|
2014
2020
|
this.state.fileReqError = false;
|
|
@@ -2164,6 +2170,9 @@ var __publicField$g = (obj, key, value) => {
|
|
|
2164
2170
|
function returnExactlyTheSame(defaultParameters) {
|
|
2165
2171
|
return defaultParameters;
|
|
2166
2172
|
}
|
|
2173
|
+
function isOneClickUploadEnabled(oneClickUploadProp) {
|
|
2174
|
+
return !window.avoidOneClickUpload && (window.forceOneClickUpload || oneClickUploadProp || false);
|
|
2175
|
+
}
|
|
2167
2176
|
const parseFileDefinition = (execution, fileDefinition, isSignRequired) => {
|
|
2168
2177
|
const { lock, isLocked, lockedBy, userLocking, ...file } = fileDefinition;
|
|
2169
2178
|
return {
|
|
@@ -2274,7 +2283,6 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
2274
2283
|
async onStartUpload(files) {
|
|
2275
2284
|
if (this.modalConfig.oneClickUpload) {
|
|
2276
2285
|
await this.saveDroppedFiles(files ?? []);
|
|
2277
|
-
this.confirmDropModal();
|
|
2278
2286
|
} else {
|
|
2279
2287
|
if (files) {
|
|
2280
2288
|
await this.saveDroppedFiles(files ?? []);
|
|
@@ -2286,14 +2294,18 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
2286
2294
|
this.modalController.openModal();
|
|
2287
2295
|
}
|
|
2288
2296
|
}
|
|
2289
|
-
async onTranslateUpload(conf) {
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
this.
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
+
async onTranslateUpload(conf, files) {
|
|
2298
|
+
if (this.modalConfig.oneClickUpload) {
|
|
2299
|
+
await this.saveDroppedFiles(files ?? [], conf);
|
|
2300
|
+
} else {
|
|
2301
|
+
await this.init();
|
|
2302
|
+
this.modalController = new UploaderModalController(
|
|
2303
|
+
this,
|
|
2304
|
+
this.modalConfig,
|
|
2305
|
+
conf
|
|
2306
|
+
);
|
|
2307
|
+
this.modalController.openModal();
|
|
2308
|
+
}
|
|
2297
2309
|
}
|
|
2298
2310
|
async onVersionUpload(file, conf = { newFiles: [] }) {
|
|
2299
2311
|
this.modalController = new UploaderModalController(this, this.modalConfig, {
|
|
@@ -2531,9 +2543,9 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
2531
2543
|
return;
|
|
2532
2544
|
}
|
|
2533
2545
|
const {
|
|
2534
|
-
|
|
2535
|
-
strictMode: isConfStrictMode = false
|
|
2536
|
-
|
|
2546
|
+
langId,
|
|
2547
|
+
strictMode: isConfStrictMode = false,
|
|
2548
|
+
translatingFile
|
|
2537
2549
|
} = conf ?? {};
|
|
2538
2550
|
const isStrictMode = isConfStrictMode || !!this.state.versioningFile;
|
|
2539
2551
|
const docType = this.getCurrentDocTypeId();
|
|
@@ -2573,7 +2585,7 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
2573
2585
|
elemId: `prmDocumentContainter${this.type}`,
|
|
2574
2586
|
frmOut: !this.modalController,
|
|
2575
2587
|
docTypeId: this.state.selectedDocTypeId,
|
|
2576
|
-
|
|
2588
|
+
langId
|
|
2577
2589
|
})
|
|
2578
2590
|
),
|
|
2579
2591
|
{
|
|
@@ -2686,6 +2698,12 @@ class UploaderApi extends EventEmitter$1 {
|
|
|
2686
2698
|
type: "success",
|
|
2687
2699
|
message: getWindow(this.execution).FILE_UPLOADED_SUCCESSFULLY
|
|
2688
2700
|
});
|
|
2701
|
+
if (isOneClickUploadEnabled(this.modalConfig.oneClickUpload)) {
|
|
2702
|
+
if (langId && translatingFile)
|
|
2703
|
+
void this.confirmDropModal({ langId, translatingFile });
|
|
2704
|
+
else
|
|
2705
|
+
void this.confirmDropModal();
|
|
2706
|
+
}
|
|
2689
2707
|
}
|
|
2690
2708
|
}
|
|
2691
2709
|
this.state.progress = 100;
|
|
@@ -3665,7 +3683,7 @@ class File extends TranslatableField {
|
|
|
3665
3683
|
});
|
|
3666
3684
|
this.uploader.init();
|
|
3667
3685
|
if (this.definition.file_prp) {
|
|
3668
|
-
const files = parseFakeJSON(this.definition.file_prp);
|
|
3686
|
+
const files = parseFakeJSON$1(this.definition.file_prp);
|
|
3669
3687
|
const mainFile = files[0];
|
|
3670
3688
|
if (mainFile) {
|
|
3671
3689
|
this.uploader.state.files = {
|
|
@@ -3688,11 +3706,13 @@ class File extends TranslatableField {
|
|
|
3688
3706
|
if (this.properties.disabled || this.properties.noModify) {
|
|
3689
3707
|
return true;
|
|
3690
3708
|
} else if (this.properties.required && Object.values(this.uploader.state.files).length == 0) {
|
|
3691
|
-
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
3709
|
+
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
3710
|
+
this.form.execution
|
|
3711
|
+
);
|
|
3692
3712
|
return false;
|
|
3693
3713
|
} else if (this.getForm().definition.frmParent !== "P") {
|
|
3694
3714
|
const langEntries = Object.entries(
|
|
3695
|
-
parseFakeJSON(this.form.definition.langs || "{}")
|
|
3715
|
+
parseFakeJSON$1(this.form.definition.langs || "{}")
|
|
3696
3716
|
).map(([key, value]) => [Number(key), value]);
|
|
3697
3717
|
const innerMap = [...this.uploader.state.translatedFiles.values()][0];
|
|
3698
3718
|
const translationValid = !this.properties.required || !this.getForm().definition.langs || langEntries.every(([langId, langLabel]) => {
|
|
@@ -3714,7 +3734,7 @@ class File extends TranslatableField {
|
|
|
3714
3734
|
}
|
|
3715
3735
|
loadFromDefinition(def) {
|
|
3716
3736
|
if (def) {
|
|
3717
|
-
const uploadedFile = parseFakeJSON(def ?? "")[0];
|
|
3737
|
+
const uploadedFile = parseFakeJSON$1(def ?? "")[0];
|
|
3718
3738
|
if (uploadedFile) {
|
|
3719
3739
|
this.uploader.state.files = {
|
|
3720
3740
|
[uploadedFile.docId]: {
|
|
@@ -3918,6 +3938,9 @@ class ModalInput extends FieldWithAttribute {
|
|
|
3918
3938
|
fireEvent(eventName) {
|
|
3919
3939
|
return super.fireEvent(eventName);
|
|
3920
3940
|
}
|
|
3941
|
+
hasValue() {
|
|
3942
|
+
return this.getValue().showValue !== "" && this.getValue().storeValue !== "";
|
|
3943
|
+
}
|
|
3921
3944
|
async setValueFromInputWrite(value) {
|
|
3922
3945
|
if (value !== this.getValue().showValue) {
|
|
3923
3946
|
const result = await post(
|
|
@@ -3972,7 +3995,9 @@ class ModalInput extends FieldWithAttribute {
|
|
|
3972
3995
|
return false;
|
|
3973
3996
|
const isValid = !!this.getValue().storeValue || !this.properties.required || this.properties.inputAsText || this.properties.visibilityHidden || this.properties.disabled;
|
|
3974
3997
|
if (!isValid) {
|
|
3975
|
-
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
3998
|
+
this.state.validation.errorMessage = labels.errorFieldRequired(
|
|
3999
|
+
this.form.execution
|
|
4000
|
+
);
|
|
3976
4001
|
return false;
|
|
3977
4002
|
}
|
|
3978
4003
|
return true;
|
|
@@ -4047,7 +4072,7 @@ class Grid extends Field$1 {
|
|
|
4047
4072
|
).filter(Boolean);
|
|
4048
4073
|
this.fieldsDefinitions = fieldsArray.map(
|
|
4049
4074
|
({ fieldValue, properties: properties2, ...current }) => {
|
|
4050
|
-
return { ...current, properties: parseFakeJSON(properties2) };
|
|
4075
|
+
return { ...current, properties: parseFakeJSON$1(properties2) };
|
|
4051
4076
|
}
|
|
4052
4077
|
);
|
|
4053
4078
|
this.state.header = arrayOrArray(definition.gridHeader.col).map((c) => ({
|
|
@@ -4630,7 +4655,7 @@ class Grid extends Field$1 {
|
|
|
4630
4655
|
);
|
|
4631
4656
|
this.tableController.body.addRow(newRow);
|
|
4632
4657
|
for await (const field of definitions) {
|
|
4633
|
-
const fieldProps = parseFakeJSON(
|
|
4658
|
+
const fieldProps = parseFakeJSON$1(
|
|
4634
4659
|
field.properties
|
|
4635
4660
|
);
|
|
4636
4661
|
field.properties = fieldProps;
|
|
@@ -4762,7 +4787,7 @@ class Grid extends Field$1 {
|
|
|
4762
4787
|
}
|
|
4763
4788
|
Object.assign(
|
|
4764
4789
|
field.properties,
|
|
4765
|
-
parseFakeJSON(state.properties)
|
|
4790
|
+
parseFakeJSON$1(state.properties)
|
|
4766
4791
|
);
|
|
4767
4792
|
field.definition.index = this.startIndex + rowIndex;
|
|
4768
4793
|
if (field instanceof File) {
|
|
@@ -5089,6 +5114,9 @@ class Multiple extends FieldWithAttribute {
|
|
|
5089
5114
|
}
|
|
5090
5115
|
});
|
|
5091
5116
|
}
|
|
5117
|
+
hasValue() {
|
|
5118
|
+
return this.state.value.length > 0;
|
|
5119
|
+
}
|
|
5092
5120
|
setValue(newValue, options) {
|
|
5093
5121
|
return super.setValue(arrayOrArray(newValue), options);
|
|
5094
5122
|
}
|
|
@@ -5100,7 +5128,7 @@ class Multiple extends FieldWithAttribute {
|
|
|
5100
5128
|
}
|
|
5101
5129
|
}
|
|
5102
5130
|
const isValid = !!this.getValue()[0] || !this.properties.required || this.properties.inputAsText || this.properties.visibilityHidden || this.properties.disabled;
|
|
5103
|
-
this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired();
|
|
5131
|
+
this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired(this.form.execution);
|
|
5104
5132
|
return !this.state.validation.errorMessage;
|
|
5105
5133
|
}
|
|
5106
5134
|
}
|
|
@@ -5211,6 +5239,9 @@ class Tree extends FieldWithAttribute {
|
|
|
5211
5239
|
fireEvent(eventName) {
|
|
5212
5240
|
return super.fireEvent(eventName);
|
|
5213
5241
|
}
|
|
5242
|
+
hasValue() {
|
|
5243
|
+
return this.state.value.length > 0;
|
|
5244
|
+
}
|
|
5214
5245
|
setProperty(propName, propValue) {
|
|
5215
5246
|
if (propName === "possibleValue") {
|
|
5216
5247
|
this.controller.removeAllChildren();
|
|
@@ -7496,7 +7527,7 @@ class CustomComponent {
|
|
|
7496
7527
|
parseStateObject(o) {
|
|
7497
7528
|
if (o.additional) {
|
|
7498
7529
|
try {
|
|
7499
|
-
this._state.additional = JSON.parse(o.additional
|
|
7530
|
+
this._state.additional = JSON.parse(o.additional);
|
|
7500
7531
|
} catch (e) {
|
|
7501
7532
|
console.error(e);
|
|
7502
7533
|
}
|
|
@@ -7511,7 +7542,7 @@ class CustomComponent {
|
|
|
7511
7542
|
async processResult(res) {
|
|
7512
7543
|
let proceed = true;
|
|
7513
7544
|
const scheduledEvents = [];
|
|
7514
|
-
const newState = res?.
|
|
7545
|
+
const newState = res?.processResult?.state;
|
|
7515
7546
|
if (newState) {
|
|
7516
7547
|
for (const directive of arrayOrArray(newState.directive)) {
|
|
7517
7548
|
if (directive.type === "RELOAD") {
|
|
@@ -7533,7 +7564,7 @@ class CustomComponent {
|
|
|
7533
7564
|
}
|
|
7534
7565
|
if (proceed) {
|
|
7535
7566
|
if (res.ajaxUpdated) {
|
|
7536
|
-
const result = parseXml(res.ajaxUpdated
|
|
7567
|
+
const result = parseXml(res.ajaxUpdated);
|
|
7537
7568
|
setAjaxFormResponse(
|
|
7538
7569
|
this.execution,
|
|
7539
7570
|
result
|
|
@@ -7546,6 +7577,7 @@ class CustomComponent {
|
|
|
7546
7577
|
await this.fireEvent(event);
|
|
7547
7578
|
}
|
|
7548
7579
|
this._state.isLoading = false;
|
|
7580
|
+
return res.processResult?.state?.result;
|
|
7549
7581
|
}
|
|
7550
7582
|
}
|
|
7551
7583
|
getScriptEventParams(fncParams) {
|
|
@@ -7599,11 +7631,13 @@ class CustomComponent {
|
|
|
7599
7631
|
if (!event) {
|
|
7600
7632
|
throw new Error("Unknown event " + evtName);
|
|
7601
7633
|
}
|
|
7602
|
-
|
|
7603
|
-
|
|
7634
|
+
const scriptsResult = !event.script || await this.fireScriptEvents(event);
|
|
7635
|
+
if (scriptsResult && event.serverEvents) {
|
|
7636
|
+
return (await this.processResult(
|
|
7604
7637
|
(await this.postMessage("fireEvent", evtName))?.data
|
|
7605
|
-
);
|
|
7638
|
+
))?.success || false;
|
|
7606
7639
|
}
|
|
7640
|
+
return scriptsResult && !event.serverEvents;
|
|
7607
7641
|
} finally {
|
|
7608
7642
|
this._state.isLoading = false;
|
|
7609
7643
|
}
|
|
@@ -7633,7 +7667,7 @@ class CustomComponent {
|
|
|
7633
7667
|
async setStringValue(attName, value) {
|
|
7634
7668
|
this._state.isLoading = true;
|
|
7635
7669
|
try {
|
|
7636
|
-
await this.processResult(
|
|
7670
|
+
return (await this.processResult(
|
|
7637
7671
|
(await this.postMessage(
|
|
7638
7672
|
"setValue",
|
|
7639
7673
|
JSON.stringify({
|
|
@@ -7642,7 +7676,7 @@ class CustomComponent {
|
|
|
7642
7676
|
value
|
|
7643
7677
|
})
|
|
7644
7678
|
))?.data
|
|
7645
|
-
);
|
|
7679
|
+
))?.success || false;
|
|
7646
7680
|
} finally {
|
|
7647
7681
|
this._state.isLoading = false;
|
|
7648
7682
|
}
|
|
@@ -7653,10 +7687,40 @@ class CustomComponent {
|
|
|
7653
7687
|
getValue(attName, index = 0) {
|
|
7654
7688
|
return this._state.attributes[attName]?.[index];
|
|
7655
7689
|
}
|
|
7690
|
+
getValues(attName) {
|
|
7691
|
+
return this._state.attributes[attName];
|
|
7692
|
+
}
|
|
7693
|
+
async removeIndex(attName, index) {
|
|
7694
|
+
this._state.isLoading = true;
|
|
7695
|
+
try {
|
|
7696
|
+
return (await this.processResult(
|
|
7697
|
+
(await post(
|
|
7698
|
+
this.execution,
|
|
7699
|
+
makeApiaUrl(this.execution, {
|
|
7700
|
+
ajaxUrl: actions.forms,
|
|
7701
|
+
action: "cusCmpProcess",
|
|
7702
|
+
method: "removeIndex",
|
|
7703
|
+
cmpId: this.definition.id,
|
|
7704
|
+
frmId: this.form.definition.id,
|
|
7705
|
+
frmParent: this.form.definition.frmParent
|
|
7706
|
+
}),
|
|
7707
|
+
{
|
|
7708
|
+
postData: {
|
|
7709
|
+
attName,
|
|
7710
|
+
index
|
|
7711
|
+
},
|
|
7712
|
+
postDataTreatment: "stringify"
|
|
7713
|
+
}
|
|
7714
|
+
))?.data
|
|
7715
|
+
))?.success || false;
|
|
7716
|
+
} finally {
|
|
7717
|
+
this._state.isLoading = false;
|
|
7718
|
+
}
|
|
7719
|
+
}
|
|
7656
7720
|
async setValue(attName, value, index) {
|
|
7657
7721
|
this._state.isLoading = true;
|
|
7658
7722
|
try {
|
|
7659
|
-
await this.processResult(
|
|
7723
|
+
return (await this.processResult(
|
|
7660
7724
|
(await this.postMessage(
|
|
7661
7725
|
"setValue",
|
|
7662
7726
|
JSON.stringify({
|
|
@@ -7665,7 +7729,7 @@ class CustomComponent {
|
|
|
7665
7729
|
value
|
|
7666
7730
|
})
|
|
7667
7731
|
))?.data
|
|
7668
|
-
);
|
|
7732
|
+
))?.success || false;
|
|
7669
7733
|
} finally {
|
|
7670
7734
|
this._state.isLoading = false;
|
|
7671
7735
|
}
|
|
@@ -7673,7 +7737,7 @@ class CustomComponent {
|
|
|
7673
7737
|
async setProperty(prpName, value) {
|
|
7674
7738
|
this._state.isLoading = true;
|
|
7675
7739
|
try {
|
|
7676
|
-
await this.processResult(
|
|
7740
|
+
return (await this.processResult(
|
|
7677
7741
|
(await this.postMessage(
|
|
7678
7742
|
"setProperty",
|
|
7679
7743
|
JSON.stringify({
|
|
@@ -7681,7 +7745,7 @@ class CustomComponent {
|
|
|
7681
7745
|
value
|
|
7682
7746
|
})
|
|
7683
7747
|
))?.data
|
|
7684
|
-
);
|
|
7748
|
+
))?.success || false;
|
|
7685
7749
|
} finally {
|
|
7686
7750
|
this._state.isLoading = false;
|
|
7687
7751
|
}
|
|
@@ -7689,7 +7753,7 @@ class CustomComponent {
|
|
|
7689
7753
|
async sendMessage(payload) {
|
|
7690
7754
|
this._state.isLoading = true;
|
|
7691
7755
|
try {
|
|
7692
|
-
await this.processResult(
|
|
7756
|
+
return await this.processResult(
|
|
7693
7757
|
(await this.postMessage(
|
|
7694
7758
|
"message",
|
|
7695
7759
|
typeof payload === "object" && payload ? JSON.stringify(payload) : payload
|
|
@@ -7699,6 +7763,40 @@ class CustomComponent {
|
|
|
7699
7763
|
this._state.isLoading = false;
|
|
7700
7764
|
}
|
|
7701
7765
|
}
|
|
7766
|
+
async upload(attName, file, options) {
|
|
7767
|
+
const formData = new FormData();
|
|
7768
|
+
formData.append("file", file);
|
|
7769
|
+
Object.entries(options?.params || {}).forEach(
|
|
7770
|
+
([key, value]) => formData.append(key, value)
|
|
7771
|
+
);
|
|
7772
|
+
const response = await axios.post(
|
|
7773
|
+
await makeApiaUrl(this.execution, {
|
|
7774
|
+
ajaxUrl: actions.forms,
|
|
7775
|
+
action: "cusCmpProcess",
|
|
7776
|
+
method: "upload",
|
|
7777
|
+
cmpId: this.definition.id,
|
|
7778
|
+
frmId: this.form.definition.id,
|
|
7779
|
+
frmParent: this.form.definition.frmParent,
|
|
7780
|
+
attName,
|
|
7781
|
+
originalName: file.name
|
|
7782
|
+
}),
|
|
7783
|
+
formData,
|
|
7784
|
+
{
|
|
7785
|
+
signal: options?.signal,
|
|
7786
|
+
onUploadProgress({ total, progress }) {
|
|
7787
|
+
const percent = Math.round((progress || 0) / (total || 1) * 100 * 100) / 100;
|
|
7788
|
+
options?.onUploadProgress?.(percent);
|
|
7789
|
+
}
|
|
7790
|
+
}
|
|
7791
|
+
);
|
|
7792
|
+
const result = await parseSuccessfulResponse(
|
|
7793
|
+
this.execution,
|
|
7794
|
+
response
|
|
7795
|
+
);
|
|
7796
|
+
return await this.processResult(
|
|
7797
|
+
result
|
|
7798
|
+
);
|
|
7799
|
+
}
|
|
7702
7800
|
}
|
|
7703
7801
|
_hasInited = new WeakMap();
|
|
7704
7802
|
|
|
@@ -7743,7 +7841,7 @@ var __publicField$6 = (obj, key, value) => {
|
|
|
7743
7841
|
};
|
|
7744
7842
|
class Form extends WithProperties {
|
|
7745
7843
|
constructor(execution, definition) {
|
|
7746
|
-
const props = parseFakeJSON(definition.properties);
|
|
7844
|
+
const props = parseFakeJSON$1(definition.properties);
|
|
7747
7845
|
super(props);
|
|
7748
7846
|
this.execution = execution;
|
|
7749
7847
|
__publicField$6(this, "fields");
|
|
@@ -7928,7 +8026,7 @@ class Form extends WithProperties {
|
|
|
7928
8026
|
});
|
|
7929
8027
|
}
|
|
7930
8028
|
for await (const field of arrayOrArray(this.fields)) {
|
|
7931
|
-
field.properties = parseFakeJSON(field.properties);
|
|
8029
|
+
field.properties = parseFakeJSON$1(field.properties);
|
|
7932
8030
|
const fieldConstructor = this.execution.fieldsMapping[field.fieldType](field);
|
|
7933
8031
|
if (fieldConstructor) {
|
|
7934
8032
|
const newField = new fieldConstructor(field);
|
|
@@ -8467,7 +8565,14 @@ class Observations {
|
|
|
8467
8565
|
throw new Error("Cannot retrieve the entity data");
|
|
8468
8566
|
}
|
|
8469
8567
|
const parsedData = JSON.parse(res?.data?.obData);
|
|
8470
|
-
this.state.observations = arrayOrArray(parsedData);
|
|
8568
|
+
this.state.observations = arrayOrArray(parsedData.observations);
|
|
8569
|
+
const newObservation = {
|
|
8570
|
+
commentValue: parsedData.newCommentData?.comment,
|
|
8571
|
+
chkAddAlert: parsedData.newCommentData?.isChecked,
|
|
8572
|
+
chkAddAllAlert: false,
|
|
8573
|
+
chkRemAlert: false
|
|
8574
|
+
};
|
|
8575
|
+
this.state.newObservation = newObservation;
|
|
8471
8576
|
}
|
|
8472
8577
|
}
|
|
8473
8578
|
getConfirmParams() {
|
|
@@ -9249,7 +9354,7 @@ class Execution extends EventEmitter$1 {
|
|
|
9249
9354
|
const res = await InitialData.getFormsDefinition(this);
|
|
9250
9355
|
try {
|
|
9251
9356
|
for await (const formDefinition of res) {
|
|
9252
|
-
if (!parseFakeJSON(formDefinition.properties).frmTab) {
|
|
9357
|
+
if (!parseFakeJSON$1(formDefinition.properties).frmTab) {
|
|
9253
9358
|
this.mustRenderForms.push(
|
|
9254
9359
|
formDefinition.frmParent + "_" + formDefinition.formName
|
|
9255
9360
|
);
|
|
@@ -9552,5 +9657,5 @@ class StatusNotification extends Notification {
|
|
|
9552
9657
|
}
|
|
9553
9658
|
}
|
|
9554
9659
|
|
|
9555
|
-
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$1 as 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, Scheduler, Select, SelectField, ShowConfirmMessage$1 as ShowConfirmMessage, ShowPathSelection, ShowPoolSelection, ShowSign$1 as ShowSign, ShowSignSelection$1 as ShowSignSelection, StatefulEmitter, StatusNotification, AreaField as TextAreaField, TextField, Textarea, Title, TranslatableField, Translation, Tree, TreeField, UploaderApi, UploaderModalController, createNewField, deepEqual, get, getCurrentDate, getLabel, isHtmlResponse, isJsonResponse, isXmlResponse, makeApiaUrl, parseFileDefinition, parseSuccessfulResponse, parseXml, post, returnExactlyTheSame, shallowEqual };
|
|
9660
|
+
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$1 as 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, Scheduler, Select, SelectField, ShowConfirmMessage$1 as ShowConfirmMessage, ShowPathSelection, ShowPoolSelection, ShowSign$1 as ShowSign, ShowSignSelection$1 as ShowSignSelection, StatefulEmitter, StatusNotification, AreaField as TextAreaField, TextField, Textarea, Title, TranslatableField, Translation, Tree, TreeField, UploaderApi, UploaderModalController, createNewField, deepEqual, get, getCurrentDate, getLabel, isHtmlResponse, isJsonResponse, isOneClickUploadEnabled, isXmlResponse, makeApiaUrl, parseFakeJSON$1 as parseFakeJSON, parseFileDefinition, parseSuccessfulResponse, parseXml, post, returnExactlyTheSame, shallowEqual };
|
|
9556
9661
|
//# sourceMappingURL=index.js.map
|