@apia/execution 4.0.24 → 4.0.26

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.js CHANGED
@@ -1,9 +1,9 @@
1
- import { makeObservable, observable, action, runInAction, reaction, computed, toJS, makeAutoObservable } from 'mobx';
1
+ import { makeObservable, observable, action, runInAction, reaction, computed, toJS } from 'mobx';
2
2
  import xml2js from 'xml2js';
3
3
  import he from 'he';
4
4
  import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
5
5
  import QueryString from 'qs';
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';
6
+ import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, addBoundary, formatMessage, parseAsSize, shallowEqual as shallowEqual$1, Mutex, awaitTime, noNaN as noNaN$1, getDateFormat, freezeDeep, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
7
7
  import axios from 'axios';
8
8
  import { Cell, TableController, Row, FocusControllerPlugin } from '@apia/table2-controller';
9
9
  import dayjs from 'dayjs';
@@ -456,7 +456,14 @@ function dispatchMessage(execution, type, message) {
456
456
  );
457
457
  }
458
458
  function getAxios() {
459
- return import('axios').then((r) => r.default);
459
+ return import('axios').then(
460
+ (r) => typeof process !== "undefined" && process.env?.APIA_SERVER && process.env?.CONTEXT ? r.default.create({
461
+ baseURL: process?.env?.APIA_SERVER.replaceAll(
462
+ process.env.CONTEXT,
463
+ ""
464
+ )
465
+ }) : r.default
466
+ );
460
467
  }
461
468
  const handleWrongResponse = (execution, error) => {
462
469
  if (error instanceof InvalidSessionException)
@@ -882,7 +889,7 @@ const labels = {
882
889
  errorFieldRequired: (execution) => getLabel(execution, "msgReqField").text,
883
890
  errorTranslateRequired: (execution, lang) => getLabel(execution, "lblReqLang", { text: { TOK1: lang } }).text,
884
891
  errorLoadForms: () => "Error al inicializar los formularios, contacte al administrador.",
885
- errorOnEvent: (eventName, className) => window.SERVER_MODE ? "Error al ejecutar la clase de negocios, contacte al administrador." : `Error on event ${eventName}, className ${className}`
892
+ errorOnEvent: (execution, eventName) => window.SERVER_MODE ? "Error al ejecutar la clase de negocios, contacte al administrador." : getLabel(execution, "msgErrorOnEvent", { text: { TOK1: eventName } }).text
886
893
  };
887
894
 
888
895
  const parseBoolean = (val) => {
@@ -949,6 +956,9 @@ class WithProperties {
949
956
  }
950
957
  makeObservable(this, { properties: observable, setProperty: action });
951
958
  }
959
+ getParentGrid() {
960
+ return this.parentGrid;
961
+ }
952
962
  getProperty(propName) {
953
963
  return this.properties[propName];
954
964
  }
@@ -1212,6 +1222,19 @@ let Field$1 = class Field extends WithProperties {
1212
1222
  for (const event of events) {
1213
1223
  try {
1214
1224
  const fn = window[event.fncName];
1225
+ if (fn === void 0) {
1226
+ new MessageNotification({
1227
+ message: getLabel(this.form.execution, "msgFunction404", {
1228
+ text: { TOK1: eventName }
1229
+ }).text,
1230
+ type: "error"
1231
+ });
1232
+ throw new Error(
1233
+ getLabel(this.form.execution, "msgFunction404", {
1234
+ text: { TOK1: eventName }
1235
+ }).text
1236
+ );
1237
+ }
1215
1238
  const result = await fn(
1216
1239
  await asyncCreateNewField(this.form.execution, this),
1217
1240
  ...await this.getScriptEventParams(event.fncParams)
@@ -1221,7 +1244,7 @@ let Field$1 = class Field extends WithProperties {
1221
1244
  console.error(e);
1222
1245
  this.form.execution.notifications.add(
1223
1246
  new MessageNotification({
1224
- message: labels.errorOnEvent(eventName, event.evtName),
1247
+ message: labels.errorOnEvent(this.form.execution, event.fncName) + ", " + e,
1225
1248
  type: "error"
1226
1249
  })
1227
1250
  );
@@ -1752,6 +1775,12 @@ class Translation {
1752
1775
  this.state.tempValue = "";
1753
1776
  this.state.hasChanged = false;
1754
1777
  }
1778
+ deleteTranslation() {
1779
+ delete this.state.remoteValue;
1780
+ this.state.tempValue = "";
1781
+ this.state.hasChanged = false;
1782
+ this.state.isTranslated = false;
1783
+ }
1755
1784
  setTempValue(str) {
1756
1785
  this.state.tempValue = str;
1757
1786
  this.state.hasChanged = str !== this.state.remoteValue;
@@ -1838,6 +1867,11 @@ class TranslatableField extends FieldWithAttribute {
1838
1867
  c.reset();
1839
1868
  });
1840
1869
  }
1870
+ deleteTranslations() {
1871
+ this.getTranslations().forEach((c) => {
1872
+ c.deleteTranslation();
1873
+ });
1874
+ }
1841
1875
  async changeLanguage(langId) {
1842
1876
  this.selectedLanguageId = langId;
1843
1877
  this.syncTranslation();
@@ -1862,6 +1896,7 @@ class TranslatableField extends FieldWithAttribute {
1862
1896
  })
1863
1897
  );
1864
1898
  });
1899
+ this.state.validation.errorMessage = null;
1865
1900
  }
1866
1901
  async syncTranslation() {
1867
1902
  const langId = this.selectedLanguageId;
@@ -1899,6 +1934,12 @@ class TranslatableField extends FieldWithAttribute {
1899
1934
  }
1900
1935
  return isValid;
1901
1936
  }
1937
+ setValue(newValue, options) {
1938
+ if (newValue === "") {
1939
+ this.deleteTranslations();
1940
+ }
1941
+ return super.setValue(newValue, options);
1942
+ }
1902
1943
  }
1903
1944
 
1904
1945
  class Editor extends TranslatableField {
@@ -1930,6 +1971,7 @@ const getInitialState = (execution) => Object.freeze({
1930
1971
  docFolder: void 0,
1931
1972
  docExpDate: void 0,
1932
1973
  description: "",
1974
+ isReadonly: false,
1933
1975
  permissions: {
1934
1976
  pools: [],
1935
1977
  users: getWindow(execution).DOCUMENT_OWNER_PRIVILEGES ? [
@@ -2014,6 +2056,7 @@ class UploaderModalController {
2014
2056
  }
2015
2057
  addFiles(files) {
2016
2058
  this.state.fileReqError = false;
2059
+ this.state.isReadonly = false;
2017
2060
  this.api.saveDroppedFiles(files, this.conf);
2018
2061
  }
2019
2062
  addDirectoryFile(file) {
@@ -2027,6 +2070,10 @@ class UploaderModalController {
2027
2070
  this.onChangeExtension();
2028
2071
  this.api.reloadMetadata({ docTypeId });
2029
2072
  }
2073
+ clearDirectoryFile() {
2074
+ this.state.fromDirectoryFile = null;
2075
+ this.state.isReadonly = false;
2076
+ }
2030
2077
  clearFile(name) {
2031
2078
  this.api.clearFile(name);
2032
2079
  }
@@ -2259,6 +2306,10 @@ class UploaderApi extends EventEmitter$1 {
2259
2306
  docTypePermittedObjId: this.docTypePermittedObjId,
2260
2307
  docTypePermittedObjType: this.type
2261
2308
  }));
2309
+ if (!window.fileApi) {
2310
+ window.fileApi = {};
2311
+ }
2312
+ window.fileApi[this.id] = this;
2262
2313
  makeObservable(this, {
2263
2314
  state: observable
2264
2315
  });
@@ -2285,7 +2336,9 @@ class UploaderApi extends EventEmitter$1 {
2285
2336
  await this.saveDroppedFiles(files ?? []);
2286
2337
  } else {
2287
2338
  if (files) {
2288
- await this.saveDroppedFiles(files ?? []);
2339
+ const result = await this.saveDroppedFiles(files ?? []);
2340
+ if (!result)
2341
+ return;
2289
2342
  }
2290
2343
  this.modalController = new UploaderModalController(
2291
2344
  this,
@@ -2299,12 +2352,21 @@ class UploaderApi extends EventEmitter$1 {
2299
2352
  await this.saveDroppedFiles(files ?? [], conf);
2300
2353
  } else {
2301
2354
  await this.init();
2302
- this.modalController = new UploaderModalController(
2303
- this,
2304
- this.modalConfig,
2305
- conf
2306
- );
2307
- this.modalController.openModal();
2355
+ let mustOpen = true;
2356
+ if (files) {
2357
+ const res = await this.saveDroppedFiles(files ?? [], conf);
2358
+ if (!res) {
2359
+ mustOpen = false;
2360
+ }
2361
+ }
2362
+ if (mustOpen) {
2363
+ this.modalController = new UploaderModalController(
2364
+ this,
2365
+ this.modalConfig,
2366
+ conf
2367
+ );
2368
+ this.modalController.openModal();
2369
+ }
2308
2370
  }
2309
2371
  }
2310
2372
  async onVersionUpload(file, conf = { newFiles: [] }) {
@@ -2421,15 +2483,24 @@ class UploaderApi extends EventEmitter$1 {
2421
2483
  }
2422
2484
  }
2423
2485
  clearFile(name) {
2486
+ if (this.modalController) {
2487
+ this.modalController.state.isReadonly = false;
2488
+ }
2424
2489
  this.state.inProgressFiles = this.state.inProgressFiles.filter(
2425
2490
  (c) => c.name !== name
2426
2491
  );
2427
2492
  }
2428
2493
  clearFiles() {
2494
+ if (this.modalController) {
2495
+ this.modalController.state.isReadonly = false;
2496
+ }
2429
2497
  this.state.inProgressFiles = [];
2430
2498
  this.state.hiddenFiles = [];
2431
2499
  }
2432
2500
  clearState() {
2501
+ if (this.modalController) {
2502
+ this.modalController.state.isReadonly = false;
2503
+ }
2433
2504
  this.state.selectedDocTypeId = "1";
2434
2505
  this.state.inProgressFiles = [];
2435
2506
  this.state.versioningFile = null;
@@ -2540,21 +2611,21 @@ class UploaderApi extends EventEmitter$1 {
2540
2611
  }
2541
2612
  async saveDroppedFiles(unprocessedFiles, conf) {
2542
2613
  if (getWindow(this.execution).IN_MONITOR) {
2543
- return;
2614
+ return false;
2544
2615
  }
2545
2616
  const {
2546
2617
  langId,
2547
2618
  strictMode: isConfStrictMode = false,
2548
2619
  translatingFile
2549
2620
  } = conf ?? {};
2550
- const isStrictMode = isConfStrictMode || !!this.state.versioningFile;
2621
+ const isStrictMode = isConfStrictMode || !!this.state.versioningFile || !!this.modalController?.state.fromDirectoryFile;
2551
2622
  const docType = this.getCurrentDocTypeId();
2552
2623
  if (!isStrictMode && !docType) {
2553
2624
  this.notify({
2554
2625
  message: `${getWindow(this.execution).LBL_DROP_FILE_DELETED}: ${unprocessedFiles.map((current) => current.name).join(", ")}.`,
2555
2626
  type: "warning"
2556
2627
  });
2557
- return;
2628
+ return false;
2558
2629
  }
2559
2630
  const allowedFiles = this.filterAlreadyUploadedFiles(
2560
2631
  this.filterByFilesAmountLimit(
@@ -2569,144 +2640,151 @@ class UploaderApi extends EventEmitter$1 {
2569
2640
  ),
2570
2641
  conf
2571
2642
  );
2572
- const formData = new FormData();
2573
- allowedFiles.forEach(
2574
- (file) => formData.append("fileRepository", file, file.name)
2575
- );
2576
- await post(
2577
- this.execution,
2578
- makeApiaUrl(
2579
- this.execution,
2580
- this.getSaveDroppedFilesParameters({
2581
- action: "saveDroppedFiles",
2582
- docId: this.state.versioningFile?.docId,
2583
- ajaxUrl: this.getAjaxUrl(),
2584
- elemType: this.type,
2585
- elemId: `prmDocumentContainter${this.type}`,
2586
- frmOut: !this.modalController,
2587
- docTypeId: this.state.selectedDocTypeId,
2588
- langId
2589
- })
2590
- ),
2591
- {
2592
- postData: formData,
2593
- axiosConfig: {
2594
- onUploadProgress: (ev) => this.state.progress = ev.loaded * 100 / ((ev.total ?? ev.loaded) * 2)
2595
- }
2596
- }
2597
- );
2598
- const ajaxUploadFileStatusParameters = this.getAjaxUploadFileStatusParameters({
2599
- action: "ajaxUploadFileStatus",
2600
- ajaxUrl: this.getAjaxUrl(),
2601
- delayForDrop: true,
2602
- isAjax: true,
2603
- prefix: this.type
2604
- });
2605
- let tries = 0;
2606
- const checkUploadResult = async () => {
2607
- return new Promise(async (resolve) => {
2608
- tries += 1;
2609
- if (tries === 10) {
2610
- this.notify({
2611
- message: "Error while checking for uploadFileStatus, too many tries",
2612
- type: "error"
2613
- });
2614
- resolve(false);
2615
- return;
2616
- }
2617
- const response = await post(
2618
- this.execution,
2619
- makeApiaUrl(this.execution, ajaxUploadFileStatusParameters)
2620
- );
2621
- if (response && response.data) {
2622
- const hasMessages = arrayOrArray(
2623
- response.data?.sysMessages?.message ?? response.data?.sysExceptions?.exception ?? response.data?.exceptions?.exception ?? response.data.function.messages?.message
2624
- ).length > 0 || !!response.data.function.dropLastMessage;
2625
- const uploadMessage = arrayOrArray(
2626
- response.data.function.messages?.message
2627
- ).find((current) => current.name === "message");
2628
- if (uploadMessage)
2629
- this.notify({ message: uploadMessage.label, type: "warning" });
2630
- const method = response.data?.function.name;
2631
- this.state.progress = 44;
2632
- if (hasMessages) {
2633
- resolve(false);
2634
- return;
2635
- }
2636
- if (method === "fncProceedDocumentProcessing") {
2637
- resolve(true);
2638
- return;
2639
- }
2640
- if (tries === 10) {
2641
- resolve(method === "fncProceedDocumentProcessing");
2642
- }
2643
- setTimeout(() => {
2644
- checkUploadResult().then(resolve).catch(() => resolve(false));
2645
- }, 100);
2646
- } else {
2647
- resolve(false);
2648
- }
2649
- });
2650
- };
2651
- const hasUploadedCorrectly = await checkUploadResult();
2652
- this.state.progress = 66;
2653
- if (hasUploadedCorrectly) {
2654
- const shown = (this.state.inProgressFiles ?? []).map((file) => file.name);
2655
- const postData = QueryString.stringify(
2656
- this.getProcessDroppedFilesPostdata({
2657
- useDocTypePermitted: true,
2658
- docTypePermittedObjId: this.docTypePermittedObjId?.toString(),
2659
- docTypePermittedObjType: this.type,
2660
- dropped: allowedFiles.map((file) => file.name).concat(shown),
2661
- shown
2662
- }),
2663
- { arrayFormat: "repeat" }
2643
+ if (allowedFiles.length > 0) {
2644
+ const formData = new FormData();
2645
+ allowedFiles.forEach(
2646
+ (file) => formData.append("fileRepository", file, file.name)
2664
2647
  );
2665
- const secondResult = await post(
2648
+ await post(
2666
2649
  this.execution,
2667
2650
  makeApiaUrl(
2668
2651
  this.execution,
2669
- this.getProcessDroppedFilesParameters({
2670
- action: "processDroppedFiles",
2671
- elemType: this.type,
2652
+ this.getSaveDroppedFilesParameters({
2653
+ action: "saveDroppedFiles",
2672
2654
  docId: this.state.versioningFile?.docId,
2655
+ ajaxUrl: this.getAjaxUrl(),
2656
+ elemType: this.type,
2657
+ elemId: `prmDocumentContainter${this.type}`,
2673
2658
  frmOut: !this.modalController,
2674
- ajaxUrl: this.getAjaxUrl()
2659
+ docTypeId: this.state.selectedDocTypeId,
2660
+ langId
2675
2661
  })
2676
2662
  ),
2677
2663
  {
2678
- postData: postData.toString()
2664
+ postData: formData,
2665
+ axiosConfig: {
2666
+ onUploadProgress: (ev) => this.state.progress = ev.loaded * 100 / ((ev.total ?? ev.loaded) * 2)
2667
+ }
2679
2668
  }
2680
2669
  );
2681
- this.state.progress = 83;
2682
- if (secondResult?.data?.function?.principal?.docInfo) {
2683
- const acceptedByServerFiles = arrayOrArray(
2684
- secondResult.data.function?.principal?.docInfo
2685
- );
2686
- this.state.inProgressFiles = [
2687
- ...this.state.inProgressFiles ?? [],
2688
- ...acceptedByServerFiles.map(
2689
- (current) => [...this.state.inProgressFiles, ...unprocessedFiles].find(
2690
- (search) => search.name === current.docInfoName
2691
- )
2692
- ).filter((current) => !!current)
2693
- ];
2694
- this.state.progress = 100;
2695
- if (this.modalController)
2696
- this.modalController.state.fromDirectoryFile = null;
2697
- this.notify({
2698
- type: "success",
2699
- message: getWindow(this.execution).FILE_UPLOADED_SUCCESSFULLY
2670
+ const ajaxUploadFileStatusParameters = this.getAjaxUploadFileStatusParameters({
2671
+ action: "ajaxUploadFileStatus",
2672
+ ajaxUrl: this.getAjaxUrl(),
2673
+ delayForDrop: true,
2674
+ isAjax: true,
2675
+ prefix: this.type
2676
+ });
2677
+ let tries = 0;
2678
+ const checkUploadResult = async () => {
2679
+ return new Promise(async (resolve) => {
2680
+ tries += 1;
2681
+ if (tries === 10) {
2682
+ this.notify({
2683
+ message: "Error while checking for uploadFileStatus, too many tries",
2684
+ type: "error"
2685
+ });
2686
+ resolve(false);
2687
+ return;
2688
+ }
2689
+ const response = await post(
2690
+ this.execution,
2691
+ makeApiaUrl(this.execution, ajaxUploadFileStatusParameters)
2692
+ );
2693
+ if (response && response.data) {
2694
+ const hasMessages = arrayOrArray(
2695
+ response.data?.sysMessages?.message ?? response.data?.sysExceptions?.exception ?? response.data?.exceptions?.exception ?? response.data.function.messages?.message
2696
+ ).length > 0 || !!response.data.function.dropLastMessage;
2697
+ const uploadMessage = arrayOrArray(
2698
+ response.data.function.messages?.message
2699
+ ).find((current) => current.name === "message");
2700
+ if (uploadMessage)
2701
+ this.notify({ message: uploadMessage.label, type: "warning" });
2702
+ const method = response.data?.function.name;
2703
+ this.state.progress = 44;
2704
+ if (hasMessages) {
2705
+ resolve(false);
2706
+ return;
2707
+ }
2708
+ if (method === "fncProceedDocumentProcessing") {
2709
+ resolve(true);
2710
+ return;
2711
+ }
2712
+ if (tries === 10) {
2713
+ resolve(method === "fncProceedDocumentProcessing");
2714
+ }
2715
+ setTimeout(() => {
2716
+ checkUploadResult().then(resolve).catch(() => resolve(false));
2717
+ }, 100);
2718
+ } else {
2719
+ resolve(false);
2720
+ }
2700
2721
  });
2701
- if (isOneClickUploadEnabled(this.modalConfig.oneClickUpload)) {
2702
- if (langId && translatingFile)
2703
- void this.confirmDropModal({ langId, translatingFile });
2704
- else
2705
- void this.confirmDropModal();
2722
+ };
2723
+ const hasUploadedCorrectly = await checkUploadResult();
2724
+ this.state.progress = 66;
2725
+ if (hasUploadedCorrectly) {
2726
+ const shown = (this.state.inProgressFiles ?? []).map(
2727
+ (file) => file.name
2728
+ );
2729
+ const postData = QueryString.stringify(
2730
+ this.getProcessDroppedFilesPostdata({
2731
+ useDocTypePermitted: true,
2732
+ docTypePermittedObjId: this.docTypePermittedObjId?.toString(),
2733
+ docTypePermittedObjType: this.type,
2734
+ dropped: allowedFiles.map((file) => file.name).concat(shown),
2735
+ shown
2736
+ }),
2737
+ { arrayFormat: "repeat" }
2738
+ );
2739
+ const secondResult = await post(
2740
+ this.execution,
2741
+ makeApiaUrl(
2742
+ this.execution,
2743
+ this.getProcessDroppedFilesParameters({
2744
+ action: "processDroppedFiles",
2745
+ elemType: this.type,
2746
+ docId: this.state.versioningFile?.docId,
2747
+ frmOut: !this.modalController,
2748
+ ajaxUrl: this.getAjaxUrl()
2749
+ })
2750
+ ),
2751
+ {
2752
+ postData: postData.toString()
2753
+ }
2754
+ );
2755
+ this.state.progress = 83;
2756
+ if (secondResult?.data?.function?.principal?.docInfo) {
2757
+ const acceptedByServerFiles = arrayOrArray(
2758
+ secondResult.data.function?.principal?.docInfo
2759
+ );
2760
+ this.state.inProgressFiles = [
2761
+ ...this.state.inProgressFiles ?? [],
2762
+ ...acceptedByServerFiles.map(
2763
+ (current) => [...this.state.inProgressFiles, ...unprocessedFiles].find(
2764
+ (search) => search.name === current.docInfoName
2765
+ )
2766
+ ).filter((current) => !!current)
2767
+ ];
2768
+ this.state.progress = 100;
2769
+ if (this.modalController)
2770
+ this.modalController.state.fromDirectoryFile = null;
2771
+ this.notify({
2772
+ type: "success",
2773
+ message: getWindow(this.execution).FILE_UPLOADED_SUCCESSFULLY
2774
+ });
2775
+ if (isOneClickUploadEnabled(this.modalConfig.oneClickUpload)) {
2776
+ if (langId && translatingFile)
2777
+ void this.confirmDropModal({ langId, translatingFile });
2778
+ else
2779
+ void this.confirmDropModal();
2780
+ }
2706
2781
  }
2707
2782
  }
2783
+ this.state.progress = 100;
2784
+ return true;
2785
+ } else {
2786
+ return false;
2708
2787
  }
2709
- this.state.progress = 100;
2710
2788
  }
2711
2789
  async checkWebDavLock(docId) {
2712
2790
  if (getWindow(this.execution).IN_MONITOR) {
@@ -2919,7 +2997,7 @@ class UploaderApi extends EventEmitter$1 {
2919
2997
  if (this.modalController) {
2920
2998
  this.modalController.addDirectoryFile(document);
2921
2999
  this.modalController.state.permissions = {
2922
- pools: arrayOrArray(permissions.pool).map((c) => {
3000
+ pools: arrayOrArray(permissions?.pool).map((c) => {
2923
3001
  return {
2924
3002
  poolId: c.id,
2925
3003
  poolName: c.name,
@@ -2927,14 +3005,7 @@ class UploaderApi extends EventEmitter$1 {
2927
3005
  };
2928
3006
  }),
2929
3007
  users: [
2930
- ...getWindow(this.execution).DOCUMENT_OWNER_PRIVILEGES ? [
2931
- {
2932
- canUpdate: true,
2933
- userId: getWindow(this.execution).CURRENT_USER_LOGIN,
2934
- userLogin: getWindow(this.execution).CURRENT_USER_LOGIN
2935
- }
2936
- ] : [],
2937
- ...arrayOrArray(permissions.pool).map((c) => {
3008
+ ...arrayOrArray(permissions?.user).map((c) => {
2938
3009
  return {
2939
3010
  userId: c.id,
2940
3011
  userLogin: c.name,
@@ -2945,6 +3016,7 @@ class UploaderApi extends EventEmitter$1 {
2945
3016
  allowAllType: document.docAllPoolPerm
2946
3017
  };
2947
3018
  this.modalController.changeDocType(document.docTypeId);
3019
+ this.modalController.state.isReadonly = !documentInfo.function.currentUsrPems.usrCanModify;
2948
3020
  }
2949
3021
  void this.reloadMetadata(
2950
3022
  { docId: document.docId, docTypeId: document.docTypeId },
@@ -3095,8 +3167,8 @@ class UploaderApi extends EventEmitter$1 {
3095
3167
  this.setTranslationFile(firstFile, translatingFile.docId, langId);
3096
3168
  } else {
3097
3169
  this.state.files = { ...currentFiles, ...newFiles };
3098
- this.state.inProgressFiles = [];
3099
3170
  }
3171
+ this.state.inProgressFiles = [];
3100
3172
  this.emit("fileUploaded", null);
3101
3173
  return true;
3102
3174
  }
@@ -3641,7 +3713,7 @@ class FormsUploader extends UploaderApi {
3641
3713
  return null;
3642
3714
  }
3643
3715
  async saveDroppedFiles(unprocessedFiles, conf) {
3644
- await super.saveDroppedFiles(unprocessedFiles, conf);
3716
+ return await super.saveDroppedFiles(unprocessedFiles, conf);
3645
3717
  }
3646
3718
  }
3647
3719
 
@@ -3651,7 +3723,7 @@ var __publicField$e = (obj, key, value) => {
3651
3723
  __defNormalProp$e(obj, key + "" , value);
3652
3724
  return value;
3653
3725
  };
3654
- class File extends TranslatableField {
3726
+ class File extends FieldWithAttribute {
3655
3727
  constructor() {
3656
3728
  super(...arguments);
3657
3729
  __publicField$e(this, "uploader", {});
@@ -3942,6 +4014,8 @@ class ModalInput extends FieldWithAttribute {
3942
4014
  return this.getValue().showValue !== "" && this.getValue().storeValue !== "";
3943
4015
  }
3944
4016
  async setValueFromInputWrite(value) {
4017
+ if (isFieldShowAsText(this) || shallowEqual$1(value, this.getValue().showValue) || value === "")
4018
+ return;
3945
4019
  if (value !== this.getValue().showValue) {
3946
4020
  const result = await post(
3947
4021
  this.form.execution,
@@ -3963,10 +4037,13 @@ class ModalInput extends FieldWithAttribute {
3963
4037
  }
3964
4038
  );
3965
4039
  if (result?.data?.ret_value) {
3966
- this.setValue({
4040
+ const setValueResult = await this.setValue({
3967
4041
  storeValue: result?.data?.ret_value.value,
3968
4042
  showValue: result?.data?.ret_value.show_value
3969
4043
  });
4044
+ if (setValueResult) {
4045
+ this.fireEvent("onChange");
4046
+ }
3970
4047
  this.setError("");
3971
4048
  } else {
3972
4049
  this.setValue({ showValue: "", storeValue: "" });
@@ -3984,10 +4061,15 @@ class ModalInput extends FieldWithAttribute {
3984
4061
  { postData: { id: rowId }, postDataTreatment: "stringify" }
3985
4062
  );
3986
4063
  if (result?.data?.row?.cell) {
3987
- this.setValue({
4064
+ const setValueResult = await this.setValue({
3988
4065
  storeValue: result.data.row.cell[0],
3989
4066
  showValue: result.data.row.cell[1]
3990
4067
  });
4068
+ this.form.execution.setLastModalReturn(result.data.row.cell);
4069
+ if (setValueResult) {
4070
+ this.fireEvent("onModalReturn");
4071
+ this.fireEvent("onChange");
4072
+ }
3991
4073
  }
3992
4074
  }
3993
4075
  async validate() {
@@ -4002,6 +4084,25 @@ class ModalInput extends FieldWithAttribute {
4002
4084
  }
4003
4085
  return true;
4004
4086
  }
4087
+ setValue(newValue, options) {
4088
+ if (isFieldShowAsText(this) || shallowEqual$1(newValue, this.getValue()))
4089
+ return Promise.resolve(true);
4090
+ this.state.value = newValue;
4091
+ this.state.validation.errorMessage = null;
4092
+ if (options?.synchronize === false) {
4093
+ this.lastSynchronizationValue = newValue;
4094
+ return Promise.resolve(true);
4095
+ }
4096
+ return this.synchronize(newValue).then((res) => {
4097
+ if (res) {
4098
+ if (options?.markAsDirty !== false) {
4099
+ this.form.execution.state.hasChangedAnything = true;
4100
+ }
4101
+ return true;
4102
+ }
4103
+ return Promise.resolve(false);
4104
+ });
4105
+ }
4005
4106
  getSynchronizePostConfiguration(value) {
4006
4107
  const storeIdValue = this.properties.storeMdlQryResult;
4007
4108
  return {
@@ -4442,14 +4543,15 @@ class Grid extends Field$1 {
4442
4543
  async init(form) {
4443
4544
  await super.init(form);
4444
4545
  const headerRow = new Row("header");
4445
- headerRow.addCell(
4446
- new AdditionalCell(
4447
- this,
4448
- () => -1,
4449
- () => {
4450
- }
4451
- )
4452
- );
4546
+ if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly)
4547
+ headerRow.addCell(
4548
+ new AdditionalCell(
4549
+ this,
4550
+ () => -1,
4551
+ () => {
4552
+ }
4553
+ )
4554
+ );
4453
4555
  const hiddenColumns = /* @__PURE__ */ new Set();
4454
4556
  this.header.forEach((c) => {
4455
4557
  hiddenColumns.add(c.fldId);
@@ -4480,7 +4582,8 @@ class Grid extends Field$1 {
4480
4582
  colName: col.fldId || String(i),
4481
4583
  content: col.label,
4482
4584
  domProperties: {
4483
- style: { width, maxWidth: width }
4585
+ style: { width, maxWidth: width },
4586
+ title: col.title
4484
4587
  },
4485
4588
  properties: { col }
4486
4589
  })
@@ -4641,18 +4744,19 @@ class Grid extends Field$1 {
4641
4744
  });
4642
4745
  }
4643
4746
  const newRow = new Row(String(this.rowId++));
4644
- newRow.addCell(
4645
- new AdditionalCell(
4646
- this,
4647
- () => newRow.index,
4648
- () => {
4649
- this.deleteRows(newRow.index);
4650
- },
4651
- this.properties.gridForm ? (handler) => {
4652
- this.openEditionModal(handler);
4653
- } : void 0
4654
- )
4655
- );
4747
+ if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly)
4748
+ newRow.addCell(
4749
+ new AdditionalCell(
4750
+ this,
4751
+ () => newRow.index,
4752
+ () => {
4753
+ this.deleteRows(newRow.index);
4754
+ },
4755
+ this.properties.gridForm ? (handler) => {
4756
+ this.openEditionModal(handler);
4757
+ } : void 0
4758
+ )
4759
+ );
4656
4760
  this.tableController.body.addRow(newRow);
4657
4761
  for await (const field of definitions) {
4658
4762
  const fieldProps = parseFakeJSON$1(
@@ -6172,6 +6276,9 @@ class ButtonField extends ApiaField {
6172
6276
  clearValue() {
6173
6277
  __privateGet$g(this, _field$d).properties.value = "";
6174
6278
  }
6279
+ setValue(value) {
6280
+ this.setProperty("value", value);
6281
+ }
6175
6282
  }
6176
6283
  _field$d = new WeakMap();
6177
6284
 
@@ -6755,6 +6862,9 @@ class TextField extends ApiaField {
6755
6862
  `Apia JSApi Error: The field ${__privateGet$7(this, _field$4).definition.fieldType} does not use a label`
6756
6863
  );
6757
6864
  }
6865
+ setValue(value) {
6866
+ this.setProperty("value", value);
6867
+ }
6758
6868
  }
6759
6869
  _field$4 = new WeakMap();
6760
6870
 
@@ -6979,13 +7089,15 @@ class GridField extends ApiaField {
6979
7089
  );
6980
7090
  }
6981
7091
  getAllColumns() {
6982
- return __privateGet$5(this, _field$2).getAllColumns().map((c) => c.map((f) => createNewField(this.form.execution, f)));
7092
+ return __privateGet$5(this, _field$2).getAllColumns().map(
7093
+ (c) => c.map((f) => createNewField(__privateGet$5(this, _field$2).getForm().execution, f))
7094
+ );
6983
7095
  }
6984
7096
  getColumn(fieldName) {
6985
7097
  const fields = __privateGet$5(this, _field$2).getColumn(fieldName);
6986
7098
  if (fields) {
6987
7099
  return arrayOrArray(fields).map(
6988
- (c) => createNewField(this.form.execution, c)
7100
+ (c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c)
6989
7101
  );
6990
7102
  }
6991
7103
  return [];
@@ -6996,7 +7108,10 @@ class GridField extends ApiaField {
6996
7108
  getField(fieldName, fieldIndex) {
6997
7109
  const fields = __privateGet$5(this, _field$2).getField(fieldName, fieldIndex);
6998
7110
  if (fields) {
6999
- return fieldIndex !== void 0 ? createNewField(this.form.execution, arrayOrArray(fields)[0]) : arrayOrArray(fields).map((c) => createNewField(this.form.execution, c)).filter((c) => Boolean(c));
7111
+ return fieldIndex !== void 0 ? createNewField(
7112
+ __privateGet$5(this, _field$2).getForm().execution,
7113
+ arrayOrArray(fields)[0]
7114
+ ) : arrayOrArray(fields).map((c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c)).filter((c) => Boolean(c));
7000
7115
  }
7001
7116
  return null;
7002
7117
  }
@@ -7007,7 +7122,7 @@ class GridField extends ApiaField {
7007
7122
  return __privateGet$5(this, _field$2).pageSize;
7008
7123
  }
7009
7124
  getRow(index) {
7010
- return __privateGet$5(this, _field$2).getRowByFieldIndex(index)?.map((c) => createNewField(this.form.execution, c));
7125
+ return __privateGet$5(this, _field$2).getRowByFieldIndex(index)?.map((c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c));
7011
7126
  }
7012
7127
  getSelection() {
7013
7128
  const selected = __privateGet$5(this, _field$2).getSelectedRows();
@@ -7015,7 +7130,7 @@ class GridField extends ApiaField {
7015
7130
  selected.forEach((r) => {
7016
7131
  const row = [];
7017
7132
  r.forEach((c) => {
7018
- const fld = createNewField(this.form.execution, c);
7133
+ const fld = createNewField(__privateGet$5(this, _field$2).getForm().execution, c);
7019
7134
  if (fld) {
7020
7135
  row.push(fld);
7021
7136
  }
@@ -7373,13 +7488,13 @@ class ApiaFunctions {
7373
7488
  return getWindow(this.execution).LANG_CODE;
7374
7489
  }
7375
7490
  getCurrentProcessName() {
7376
- return this.execution.getProcess().name ?? null;
7491
+ return this.execution.environment.properties?.processName ?? "";
7377
7492
  }
7378
7493
  getCurrentStep() {
7379
7494
  return this.execution.currentStep;
7380
7495
  }
7381
7496
  getCurrentTaskName() {
7382
- return this.execution.getCurrentTask().name;
7497
+ return this.execution.environment.properties?.taskName ?? "";
7383
7498
  }
7384
7499
  getEntityForm(frmName) {
7385
7500
  const frm = this.getForm(frmName, "E");
@@ -7400,19 +7515,19 @@ class ApiaFunctions {
7400
7515
  return pForm;
7401
7516
  }
7402
7517
  getLastModalReturn() {
7403
- return getWindow(this.execution).lastModalReturn;
7518
+ return this.execution.getLastModalReturn();
7404
7519
  }
7405
7520
  getModalReturn() {
7406
7521
  return this.getLastModalReturn();
7407
7522
  }
7408
7523
  getModalSelectedRow() {
7409
- return getWindow(this.execution).lastModalReturn.slice(2);
7524
+ return this.execution.getLastModalReturn()?.slice(2);
7410
7525
  }
7411
7526
  getModalShowValue() {
7412
- return getWindow(this.execution).lastModalReturn[1];
7527
+ return this.execution.getLastModalReturn()[1];
7413
7528
  }
7414
7529
  getModalValue() {
7415
- return getWindow(this.execution).lastModalReturn[0];
7530
+ return this.execution.getLastModalReturn()[0];
7416
7531
  }
7417
7532
  getProcessForm(frmName) {
7418
7533
  const frm = this.getForm(frmName, "P");
@@ -7446,7 +7561,6 @@ class ApiaFunctions {
7446
7561
  }
7447
7562
  setLastModalReturn(value) {
7448
7563
  getWindow(this.execution).lastModalReturn = value;
7449
- getWindow(this.execution).lastModalReturn = value;
7450
7564
  }
7451
7565
  setStepTitle(stepNumber, stepTitle) {
7452
7566
  this.execution.setStepTitle(stepNumber, stepTitle);
@@ -7613,7 +7727,7 @@ class CustomComponent {
7613
7727
  console.error(e);
7614
7728
  this.form.execution.notifications.add(
7615
7729
  new MessageNotification({
7616
- message: labels.errorOnEvent(event.name, def.fncName),
7730
+ message: labels.errorOnEvent(this.execution, def.fncName),
7617
7731
  type: "error"
7618
7732
  })
7619
7733
  );
@@ -7657,9 +7771,9 @@ class CustomComponent {
7657
7771
  frmParent: this.form.definition.frmParent
7658
7772
  }),
7659
7773
  {
7660
- postData: {
7774
+ postData: typeof body === "string" ? {
7661
7775
  payload: body
7662
- },
7776
+ } : body,
7663
7777
  postDataTreatment: "stringify"
7664
7778
  }
7665
7779
  );
@@ -7682,7 +7796,7 @@ class CustomComponent {
7682
7796
  }
7683
7797
  }
7684
7798
  getStringValue(attName) {
7685
- return this._state.attributes[attName]?.join();
7799
+ return this._state.attributes[attName]?.join("");
7686
7800
  }
7687
7801
  getValue(attName, index = 0) {
7688
7802
  return this._state.attributes[attName]?.[index];
@@ -7763,39 +7877,57 @@ class CustomComponent {
7763
7877
  this._state.isLoading = false;
7764
7878
  }
7765
7879
  }
7880
+ async download(attName, index) {
7881
+ this._state.isLoading = true;
7882
+ try {
7883
+ const data = await this.processResult(
7884
+ (await this.postMessage("download", { attName, index }))?.data
7885
+ );
7886
+ if (data?.url) {
7887
+ window.open(data.url, "_blank");
7888
+ }
7889
+ } finally {
7890
+ this._state.isLoading = false;
7891
+ }
7892
+ }
7766
7893
  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);
7894
+ this._state.isLoading = true;
7895
+ try {
7896
+ const formData = new FormData();
7897
+ formData.append("file", file);
7898
+ Object.entries(options?.params || {}).forEach(
7899
+ ([key, value]) => formData.append(key, value)
7900
+ );
7901
+ const response = await axios.post(
7902
+ await makeApiaUrl(this.execution, {
7903
+ ajaxUrl: actions.forms,
7904
+ action: "cusCmpProcess",
7905
+ method: "upload",
7906
+ cmpId: this.definition.id,
7907
+ frmId: this.form.definition.id,
7908
+ frmParent: this.form.definition.frmParent,
7909
+ attName,
7910
+ originalName: file.name
7911
+ }),
7912
+ formData,
7913
+ {
7914
+ signal: options?.signal,
7915
+ onUploadProgress({ total, progress }) {
7916
+ const percent = Math.round((progress || 0) / (total || 1) * 100 * 100) / 100;
7917
+ options?.onUploadProgress?.(percent);
7918
+ }
7789
7919
  }
7790
- }
7791
- );
7792
- const result = await parseSuccessfulResponse(
7793
- this.execution,
7794
- response
7795
- );
7796
- return await this.processResult(
7797
- result
7798
- );
7920
+ );
7921
+ const result = await parseSuccessfulResponse(
7922
+ this.execution,
7923
+ response
7924
+ );
7925
+ return await this.processResult(
7926
+ result
7927
+ );
7928
+ } finally {
7929
+ this._state.isLoading = false;
7930
+ }
7799
7931
  }
7800
7932
  }
7801
7933
  _hasInited = new WeakMap();
@@ -8079,10 +8211,10 @@ class Form extends WithProperties {
8079
8211
  }
8080
8212
  async fireScriptEvent(eventName) {
8081
8213
  if (eventName === "onLoad") {
8082
- const mapEvent = window[`LOAD_RELOAD_MAP_${this.definition.frmParent}`];
8214
+ const mapEvent = getWindow(this.execution)[`LOAD_RELOAD_MAP_${this.definition.frmParent}`];
8083
8215
  const mappedEvent = mapEvent ? mapEvent[this.definition.formName] : void 0;
8084
8216
  const actualMapEvent = mapEvent && (!mappedEvent || mappedEvent === "load" ? "onLoad" : "onReload");
8085
- eventName = actualMapEvent || (window.IS_RELOAD ? "onReload" : "onLoad");
8217
+ eventName = actualMapEvent || (getWindow(this.execution).IS_RELOAD ? "onReload" : "onLoad");
8086
8218
  }
8087
8219
  const events = (this.definition.scriptEvents || []).filter(
8088
8220
  (c) => c.evtName === eventName
@@ -8090,7 +8222,7 @@ class Form extends WithProperties {
8090
8222
  if (events.length > 0) {
8091
8223
  for (const event of events) {
8092
8224
  try {
8093
- const fn = window[event.fncName];
8225
+ const fn = getWindow(this.execution)[event.fncName];
8094
8226
  const result = await fn(
8095
8227
  new ApiaForm(this.execution, this),
8096
8228
  ...await this.getScriptEventParams(event.fncParams)
@@ -8102,7 +8234,7 @@ class Form extends WithProperties {
8102
8234
  console.error(e);
8103
8235
  this.execution.notifications.add(
8104
8236
  new MessageNotification({
8105
- message: labels.errorOnEvent(eventName, event.evtName),
8237
+ message: labels.errorOnEvent(this.execution, event.fncName) + e,
8106
8238
  type: "error"
8107
8239
  })
8108
8240
  );
@@ -8651,13 +8783,13 @@ let ShowSignSelection$1 = class ShowSignSelection extends FlowModal$1 {
8651
8783
  }
8652
8784
  };
8653
8785
 
8654
- let ShowConfirmMessage$1 = class ShowConfirmMessage extends FlowModal$1 {
8786
+ class ShowConfirmMessage extends FlowModal$1 {
8655
8787
  constructor(fetchResult, confirm) {
8656
8788
  super();
8657
8789
  this.fetchResult = fetchResult;
8658
8790
  this.confirm = confirm;
8659
8791
  }
8660
- };
8792
+ }
8661
8793
 
8662
8794
  let ShowSign$1 = class ShowSign extends FlowModal$1 {
8663
8795
  constructor(fetchResult, confirm) {
@@ -8850,7 +8982,7 @@ async function defaultConfirm$1(execution, status) {
8850
8982
  }
8851
8983
  if (confirmResponse?.data?.onClose === "confirmOkOnClose") {
8852
8984
  execution.state.executionState = ExecutionState.FINISHED;
8853
- return buildConfirmMessage$1(
8985
+ return buildConfirmMessage(
8854
8986
  status,
8855
8987
  confirmResponse.data.load?.text?.label ?? ""
8856
8988
  );
@@ -8900,8 +9032,8 @@ async function defaultConfirm$1(execution, status) {
8900
9032
  step: "CHECK_WIZARD"
8901
9033
  };
8902
9034
  }
8903
- async function buildConfirmMessage$1(status, message) {
8904
- return new ShowConfirmMessage$1(message, async (result) => {
9035
+ async function buildConfirmMessage(status, message) {
9036
+ return new ShowConfirmMessage(message, async (result) => {
8905
9037
  if (result.confirmed) {
8906
9038
  return { ...status, step: "CHECK_WIZARD" };
8907
9039
  }
@@ -8999,14 +9131,6 @@ class ShowSignSelection extends FlowModal {
8999
9131
  }
9000
9132
  }
9001
9133
 
9002
- class ShowConfirmMessage extends FlowModal {
9003
- constructor(fetchResult, confirm) {
9004
- super();
9005
- this.fetchResult = fetchResult;
9006
- this.confirm = confirm;
9007
- }
9008
- }
9009
-
9010
9134
  class ShowSign extends FlowModal {
9011
9135
  constructor(fetchResult, confirm) {
9012
9136
  super();
@@ -9129,52 +9253,37 @@ async function defaultConfirm(execution, status) {
9129
9253
  step: void 0
9130
9254
  };
9131
9255
  }
9132
- if (confirmResponse?.data?.load?.text?.text) {
9133
- execution.state.executionState = ExecutionState.FINISHED;
9134
- const url = arrayOrArray(
9135
- arrayOrArray(confirmResponse.data.actions?.action)[0].param
9136
- )[1].text;
9137
- setTimeout(() => {
9138
- const c = new Url(url);
9139
- getWindow(execution).location.assign(
9140
- makeApiaUrl(execution, {
9141
- ajaxUrl: c.base,
9142
- action: c.getParameter("action")
9143
- })
9144
- );
9145
- }, 1e3);
9146
- return buildConfirmMessage(status, confirmResponse?.data?.load?.text?.text);
9147
- }
9148
- const checkConfirmEntity = await post(
9149
- execution,
9150
- makeApiaUrl(execution, {
9151
- ajaxUrl: "apia.execution.FormAction.run?",
9152
- action: "checkAfterConfirmAjax",
9153
- frmParent: "E",
9154
- currentTab: 0
9155
- })
9156
- );
9157
- if (checkConfirmEntity?.data?.form) {
9158
- setAjaxFormResponse(execution, checkConfirmEntity.data?.form);
9159
- execution.notifications.closeTab();
9160
- return {
9161
- ...status,
9162
- step: void 0
9163
- };
9256
+ if (confirmResponse?.data?.load?.text?.label) {
9257
+ const checkConfirmEntity = await post(
9258
+ execution,
9259
+ makeApiaUrl(execution, {
9260
+ ajaxUrl: "apia.execution.FormAction.run?",
9261
+ action: "checkAfterConfirmAjax",
9262
+ frmParent: "E",
9263
+ currentTab: 0
9264
+ })
9265
+ );
9266
+ if (checkConfirmEntity?.data?.form) {
9267
+ setAjaxFormResponse(execution, checkConfirmEntity.data?.form);
9268
+ }
9269
+ const url = arrayOrArray(confirmResponse.data.actions?.action.param)[1];
9270
+ const c = new Url(url);
9271
+ getWindow(execution).location.assign(
9272
+ makeApiaUrl(execution, {
9273
+ ajaxUrl: c.base,
9274
+ action: c.getParameter("action")
9275
+ })
9276
+ );
9277
+ (getWindow(execution)?.top?.ApiaUtil).notifications.notify({
9278
+ message: confirmResponse?.data?.load?.text?.label,
9279
+ type: "success"
9280
+ });
9164
9281
  }
9165
9282
  return {
9166
9283
  ...status,
9167
9284
  step: void 0
9168
9285
  };
9169
9286
  }
9170
- async function buildConfirmMessage(status, message) {
9171
- return new ShowConfirmMessage(message, async (result) => {
9172
- if (result.confirmed) {
9173
- return { ...status, step: void 0 };
9174
- }
9175
- return { ...status, step: void 0, finishedWithError: true };
9176
- });
9177
- }
9178
9287
  const checkers = {
9179
9288
  CHECK_LOCK: checkLock,
9180
9289
  CHECK_SIGN: checkSign,
@@ -9235,6 +9344,7 @@ class Execution extends EventEmitter$1 {
9235
9344
  __publicField(this, "_currentStep", 1);
9236
9345
  __publicField(this, "_stepCount", 1);
9237
9346
  __publicField(this, "notifications");
9347
+ __publicField(this, "lastModalReturn", []);
9238
9348
  __publicField(this, "formsById", {
9239
9349
  E: /* @__PURE__ */ new Map(),
9240
9350
  P: /* @__PURE__ */ new Map()
@@ -9253,7 +9363,7 @@ class Execution extends EventEmitter$1 {
9253
9363
  __publicField(this, "mustRenderForms", []);
9254
9364
  this.fieldsMapping = { ...defaultFieldsMap, ...environment.fieldsMapping };
9255
9365
  this.notifications = new Notifications(this);
9256
- makeAutoObservable(this, { fieldsMapping: false });
9366
+ makeObservable(this, { state: observable });
9257
9367
  }
9258
9368
  getAllForms() {
9259
9369
  return [...this.forms.E.values(), ...this.forms.P.values()];
@@ -9304,6 +9414,10 @@ class Execution extends EventEmitter$1 {
9304
9414
  this._stepCount = noNaN$1(getWindow(this).STEP_QTY);
9305
9415
  this._currentStep = noNaN$1(getWindow(this).CURRENT_STEP);
9306
9416
  this.executionConfig = executionConfig;
9417
+ this.environment.properties = {
9418
+ taskName: getWindow(this).CURRENT_TASK_NAME || "",
9419
+ processName: getWindow(this).CURRENT_PROCESS_NAME || ""
9420
+ };
9307
9421
  const errXML = unescapeMarkup(getWindow(this).EXEC_ERRORS);
9308
9422
  if (errXML) {
9309
9423
  const obj = parseXml(errXML);
@@ -9510,7 +9624,7 @@ class Execution extends EventEmitter$1 {
9510
9624
  }
9511
9625
  return data;
9512
9626
  }
9513
- async doNext() {
9627
+ async doNext(result) {
9514
9628
  const isValid = await this.validate();
9515
9629
  if (isValid === true) {
9516
9630
  if (!await this.fireEvents("onSubmit")) {
@@ -9543,7 +9657,6 @@ class Execution extends EventEmitter$1 {
9543
9657
  makeApiaUrl(this, {
9544
9658
  action: "hasSignableForms",
9545
9659
  isAjax: true,
9546
- prevSteps: true,
9547
9660
  appletToken: getWindow(this).appletToken
9548
9661
  }),
9549
9662
  {
@@ -9556,6 +9669,17 @@ class Execution extends EventEmitter$1 {
9556
9669
  if (checkSignableFormsRes?.status !== 200) {
9557
9670
  throw new Error("No signable forms available.");
9558
9671
  }
9672
+ const mustShowSignModal = checkSignableFormsRes?.data?.sign;
9673
+ if (mustShowSignModal && !result?.signed) {
9674
+ return new ShowSignSelection$1(
9675
+ checkSignableFormsRes?.data,
9676
+ async () => {
9677
+ return "";
9678
+ }
9679
+ );
9680
+ }
9681
+ if (mustShowSignModal && (!result?.confirmed || !result?.signed))
9682
+ return;
9559
9683
  const nextUrl = makeApiaUrl(this, {
9560
9684
  action: "gotoNextStep",
9561
9685
  asXML: true,
@@ -9632,6 +9756,12 @@ class Execution extends EventEmitter$1 {
9632
9756
  }
9633
9757
  return firstInvalid ?? true;
9634
9758
  }
9759
+ setLastModalReturn(value) {
9760
+ this.lastModalReturn = value;
9761
+ }
9762
+ getLastModalReturn() {
9763
+ return this.lastModalReturn;
9764
+ }
9635
9765
  async fireEvents(evt) {
9636
9766
  let result = true;
9637
9767
  for await (const f of this.forms.E.values()) {
@@ -9657,5 +9787,5 @@ class StatusNotification extends Notification {
9657
9787
  }
9658
9788
  }
9659
9789
 
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 };
9790
+ 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, 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 };
9661
9791
  //# sourceMappingURL=index.js.map