@apia/execution 4.0.25 → 4.0.27

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,13 +1,14 @@
1
- import { makeObservable, observable, action, runInAction, reaction, computed, toJS, makeAutoObservable } from 'mobx';
1
+ import { makeObservable, observable, action, runInAction, reaction, computed, toJS } from 'mobx';
2
+ import axios, { AxiosError } from 'axios';
2
3
  import xml2js from 'xml2js';
3
4
  import he from 'he';
4
5
  import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
5
6
  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';
7
- import axios from 'axios';
7
+ import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, addBoundary, formatMessage, parseAsSize, shallowEqual as shallowEqual$1, Mutex, awaitTime, noNaN as noNaN$1, getDateFormat, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
8
8
  import { Cell, TableController, Row, FocusControllerPlugin } from '@apia/table2-controller';
9
9
  import dayjs from 'dayjs';
10
10
  import { MobXTree } from '@apia/tree2-controller';
11
+ import { Scheduler } from '@apia/scheduler-controller';
11
12
 
12
13
  const deepEqual = (a, b) => {
13
14
  if (Object.is(a, b))
@@ -45,16 +46,16 @@ const deepEqual = (a, b) => {
45
46
  return a === b;
46
47
  };
47
48
 
48
- var __defProp$r = Object.defineProperty;
49
- var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
50
- var __publicField$r = (obj, key, value) => {
51
- __defNormalProp$r(obj, key + "" , value);
49
+ var __defProp$s = Object.defineProperty;
50
+ var __defNormalProp$s = (obj, key, value) => key in obj ? __defProp$s(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
51
+ var __publicField$s = (obj, key, value) => {
52
+ __defNormalProp$s(obj, key + "" , value);
52
53
  return value;
53
54
  };
54
55
  class Notification {
55
56
  constructor(props) {
56
57
  this.props = props;
57
- __publicField$r(this, "state");
58
+ __publicField$s(this, "state");
58
59
  this.state = props;
59
60
  makeObservable(this, { state: observable });
60
61
  }
@@ -401,14 +402,14 @@ function replaceLabelHtmlValues(o) {
401
402
  }
402
403
  return o;
403
404
  }
404
- const parseXml = (xml) => {
405
+ const parseXml = (xml, behaveConfig) => {
405
406
  let objJS;
406
407
  if (typeof xml === "object" && !(xml instanceof XMLDocument)) {
407
408
  return xml;
408
409
  }
409
410
  const parser = new xml2js.Parser({
410
- trim: true,
411
- normalize: true,
411
+ trim: !behaveConfig?.avoidTrimXml,
412
+ normalize: !behaveConfig?.avoidNormalize,
412
413
  explicitRoot: false,
413
414
  mergeAttrs: true,
414
415
  explicitArray: false,
@@ -445,6 +446,16 @@ function getWindow(execution) {
445
446
  return execution.environment.window;
446
447
  }
447
448
 
449
+ var ExecutionState = /* @__PURE__ */ ((ExecutionState2) => {
450
+ ExecutionState2[ExecutionState2["RUNNING"] = 0] = "RUNNING";
451
+ ExecutionState2[ExecutionState2["LOADING"] = 1] = "LOADING";
452
+ ExecutionState2[ExecutionState2["FINISHED"] = 2] = "FINISHED";
453
+ ExecutionState2[ExecutionState2["RENDERING"] = 3] = "RENDERING";
454
+ ExecutionState2[ExecutionState2["CONFIRMING"] = 4] = "CONFIRMING";
455
+ ExecutionState2[ExecutionState2["FINISHED_WITH_ERROR"] = 5] = "FINISHED_WITH_ERROR";
456
+ return ExecutionState2;
457
+ })(ExecutionState || {});
458
+
448
459
  function dispatchMessage(execution, type, message) {
449
460
  execution.notifications.add(
450
461
  new MessageNotification({
@@ -456,11 +467,20 @@ function dispatchMessage(execution, type, message) {
456
467
  );
457
468
  }
458
469
  function getAxios() {
459
- return import('axios').then((r) => r.default);
470
+ return import('axios').then(
471
+ (r) => typeof process !== "undefined" && process.env?.APIA_SERVER && process.env?.CONTEXT ? r.default.create({
472
+ baseURL: process?.env?.APIA_SERVER.replaceAll(
473
+ process.env.CONTEXT,
474
+ ""
475
+ )
476
+ }) : r.default
477
+ );
460
478
  }
461
479
  const handleWrongResponse = (execution, error) => {
462
- if (error instanceof InvalidSessionException)
463
- throw error;
480
+ if (error instanceof InvalidSessionException || error instanceof AxiosError && error.status === 403) {
481
+ execution.kill();
482
+ throw new InvalidSessionException();
483
+ }
464
484
  let errorMessage;
465
485
  if (typeof error !== "string") {
466
486
  if (error.message)
@@ -503,12 +523,13 @@ function parseMessages(execution, response) {
503
523
  dispatchMessage.bind(dispatchMessage, execution, "error")
504
524
  );
505
525
  }
506
- async function handleResponse(execution, result) {
526
+ async function handleResponse(execution, result, behaveConfig) {
507
527
  try {
508
528
  if (!result || result.data === void 0) ; else {
509
529
  const parsedResponse = await parseSuccessfulResponse(
510
530
  execution,
511
- result
531
+ result,
532
+ behaveConfig
512
533
  );
513
534
  return {
514
535
  ...result,
@@ -528,7 +549,7 @@ async function handleResponse(execution, result) {
528
549
  }
529
550
  class InvalidSessionException extends Error {
530
551
  }
531
- const parseSuccessfulResponse = async (execution, response) => {
552
+ const parseSuccessfulResponse = async (execution, response, behaveConfig) => {
532
553
  let parsedObj = void 0;
533
554
  if (isJsonResponse(response)) {
534
555
  if (typeof response.data === "string")
@@ -539,9 +560,12 @@ const parseSuccessfulResponse = async (execution, response) => {
539
560
  parsedObj = response.data;
540
561
  } else if (isXmlResponse(response)) {
541
562
  try {
542
- parsedObj = parseXml(response.data);
563
+ parsedObj = parseXml(response.data, behaveConfig);
543
564
  } catch (e) {
544
- handleWrongResponse(execution, new Error(e));
565
+ handleWrongResponse(
566
+ execution,
567
+ e instanceof Error ? e : new Error(e)
568
+ );
545
569
  }
546
570
  } else if (isHtmlResponse(response)) {
547
571
  console.error(
@@ -578,20 +602,29 @@ const parseSuccessfulResponse = async (execution, response) => {
578
602
  return null;
579
603
  };
580
604
  async function post(execution, actualUrl, behaveConfig) {
605
+ if (execution.state.executionState === ExecutionState.FINISHED && !behaveConfig?.allowAfterFinish) {
606
+ throw new Error("Cannot perform requests after execution has finished");
607
+ }
581
608
  const postData = behaveConfig?.postDataTreatment === "stringify" ? QueryString.stringify(
582
609
  behaveConfig.postData,
583
610
  behaveConfig.stringifyOptions
584
611
  ) : behaveConfig?.postData;
585
612
  const response = await (await getAxios()).post(actualUrl, postData, { ...behaveConfig?.axiosConfig, headers: { ...behaveConfig?.axiosConfig?.headers, ...execution.environment.headers } }).catch((e) => {
586
- handleWrongResponse(execution, new Error(e));
613
+ handleWrongResponse(
614
+ execution,
615
+ e instanceof Error ? e : new Error(e)
616
+ );
587
617
  });
588
618
  if (response) {
589
- const result = handleResponse(execution, response);
619
+ const result = handleResponse(execution, response, behaveConfig);
590
620
  return result;
591
621
  }
592
622
  return null;
593
623
  }
594
624
  async function get(execution, actualUrl, behaveConfig) {
625
+ if (execution.state.executionState === ExecutionState.FINISHED) {
626
+ throw new Error("Cannot perform requests after execution has finished");
627
+ }
595
628
  const response = await (await getAxios()).get(actualUrl, { ...behaveConfig?.axiosConfig, headers: { ...behaveConfig?.axiosConfig?.headers, ...execution.environment.headers } }).catch((e) => {
596
629
  handleWrongResponse(
597
630
  execution,
@@ -654,20 +687,20 @@ function makeApiaUrl(execution, props) {
654
687
  return `${contextWord ? "/" : ""}${contextWord}/${actualAjaxUrl}?${timestamp}${!props?.preventAsXmlParameter ? "asXml=true&" : ""}${props?.queryString ? `${props.queryString}&` : ""}${queryString ? `${queryString}&` : ""}${tabId}`;
655
688
  }
656
689
 
657
- var __defProp$q = Object.defineProperty;
658
- var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
659
- var __publicField$q = (obj, key, value) => {
660
- __defNormalProp$q(obj, typeof key !== "symbol" ? key + "" : key, value);
690
+ var __defProp$r = Object.defineProperty;
691
+ var __defNormalProp$r = (obj, key, value) => key in obj ? __defProp$r(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
692
+ var __publicField$r = (obj, key, value) => {
693
+ __defNormalProp$r(obj, typeof key !== "symbol" ? key + "" : key, value);
661
694
  return value;
662
695
  };
663
696
  class EventEmitter {
664
697
  constructor() {
665
- __publicField$q(this, "callbacks", {
698
+ __publicField$r(this, "callbacks", {
666
699
  on: {},
667
700
  once: {}
668
701
  });
669
- __publicField$q(this, "enabled", true);
670
- __publicField$q(this, "debugMode", false);
702
+ __publicField$r(this, "enabled", true);
703
+ __publicField$r(this, "debugMode", false);
671
704
  }
672
705
  debug(enable = true) {
673
706
  this.debugMode = enable;
@@ -733,10 +766,10 @@ class EventEmitter {
733
766
  }
734
767
  }
735
768
 
736
- var __defProp$p = Object.defineProperty;
737
- var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
738
- var __publicField$p = (obj, key, value) => {
739
- __defNormalProp$p(obj, key + "" , value);
769
+ var __defProp$q = Object.defineProperty;
770
+ var __defNormalProp$q = (obj, key, value) => key in obj ? __defProp$q(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
771
+ var __publicField$q = (obj, key, value) => {
772
+ __defNormalProp$q(obj, key + "" , value);
740
773
  return value;
741
774
  };
742
775
  function isSetter(data) {
@@ -745,7 +778,7 @@ function isSetter(data) {
745
778
  class StatefulEmitter extends EventEmitter {
746
779
  constructor(initialState) {
747
780
  super();
748
- __publicField$p(this, "state", {});
781
+ __publicField$q(this, "state", {});
749
782
  this.state = Object.assign({}, initialState);
750
783
  }
751
784
  emit(event, data) {
@@ -780,18 +813,18 @@ class StatefulEmitter extends EventEmitter {
780
813
  }
781
814
  }
782
815
 
783
- var __defProp$o = Object.defineProperty;
784
- var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
785
- var __publicField$o = (obj, key, value) => {
786
- __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
816
+ var __defProp$p = Object.defineProperty;
817
+ var __defNormalProp$p = (obj, key, value) => key in obj ? __defProp$p(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
818
+ var __publicField$p = (obj, key, value) => {
819
+ __defNormalProp$p(obj, typeof key !== "symbol" ? key + "" : key, value);
787
820
  return value;
788
821
  };
789
822
  const NullObject = Symbol("NullObject");
790
823
  class BouncingEmitter extends StatefulEmitter {
791
824
  constructor() {
792
825
  super(...arguments);
793
- __publicField$o(this, "bouncingTimeouts", {});
794
- __publicField$o(this, "defaultTiming", 100);
826
+ __publicField$p(this, "bouncingTimeouts", {});
827
+ __publicField$p(this, "defaultTiming", 100);
795
828
  /**
796
829
  * 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:
797
830
  *
@@ -803,8 +836,8 @@ class BouncingEmitter extends StatefulEmitter {
803
836
  *
804
837
  * @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.**
805
838
  */
806
- __publicField$o(this, "throttleData", {});
807
- __publicField$o(this, "throttleEmittedOnInit", {});
839
+ __publicField$p(this, "throttleData", {});
840
+ __publicField$p(this, "throttleEmittedOnInit", {});
808
841
  }
809
842
  /**
810
843
  * 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:
@@ -882,7 +915,7 @@ const labels = {
882
915
  errorFieldRequired: (execution) => getLabel(execution, "msgReqField").text,
883
916
  errorTranslateRequired: (execution, lang) => getLabel(execution, "lblReqLang", { text: { TOK1: lang } }).text,
884
917
  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}`
918
+ errorOnEvent: (execution, eventName) => window.SERVER_MODE ? "Error al ejecutar la clase de negocios, contacte al administrador." : getLabel(execution, "msgErrorOnEvent", { text: { TOK1: eventName } }).text
886
919
  };
887
920
 
888
921
  const parseBoolean = (val) => {
@@ -934,21 +967,24 @@ function parseFakeJSON$1(str) {
934
967
  return ret;
935
968
  }
936
969
 
937
- var __defProp$n = Object.defineProperty;
938
- var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
939
- var __publicField$n = (obj, key, value) => {
940
- __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
970
+ var __defProp$o = Object.defineProperty;
971
+ var __defNormalProp$o = (obj, key, value) => key in obj ? __defProp$o(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
972
+ var __publicField$o = (obj, key, value) => {
973
+ __defNormalProp$o(obj, typeof key !== "symbol" ? key + "" : key, value);
941
974
  return value;
942
975
  };
943
976
  class WithProperties {
944
977
  constructor(initialState) {
945
- __publicField$n(this, "properties", {});
946
- __publicField$n(this, "parentGrid", null);
978
+ __publicField$o(this, "properties", {});
979
+ __publicField$o(this, "parentGrid", null);
947
980
  if (initialState) {
948
981
  this.properties = initialState;
949
982
  }
950
983
  makeObservable(this, { properties: observable, setProperty: action });
951
984
  }
985
+ getParentGrid() {
986
+ return this.parentGrid;
987
+ }
952
988
  getProperty(propName) {
953
989
  return this.properties[propName];
954
990
  }
@@ -1117,10 +1153,10 @@ const asyncCreateNewField = async (execution, fld) => {
1117
1153
  return creator(execution, fld);
1118
1154
  };
1119
1155
 
1120
- var __defProp$m = Object.defineProperty;
1121
- var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1122
- var __publicField$m = (obj, key, value) => {
1123
- __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
1156
+ var __defProp$n = Object.defineProperty;
1157
+ var __defNormalProp$n = (obj, key, value) => key in obj ? __defProp$n(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1158
+ var __publicField$n = (obj, key, value) => {
1159
+ __defNormalProp$n(obj, typeof key !== "symbol" ? key + "" : key, value);
1124
1160
  return value;
1125
1161
  };
1126
1162
  var __accessCheck$k = (obj, member, msg) => {
@@ -1154,15 +1190,15 @@ async function getApiaFunctions(execution) {
1154
1190
  let Field$1 = class Field extends WithProperties {
1155
1191
  constructor({ properties, ...definition }) {
1156
1192
  super();
1157
- __publicField$m(this, "form", {});
1158
- __publicField$m(this, "definition");
1159
- __publicField$m(this, "state", {
1193
+ __publicField$n(this, "form", {});
1194
+ __publicField$n(this, "definition");
1195
+ __publicField$n(this, "state", {
1160
1196
  validation: { dirty: false, errorMessage: "", synchronizing: false }
1161
1197
  });
1162
1198
  __privateAdd$k(this, _hasInited$1, false);
1163
1199
  this.properties = properties;
1164
1200
  this.definition = definition;
1165
- makeObservable(this, { state: observable });
1201
+ makeObservable(this, { state: observable, definition: observable });
1166
1202
  }
1167
1203
  async getScriptEventParams(fncParams) {
1168
1204
  const fncParamsArray = [];
@@ -1208,20 +1244,33 @@ let Field$1 = class Field extends WithProperties {
1208
1244
  const events = (this.definition.scriptEvents || []).filter(
1209
1245
  (c) => c.evtName === eventName
1210
1246
  );
1247
+ let result = true;
1211
1248
  if (events.length > 0) {
1212
1249
  for (const event of events) {
1213
1250
  try {
1214
1251
  const fn = window[event.fncName];
1215
- const result = await fn(
1252
+ if (fn === void 0) {
1253
+ new MessageNotification({
1254
+ message: getLabel(this.form.execution, "msgFunction404", {
1255
+ text: { TOK1: eventName }
1256
+ }).text,
1257
+ type: "error"
1258
+ });
1259
+ throw new Error(
1260
+ getLabel(this.form.execution, "msgFunction404", {
1261
+ text: { TOK1: eventName }
1262
+ }).text
1263
+ );
1264
+ }
1265
+ result = await fn(
1216
1266
  await asyncCreateNewField(this.form.execution, this),
1217
1267
  ...await this.getScriptEventParams(event.fncParams)
1218
1268
  );
1219
- return result;
1220
1269
  } catch (e) {
1221
1270
  console.error(e);
1222
1271
  this.form.execution.notifications.add(
1223
1272
  new MessageNotification({
1224
- message: labels.errorOnEvent(eventName, event.evtName),
1273
+ message: labels.errorOnEvent(this.form.execution, event.fncName) + ", " + e,
1225
1274
  type: "error"
1226
1275
  })
1227
1276
  );
@@ -1229,7 +1278,7 @@ let Field$1 = class Field extends WithProperties {
1229
1278
  }
1230
1279
  }
1231
1280
  }
1232
- return true;
1281
+ return result;
1233
1282
  }
1234
1283
  async fireAjaxServerEvent(event, params) {
1235
1284
  try {
@@ -1351,16 +1400,16 @@ class Button extends Field$1 {
1351
1400
  }
1352
1401
  }
1353
1402
 
1354
- var __defProp$l = Object.defineProperty;
1355
- var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1356
- var __publicField$l = (obj, key, value) => {
1357
- __defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
1403
+ var __defProp$m = Object.defineProperty;
1404
+ var __defNormalProp$m = (obj, key, value) => key in obj ? __defProp$m(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1405
+ var __publicField$m = (obj, key, value) => {
1406
+ __defNormalProp$m(obj, typeof key !== "symbol" ? key + "" : key, value);
1358
1407
  return value;
1359
1408
  };
1360
1409
  const _Captcha = class _Captcha extends Field$1 {
1361
1410
  constructor(definition) {
1362
1411
  super(definition);
1363
- __publicField$l(this, "id", "");
1412
+ __publicField$m(this, "id", "");
1364
1413
  this.state.value = "";
1365
1414
  this.properties.name = "__captcha__";
1366
1415
  _Captcha.emitter.on("confirm", () => {
@@ -1411,8 +1460,8 @@ const _Captcha = class _Captcha extends Field$1 {
1411
1460
  }
1412
1461
  }
1413
1462
  };
1414
- __publicField$l(_Captcha, "emitter", new EventEmitter$1());
1415
- __publicField$l(_Captcha, "confirmParams", {});
1463
+ __publicField$m(_Captcha, "emitter", new EventEmitter$1());
1464
+ __publicField$m(_Captcha, "confirmParams", {});
1416
1465
  let Captcha = _Captcha;
1417
1466
 
1418
1467
  class TooMuchRetriesException extends Error {
@@ -1485,10 +1534,10 @@ function isFieldShowAsText(f) {
1485
1534
  return isTrue(f.properties.disabled) || isTrue(f.getForm().definition.readonly) || isTrue(f.getForm().definition.readOnly) || isTrue(f.properties.inputAsText);
1486
1535
  }
1487
1536
 
1488
- var __defProp$k = Object.defineProperty;
1489
- var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1490
- var __publicField$k = (obj, key, value) => {
1491
- __defNormalProp$k(obj, typeof key !== "symbol" ? key + "" : key, value);
1537
+ var __defProp$l = Object.defineProperty;
1538
+ var __defNormalProp$l = (obj, key, value) => key in obj ? __defProp$l(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1539
+ var __publicField$l = (obj, key, value) => {
1540
+ __defNormalProp$l(obj, typeof key !== "symbol" ? key + "" : key, value);
1492
1541
  return value;
1493
1542
  };
1494
1543
  var __accessCheck$j = (obj, member, msg) => {
@@ -1529,8 +1578,8 @@ class FieldWithAttribute extends Field$1 {
1529
1578
  }) {
1530
1579
  super(definition);
1531
1580
  __privateAdd$j(this, _lastOnChangeValue, null);
1532
- __publicField$k(this, "lastSynchronizationValue", null);
1533
- __publicField$k(this, "attribute");
1581
+ __publicField$l(this, "lastSynchronizationValue", null);
1582
+ __publicField$l(this, "attribute");
1534
1583
  this.attribute = new Attribute(attId, attName, attLabel, valueType);
1535
1584
  this.state.value = value;
1536
1585
  this.state.validation = {
@@ -1715,16 +1764,16 @@ class Checkbox extends FieldWithAttribute {
1715
1764
  }
1716
1765
  }
1717
1766
 
1718
- var __defProp$j = Object.defineProperty;
1719
- var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1720
- var __publicField$j = (obj, key, value) => {
1721
- __defNormalProp$j(obj, key + "" , value);
1767
+ var __defProp$k = Object.defineProperty;
1768
+ var __defNormalProp$k = (obj, key, value) => key in obj ? __defProp$k(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1769
+ var __publicField$k = (obj, key, value) => {
1770
+ __defNormalProp$k(obj, key + "" , value);
1722
1771
  return value;
1723
1772
  };
1724
1773
  class Translation {
1725
1774
  constructor(execution, state) {
1726
1775
  this.execution = execution;
1727
- __publicField$j(this, "state");
1776
+ __publicField$k(this, "state");
1728
1777
  this.state = {
1729
1778
  ...state,
1730
1779
  hasChanged: false,
@@ -1740,7 +1789,8 @@ class Translation {
1740
1789
  if (this.state.remoteValue === void 0) {
1741
1790
  const result = await post(
1742
1791
  this.execution,
1743
- url
1792
+ url,
1793
+ { avoidNormalize: true, avoidTrimXml: true }
1744
1794
  );
1745
1795
  const newValue = result?.data?.values?.value;
1746
1796
  this.state.tempValue = newValue !== "null" ? result?.data?.values?.value ?? "" : "";
@@ -1752,6 +1802,12 @@ class Translation {
1752
1802
  this.state.tempValue = "";
1753
1803
  this.state.hasChanged = false;
1754
1804
  }
1805
+ deleteTranslation() {
1806
+ delete this.state.remoteValue;
1807
+ this.state.tempValue = "";
1808
+ this.state.hasChanged = false;
1809
+ this.state.isTranslated = false;
1810
+ }
1755
1811
  setTempValue(str) {
1756
1812
  this.state.tempValue = str;
1757
1813
  this.state.hasChanged = str !== this.state.remoteValue;
@@ -1782,19 +1838,19 @@ function parseFakeJSON(fakeJSON) {
1782
1838
  }));
1783
1839
  }
1784
1840
 
1785
- var __defProp$i = Object.defineProperty;
1786
- var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1787
- var __publicField$i = (obj, key, value) => {
1788
- __defNormalProp$i(obj, typeof key !== "symbol" ? key + "" : key, value);
1841
+ var __defProp$j = Object.defineProperty;
1842
+ var __defNormalProp$j = (obj, key, value) => key in obj ? __defProp$j(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1843
+ var __publicField$j = (obj, key, value) => {
1844
+ __defNormalProp$j(obj, typeof key !== "symbol" ? key + "" : key, value);
1789
1845
  return value;
1790
1846
  };
1791
1847
  class TranslatableField extends FieldWithAttribute {
1792
1848
  constructor(props) {
1793
1849
  super(props);
1794
- __publicField$i(this, "translations", /* @__PURE__ */ new Map());
1795
- __publicField$i(this, "selectedLanguageId", this.getLanguages()[0]?.id);
1796
- __publicField$i(this, "isTradLoading", false);
1797
- __publicField$i(this, "definitionTradParsed", {});
1850
+ __publicField$j(this, "translations", /* @__PURE__ */ new Map());
1851
+ __publicField$j(this, "selectedLanguageId", this.getLanguages()[0]?.id);
1852
+ __publicField$j(this, "isTradLoading", false);
1853
+ __publicField$j(this, "definitionTradParsed", {});
1798
1854
  makeObservable(this, {
1799
1855
  translations: observable,
1800
1856
  selectedLanguageId: observable,
@@ -1838,6 +1894,11 @@ class TranslatableField extends FieldWithAttribute {
1838
1894
  c.reset();
1839
1895
  });
1840
1896
  }
1897
+ deleteTranslations() {
1898
+ this.getTranslations().forEach((c) => {
1899
+ c.deleteTranslation();
1900
+ });
1901
+ }
1841
1902
  async changeLanguage(langId) {
1842
1903
  this.selectedLanguageId = langId;
1843
1904
  this.syncTranslation();
@@ -1862,6 +1923,7 @@ class TranslatableField extends FieldWithAttribute {
1862
1923
  })
1863
1924
  );
1864
1925
  });
1926
+ this.state.validation.errorMessage = null;
1865
1927
  }
1866
1928
  async syncTranslation() {
1867
1929
  const langId = this.selectedLanguageId;
@@ -1899,6 +1961,12 @@ class TranslatableField extends FieldWithAttribute {
1899
1961
  }
1900
1962
  return isValid;
1901
1963
  }
1964
+ setValue(newValue, options) {
1965
+ if (newValue === "") {
1966
+ this.deleteTranslations();
1967
+ }
1968
+ return super.setValue(newValue, options);
1969
+ }
1902
1970
  }
1903
1971
 
1904
1972
  class Editor extends TranslatableField {
@@ -1910,10 +1978,10 @@ class Editor extends TranslatableField {
1910
1978
  }
1911
1979
  }
1912
1980
 
1913
- var __defProp$h = Object.defineProperty;
1914
- var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1915
- var __publicField$h = (obj, key, value) => {
1916
- __defNormalProp$h(obj, key + "" , value);
1981
+ var __defProp$i = Object.defineProperty;
1982
+ var __defNormalProp$i = (obj, key, value) => key in obj ? __defProp$i(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1983
+ var __publicField$i = (obj, key, value) => {
1984
+ __defNormalProp$i(obj, key + "" , value);
1917
1985
  return value;
1918
1986
  };
1919
1987
  function getFileExtension(fileName) {
@@ -1930,6 +1998,7 @@ const getInitialState = (execution) => Object.freeze({
1930
1998
  docFolder: void 0,
1931
1999
  docExpDate: void 0,
1932
2000
  description: "",
2001
+ isReadonly: false,
1933
2002
  permissions: {
1934
2003
  pools: [],
1935
2004
  users: getWindow(execution).DOCUMENT_OWNER_PRIVILEGES ? [
@@ -1948,7 +2017,7 @@ class UploaderModalController {
1948
2017
  this.api = api;
1949
2018
  this.modalConfig = modalConfig;
1950
2019
  this.conf = conf;
1951
- __publicField$h(this, "state");
2020
+ __publicField$i(this, "state");
1952
2021
  makeObservable(this, {
1953
2022
  state: observable
1954
2023
  });
@@ -2014,6 +2083,7 @@ class UploaderModalController {
2014
2083
  }
2015
2084
  addFiles(files) {
2016
2085
  this.state.fileReqError = false;
2086
+ this.state.isReadonly = false;
2017
2087
  this.api.saveDroppedFiles(files, this.conf);
2018
2088
  }
2019
2089
  addDirectoryFile(file) {
@@ -2027,6 +2097,10 @@ class UploaderModalController {
2027
2097
  this.onChangeExtension();
2028
2098
  this.api.reloadMetadata({ docTypeId });
2029
2099
  }
2100
+ clearDirectoryFile() {
2101
+ this.state.fromDirectoryFile = null;
2102
+ this.state.isReadonly = false;
2103
+ }
2030
2104
  clearFile(name) {
2031
2105
  this.api.clearFile(name);
2032
2106
  }
@@ -2144,7 +2218,7 @@ class UploaderModalController {
2144
2218
  }
2145
2219
  this.allMetadata.forEach((c) => {
2146
2220
  if (c.required === "Y") {
2147
- if (c.name.trim() === "" && c.free) {
2221
+ if (c.name.trim() === "" && c.free === "Y") {
2148
2222
  c.labelErrorMessage = getLabel(
2149
2223
  this.api.execution,
2150
2224
  "msgReqField"
@@ -2155,16 +2229,20 @@ class UploaderModalController {
2155
2229
  c.errorMessage = getLabel(this.api.execution, "msgReqField").text;
2156
2230
  isValid = false;
2157
2231
  }
2232
+ if (c.type === "N" && c.value.trim() === "") {
2233
+ c.errorMessage = getLabel(this.api.execution, "msgMustBeNum").text;
2234
+ isValid = false;
2235
+ }
2158
2236
  }
2159
2237
  });
2160
2238
  return isValid;
2161
2239
  }
2162
2240
  }
2163
2241
 
2164
- var __defProp$g = Object.defineProperty;
2165
- var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2166
- var __publicField$g = (obj, key, value) => {
2167
- __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
2242
+ var __defProp$h = Object.defineProperty;
2243
+ var __defNormalProp$h = (obj, key, value) => key in obj ? __defProp$h(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2244
+ var __publicField$h = (obj, key, value) => {
2245
+ __defNormalProp$h(obj, typeof key !== "symbol" ? key + "" : key, value);
2168
2246
  return value;
2169
2247
  };
2170
2248
  function returnExactlyTheSame(defaultParameters) {
@@ -2191,13 +2269,13 @@ class UploaderApi extends EventEmitter$1 {
2191
2269
  this.id = id;
2192
2270
  this.type = type;
2193
2271
  this.modalConfig = modalConfig;
2194
- __publicField$g(this, "maxFiles", Infinity);
2195
- __publicField$g(this, "modalController", null);
2196
- __publicField$g(this, "allowTranslations", false);
2197
- __publicField$g(this, "langs");
2198
- __publicField$g(this, "currentConfiguration");
2199
- __publicField$g(this, "docTypePermittedObjId");
2200
- __publicField$g(this, "state", {
2272
+ __publicField$h(this, "maxFiles", Infinity);
2273
+ __publicField$h(this, "modalController", null);
2274
+ __publicField$h(this, "allowTranslations", false);
2275
+ __publicField$h(this, "langs");
2276
+ __publicField$h(this, "currentConfiguration");
2277
+ __publicField$h(this, "docTypePermittedObjId");
2278
+ __publicField$h(this, "state", {
2201
2279
  progress: 0,
2202
2280
  allowedTypes: [],
2203
2281
  selectedDocTypeId: "1",
@@ -2209,18 +2287,18 @@ class UploaderApi extends EventEmitter$1 {
2209
2287
  translatedFiles: /* @__PURE__ */ new Map(),
2210
2288
  hasAllDocTypes: false
2211
2289
  });
2212
- __publicField$g(this, "getAjaxUploadFileStatusParameters", returnExactlyTheSame);
2213
- __publicField$g(this, "getAjaxUploadStartParameters", returnExactlyTheSame);
2214
- __publicField$g(this, "getConfirmDropModalParameters", returnExactlyTheSame);
2215
- __publicField$g(this, "getCheckLockDocumentParameters", returnExactlyTheSame);
2216
- __publicField$g(this, "getCheckWebDavLockParameters", returnExactlyTheSame);
2217
- __publicField$g(this, "getConfirmDropModalPostdata", returnExactlyTheSame);
2218
- __publicField$g(this, "getConfirmDropModalMetadataString", ({
2290
+ __publicField$h(this, "getAjaxUploadFileStatusParameters", returnExactlyTheSame);
2291
+ __publicField$h(this, "getAjaxUploadStartParameters", returnExactlyTheSame);
2292
+ __publicField$h(this, "getConfirmDropModalParameters", returnExactlyTheSame);
2293
+ __publicField$h(this, "getCheckLockDocumentParameters", returnExactlyTheSame);
2294
+ __publicField$h(this, "getCheckWebDavLockParameters", returnExactlyTheSame);
2295
+ __publicField$h(this, "getConfirmDropModalPostdata", returnExactlyTheSame);
2296
+ __publicField$h(this, "getConfirmDropModalMetadataString", ({
2219
2297
  metadata
2220
2298
  }) => {
2221
2299
  return metadata?.filter?.((current) => !!current.value).map((current) => `${current.id}~${current.type}~${current.value}`).join(";") ?? [];
2222
2300
  });
2223
- __publicField$g(this, "getConfirmDropModalPermissionsString", ({
2301
+ __publicField$h(this, "getConfirmDropModalPermissionsString", ({
2224
2302
  poolsPermissions,
2225
2303
  usersPermissions
2226
2304
  }) => {
@@ -2233,32 +2311,36 @@ class UploaderApi extends EventEmitter$1 {
2233
2311
  );
2234
2312
  return returnString;
2235
2313
  });
2236
- __publicField$g(this, "getConfirmDropModalAdditionalMetadataString", (additionalMetadata) => {
2314
+ __publicField$h(this, "getConfirmDropModalAdditionalMetadataString", (additionalMetadata) => {
2237
2315
  return Object.values(additionalMetadata).filter((current) => !!current?.value).map((current) => `${current.name}~${current.value}`).join(";");
2238
2316
  });
2239
- __publicField$g(this, "getDeleteDocumentParameters", returnExactlyTheSame);
2240
- __publicField$g(this, "getClearTempFilesParameters", returnExactlyTheSame);
2241
- __publicField$g(this, "getDocumentInfoParameters", returnExactlyTheSame);
2242
- __publicField$g(this, "getDownloadMultipleDocumentsParameters", returnExactlyTheSame);
2243
- __publicField$g(this, "getEditDocumentParameters", returnExactlyTheSame);
2244
- __publicField$g(this, "getLockDocumentParameters", returnExactlyTheSame);
2245
- __publicField$g(this, "getMarkFileToSignParameters", returnExactlyTheSame);
2246
- __publicField$g(this, "getProcessDroppedFilesParameters", returnExactlyTheSame);
2247
- __publicField$g(this, "getProcessDroppedFilesPostdata", returnExactlyTheSame);
2248
- __publicField$g(this, "getReloadMetadataParameters", returnExactlyTheSame);
2249
- __publicField$g(this, "getSaveDroppedFilesParameters", returnExactlyTheSame);
2250
- __publicField$g(this, "parseFileDefinition", (file) => {
2317
+ __publicField$h(this, "getDeleteDocumentParameters", returnExactlyTheSame);
2318
+ __publicField$h(this, "getClearTempFilesParameters", returnExactlyTheSame);
2319
+ __publicField$h(this, "getDocumentInfoParameters", returnExactlyTheSame);
2320
+ __publicField$h(this, "getDownloadMultipleDocumentsParameters", returnExactlyTheSame);
2321
+ __publicField$h(this, "getEditDocumentParameters", returnExactlyTheSame);
2322
+ __publicField$h(this, "getLockDocumentParameters", returnExactlyTheSame);
2323
+ __publicField$h(this, "getMarkFileToSignParameters", returnExactlyTheSame);
2324
+ __publicField$h(this, "getProcessDroppedFilesParameters", returnExactlyTheSame);
2325
+ __publicField$h(this, "getProcessDroppedFilesPostdata", returnExactlyTheSame);
2326
+ __publicField$h(this, "getReloadMetadataParameters", returnExactlyTheSame);
2327
+ __publicField$h(this, "getSaveDroppedFilesParameters", returnExactlyTheSame);
2328
+ __publicField$h(this, "parseFileDefinition", (file) => {
2251
2329
  return {
2252
2330
  ...parseFileDefinition(this.execution, file, false),
2253
2331
  canEdit: file.canEdit || file.canWrite,
2254
2332
  canRead: file.canRead
2255
2333
  };
2256
2334
  });
2257
- __publicField$g(this, "getLoadFileSystemStructureTree", () => ({
2335
+ __publicField$h(this, "getLoadFileSystemStructureTree", () => ({
2258
2336
  useDocTypePermitted: true,
2259
2337
  docTypePermittedObjId: this.docTypePermittedObjId,
2260
2338
  docTypePermittedObjType: this.type
2261
2339
  }));
2340
+ if (!getWindow(this.execution).fileApi) {
2341
+ getWindow(this.execution).fileApi = {};
2342
+ }
2343
+ getWindow(this.execution).fileApi[this.id] = this;
2262
2344
  makeObservable(this, {
2263
2345
  state: observable
2264
2346
  });
@@ -2285,7 +2367,9 @@ class UploaderApi extends EventEmitter$1 {
2285
2367
  await this.saveDroppedFiles(files ?? []);
2286
2368
  } else {
2287
2369
  if (files) {
2288
- await this.saveDroppedFiles(files ?? []);
2370
+ const result = await this.saveDroppedFiles(files ?? []);
2371
+ if (!result)
2372
+ return;
2289
2373
  }
2290
2374
  this.modalController = new UploaderModalController(
2291
2375
  this,
@@ -2299,12 +2383,21 @@ class UploaderApi extends EventEmitter$1 {
2299
2383
  await this.saveDroppedFiles(files ?? [], conf);
2300
2384
  } else {
2301
2385
  await this.init();
2302
- this.modalController = new UploaderModalController(
2303
- this,
2304
- this.modalConfig,
2305
- conf
2306
- );
2307
- this.modalController.openModal();
2386
+ let mustOpen = true;
2387
+ if (files) {
2388
+ const res = await this.saveDroppedFiles(files ?? [], conf);
2389
+ if (!res) {
2390
+ mustOpen = false;
2391
+ }
2392
+ }
2393
+ if (mustOpen) {
2394
+ this.modalController = new UploaderModalController(
2395
+ this,
2396
+ this.modalConfig,
2397
+ conf
2398
+ );
2399
+ this.modalController.openModal();
2400
+ }
2308
2401
  }
2309
2402
  }
2310
2403
  async onVersionUpload(file, conf = { newFiles: [] }) {
@@ -2421,16 +2514,27 @@ class UploaderApi extends EventEmitter$1 {
2421
2514
  }
2422
2515
  }
2423
2516
  clearFile(name) {
2517
+ if (this.modalController) {
2518
+ this.modalController.state.isReadonly = false;
2519
+ }
2424
2520
  this.state.inProgressFiles = this.state.inProgressFiles.filter(
2425
2521
  (c) => c.name !== name
2426
2522
  );
2427
2523
  }
2428
2524
  clearFiles() {
2525
+ if (this.modalController) {
2526
+ this.modalController.state.isReadonly = false;
2527
+ }
2429
2528
  this.state.inProgressFiles = [];
2430
2529
  this.state.hiddenFiles = [];
2431
2530
  }
2432
2531
  clearState() {
2433
- this.state.selectedDocTypeId = "1";
2532
+ if (this.modalController) {
2533
+ this.modalController.state.isReadonly = false;
2534
+ }
2535
+ this.state.selectedDocTypeId = this.getDocTypes().find(
2536
+ (c) => String(c.id) === "1"
2537
+ ) ? "1" : this.getDocTypes()[0]?.id;
2434
2538
  this.state.inProgressFiles = [];
2435
2539
  this.state.versioningFile = null;
2436
2540
  }
@@ -2540,21 +2644,21 @@ class UploaderApi extends EventEmitter$1 {
2540
2644
  }
2541
2645
  async saveDroppedFiles(unprocessedFiles, conf) {
2542
2646
  if (getWindow(this.execution).IN_MONITOR) {
2543
- return;
2647
+ return false;
2544
2648
  }
2545
2649
  const {
2546
2650
  langId,
2547
2651
  strictMode: isConfStrictMode = false,
2548
2652
  translatingFile
2549
2653
  } = conf ?? {};
2550
- const isStrictMode = isConfStrictMode || !!this.state.versioningFile;
2654
+ const isStrictMode = isConfStrictMode || !!this.state.versioningFile || !!this.modalController?.state.fromDirectoryFile;
2551
2655
  const docType = this.getCurrentDocTypeId();
2552
2656
  if (!isStrictMode && !docType) {
2553
2657
  this.notify({
2554
2658
  message: `${getWindow(this.execution).LBL_DROP_FILE_DELETED}: ${unprocessedFiles.map((current) => current.name).join(", ")}.`,
2555
2659
  type: "warning"
2556
2660
  });
2557
- return;
2661
+ return false;
2558
2662
  }
2559
2663
  const allowedFiles = this.filterAlreadyUploadedFiles(
2560
2664
  this.filterByFilesAmountLimit(
@@ -2569,144 +2673,151 @@ class UploaderApi extends EventEmitter$1 {
2569
2673
  ),
2570
2674
  conf
2571
2675
  );
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" }
2676
+ if (allowedFiles.length > 0) {
2677
+ const formData = new FormData();
2678
+ allowedFiles.forEach(
2679
+ (file) => formData.append("fileRepository", file, file.name)
2664
2680
  );
2665
- const secondResult = await post(
2681
+ await post(
2666
2682
  this.execution,
2667
2683
  makeApiaUrl(
2668
2684
  this.execution,
2669
- this.getProcessDroppedFilesParameters({
2670
- action: "processDroppedFiles",
2671
- elemType: this.type,
2685
+ this.getSaveDroppedFilesParameters({
2686
+ action: "saveDroppedFiles",
2672
2687
  docId: this.state.versioningFile?.docId,
2688
+ ajaxUrl: this.getAjaxUrl(),
2689
+ elemType: this.type,
2690
+ elemId: `prmDocumentContainter${this.type}`,
2673
2691
  frmOut: !this.modalController,
2674
- ajaxUrl: this.getAjaxUrl()
2692
+ docTypeId: this.state.selectedDocTypeId,
2693
+ langId
2675
2694
  })
2676
2695
  ),
2677
2696
  {
2678
- postData: postData.toString()
2697
+ postData: formData,
2698
+ axiosConfig: {
2699
+ onUploadProgress: (ev) => this.state.progress = ev.loaded * 100 / ((ev.total ?? ev.loaded) * 2)
2700
+ }
2679
2701
  }
2680
2702
  );
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
2703
+ const ajaxUploadFileStatusParameters = this.getAjaxUploadFileStatusParameters({
2704
+ action: "ajaxUploadFileStatus",
2705
+ ajaxUrl: this.getAjaxUrl(),
2706
+ delayForDrop: true,
2707
+ isAjax: true,
2708
+ prefix: this.type
2709
+ });
2710
+ let tries = 0;
2711
+ const checkUploadResult = async () => {
2712
+ return new Promise(async (resolve) => {
2713
+ tries += 1;
2714
+ if (tries === 10) {
2715
+ this.notify({
2716
+ message: "Error while checking for uploadFileStatus, too many tries",
2717
+ type: "error"
2718
+ });
2719
+ resolve(false);
2720
+ return;
2721
+ }
2722
+ const response = await post(
2723
+ this.execution,
2724
+ makeApiaUrl(this.execution, ajaxUploadFileStatusParameters)
2725
+ );
2726
+ if (response && response.data) {
2727
+ const hasMessages = arrayOrArray(
2728
+ response.data?.sysMessages?.message ?? response.data?.sysExceptions?.exception ?? response.data?.exceptions?.exception ?? response.data.function.messages?.message
2729
+ ).length > 0 || !!response.data.function.dropLastMessage;
2730
+ const uploadMessage = arrayOrArray(
2731
+ response.data.function.messages?.message
2732
+ ).find((current) => current.name === "message");
2733
+ if (uploadMessage)
2734
+ this.notify({ message: uploadMessage.label, type: "warning" });
2735
+ const method = response.data?.function.name;
2736
+ this.state.progress = 44;
2737
+ if (hasMessages) {
2738
+ resolve(false);
2739
+ return;
2740
+ }
2741
+ if (method === "fncProceedDocumentProcessing") {
2742
+ resolve(true);
2743
+ return;
2744
+ }
2745
+ if (tries === 10) {
2746
+ resolve(method === "fncProceedDocumentProcessing");
2747
+ }
2748
+ setTimeout(() => {
2749
+ checkUploadResult().then(resolve).catch(() => resolve(false));
2750
+ }, 100);
2751
+ } else {
2752
+ resolve(false);
2753
+ }
2700
2754
  });
2701
- if (isOneClickUploadEnabled(this.modalConfig.oneClickUpload)) {
2702
- if (langId && translatingFile)
2703
- void this.confirmDropModal({ langId, translatingFile });
2704
- else
2705
- void this.confirmDropModal();
2755
+ };
2756
+ const hasUploadedCorrectly = await checkUploadResult();
2757
+ this.state.progress = 66;
2758
+ if (hasUploadedCorrectly) {
2759
+ const shown = (this.state.inProgressFiles ?? []).map(
2760
+ (file) => file.name
2761
+ );
2762
+ const postData = QueryString.stringify(
2763
+ this.getProcessDroppedFilesPostdata({
2764
+ useDocTypePermitted: true,
2765
+ docTypePermittedObjId: this.docTypePermittedObjId?.toString(),
2766
+ docTypePermittedObjType: this.type,
2767
+ dropped: allowedFiles.map((file) => file.name).concat(shown),
2768
+ shown
2769
+ }),
2770
+ { arrayFormat: "repeat" }
2771
+ );
2772
+ const secondResult = await post(
2773
+ this.execution,
2774
+ makeApiaUrl(
2775
+ this.execution,
2776
+ this.getProcessDroppedFilesParameters({
2777
+ action: "processDroppedFiles",
2778
+ elemType: this.type,
2779
+ docId: this.state.versioningFile?.docId,
2780
+ frmOut: !this.modalController,
2781
+ ajaxUrl: this.getAjaxUrl()
2782
+ })
2783
+ ),
2784
+ {
2785
+ postData: postData.toString()
2786
+ }
2787
+ );
2788
+ this.state.progress = 83;
2789
+ if (secondResult?.data?.function?.principal?.docInfo) {
2790
+ const acceptedByServerFiles = arrayOrArray(
2791
+ secondResult.data.function?.principal?.docInfo
2792
+ );
2793
+ this.state.inProgressFiles = [
2794
+ ...this.state.inProgressFiles ?? [],
2795
+ ...acceptedByServerFiles.map(
2796
+ (current) => [...this.state.inProgressFiles, ...unprocessedFiles].find(
2797
+ (search) => search.name === current.docInfoName
2798
+ )
2799
+ ).filter((current) => !!current)
2800
+ ];
2801
+ this.state.progress = 100;
2802
+ if (this.modalController)
2803
+ this.modalController.state.fromDirectoryFile = null;
2804
+ this.notify({
2805
+ type: "success",
2806
+ message: getWindow(this.execution).FILE_UPLOADED_SUCCESSFULLY
2807
+ });
2808
+ if (isOneClickUploadEnabled(this.modalConfig.oneClickUpload)) {
2809
+ if (langId && translatingFile)
2810
+ void this.confirmDropModal({ langId, translatingFile });
2811
+ else
2812
+ void this.confirmDropModal();
2813
+ }
2706
2814
  }
2707
2815
  }
2816
+ this.state.progress = 100;
2817
+ return true;
2818
+ } else {
2819
+ return false;
2708
2820
  }
2709
- this.state.progress = 100;
2710
2821
  }
2711
2822
  async checkWebDavLock(docId) {
2712
2823
  if (getWindow(this.execution).IN_MONITOR) {
@@ -2919,7 +3030,7 @@ class UploaderApi extends EventEmitter$1 {
2919
3030
  if (this.modalController) {
2920
3031
  this.modalController.addDirectoryFile(document);
2921
3032
  this.modalController.state.permissions = {
2922
- pools: arrayOrArray(permissions.pool).map((c) => {
3033
+ pools: arrayOrArray(permissions?.pool).map((c) => {
2923
3034
  return {
2924
3035
  poolId: c.id,
2925
3036
  poolName: c.name,
@@ -2927,14 +3038,7 @@ class UploaderApi extends EventEmitter$1 {
2927
3038
  };
2928
3039
  }),
2929
3040
  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) => {
3041
+ ...arrayOrArray(permissions?.user).map((c) => {
2938
3042
  return {
2939
3043
  userId: c.id,
2940
3044
  userLogin: c.name,
@@ -2945,6 +3049,7 @@ class UploaderApi extends EventEmitter$1 {
2945
3049
  allowAllType: document.docAllPoolPerm
2946
3050
  };
2947
3051
  this.modalController.changeDocType(document.docTypeId);
3052
+ this.modalController.state.isReadonly = !documentInfo.function.currentUsrPems.usrCanModify;
2948
3053
  }
2949
3054
  void this.reloadMetadata(
2950
3055
  { docId: document.docId, docTypeId: document.docTypeId },
@@ -3095,8 +3200,8 @@ class UploaderApi extends EventEmitter$1 {
3095
3200
  this.setTranslationFile(firstFile, translatingFile.docId, langId);
3096
3201
  } else {
3097
3202
  this.state.files = { ...currentFiles, ...newFiles };
3098
- this.state.inProgressFiles = [];
3099
3203
  }
3204
+ this.state.inProgressFiles = [];
3100
3205
  this.emit("fileUploaded", null);
3101
3206
  return true;
3102
3207
  }
@@ -3380,10 +3485,10 @@ class UploaderApi extends EventEmitter$1 {
3380
3485
  }
3381
3486
  }
3382
3487
 
3383
- var __defProp$f = Object.defineProperty;
3384
- var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3385
- var __publicField$f = (obj, key, value) => {
3386
- __defNormalProp$f(obj, typeof key !== "symbol" ? key + "" : key, value);
3488
+ var __defProp$g = Object.defineProperty;
3489
+ var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3490
+ var __publicField$g = (obj, key, value) => {
3491
+ __defNormalProp$g(obj, typeof key !== "symbol" ? key + "" : key, value);
3387
3492
  return value;
3388
3493
  };
3389
3494
  class FormsUploader extends UploaderApi {
@@ -3398,15 +3503,15 @@ class FormsUploader extends UploaderApi {
3398
3503
  this.type = type;
3399
3504
  this.modalConfig = modalConfig;
3400
3505
  this.field = field;
3401
- __publicField$f(this, "isEditionMode");
3402
- __publicField$f(this, "getAjaxUploadFileStatusParameters", (defaultParameters) => {
3506
+ __publicField$g(this, "isEditionMode");
3507
+ __publicField$g(this, "getAjaxUploadFileStatusParameters", (defaultParameters) => {
3403
3508
  return {
3404
3509
  ...defaultParameters,
3405
3510
  forceDocTypeId: this.field.properties.docType,
3406
3511
  ...this.getFormParameters()
3407
3512
  };
3408
3513
  });
3409
- __publicField$f(this, "getAjaxUploadStartParameters", ({
3514
+ __publicField$g(this, "getAjaxUploadStartParameters", ({
3410
3515
  useDocTypePermitted,
3411
3516
  docTypePermittedObjType,
3412
3517
  docTypePermittedObjId,
@@ -3418,7 +3523,7 @@ class FormsUploader extends UploaderApi {
3418
3523
  ...this.getFormParameters()
3419
3524
  };
3420
3525
  });
3421
- __publicField$f(this, "getCheckLockDocumentParameters", ({
3526
+ __publicField$g(this, "getCheckLockDocumentParameters", ({
3422
3527
  prefix,
3423
3528
  ...parameters
3424
3529
  }) => {
@@ -3427,7 +3532,7 @@ class FormsUploader extends UploaderApi {
3427
3532
  ...this.getFormParameters()
3428
3533
  };
3429
3534
  });
3430
- __publicField$f(this, "getCheckSignatureParameters", (parameters) => {
3535
+ __publicField$g(this, "getCheckSignatureParameters", (parameters) => {
3431
3536
  const { frmId, frmParent } = this.getFormParameters();
3432
3537
  return {
3433
3538
  ...parameters,
@@ -3435,7 +3540,7 @@ class FormsUploader extends UploaderApi {
3435
3540
  frmParent
3436
3541
  };
3437
3542
  });
3438
- __publicField$f(this, "getClearTempFilesParameters", ({
3543
+ __publicField$g(this, "getClearTempFilesParameters", ({
3439
3544
  elemType,
3440
3545
  ...rest
3441
3546
  }) => {
@@ -3448,7 +3553,7 @@ class FormsUploader extends UploaderApi {
3448
3553
  index
3449
3554
  };
3450
3555
  });
3451
- __publicField$f(this, "getConfirmDropModalParameters", (defaultParameters) => {
3556
+ __publicField$g(this, "getConfirmDropModalParameters", (defaultParameters) => {
3452
3557
  return {
3453
3558
  ...defaultParameters,
3454
3559
  elemType: this.elemId(),
@@ -3456,7 +3561,7 @@ class FormsUploader extends UploaderApi {
3456
3561
  ...this.getFormParameters()
3457
3562
  };
3458
3563
  });
3459
- __publicField$f(this, "getConfirmDropModalPostdata", ({
3564
+ __publicField$g(this, "getConfirmDropModalPostdata", ({
3460
3565
  pe,
3461
3566
  ...parameters
3462
3567
  }) => {
@@ -3466,7 +3571,7 @@ class FormsUploader extends UploaderApi {
3466
3571
  editionMode
3467
3572
  };
3468
3573
  });
3469
- __publicField$f(this, "getDeleteDocumentParameters", ({
3574
+ __publicField$g(this, "getDeleteDocumentParameters", ({
3470
3575
  prefix,
3471
3576
  isAjax,
3472
3577
  ...currentParameters
@@ -3477,13 +3582,13 @@ class FormsUploader extends UploaderApi {
3477
3582
  ...rest
3478
3583
  };
3479
3584
  });
3480
- __publicField$f(this, "getDocumentInfoParameters", (parameters) => {
3585
+ __publicField$g(this, "getDocumentInfoParameters", (parameters) => {
3481
3586
  return {
3482
3587
  ...parameters,
3483
3588
  ajaxUrl: getWindow(this.execution).URL_REQUEST_AJAX
3484
3589
  };
3485
3590
  });
3486
- __publicField$f(this, "getEditDocumentParameters", ({ action, docId }) => {
3591
+ __publicField$g(this, "getEditDocumentParameters", ({ action, docId }) => {
3487
3592
  const { prefix, editionMode, ...rest } = this.getFormParameters();
3488
3593
  return {
3489
3594
  action,
@@ -3492,7 +3597,7 @@ class FormsUploader extends UploaderApi {
3492
3597
  ajaxUrl: "apia.execution.FormAction.run"
3493
3598
  };
3494
3599
  });
3495
- __publicField$f(this, "getLoadFilesForFolderParameters", () => {
3600
+ __publicField$g(this, "getLoadFilesForFolderParameters", () => {
3496
3601
  return {
3497
3602
  useDocTypePermitted: this.state.allowedTypes.length === 1 ? true : void 0,
3498
3603
  docTypeForcedId: this.state.allowedTypes.length === 1 ? this.state.allowedTypes[0].id : void 0,
@@ -3500,11 +3605,11 @@ class FormsUploader extends UploaderApi {
3500
3605
  loadFolders: true
3501
3606
  };
3502
3607
  });
3503
- __publicField$f(this, "getLoadFileSystemStructureTree", () => ({
3608
+ __publicField$g(this, "getLoadFileSystemStructureTree", () => ({
3504
3609
  useDocTypePermitted: this.state.allowedTypes.length === 1,
3505
3610
  docTypeForcedId: this.docTypePermittedObjId
3506
3611
  }));
3507
- __publicField$f(this, "getLockDocumentParameters", ({
3612
+ __publicField$g(this, "getLockDocumentParameters", ({
3508
3613
  prefix,
3509
3614
  isAjax,
3510
3615
  ...currentParameters
@@ -3515,7 +3620,7 @@ class FormsUploader extends UploaderApi {
3515
3620
  ...rest
3516
3621
  };
3517
3622
  });
3518
- __publicField$f(this, "getMarkFileToSignParameters", ({
3623
+ __publicField$g(this, "getMarkFileToSignParameters", ({
3519
3624
  docId,
3520
3625
  prefix,
3521
3626
  ...defaultParameters
@@ -3527,7 +3632,7 @@ class FormsUploader extends UploaderApi {
3527
3632
  ...this.getFormParameters()
3528
3633
  };
3529
3634
  });
3530
- __publicField$f(this, "getProcessDroppedFilesParameters", (defaultParameters) => {
3635
+ __publicField$g(this, "getProcessDroppedFilesParameters", (defaultParameters) => {
3531
3636
  const { prefix, ...rest } = this.getFormParameters();
3532
3637
  return {
3533
3638
  ...defaultParameters,
@@ -3536,7 +3641,7 @@ class FormsUploader extends UploaderApi {
3536
3641
  ...rest
3537
3642
  };
3538
3643
  });
3539
- __publicField$f(this, "getProcessDroppedFilesPostdata", ({
3644
+ __publicField$g(this, "getProcessDroppedFilesPostdata", ({
3540
3645
  useDocTypePermitted,
3541
3646
  docTypePermittedObjId,
3542
3647
  docTypePermittedObjType,
@@ -3544,14 +3649,14 @@ class FormsUploader extends UploaderApi {
3544
3649
  }) => {
3545
3650
  return { ...parameters, editionMode: this.getFormParameters().editionMode };
3546
3651
  });
3547
- __publicField$f(this, "getReloadMetadataParameters", (defaultParameters) => {
3652
+ __publicField$g(this, "getReloadMetadataParameters", (defaultParameters) => {
3548
3653
  return {
3549
3654
  ...defaultParameters,
3550
3655
  ...getWindow(this.execution).IS_EDIT_GRID ? { editionMode: true } : null,
3551
3656
  ...this.getFormParameters()
3552
3657
  };
3553
3658
  });
3554
- __publicField$f(this, "getSaveDroppedFilesParameters", (defaultParameters) => {
3659
+ __publicField$g(this, "getSaveDroppedFilesParameters", (defaultParameters) => {
3555
3660
  const elemId = this.elemId();
3556
3661
  const { prefix, ...rest } = this.getFormParameters();
3557
3662
  return {
@@ -3562,7 +3667,7 @@ class FormsUploader extends UploaderApi {
3562
3667
  ...rest
3563
3668
  };
3564
3669
  });
3565
- __publicField$f(this, "parseFileDefinition", (file) => {
3670
+ __publicField$g(this, "parseFileDefinition", (file) => {
3566
3671
  return {
3567
3672
  ...parseFileDefinition(
3568
3673
  this.execution,
@@ -3641,20 +3746,20 @@ class FormsUploader extends UploaderApi {
3641
3746
  return null;
3642
3747
  }
3643
3748
  async saveDroppedFiles(unprocessedFiles, conf) {
3644
- await super.saveDroppedFiles(unprocessedFiles, conf);
3749
+ return await super.saveDroppedFiles(unprocessedFiles, conf);
3645
3750
  }
3646
3751
  }
3647
3752
 
3648
- var __defProp$e = Object.defineProperty;
3649
- var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3650
- var __publicField$e = (obj, key, value) => {
3651
- __defNormalProp$e(obj, key + "" , value);
3753
+ var __defProp$f = Object.defineProperty;
3754
+ var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3755
+ var __publicField$f = (obj, key, value) => {
3756
+ __defNormalProp$f(obj, key + "" , value);
3652
3757
  return value;
3653
3758
  };
3654
- class File extends TranslatableField {
3759
+ class File extends FieldWithAttribute {
3655
3760
  constructor() {
3656
3761
  super(...arguments);
3657
- __publicField$e(this, "uploader", {});
3762
+ __publicField$f(this, "uploader", {});
3658
3763
  }
3659
3764
  async init(form) {
3660
3765
  await super.init(form);
@@ -3756,10 +3861,10 @@ function noNaN(number, defaultReturn = 0) {
3756
3861
  return returnNumber;
3757
3862
  }
3758
3863
 
3759
- var __defProp$d = Object.defineProperty;
3760
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3761
- var __publicField$d = (obj, key, value) => {
3762
- __defNormalProp$d(obj, key + "" , value);
3864
+ var __defProp$e = Object.defineProperty;
3865
+ var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3866
+ var __publicField$e = (obj, key, value) => {
3867
+ __defNormalProp$e(obj, key + "" , value);
3763
3868
  return value;
3764
3869
  };
3765
3870
  var __accessCheck$i = (obj, member, msg) => {
@@ -3784,7 +3889,7 @@ var _unsubscribeTableEvents;
3784
3889
  class GridFooterHandler {
3785
3890
  constructor(grid) {
3786
3891
  this.grid = grid;
3787
- __publicField$d(this, "state", {
3892
+ __publicField$e(this, "state", {
3788
3893
  isSortUpDisabled: true,
3789
3894
  isSortDownDisabled: true
3790
3895
  });
@@ -3884,15 +3989,15 @@ class HeaderCell extends Cell {
3884
3989
  }
3885
3990
  }
3886
3991
 
3887
- var __defProp$c = Object.defineProperty;
3888
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3889
- var __publicField$c = (obj, key, value) => {
3890
- __defNormalProp$c(obj, key + "" , value);
3992
+ var __defProp$d = Object.defineProperty;
3993
+ var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3994
+ var __publicField$d = (obj, key, value) => {
3995
+ __defNormalProp$d(obj, key + "" , value);
3891
3996
  return value;
3892
3997
  };
3893
3998
  class FieldsCache {
3894
3999
  constructor() {
3895
- __publicField$c(this, "cached", {});
4000
+ __publicField$d(this, "cached", {});
3896
4001
  }
3897
4002
  getIndex(index) {
3898
4003
  if (!this.cached[index])
@@ -3925,6 +4030,12 @@ class FieldsCache {
3925
4030
  }
3926
4031
  }
3927
4032
 
4033
+ var __defProp$c = Object.defineProperty;
4034
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4035
+ var __publicField$c = (obj, key, value) => {
4036
+ __defNormalProp$c(obj, key + "" , value);
4037
+ return value;
4038
+ };
3928
4039
  class ModalInput extends FieldWithAttribute {
3929
4040
  constructor({ value, ...definition }) {
3930
4041
  super({
@@ -3934,6 +4045,8 @@ class ModalInput extends FieldWithAttribute {
3934
4045
  },
3935
4046
  value: { storeValue: value, showValue: definition.qry_show_value }
3936
4047
  });
4048
+ __publicField$c(this, "isLoading", false);
4049
+ makeObservable(this, { isLoading: observable });
3937
4050
  }
3938
4051
  fireEvent(eventName) {
3939
4052
  return super.fireEvent(eventName);
@@ -3942,52 +4055,72 @@ class ModalInput extends FieldWithAttribute {
3942
4055
  return this.getValue().showValue !== "" && this.getValue().storeValue !== "";
3943
4056
  }
3944
4057
  async setValueFromInputWrite(value) {
3945
- if (value !== this.getValue().showValue) {
4058
+ this.isLoading = true;
4059
+ try {
4060
+ if (isFieldShowAsText(this) || shallowEqual$1(value, this.getValue().showValue) || value === "")
4061
+ return;
4062
+ if (value !== this.getValue().showValue) {
4063
+ const result = await post(
4064
+ this.form.execution,
4065
+ makeApiaUrl(this.form.execution, {
4066
+ action: "checkModalValue",
4067
+ ajaxUrl: "/apia.execution.FormAction.run"
4068
+ }),
4069
+ {
4070
+ postData: {
4071
+ frmId: this.form.definition.id,
4072
+ frmParent: this.form.definition.frmParent,
4073
+ fldId: this.definition.id,
4074
+ attId: this.attribute.id,
4075
+ qryId: this.definition.qryId,
4076
+ index: this.definition.index,
4077
+ value
4078
+ },
4079
+ postDataTreatment: "stringify"
4080
+ }
4081
+ );
4082
+ if (result?.data?.ret_value) {
4083
+ const setValueResult = await this.setValue({
4084
+ storeValue: result?.data?.ret_value.value,
4085
+ showValue: result?.data?.ret_value.show_value
4086
+ });
4087
+ if (setValueResult) {
4088
+ this.fireEvent("onChange");
4089
+ }
4090
+ this.setError("");
4091
+ } else {
4092
+ this.setValue({ showValue: "", storeValue: "" });
4093
+ this.setError(getWindow(this.form.execution).MSG_VAL_NOT_FOUND);
4094
+ }
4095
+ }
4096
+ } finally {
4097
+ this.isLoading = false;
4098
+ }
4099
+ }
4100
+ async setValueFromModalSelection(rowId) {
4101
+ this.isLoading = true;
4102
+ try {
3946
4103
  const result = await post(
3947
4104
  this.form.execution,
3948
4105
  makeApiaUrl(this.form.execution, {
3949
- action: "checkModalValue",
3950
- ajaxUrl: "/apia.execution.FormAction.run"
4106
+ ajaxUrl: "/apia.query.ModalAction.run",
4107
+ action: "getValues"
3951
4108
  }),
3952
- {
3953
- postData: {
3954
- frmId: this.form.definition.id,
3955
- frmParent: this.form.definition.frmParent,
3956
- fldId: this.definition.id,
3957
- attId: this.attribute.id,
3958
- qryId: this.definition.qryId,
3959
- index: this.definition.index,
3960
- value
3961
- },
3962
- postDataTreatment: "stringify"
3963
- }
4109
+ { postData: { id: rowId }, postDataTreatment: "stringify" }
3964
4110
  );
3965
- if (result?.data?.ret_value) {
3966
- this.setValue({
3967
- storeValue: result?.data?.ret_value.value,
3968
- showValue: result?.data?.ret_value.show_value
4111
+ if (result?.data?.row?.cell) {
4112
+ const setValueResult = await this.setValue({
4113
+ storeValue: result.data.row.cell[0],
4114
+ showValue: result.data.row.cell[1]
3969
4115
  });
3970
- this.setError("");
3971
- } else {
3972
- this.setValue({ showValue: "", storeValue: "" });
3973
- this.setError(getWindow(this.form.execution).MSG_VAL_NOT_FOUND);
4116
+ this.form.execution.setLastModalReturn(result.data.row.cell);
4117
+ if (setValueResult) {
4118
+ this.fireEvent("onModalReturn");
4119
+ this.fireEvent("onChange");
4120
+ }
3974
4121
  }
3975
- }
3976
- }
3977
- async setValueFromModalSelection(rowId) {
3978
- const result = await post(
3979
- this.form.execution,
3980
- makeApiaUrl(this.form.execution, {
3981
- ajaxUrl: "/apia.query.ModalAction.run",
3982
- action: "getValues"
3983
- }),
3984
- { postData: { id: rowId }, postDataTreatment: "stringify" }
3985
- );
3986
- if (result?.data?.row?.cell) {
3987
- this.setValue({
3988
- storeValue: result.data.row.cell[0],
3989
- showValue: result.data.row.cell[1]
3990
- });
4122
+ } finally {
4123
+ this.isLoading = false;
3991
4124
  }
3992
4125
  }
3993
4126
  async validate() {
@@ -4002,6 +4135,25 @@ class ModalInput extends FieldWithAttribute {
4002
4135
  }
4003
4136
  return true;
4004
4137
  }
4138
+ setValue(newValue, options) {
4139
+ if (isFieldShowAsText(this) || shallowEqual$1(newValue, this.getValue()))
4140
+ return Promise.resolve(true);
4141
+ this.state.value = newValue;
4142
+ this.state.validation.errorMessage = null;
4143
+ if (options?.synchronize === false) {
4144
+ this.lastSynchronizationValue = newValue;
4145
+ return Promise.resolve(true);
4146
+ }
4147
+ return this.synchronize(newValue).then((res) => {
4148
+ if (res) {
4149
+ if (options?.markAsDirty !== false) {
4150
+ this.form.execution.state.hasChangedAnything = true;
4151
+ }
4152
+ return true;
4153
+ }
4154
+ return Promise.resolve(false);
4155
+ });
4156
+ }
4005
4157
  getSynchronizePostConfiguration(value) {
4006
4158
  const storeIdValue = this.properties.storeMdlQryResult;
4007
4159
  return {
@@ -4292,6 +4444,13 @@ class Grid extends Field$1 {
4292
4444
  deletingIndices.forEach(
4293
4445
  (c) => this.controller.body.getRowByIndex(c).remove()
4294
4446
  );
4447
+ for (let i = minIndex; i < this.controller.body.rows.length; i++) {
4448
+ this.controller.body.getRowByIndex(i).cells.forEach((c) => {
4449
+ if (c instanceof GridCell) {
4450
+ c.getField().definition.index = i;
4451
+ }
4452
+ });
4453
+ }
4295
4454
  this.tableController.clearSelection();
4296
4455
  if (this.tableController.body.rows.length === 0 && this.getProperty("includeFirstRow")) {
4297
4456
  await res;
@@ -4442,14 +4601,15 @@ class Grid extends Field$1 {
4442
4601
  async init(form) {
4443
4602
  await super.init(form);
4444
4603
  const headerRow = new Row("header");
4445
- headerRow.addCell(
4446
- new AdditionalCell(
4447
- this,
4448
- () => -1,
4449
- () => {
4450
- }
4451
- )
4452
- );
4604
+ if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly)
4605
+ headerRow.addCell(
4606
+ new AdditionalCell(
4607
+ this,
4608
+ () => -1,
4609
+ () => {
4610
+ }
4611
+ )
4612
+ );
4453
4613
  const hiddenColumns = /* @__PURE__ */ new Set();
4454
4614
  this.header.forEach((c) => {
4455
4615
  hiddenColumns.add(c.fldId);
@@ -4480,7 +4640,8 @@ class Grid extends Field$1 {
4480
4640
  colName: col.fldId || String(i),
4481
4641
  content: col.label,
4482
4642
  domProperties: {
4483
- style: { width, maxWidth: width }
4643
+ style: { width, maxWidth: width },
4644
+ title: col.title
4484
4645
  },
4485
4646
  properties: { col }
4486
4647
  })
@@ -4641,18 +4802,19 @@ class Grid extends Field$1 {
4641
4802
  });
4642
4803
  }
4643
4804
  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
- );
4805
+ if (this.properties.gridForm || !this.properties.hideDelButton && !this.properties.readonly && !this.properties.inputAsText && !this.getForm().definition.readOnly && !this.getForm().definition.readonly)
4806
+ newRow.addCell(
4807
+ new AdditionalCell(
4808
+ this,
4809
+ () => newRow.index,
4810
+ () => {
4811
+ this.deleteRows(newRow.index);
4812
+ },
4813
+ this.properties.gridForm ? (handler) => {
4814
+ this.openEditionModal(handler);
4815
+ } : void 0
4816
+ )
4817
+ );
4656
4818
  this.tableController.body.addRow(newRow);
4657
4819
  for await (const field of definitions) {
4658
4820
  const fieldProps = parseFakeJSON$1(
@@ -5169,7 +5331,9 @@ class Select extends FieldWithAttribute {
5169
5331
  properties: { possibleValue }
5170
5332
  }) {
5171
5333
  return Promise.resolve(
5172
- String(possibleValue?.find((c) => c.selected)?.value || "")
5334
+ String(
5335
+ possibleValue?.find((c) => c.selected)?.value || possibleValue?.[0]?.value || ""
5336
+ )
5173
5337
  );
5174
5338
  }
5175
5339
  }
@@ -5294,70 +5458,34 @@ class Tree extends FieldWithAttribute {
5294
5458
  var __defProp$9 = Object.defineProperty;
5295
5459
  var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
5296
5460
  var __publicField$9 = (obj, key, value) => {
5297
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
5461
+ __defNormalProp$9(obj, key + "" , value);
5298
5462
  return value;
5299
5463
  };
5300
- const dateFormat = "DD/MM/YYYY";
5301
- function getCurrentDate() {
5302
- return dayjs().format(dateFormat);
5303
- }
5304
- const initState = {
5305
- validation: {
5306
- dirty: false,
5307
- errorMessage: "",
5308
- synchronizing: false
5309
- },
5310
- isStageMounted: {},
5311
- stageData: [],
5312
- isLoading: "NotLoading",
5313
- initialProps: {
5314
- schId: "",
5315
- proId: "",
5316
- proVerId: "",
5317
- tskId: "",
5318
- showDisponibility: "false",
5319
- showAttributes: "false"
5320
- }
5321
- };
5322
- class Scheduler extends Field$1 {
5464
+ class SchedulerField extends Field$1 {
5323
5465
  constructor(definition) {
5324
5466
  super(definition);
5325
- __publicField$9(this, "inited", false);
5326
- __publicField$9(this, "tableController", new TableController({
5327
- allowEdition: false,
5328
- allowSelection: false,
5329
- isSelectionMultiple: false,
5330
- allowResize: false
5331
- }));
5332
- __publicField$9(this, "parsedDateLabel", () => {
5333
- const mondayWeek = this.state?.data?.mondayWeek;
5334
- if (!mondayWeek) {
5335
- return "";
5336
- } else {
5337
- const monday = dayjs(mondayWeek, dateFormat);
5338
- const sunday = monday.add(6, "day");
5339
- const mondayDate = noNaN$1(monday.date());
5340
- const sundayDate = noNaN$1(sunday.date());
5341
- const mondayMonth = noNaN$1(monday.month());
5342
- const sundayMonth = noNaN$1(sunday.month());
5343
- const mondayYear = noNaN$1(monday.year());
5344
- const sundayYear = noNaN$1(sunday.year());
5345
- const getMonthLabel = (monthIndex) => getWindow(this.form.execution).LBL_MONTHS[monthIndex];
5346
- if (mondayDate > sundayDate && mondayMonth < sundayMonth) {
5347
- return `${mondayDate} de ${getMonthLabel(mondayMonth)} - ${sundayDate} de ${getMonthLabel(sundayMonth)}, ${mondayYear}`;
5348
- }
5349
- if (mondayMonth > sundayMonth) {
5350
- return `${mondayDate} de ${getMonthLabel(mondayMonth)}, ${mondayYear} - ${sundayDate} de ${getMonthLabel(sundayMonth)}, ${sundayYear}`;
5351
- }
5352
- return `${mondayDate} - ${sundayDate} de ${getMonthLabel(mondayMonth)}, ${mondayYear}`;
5353
- }
5467
+ __publicField$9(this, "_schedController");
5468
+ this._schedController = new Scheduler(this.parsedInitialProperties, {
5469
+ loadWeek: this.loadWeek.bind(this),
5470
+ deleteDate: this.deleteDate.bind(this),
5471
+ markDay: this.markDay.bind(this),
5472
+ loadInfo: this.loadInfo.bind(this)
5354
5473
  });
5355
- this.state = initState;
5356
5474
  }
5357
- get controller() {
5358
- return this.tableController;
5475
+ async deleteDate() {
5476
+ const res = await get(
5477
+ this.form.execution,
5478
+ makeApiaUrl(this.form.execution, {
5479
+ ajaxUrl: "/apia.design.TaskSchedulerAction.run",
5480
+ action: "clearExecutionSchedulerSelectedDay"
5481
+ })
5482
+ );
5483
+ if (res?.data?.success) {
5484
+ return true;
5485
+ }
5486
+ return false;
5359
5487
  }
5360
- get initialProperties() {
5488
+ get parsedInitialProperties() {
5361
5489
  const value = String(this.properties.value);
5362
5490
  let start = 0;
5363
5491
  let end = 0;
@@ -5378,11 +5506,10 @@ class Scheduler extends Field$1 {
5378
5506
  }
5379
5507
  async init(form) {
5380
5508
  await super.init(form);
5381
- this.loadWeek();
5509
+ this._schedController.loadWeek();
5382
5510
  }
5383
- async loadWeek(weekDay = getCurrentDate()) {
5384
- const { schId, proId, proVerId, tskId } = this.initialProperties;
5385
- const result = await get(
5511
+ async loadWeek(weekDay, schId, proId, proVerId, tskId) {
5512
+ const res = await get(
5386
5513
  this.form.execution,
5387
5514
  makeApiaUrl(this.form.execution, {
5388
5515
  ajaxUrl: "/apia.design.TaskSchedulerAction.run",
@@ -5394,427 +5521,36 @@ class Scheduler extends Field$1 {
5394
5521
  tskId
5395
5522
  })
5396
5523
  );
5397
- if (result?.data) {
5398
- this.state.data = result.data;
5399
- this.state.initialProps = this.initialProperties;
5400
- this.makeDaysStage(result.data);
5401
- this.state.validation = {
5402
- ...this.state.validation,
5403
- synchronizing: false
5404
- };
5405
- const rows = this.parseRows(result.data);
5406
- if (!this.inited) {
5407
- this.inited = true;
5408
- const tableJson = {
5409
- columns: this.getSchedulerColumns(result?.data),
5410
- rows,
5411
- filters: []
5412
- };
5413
- this.controller.build(tableJson);
5414
- } else {
5415
- this.controller.head.getState("rows").forEach((r) => {
5416
- r.cells.forEach((cell, cellIndex) => {
5417
- const newCell = this.getSchedulerColumns(result.data)[cellIndex];
5418
- if (newCell) {
5419
- if (cellIndex !== 0) {
5420
- cell.setState((cellState) => {
5421
- return {
5422
- ...cellState,
5423
- content: newCell.content
5424
- };
5425
- });
5426
- }
5427
- }
5428
- });
5429
- });
5430
- this.controller.body.getState("rows").forEach((r, i) => {
5431
- r.cells.forEach((cell, cellIndex) => {
5432
- const newCell = rows[i]?.cells?.[cellIndex];
5433
- if (newCell) {
5434
- cell.setState((cellState) => {
5435
- return {
5436
- ...cellState,
5437
- content: newCell.content,
5438
- properties: newCell.properties,
5439
- domProperties: newCell.domProperties
5440
- };
5441
- });
5442
- }
5443
- });
5444
- });
5445
- }
5446
- } else {
5447
- this.state.validation.errorMessage = "Failed to load scheduler data";
5448
- }
5449
- this.state.isLoading = "NotLoading";
5450
- }
5451
- parseRows(data) {
5452
- const retrievedDays = arrayOrArray(data?.tskSchDay);
5453
- const hourIndexes = arrayOrArray(
5454
- retrievedDays.find((c) => c?.tskSchHour)?.tskSchHour
5455
- );
5456
- const columnsWithOutHour = this.getSchedulerColumns(data).slice(1);
5457
- const newRows = hourIndexes.map((hour, rowIdx) => {
5458
- const currentDate = dayjs();
5459
- const currentHour = Number(dayjs().format("HHmm"));
5460
- const newRow = {
5461
- id: hour.hour,
5462
- cells: [
5463
- {
5464
- colName: "hour",
5465
- content: `${hour.hour.slice(0, -2)}:${hour.hour.slice(2)}`
5466
- },
5467
- ...columnsWithOutHour.map((_, colIdx) => {
5468
- const currentDayDefinition = retrievedDays[colIdx];
5469
- const currentHourDefinition = arrayOrArray(
5470
- currentDayDefinition?.tskSchHour
5471
- )[rowIdx];
5472
- const parsingDay = dayjs(currentDayDefinition?.day, dateFormat);
5473
- const parsingHour = Number(currentHourDefinition?.hour);
5474
- const isEnabled = !hour?.disabled && Number(currentHourDefinition?.value) + Number(this.state.data?.overassign) > 0 && (!(parsingDay.isSame(currentDate, "day") || parsingDay.isBefore(currentDate, "day")) || parsingDay.isSame(currentDate, "day") && currentHour <= parsingHour);
5475
- const isQueriedDisabled = hour?.disabled;
5476
- const returnCell = {
5477
- colName: columnsWithOutHour[colIdx].colName,
5478
- domProperties: {
5479
- className: isEnabled ? "" : "disabled"
5480
- },
5481
- properties: {
5482
- cellId: `${hour.hour}_${colIdx + 1}_${data?.mondayWeek ?? ""}`,
5483
- currentDayDefinition,
5484
- isEnabled,
5485
- isQueriedDisabled,
5486
- weekDay: data?.mondayWeek ?? "",
5487
- dayNumber: colIdx + 1,
5488
- hour: hour.hour,
5489
- value: Number(currentHourDefinition?.value),
5490
- valuePlusOverassign: Number(currentHourDefinition?.value) + Number(this.state.data?.overassign),
5491
- isOverassignClassName: !!(!Number(currentHourDefinition?.value) && Number(currentHourDefinition?.value) < Number(this.state.data?.overassign))
5492
- }
5493
- };
5494
- return returnCell;
5495
- }).filter((c) => c !== null)
5496
- ]
5497
- };
5498
- return newRow;
5499
- });
5500
- return newRows;
5501
- }
5502
- isMorningTime(hour) {
5503
- if (Number(hour) < 1200)
5504
- return true;
5505
- return false;
5506
- }
5507
- setState(newState) {
5508
- Object.entries(newState).forEach(([key, value]) => {
5509
- this.state[key] = value;
5510
- });
5511
- }
5512
- setDay(day) {
5513
- if (!this.state.selectedDay)
5514
- this.state.selectedDay = {};
5515
- this.state.selectedDay = { ...this.state.selectedDay, ...day };
5516
- }
5517
- setStage({ index, newStage }) {
5518
- if (!this.state.stageData)
5519
- this.state.stageData = [];
5520
- this.state.stageData[index] = newStage;
5521
- this.state.stageData.splice(index + 1);
5522
- }
5523
- syncStage(day, hour) {
5524
- this.makeMorningOrAfternoonStage(day);
5525
- this.makeHoursStage(day, this.isMorningTime(hour));
5526
- }
5527
- makeDaysStage(data) {
5528
- const dayData = data ?? this.state.data;
5529
- const overassign = this.state.data?.overassign;
5530
- const availableDays = arrayOrArray(dayData?.tskSchDay).map((currentDay) => {
5531
- const isDisabled = !arrayOrArray(currentDay?.tskSchHour).find(
5532
- (hour) => {
5533
- const parsingDay = dayjs(currentDay.day, dateFormat);
5534
- const currentDate = dayjs();
5535
- const parsingHour = Number(hour.hour);
5536
- const currentHour = Number(dayjs().format("HHmm"));
5537
- if (hour.hour !== void 0 && noNaN$1(hour.value) + noNaN$1(overassign) >= 0 && !(parsingDay.isSame(currentDate, "day") || parsingDay.isBefore(currentDate, "day")) || parsingDay.isSame(currentDate, "day") && currentHour <= parsingHour && !hour.disabled) {
5538
- return true;
5539
- }
5540
- return false;
5541
- }
5542
- );
5543
- return { ...currentDay, isDisabled };
5544
- }) ?? [];
5545
- const availableDaysButtons = availableDays.map((c) => {
5546
- const parsingDay = dayjs(c.day, dateFormat);
5547
- const returnBtn = {
5548
- isDisabled: c.isDisabled,
5549
- "aria-label": getWindow(this.form.execution).LBL_DAYS[dayjs(parsingDay).day()],
5550
- title: c.day,
5551
- label: `${getWindow(this.form.execution).LBL_DAYS[dayjs(parsingDay).day()]},
5552
- ${dayjs(parsingDay).get("date")}`,
5553
- value: "",
5554
- isSelectedSelector: () => {
5555
- return this.state.selectedDay?.day === c.day;
5556
- },
5557
- action: () => {
5558
- const isLoading = this.state.isLoading;
5559
- if (isLoading !== "NotLoading")
5560
- return;
5561
- this.makeMorningOrAfternoonStage(c);
5562
- const parsedMondayWeek = dayjs(dayData?.mondayWeek, dateFormat).get(
5563
- "date"
5564
- );
5565
- const parsedDay = dayjs(c.day, dateFormat).get("date");
5566
- this.setDay({
5567
- mondayWeek: dayData?.mondayWeek,
5568
- day: c.day,
5569
- dayNumber: Number(parsedDay) - Number(parsedMondayWeek) + 1
5570
- });
5571
- }
5572
- };
5573
- return returnBtn;
5574
- });
5575
- this.setStage({
5576
- index: 0,
5577
- newStage: {
5578
- name: "daysList",
5579
- buttons: [...availableDaysButtons]
5580
- }
5581
- });
5582
- }
5583
- makeMorningOrAfternoonStage(day) {
5584
- const thisDate = day.day;
5585
- const hours = arrayOrArray(day.tskSchHour);
5586
- const isLoading = this.state.isLoading;
5587
- const overassign = this.state.data?.overassign;
5588
- const parsingDay = dayjs(thisDate, dateFormat);
5589
- const currentDate = dayjs();
5590
- const currentHour = Number(dayjs().format("HHmm"));
5591
- const morningHours = hours?.filter((hour) => {
5592
- return (parsingDay.isSame(currentDate, "day") && currentHour <= Number(hour.hour) || !parsingDay.isSame(currentDate, "day") && Number(hour.value) + Number(overassign) > 0) && Number(hour.hour) < 1200;
5593
- });
5594
- const afternoonHours = hours?.filter((hour) => {
5595
- return (parsingDay.isSame(currentDate, "day") && currentHour <= Number(hour.hour) || !parsingDay.isSame(currentDate, "day") && Number(hour.value) + Number(overassign) > 0) && Number(hour.hour) >= 1200;
5596
- });
5597
- const morningButton = {
5598
- isDisabled: (morningHours?.length ?? 0) === 0,
5599
- label: getWindow(this.form.execution).LBL_SCHED_MORNING_TEXT,
5600
- title: getWindow(this.form.execution).LBL_SCHED_MORNING_TEXT,
5601
- "aria-label": getWindow(this.form.execution).LBL_SCHED_MORNING_TEXT,
5602
- value: "",
5603
- isSelectedSelector: () => {
5604
- return this.isMorningTime(
5605
- this.state.selectedDay?.morningOrAfternoonSelected
5606
- );
5607
- },
5608
- action: () => {
5609
- if (isLoading !== "NotLoading")
5610
- return;
5611
- this.setDay({
5612
- morningOrAfternoonSelected: 1100
5613
- });
5614
- const newStagesStringArray = [];
5615
- this.makeHoursStage(day, this.isMorningTime(1100));
5616
- this.setState({
5617
- stageList: newStagesStringArray
5618
- });
5619
- }
5620
- };
5621
- const afternoonButton = {
5622
- isDisabled: (afternoonHours?.length ?? 0) === 0,
5623
- label: getWindow(this.form.execution).LBL_SCHED_AFTERNOON_TEXT,
5624
- title: getWindow(this.form.execution).LBL_SCHED_AFTERNOON_TEXT,
5625
- "aria-label": getWindow(this.form.execution).LBL_SCHED_AFTERNOON_TEXT,
5626
- value: "",
5627
- isSelectedSelector: () => {
5628
- if (this.state.selectedDay?.morningOrAfternoonSelected) {
5629
- return !this.isMorningTime(
5630
- this.state.selectedDay?.morningOrAfternoonSelected
5631
- );
5632
- }
5633
- return false;
5634
- },
5635
- action: () => {
5636
- if (isLoading !== "NotLoading")
5637
- return;
5638
- this.setDay({
5639
- morningOrAfternoonSelected: 1300
5640
- });
5641
- this.makeHoursStage(day, this.isMorningTime(1300));
5642
- }
5643
- };
5644
- this.setStage({
5645
- index: 1,
5646
- newStage: {
5647
- name: "morningOrAfternoon",
5648
- buttons: [morningButton, afternoonButton].filter(
5649
- (current) => current !== null
5650
- )
5651
- }
5652
- });
5524
+ return res?.data ?? null;
5653
5525
  }
5654
- makeHoursStage(day, isMorning) {
5655
- const thisDate = day.day;
5656
- const hours = arrayOrArray(day.tskSchHour);
5657
- const overassign = this.state.data?.overassign;
5658
- const parsingDay = dayjs(thisDate, dateFormat);
5659
- const currentDate = dayjs();
5660
- const currentHour = Number(dayjs().format("HHmm"));
5661
- const isLoading = this.state.isLoading;
5662
- let morningOrAfternoonHours;
5663
- if (isMorning) {
5664
- morningOrAfternoonHours = hours?.filter((hour) => {
5665
- return (parsingDay.isSame(currentDate, "day") && currentHour <= Number(hour.hour) || !parsingDay.isSame(currentDate, "day") && Number(hour.value) + Number(overassign) > 0) && Number(hour.hour) < 1200;
5666
- });
5667
- } else {
5668
- morningOrAfternoonHours = hours?.filter((hour) => {
5669
- return (parsingDay.isSame(currentDate, "day") && currentHour <= Number(hour.hour) || !parsingDay.isSame(currentDate, "day") && Number(hour.value) + Number(overassign) > 0) && Number(hour.hour) >= 1200;
5670
- });
5671
- }
5672
- const enableHours = morningOrAfternoonHours?.filter(
5673
- (hour) => !hour.disabled
5526
+ async loadInfo(schId, weekDay, dayNumber, hour) {
5527
+ const res = await post(
5528
+ this.form.execution,
5529
+ makeApiaUrl(this.form.execution, {
5530
+ ajaxUrl: "/apia.design.TaskSchedulerAction.run",
5531
+ action: "getExecutionSchedulerDayInfo",
5532
+ schId,
5533
+ weekDay,
5534
+ dayNumber,
5535
+ hour
5536
+ })
5674
5537
  );
5675
- this.setStage({
5676
- index: 2,
5677
- newStage: {
5678
- name: "daysHours",
5679
- buttons: enableHours?.map((hour) => {
5680
- const returnButton = {
5681
- title: hour.hour,
5682
- label: `${hour.hour.slice(0, -2)}:${hour.hour.slice(2)}`,
5683
- value: hour.value,
5684
- "aria-label": hour.hour,
5685
- isSelectedSelector: () => {
5686
- return this.state?.selectedDay?.hour === hour.hour;
5687
- },
5688
- action: () => {
5689
- if (isLoading !== "NotLoading")
5690
- return;
5691
- this.setState({
5692
- selectedCell: `${hour.hour} ${String(
5693
- this.state?.selectedDay?.dayNumber
5694
- )} ${this.state?.selectedDay?.mondayWeek}`
5695
- });
5696
- this.setDay({
5697
- hour: hour.hour,
5698
- mondayWeek: this.state?.selectedDay?.mondayWeek
5699
- });
5700
- get(
5701
- this.form.execution,
5702
- makeApiaUrl(this.form.execution, {
5703
- ajaxUrl: "/apia.design.TaskSchedulerAction.run",
5704
- action: "setExecutionSchedulerSelectedDay",
5705
- weekDay: this.state?.selectedDay?.mondayWeek,
5706
- hour: hour.hour,
5707
- dayNumber: this.state?.selectedDay?.dayNumber
5708
- })
5709
- ).then(() => {
5710
- }).catch(() => {
5711
- });
5712
- }
5713
- };
5714
- return returnButton;
5715
- })
5716
- }
5717
- });
5538
+ return res?.data?.pro_instances?.pro_instance ?? [];
5718
5539
  }
5719
- async deleteDate() {
5720
- this.setState({ isLoading: "DeleteWeek" });
5721
- get(
5540
+ async markDay(weekDay, hour, dayNumber) {
5541
+ await get(
5722
5542
  this.form.execution,
5723
5543
  makeApiaUrl(this.form.execution, {
5724
5544
  ajaxUrl: "/apia.design.TaskSchedulerAction.run",
5725
- action: "clearExecutionSchedulerSelectedDay"
5545
+ action: "setExecutionSchedulerSelectedDay",
5546
+ weekDay,
5547
+ hour,
5548
+ dayNumber
5726
5549
  })
5727
- ).then((response) => {
5728
- if (response?.data?.success) {
5729
- this.setState({
5730
- selectedDay: {},
5731
- selectedCell: null,
5732
- isLoading: "NotLoading"
5733
- });
5734
- this.makeDaysStage();
5735
- }
5736
- }).catch(() => {
5737
- });
5738
- }
5739
- async goNextWeek() {
5740
- if (this.state.isLoading === "NotLoading") {
5741
- this.setState({ isLoading: "NextWeek" });
5742
- await this.loadWeek(
5743
- dayjs(this.state.data?.mondayWeek, dateFormat).add(7, "day").format(dateFormat)
5744
- );
5745
- this.makeDaysStage(this.state.data);
5746
- }
5747
- }
5748
- async goPreviousWeek() {
5749
- if (this.state.isLoading === "NotLoading") {
5750
- this.setState({ isLoading: "LastWeek" });
5751
- await this.loadWeek(
5752
- dayjs(this.state.data?.mondayWeek, dateFormat).subtract(7, "day").format(dateFormat)
5753
- );
5754
- this.makeDaysStage(this.state.data);
5755
- }
5550
+ );
5756
5551
  }
5757
- getSchedulerColumns(data) {
5758
- if (!data || !data.mondayWeek) {
5759
- return [];
5760
- }
5761
- const columns = [
5762
- {
5763
- content: getWindow(this.form.execution).TSK_SCH_HOUR,
5764
- colName: "Hour",
5765
- width: "75px"
5766
- },
5767
- {
5768
- content: `${getWindow(this.form.execution).TSK_DAY_MON} ${dayjs(
5769
- data?.mondayWeek,
5770
- dateFormat
5771
- ).format("DD/MM")}`,
5772
- colName: "Monday"
5773
- },
5774
- {
5775
- content: `${getWindow(this.form.execution).TSK_DAY_TUE} ${dayjs(
5776
- data?.mondayWeek,
5777
- dateFormat
5778
- ).add(1, "day").format("DD/MM")}`,
5779
- colName: "Tuesday"
5780
- },
5781
- {
5782
- content: `${getWindow(this.form.execution).TSK_DAY_WED} ${dayjs(
5783
- data?.mondayWeek,
5784
- dateFormat
5785
- ).add(2, "day").format("DD/MM")} `,
5786
- colName: "Wednesday"
5787
- },
5788
- {
5789
- content: `${getWindow(this.form.execution).TSK_DAY_THU} ${dayjs(
5790
- data?.mondayWeek,
5791
- dateFormat
5792
- ).add(3, "day").format("DD/MM")}`,
5793
- colName: "Thursday"
5794
- },
5795
- {
5796
- content: `${getWindow(this.form.execution).TSK_DAY_FRI} ${dayjs(
5797
- data?.mondayWeek,
5798
- dateFormat
5799
- ).add(4, "day").format("DD/MM")}`,
5800
- colName: "Friday"
5801
- },
5802
- {
5803
- content: `${getWindow(this.form.execution).TSK_DAY_SAT} ${dayjs(
5804
- data?.mondayWeek,
5805
- dateFormat
5806
- ).add(5, "day").format("DD/MM")}`,
5807
- colName: "Saturday"
5808
- },
5809
- {
5810
- content: `${getWindow(this.form.execution).TSK_DAY_SUN} ${dayjs(
5811
- data?.mondayWeek,
5812
- dateFormat
5813
- ).add(6, "day").format("DD/MM")}`,
5814
- colName: "Sunday"
5815
- }
5816
- ];
5817
- return columns;
5552
+ get schedController() {
5553
+ return this._schedController;
5818
5554
  }
5819
5555
  }
5820
5556
 
@@ -6172,12 +5908,12 @@ class ButtonField extends ApiaField {
6172
5908
  clearValue() {
6173
5909
  __privateGet$g(this, _field$d).properties.value = "";
6174
5910
  }
5911
+ setValue(value) {
5912
+ this.setProperty("value", value);
5913
+ }
6175
5914
  }
6176
5915
  _field$d = new WeakMap();
6177
5916
 
6178
- class EditorField extends ApiaField {
6179
- }
6180
-
6181
5917
  var __accessCheck$f = (obj, member, msg) => {
6182
5918
  if (!member.has(obj))
6183
5919
  throw TypeError("Cannot " + msg);
@@ -6244,6 +5980,9 @@ class ApiaFieldWithAttribute extends ApiaField {
6244
5980
  }
6245
5981
  _field$c = new WeakMap();
6246
5982
 
5983
+ class EditorField extends ApiaFieldWithAttribute {
5984
+ }
5985
+
6247
5986
  var __accessCheck$e = (obj, member, msg) => {
6248
5987
  if (!member.has(obj))
6249
5988
  throw TypeError("Cannot " + msg);
@@ -6755,6 +6494,9 @@ class TextField extends ApiaField {
6755
6494
  `Apia JSApi Error: The field ${__privateGet$7(this, _field$4).definition.fieldType} does not use a label`
6756
6495
  );
6757
6496
  }
6497
+ setValue(value) {
6498
+ this.setProperty("value", value);
6499
+ }
6758
6500
  }
6759
6501
  _field$4 = new WeakMap();
6760
6502
 
@@ -6979,13 +6721,15 @@ class GridField extends ApiaField {
6979
6721
  );
6980
6722
  }
6981
6723
  getAllColumns() {
6982
- return __privateGet$5(this, _field$2).getAllColumns().map((c) => c.map((f) => createNewField(this.form.execution, f)));
6724
+ return __privateGet$5(this, _field$2).getAllColumns().map(
6725
+ (c) => c.map((f) => createNewField(__privateGet$5(this, _field$2).getForm().execution, f))
6726
+ );
6983
6727
  }
6984
6728
  getColumn(fieldName) {
6985
6729
  const fields = __privateGet$5(this, _field$2).getColumn(fieldName);
6986
6730
  if (fields) {
6987
6731
  return arrayOrArray(fields).map(
6988
- (c) => createNewField(this.form.execution, c)
6732
+ (c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c)
6989
6733
  );
6990
6734
  }
6991
6735
  return [];
@@ -6996,7 +6740,10 @@ class GridField extends ApiaField {
6996
6740
  getField(fieldName, fieldIndex) {
6997
6741
  const fields = __privateGet$5(this, _field$2).getField(fieldName, fieldIndex);
6998
6742
  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));
6743
+ return fieldIndex !== void 0 ? createNewField(
6744
+ __privateGet$5(this, _field$2).getForm().execution,
6745
+ arrayOrArray(fields)[0]
6746
+ ) : arrayOrArray(fields).map((c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c)).filter((c) => Boolean(c));
7000
6747
  }
7001
6748
  return null;
7002
6749
  }
@@ -7007,7 +6754,7 @@ class GridField extends ApiaField {
7007
6754
  return __privateGet$5(this, _field$2).pageSize;
7008
6755
  }
7009
6756
  getRow(index) {
7010
- return __privateGet$5(this, _field$2).getRowByFieldIndex(index)?.map((c) => createNewField(this.form.execution, c));
6757
+ return __privateGet$5(this, _field$2).getRowByFieldIndex(index)?.map((c) => createNewField(__privateGet$5(this, _field$2).getForm().execution, c));
7011
6758
  }
7012
6759
  getSelection() {
7013
6760
  const selected = __privateGet$5(this, _field$2).getSelectedRows();
@@ -7015,7 +6762,7 @@ class GridField extends ApiaField {
7015
6762
  selected.forEach((r) => {
7016
6763
  const row = [];
7017
6764
  r.forEach((c) => {
7018
- const fld = createNewField(this.form.execution, c);
6765
+ const fld = createNewField(__privateGet$5(this, _field$2).getForm().execution, c);
7019
6766
  if (fld) {
7020
6767
  row.push(fld);
7021
6768
  }
@@ -7299,16 +7046,13 @@ class ApiaFunctions {
7299
7046
  this.actionButton(actualId)?.disable();
7300
7047
  }
7301
7048
  disableOptionButton(id) {
7302
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7303
- this.disableActionButton(actualId);
7049
+ this.disableActionButton(id);
7304
7050
  }
7305
7051
  enableActionButton(id) {
7306
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7307
- this.actionButton(actualId)?.enable();
7052
+ this.actionButton(id)?.enable();
7308
7053
  }
7309
7054
  enableOptionButton(id) {
7310
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7311
- this.enableActionButton(actualId);
7055
+ this.enableActionButton(id);
7312
7056
  }
7313
7057
  getAllForms() {
7314
7058
  return this.execution.getAllForms().map((c) => new ApiaForm(this.execution, c));
@@ -7331,38 +7075,38 @@ class ApiaFunctions {
7331
7075
  getButtonAction(id) {
7332
7076
  let btnId;
7333
7077
  switch (id) {
7334
- case (ActionsController.CLOSE || "CLOSE"):
7335
- btnId = "CLOSE";
7078
+ case ActionsController.CLOSE:
7079
+ btnId = "btnClose";
7336
7080
  break;
7337
- case (ActionsController.CONFIRM || "CONFIRM"):
7338
- btnId = "CONFIRM";
7081
+ case ActionsController.CONFIRM:
7082
+ btnId = "btnCon";
7339
7083
  break;
7340
- case (ActionsController.DELEGATE || "DELEGATE"):
7341
- btnId = "DELEGATE";
7084
+ case ActionsController.DELEGATE:
7085
+ btnId = "lblExeDelegar";
7342
7086
  break;
7343
- case (ActionsController.NEXT || "NEXT"):
7344
- btnId = "NEXT";
7087
+ case ActionsController.NEXT:
7088
+ btnId = "btnSig";
7345
7089
  break;
7346
- case (ActionsController.PREVIOUS || "PREVIOUS"):
7347
- btnId = "PREVIOUS";
7090
+ case ActionsController.PREVIOUS:
7091
+ btnId = "btnAnt";
7348
7092
  break;
7349
- case (ActionsController.PRINT || "PRINT"):
7350
- btnId = "PRINT";
7093
+ case ActionsController.PRINT:
7094
+ btnId = "btnStaPri";
7351
7095
  break;
7352
- case (ActionsController.RELEASE || "RELEASE"):
7353
- btnId = "RELEASE";
7096
+ case ActionsController.RELEASE:
7097
+ btnId = "btnEjeLib";
7354
7098
  break;
7355
- case (ActionsController.SAVE || "SAVE"):
7356
- btnId = "SAVE";
7099
+ case ActionsController.SAVE:
7100
+ btnId = "btnGua";
7357
7101
  break;
7358
- case (ActionsController.SIGN || "SIGN"):
7359
- btnId = "SIGN";
7102
+ case ActionsController.SIGN:
7103
+ btnId = "btnSig";
7360
7104
  break;
7361
- case (ActionsController.SHARE || "SHARE"):
7362
- btnId = "SHARE";
7105
+ case ActionsController.SHARE:
7106
+ btnId = "lblShareMsg";
7363
7107
  break;
7364
- case (ActionsController.VIEW_DOCS || "VIEW_DOCS"):
7365
- btnId = "VIEW_DOCS";
7108
+ case ActionsController.VIEW_DOCS:
7109
+ btnId = "sbtEjeDoc";
7366
7110
  break;
7367
7111
  default:
7368
7112
  throw new Error(`There is no button with id ${id}`);
@@ -7373,13 +7117,13 @@ class ApiaFunctions {
7373
7117
  return getWindow(this.execution).LANG_CODE;
7374
7118
  }
7375
7119
  getCurrentProcessName() {
7376
- return this.execution.getProcess().name ?? null;
7120
+ return this.execution.environment.properties?.processName ?? "";
7377
7121
  }
7378
7122
  getCurrentStep() {
7379
7123
  return this.execution.currentStep;
7380
7124
  }
7381
7125
  getCurrentTaskName() {
7382
- return this.execution.getCurrentTask().name;
7126
+ return this.execution.environment.properties?.taskName ?? "";
7383
7127
  }
7384
7128
  getEntityForm(frmName) {
7385
7129
  const frm = this.getForm(frmName, "E");
@@ -7400,19 +7144,19 @@ class ApiaFunctions {
7400
7144
  return pForm;
7401
7145
  }
7402
7146
  getLastModalReturn() {
7403
- return getWindow(this.execution).lastModalReturn;
7147
+ return this.execution.getLastModalReturn();
7404
7148
  }
7405
7149
  getModalReturn() {
7406
7150
  return this.getLastModalReturn();
7407
7151
  }
7408
7152
  getModalSelectedRow() {
7409
- return getWindow(this.execution).lastModalReturn.slice(2);
7153
+ return this.execution.getLastModalReturn()?.slice(2);
7410
7154
  }
7411
7155
  getModalShowValue() {
7412
- return getWindow(this.execution).lastModalReturn[1];
7156
+ return this.execution.getLastModalReturn()[1];
7413
7157
  }
7414
7158
  getModalValue() {
7415
- return getWindow(this.execution).lastModalReturn[0];
7159
+ return this.execution.getLastModalReturn()[0];
7416
7160
  }
7417
7161
  getProcessForm(frmName) {
7418
7162
  const frm = this.getForm(frmName, "P");
@@ -7431,12 +7175,10 @@ class ApiaFunctions {
7431
7175
  return null;
7432
7176
  }
7433
7177
  hideActionButton(id) {
7434
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7435
- this.actionButton(actualId)?.hide();
7178
+ this.actionButton(id)?.hide();
7436
7179
  }
7437
7180
  hideOptionButton(id) {
7438
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7439
- this.hideActionButton(actualId);
7181
+ this.hideActionButton(id);
7440
7182
  }
7441
7183
  saveTask() {
7442
7184
  this.execution.doSave().then((res) => {
@@ -7446,18 +7188,15 @@ class ApiaFunctions {
7446
7188
  }
7447
7189
  setLastModalReturn(value) {
7448
7190
  getWindow(this.execution).lastModalReturn = value;
7449
- getWindow(this.execution).lastModalReturn = value;
7450
7191
  }
7451
7192
  setStepTitle(stepNumber, stepTitle) {
7452
7193
  this.execution.setStepTitle(stepNumber, stepTitle);
7453
7194
  }
7454
7195
  showActionButton(id) {
7455
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7456
- this.actionButton(actualId)?.show();
7196
+ this.actionButton(id)?.show();
7457
7197
  }
7458
7198
  showOptionButton(id) {
7459
- const actualId = typeof id === "number" ? this.getButtonAction(id) : id;
7460
- this.showActionButton(actualId);
7199
+ this.showActionButton(id);
7461
7200
  }
7462
7201
  viewAdmEntity(entName, entNum) {
7463
7202
  this.admEntity(entName, entNum);
@@ -7504,8 +7243,14 @@ class CustomComponent {
7504
7243
  isLoading: false,
7505
7244
  attributes: {},
7506
7245
  properties: {},
7507
- additional: {}
7246
+ additional: {},
7247
+ component: null
7508
7248
  });
7249
+ if (definition.error_while_processing) {
7250
+ throw new Error(
7251
+ `Cannot initialize custom component ${definition.name}: ${definition.error_while_processing}`
7252
+ );
7253
+ }
7509
7254
  makeObservable(this, {
7510
7255
  _state: observable,
7511
7256
  state: computed
@@ -7513,7 +7258,7 @@ class CustomComponent {
7513
7258
  this.parseStateObject(definition.state.state);
7514
7259
  }
7515
7260
  get state() {
7516
- return freezeDeep(toJS(this._state));
7261
+ return toJS(this._state);
7517
7262
  }
7518
7263
  getAdditional() {
7519
7264
  return this.state.additional;
@@ -7613,7 +7358,7 @@ class CustomComponent {
7613
7358
  console.error(e);
7614
7359
  this.form.execution.notifications.add(
7615
7360
  new MessageNotification({
7616
- message: labels.errorOnEvent(event.name, def.fncName),
7361
+ message: labels.errorOnEvent(this.execution, def.fncName),
7617
7362
  type: "error"
7618
7363
  })
7619
7364
  );
@@ -7657,9 +7402,9 @@ class CustomComponent {
7657
7402
  frmParent: this.form.definition.frmParent
7658
7403
  }),
7659
7404
  {
7660
- postData: {
7405
+ postData: typeof body === "string" ? {
7661
7406
  payload: body
7662
- },
7407
+ } : body,
7663
7408
  postDataTreatment: "stringify"
7664
7409
  }
7665
7410
  );
@@ -7682,7 +7427,7 @@ class CustomComponent {
7682
7427
  }
7683
7428
  }
7684
7429
  getStringValue(attName) {
7685
- return this._state.attributes[attName]?.join();
7430
+ return this._state.attributes[attName]?.join("");
7686
7431
  }
7687
7432
  getValue(attName, index = 0) {
7688
7433
  return this._state.attributes[attName]?.[index];
@@ -7763,73 +7508,68 @@ class CustomComponent {
7763
7508
  this._state.isLoading = false;
7764
7509
  }
7765
7510
  }
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
- }
7511
+ async download(attName, index) {
7512
+ this._state.isLoading = true;
7513
+ try {
7514
+ const data = await this.processResult(
7515
+ (await this.postMessage("download", { attName, index }))?.data
7516
+ );
7517
+ if (data?.url) {
7518
+ window.open(data.url, "_blank");
7790
7519
  }
7791
- );
7792
- const result = await parseSuccessfulResponse(
7793
- this.execution,
7794
- response
7795
- );
7796
- return await this.processResult(
7797
- result
7798
- );
7520
+ } finally {
7521
+ this._state.isLoading = false;
7522
+ }
7799
7523
  }
7800
- }
7801
- _hasInited = new WeakMap();
7802
-
7803
- function decodeBase64ToUtf8(base64String) {
7804
- const binaryString = atob(base64String);
7805
- const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
7806
- return new TextDecoder("utf-8").decode(bytes);
7807
- }
7808
- async function getFormXMLDataAsObj(formDiv) {
7809
- if (formDiv.dataset.xml) {
7810
- const formData = await parseXml(
7811
- decodeBase64ToUtf8(formDiv.dataset.xml)
7812
- );
7813
- return formData;
7524
+ async upload(attName, file, options) {
7525
+ this._state.isLoading = true;
7526
+ try {
7527
+ const formData = new FormData();
7528
+ formData.append("file", file);
7529
+ Object.entries(options?.params || {}).forEach(
7530
+ ([key, value]) => formData.append(key, value)
7531
+ );
7532
+ const response = await axios.post(
7533
+ await makeApiaUrl(this.execution, {
7534
+ ajaxUrl: actions.forms,
7535
+ action: "cusCmpProcess",
7536
+ method: "upload",
7537
+ cmpId: this.definition.id,
7538
+ frmId: this.form.definition.id,
7539
+ frmParent: this.form.definition.frmParent,
7540
+ attName,
7541
+ originalName: file.name
7542
+ }),
7543
+ formData,
7544
+ {
7545
+ signal: options?.signal,
7546
+ onUploadProgress({ total, progress }) {
7547
+ const percent = Math.round((progress || 0) / (total || 1) * 100 * 100) / 100;
7548
+ options?.onUploadProgress?.(percent);
7549
+ }
7550
+ }
7551
+ );
7552
+ const result = await parseSuccessfulResponse(
7553
+ this.execution,
7554
+ response
7555
+ );
7556
+ return await this.processResult(
7557
+ result
7558
+ );
7559
+ } finally {
7560
+ this._state.isLoading = false;
7561
+ }
7814
7562
  }
7815
- return null;
7816
- }
7817
- async function readFormsDefinition(execution) {
7818
- const elements = [
7819
- ...getDocument(execution).querySelectorAll(".formContainer")
7820
- ];
7821
- const forms = [];
7822
- for await (const form of elements) {
7823
- const def = await getFormXMLDataAsObj(form);
7824
- if (def)
7825
- forms.push(def);
7563
+ setState(prop, value) {
7564
+ this._state[prop] = value;
7826
7565
  }
7827
- return forms;
7828
7566
  }
7567
+ _hasInited = new WeakMap();
7829
7568
 
7830
- class InitialData {
7831
- static getFormsDefinition(execution) {
7832
- return readFormsDefinition(execution);
7569
+ class StatusNotification extends Notification {
7570
+ constructor(props) {
7571
+ super(props);
7572
+ this.props = props;
7833
7573
  }
7834
7574
  }
7835
7575
 
@@ -7839,24 +7579,67 @@ var __publicField$6 = (obj, key, value) => {
7839
7579
  __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
7840
7580
  return value;
7841
7581
  };
7582
+ class Notifications {
7583
+ constructor(execution) {
7584
+ this.execution = execution;
7585
+ __publicField$6(this, "emitter", new EventEmitter());
7586
+ __publicField$6(this, "notifications", []);
7587
+ __publicField$6(this, "on", this.emitter.on.bind(this.emitter));
7588
+ makeObservable(this, {
7589
+ notifications: observable,
7590
+ add: action,
7591
+ remove: action
7592
+ });
7593
+ }
7594
+ add(notification) {
7595
+ this.notifications.push(notification);
7596
+ this.emitter.emit("notification", notification);
7597
+ }
7598
+ closeTab() {
7599
+ this.emitter.emit("closeTab", null);
7600
+ }
7601
+ getAll() {
7602
+ return this.notifications;
7603
+ }
7604
+ getById(id) {
7605
+ return this.notifications.find((c) => c.id === id);
7606
+ }
7607
+ kill() {
7608
+ this.emitter.emit("kill", null);
7609
+ }
7610
+ remove(notification) {
7611
+ this.notifications = this.notifications.filter((c) => {
7612
+ if (typeof notification === "string" || typeof notification === "number")
7613
+ return c.id !== notification;
7614
+ return c !== notification;
7615
+ });
7616
+ }
7617
+ }
7618
+
7619
+ var __defProp$5 = Object.defineProperty;
7620
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7621
+ var __publicField$5 = (obj, key, value) => {
7622
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
7623
+ return value;
7624
+ };
7842
7625
  class Form extends WithProperties {
7843
7626
  constructor(execution, definition) {
7844
7627
  const props = parseFakeJSON$1(definition.properties);
7845
7628
  super(props);
7846
7629
  this.execution = execution;
7847
- __publicField$6(this, "fields");
7848
- __publicField$6(this, "state", { isMarkedToSign: false });
7849
- __publicField$6(this, "_customComponents", /* @__PURE__ */ new Map());
7850
- __publicField$6(this, "fieldsById", /* @__PURE__ */ new Map());
7851
- __publicField$6(this, "fieldsByName", /* @__PURE__ */ new Map());
7852
- __publicField$6(this, "fieldsByAttributeId", /* @__PURE__ */ new Map());
7853
- __publicField$6(this, "fieldsByAttributeName", /* @__PURE__ */ new Map());
7854
- __publicField$6(this, "fieldsGroups", /* @__PURE__ */ new Map());
7855
- __publicField$6(this, "definition", {});
7856
- __publicField$6(this, "cucCmpByAttId", /* @__PURE__ */ new Map());
7857
- __publicField$6(this, "cucCmpByFldId", /* @__PURE__ */ new Map());
7858
- __publicField$6(this, "cucCmpByAttName", /* @__PURE__ */ new Map());
7859
- __publicField$6(this, "mustRenderFields", []);
7630
+ __publicField$5(this, "fields");
7631
+ __publicField$5(this, "state", { isMarkedToSign: false });
7632
+ __publicField$5(this, "_customComponents", /* @__PURE__ */ new Map());
7633
+ __publicField$5(this, "fieldsById", /* @__PURE__ */ new Map());
7634
+ __publicField$5(this, "fieldsByName", /* @__PURE__ */ new Map());
7635
+ __publicField$5(this, "fieldsByAttributeId", /* @__PURE__ */ new Map());
7636
+ __publicField$5(this, "fieldsByAttributeName", /* @__PURE__ */ new Map());
7637
+ __publicField$5(this, "fieldsGroups", /* @__PURE__ */ new Map());
7638
+ __publicField$5(this, "definition", {});
7639
+ __publicField$5(this, "cucCmpByAttId", /* @__PURE__ */ new Map());
7640
+ __publicField$5(this, "cucCmpByFldId", /* @__PURE__ */ new Map());
7641
+ __publicField$5(this, "cucCmpByAttName", /* @__PURE__ */ new Map());
7642
+ __publicField$5(this, "mustRenderFields", []);
7860
7643
  makeObservable(this, {
7861
7644
  state: observable,
7862
7645
  allFields: computed,
@@ -8079,10 +7862,10 @@ class Form extends WithProperties {
8079
7862
  }
8080
7863
  async fireScriptEvent(eventName) {
8081
7864
  if (eventName === "onLoad") {
8082
- const mapEvent = window[`LOAD_RELOAD_MAP_${this.definition.frmParent}`];
7865
+ const mapEvent = getWindow(this.execution)[`LOAD_RELOAD_MAP_${this.definition.frmParent}`];
8083
7866
  const mappedEvent = mapEvent ? mapEvent[this.definition.formName] : void 0;
8084
7867
  const actualMapEvent = mapEvent && (!mappedEvent || mappedEvent === "load" ? "onLoad" : "onReload");
8085
- eventName = actualMapEvent || (window.IS_RELOAD ? "onReload" : "onLoad");
7868
+ eventName = actualMapEvent || (getWindow(this.execution).IS_RELOAD ? "onReload" : "onLoad");
8086
7869
  }
8087
7870
  const events = (this.definition.scriptEvents || []).filter(
8088
7871
  (c) => c.evtName === eventName
@@ -8090,7 +7873,7 @@ class Form extends WithProperties {
8090
7873
  if (events.length > 0) {
8091
7874
  for (const event of events) {
8092
7875
  try {
8093
- const fn = window[event.fncName];
7876
+ const fn = getWindow(this.execution)[event.fncName];
8094
7877
  const result = await fn(
8095
7878
  new ApiaForm(this.execution, this),
8096
7879
  ...await this.getScriptEventParams(event.fncParams)
@@ -8102,7 +7885,7 @@ class Form extends WithProperties {
8102
7885
  console.error(e);
8103
7886
  this.execution.notifications.add(
8104
7887
  new MessageNotification({
8105
- message: labels.errorOnEvent(eventName, event.evtName),
7888
+ message: labels.errorOnEvent(this.execution, event.fncName) + e,
8106
7889
  type: "error"
8107
7890
  })
8108
7891
  );
@@ -8135,6 +7918,39 @@ class Form extends WithProperties {
8135
7918
  }
8136
7919
  }
8137
7920
 
7921
+ function decodeBase64ToUtf8(base64String) {
7922
+ const binaryString = atob(base64String);
7923
+ const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
7924
+ return new TextDecoder("utf-8").decode(bytes);
7925
+ }
7926
+ async function getFormXMLDataAsObj(formDiv) {
7927
+ if (formDiv.dataset.xml) {
7928
+ const formData = await parseXml(
7929
+ decodeBase64ToUtf8(formDiv.dataset.xml)
7930
+ );
7931
+ return formData;
7932
+ }
7933
+ return null;
7934
+ }
7935
+ async function readFormsDefinition(execution) {
7936
+ const elements = [
7937
+ ...getDocument(execution).querySelectorAll(".formContainer")
7938
+ ];
7939
+ const forms = [];
7940
+ for await (const form of elements) {
7941
+ const def = await getFormXMLDataAsObj(form);
7942
+ if (def)
7943
+ forms.push(def);
7944
+ }
7945
+ return forms;
7946
+ }
7947
+
7948
+ class InitialData {
7949
+ static getFormsDefinition(execution) {
7950
+ return readFormsDefinition(execution);
7951
+ }
7952
+ }
7953
+
8138
7954
  const defaultFieldsMap = Object.freeze({
8139
7955
  area: () => Textarea,
8140
7956
  button: () => Button,
@@ -8163,7 +7979,7 @@ const defaultFieldsMap = Object.freeze({
8163
7979
  const definition = def;
8164
7980
  const value = definition.properties?.value;
8165
7981
  if (value && String(value).indexOf("schedContainer") !== -1) {
8166
- return Scheduler;
7982
+ return SchedulerField;
8167
7983
  }
8168
7984
  return Label;
8169
7985
  },
@@ -8175,46 +7991,6 @@ const defaultFieldsMap = Object.freeze({
8175
7991
  tree: () => Tree
8176
7992
  });
8177
7993
 
8178
- var __defProp$5 = Object.defineProperty;
8179
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8180
- var __publicField$5 = (obj, key, value) => {
8181
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
8182
- return value;
8183
- };
8184
- class Notifications {
8185
- constructor(execution) {
8186
- this.execution = execution;
8187
- __publicField$5(this, "emitter", new EventEmitter());
8188
- __publicField$5(this, "notifications", []);
8189
- __publicField$5(this, "on", this.emitter.on.bind(this.emitter));
8190
- makeObservable(this, {
8191
- notifications: observable,
8192
- add: action,
8193
- remove: action
8194
- });
8195
- }
8196
- add(notification) {
8197
- this.notifications.push(notification);
8198
- this.emitter.emit("notification", notification);
8199
- }
8200
- closeTab() {
8201
- this.emitter.emit("closeTab", null);
8202
- }
8203
- getAll() {
8204
- return this.notifications;
8205
- }
8206
- getById(id) {
8207
- return this.notifications.find((c) => c.id === id);
8208
- }
8209
- remove(notification) {
8210
- this.notifications = this.notifications.filter((c) => {
8211
- if (typeof notification === "string" || typeof notification === "number")
8212
- return c.id !== notification;
8213
- return c !== notification;
8214
- });
8215
- }
8216
- }
8217
-
8218
7994
  var __defProp$4 = Object.defineProperty;
8219
7995
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8220
7996
  var __publicField$4 = (obj, key, value) => {
@@ -8454,6 +8230,9 @@ class Entity {
8454
8230
  const result = {
8455
8231
  busEntSta: this.state?.status.value ?? ""
8456
8232
  };
8233
+ if (this.state?.identifier?.body?.value) {
8234
+ result.txtEntNum = this.state?.identifier.body.value ?? "";
8235
+ }
8457
8236
  if (this.state?.categories) {
8458
8237
  result.catId = this.state?.categories.map((c) => c.id);
8459
8238
  this.state?.categories.filter((c) => c.checked).forEach((c) => {
@@ -8651,13 +8430,13 @@ let ShowSignSelection$1 = class ShowSignSelection extends FlowModal$1 {
8651
8430
  }
8652
8431
  };
8653
8432
 
8654
- let ShowConfirmMessage$1 = class ShowConfirmMessage extends FlowModal$1 {
8433
+ class ShowConfirmMessage extends FlowModal$1 {
8655
8434
  constructor(fetchResult, confirm) {
8656
8435
  super();
8657
8436
  this.fetchResult = fetchResult;
8658
8437
  this.confirm = confirm;
8659
8438
  }
8660
- };
8439
+ }
8661
8440
 
8662
8441
  let ShowSign$1 = class ShowSign extends FlowModal$1 {
8663
8442
  constructor(fetchResult, confirm) {
@@ -8850,7 +8629,7 @@ async function defaultConfirm$1(execution, status) {
8850
8629
  }
8851
8630
  if (confirmResponse?.data?.onClose === "confirmOkOnClose") {
8852
8631
  execution.state.executionState = ExecutionState.FINISHED;
8853
- return buildConfirmMessage$1(
8632
+ return buildConfirmMessage(
8854
8633
  status,
8855
8634
  confirmResponse.data.load?.text?.label ?? ""
8856
8635
  );
@@ -8900,8 +8679,8 @@ async function defaultConfirm$1(execution, status) {
8900
8679
  step: "CHECK_WIZARD"
8901
8680
  };
8902
8681
  }
8903
- async function buildConfirmMessage$1(status, message) {
8904
- return new ShowConfirmMessage$1(message, async (result) => {
8682
+ async function buildConfirmMessage(status, message) {
8683
+ return new ShowConfirmMessage(message, async (result) => {
8905
8684
  if (result.confirmed) {
8906
8685
  return { ...status, step: "CHECK_WIZARD" };
8907
8686
  }
@@ -8919,7 +8698,8 @@ async function checkWizard(execution, status) {
8919
8698
  postDataTreatment: "stringify",
8920
8699
  stringifyOptions: {
8921
8700
  arrayFormat: "repeat"
8922
- }
8701
+ },
8702
+ allowAfterFinish: true
8923
8703
  }
8924
8704
  );
8925
8705
  if (checkWizardResponse?.data?.url) {
@@ -8999,14 +8779,6 @@ class ShowSignSelection extends FlowModal {
8999
8779
  }
9000
8780
  }
9001
8781
 
9002
- class ShowConfirmMessage extends FlowModal {
9003
- constructor(fetchResult, confirm) {
9004
- super();
9005
- this.fetchResult = fetchResult;
9006
- this.confirm = confirm;
9007
- }
9008
- }
9009
-
9010
8782
  class ShowSign extends FlowModal {
9011
8783
  constructor(fetchResult, confirm) {
9012
8784
  super();
@@ -9129,52 +8901,37 @@ async function defaultConfirm(execution, status) {
9129
8901
  step: void 0
9130
8902
  };
9131
8903
  }
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
- };
8904
+ if (confirmResponse?.data?.load?.text?.label) {
8905
+ const checkConfirmEntity = await post(
8906
+ execution,
8907
+ makeApiaUrl(execution, {
8908
+ ajaxUrl: "apia.execution.FormAction.run?",
8909
+ action: "checkAfterConfirmAjax",
8910
+ frmParent: "E",
8911
+ currentTab: 0
8912
+ })
8913
+ );
8914
+ if (checkConfirmEntity?.data?.form) {
8915
+ setAjaxFormResponse(execution, checkConfirmEntity.data?.form);
8916
+ }
8917
+ const url = arrayOrArray(confirmResponse.data.actions?.action.param)[1];
8918
+ const c = new Url(url);
8919
+ getWindow(execution).location.assign(
8920
+ makeApiaUrl(execution, {
8921
+ ajaxUrl: c.base,
8922
+ action: c.getParameter("action")
8923
+ })
8924
+ );
8925
+ (getWindow(execution)?.top?.ApiaUtil).notifications.notify({
8926
+ message: confirmResponse?.data?.load?.text?.label,
8927
+ type: "success"
8928
+ });
9164
8929
  }
9165
8930
  return {
9166
8931
  ...status,
9167
8932
  step: void 0
9168
8933
  };
9169
8934
  }
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
8935
  const checkers = {
9179
8936
  CHECK_LOCK: checkLock,
9180
8937
  CHECK_SIGN: checkSign,
@@ -9208,14 +8965,6 @@ var __publicField = (obj, key, value) => {
9208
8965
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9209
8966
  return value;
9210
8967
  };
9211
- var ExecutionState = /* @__PURE__ */ ((ExecutionState2) => {
9212
- ExecutionState2[ExecutionState2["RUNNING"] = 0] = "RUNNING";
9213
- ExecutionState2[ExecutionState2["LOADING"] = 1] = "LOADING";
9214
- ExecutionState2[ExecutionState2["FINISHED"] = 2] = "FINISHED";
9215
- ExecutionState2[ExecutionState2["RENDERING"] = 3] = "RENDERING";
9216
- ExecutionState2[ExecutionState2["CONFIRMING"] = 4] = "CONFIRMING";
9217
- return ExecutionState2;
9218
- })(ExecutionState || {});
9219
8968
  const unescapeMarkup = (str) => {
9220
8969
  if (str !== void 0 && str.length > 0) {
9221
8970
  return str.replace(/&apos;/g, "'").replace(/&quot;/g, '"').replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
@@ -9235,6 +8984,7 @@ class Execution extends EventEmitter$1 {
9235
8984
  __publicField(this, "_currentStep", 1);
9236
8985
  __publicField(this, "_stepCount", 1);
9237
8986
  __publicField(this, "notifications");
8987
+ __publicField(this, "lastModalReturn", []);
9238
8988
  __publicField(this, "formsById", {
9239
8989
  E: /* @__PURE__ */ new Map(),
9240
8990
  P: /* @__PURE__ */ new Map()
@@ -9245,7 +8995,7 @@ class Execution extends EventEmitter$1 {
9245
8995
  });
9246
8996
  __publicField(this, "state", {
9247
8997
  formsReady: [],
9248
- executionState: 1 /* LOADING */,
8998
+ executionState: ExecutionState.LOADING,
9249
8999
  locked: true,
9250
9000
  hasChangedAnything: false
9251
9001
  });
@@ -9253,7 +9003,7 @@ class Execution extends EventEmitter$1 {
9253
9003
  __publicField(this, "mustRenderForms", []);
9254
9004
  this.fieldsMapping = { ...defaultFieldsMap, ...environment.fieldsMapping };
9255
9005
  this.notifications = new Notifications(this);
9256
- makeAutoObservable(this, { fieldsMapping: false });
9006
+ makeObservable(this, { state: observable });
9257
9007
  }
9258
9008
  getAllForms() {
9259
9009
  return [...this.forms.E.values(), ...this.forms.P.values()];
@@ -9304,6 +9054,10 @@ class Execution extends EventEmitter$1 {
9304
9054
  this._stepCount = noNaN$1(getWindow(this).STEP_QTY);
9305
9055
  this._currentStep = noNaN$1(getWindow(this).CURRENT_STEP);
9306
9056
  this.executionConfig = executionConfig;
9057
+ this.environment.properties = {
9058
+ taskName: getWindow(this).CURRENT_TASK_NAME || "",
9059
+ processName: getWindow(this).CURRENT_PROCESS_NAME || ""
9060
+ };
9307
9061
  const errXML = unescapeMarkup(getWindow(this).EXEC_ERRORS);
9308
9062
  if (errXML) {
9309
9063
  const obj = parseXml(errXML);
@@ -9354,7 +9108,7 @@ class Execution extends EventEmitter$1 {
9354
9108
  const res = await InitialData.getFormsDefinition(this);
9355
9109
  try {
9356
9110
  for await (const formDefinition of res) {
9357
- if (!parseFakeJSON$1(formDefinition.properties).frmTab) {
9111
+ if (!parseFakeJSON$1(formDefinition.properties).frmTab && !parseFakeJSON$1(formDefinition.properties).frmHidden) {
9358
9112
  this.mustRenderForms.push(
9359
9113
  formDefinition.frmParent + "_" + formDefinition.formName
9360
9114
  );
@@ -9372,17 +9126,12 @@ class Execution extends EventEmitter$1 {
9372
9126
  }
9373
9127
  }
9374
9128
  this.state.formsReady = this.getAllForms();
9375
- this.state.executionState = this.mustRenderForms.length === 0 ? 0 /* RUNNING */ : 3 /* RENDERING */;
9129
+ this.state.executionState = this.mustRenderForms.length === 0 ? ExecutionState.RUNNING : ExecutionState.RENDERING;
9376
9130
  this.state.locked = false;
9377
9131
  this.fireEvents("onLoad");
9378
9132
  } catch (e) {
9379
- console.error(e);
9380
- this.notifications.add(
9381
- new MessageNotification({
9382
- type: "error",
9383
- message: labels.errorLoadForms()
9384
- })
9385
- );
9133
+ this.state.executionState = ExecutionState.FINISHED_WITH_ERROR;
9134
+ throw e;
9386
9135
  }
9387
9136
  }
9388
9137
  getHiddenForms() {
@@ -9395,8 +9144,8 @@ class Execution extends EventEmitter$1 {
9395
9144
  this.mustRenderForms = this.mustRenderForms.filter(
9396
9145
  (c) => c !== frmParent + "_" + frmName
9397
9146
  );
9398
- if (this.mustRenderForms.length - this.getHiddenForms().length === 0) {
9399
- this.state.executionState = 0 /* RUNNING */;
9147
+ if (this.mustRenderForms.length === 0) {
9148
+ this.state.executionState = ExecutionState.RUNNING;
9400
9149
  }
9401
9150
  }
9402
9151
  async delegate() {
@@ -9506,11 +9255,11 @@ class Execution extends EventEmitter$1 {
9506
9255
  }
9507
9256
  );
9508
9257
  if (data?.data?.text) {
9509
- this.state.executionState = 2 /* FINISHED */;
9258
+ this.state.executionState = ExecutionState.FINISHED;
9510
9259
  }
9511
9260
  return data;
9512
9261
  }
9513
- async doNext() {
9262
+ async doNext(result) {
9514
9263
  const isValid = await this.validate();
9515
9264
  if (isValid === true) {
9516
9265
  if (!await this.fireEvents("onSubmit")) {
@@ -9543,7 +9292,6 @@ class Execution extends EventEmitter$1 {
9543
9292
  makeApiaUrl(this, {
9544
9293
  action: "hasSignableForms",
9545
9294
  isAjax: true,
9546
- prevSteps: true,
9547
9295
  appletToken: getWindow(this).appletToken
9548
9296
  }),
9549
9297
  {
@@ -9556,6 +9304,17 @@ class Execution extends EventEmitter$1 {
9556
9304
  if (checkSignableFormsRes?.status !== 200) {
9557
9305
  throw new Error("No signable forms available.");
9558
9306
  }
9307
+ const mustShowSignModal = checkSignableFormsRes?.data?.sign;
9308
+ if (mustShowSignModal && !result?.signed) {
9309
+ return new ShowSignSelection$1(
9310
+ checkSignableFormsRes?.data,
9311
+ async () => {
9312
+ return "";
9313
+ }
9314
+ );
9315
+ }
9316
+ if (mustShowSignModal && (!result?.confirmed || !result?.signed))
9317
+ return;
9559
9318
  const nextUrl = makeApiaUrl(this, {
9560
9319
  action: "gotoNextStep",
9561
9320
  asXML: true,
@@ -9604,6 +9363,14 @@ class Execution extends EventEmitter$1 {
9604
9363
  if (this._steps)
9605
9364
  return this._steps[step];
9606
9365
  }
9366
+ /**
9367
+ * Ends the current session
9368
+ */
9369
+ kill() {
9370
+ frameElement?.handleDeadSession?.();
9371
+ this.state.executionState = ExecutionState.FINISHED;
9372
+ this.notifications.kill();
9373
+ }
9607
9374
  async viewDocs() {
9608
9375
  const url = `${getWindow(this).CONTEXT}/react/generic/docExecutionModal.jsp?isProcessMonitor=${getWindow(this).IN_MONITOR_PROCESS ?? "false"}&isTaskMonitor=${getWindow(this).IN_MONITOR_TASK ?? "false"}&isTask=true${getWindow(this).TAB_ID_REQUEST}&react=true`;
9609
9376
  const result = await get(this, url);
@@ -9632,6 +9399,12 @@ class Execution extends EventEmitter$1 {
9632
9399
  }
9633
9400
  return firstInvalid ?? true;
9634
9401
  }
9402
+ setLastModalReturn(value) {
9403
+ this.lastModalReturn = value;
9404
+ }
9405
+ getLastModalReturn() {
9406
+ return this.lastModalReturn;
9407
+ }
9635
9408
  async fireEvents(evt) {
9636
9409
  let result = true;
9637
9410
  for await (const f of this.forms.E.values()) {
@@ -9650,12 +9423,5 @@ class Execution extends EventEmitter$1 {
9650
9423
  }
9651
9424
  }
9652
9425
 
9653
- class StatusNotification extends Notification {
9654
- constructor(props) {
9655
- super(props);
9656
- this.props = props;
9657
- }
9658
- }
9659
-
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 };
9426
+ 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, 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, UploaderModalController, createNewField, deepEqual, get, getLabel, isHtmlResponse, isJsonResponse, isOneClickUploadEnabled, isXmlResponse, makeApiaUrl, parseFakeJSON$1 as parseFakeJSON, parseFileDefinition, parseSuccessfulResponse, parseXml, post, returnExactlyTheSame, shallowEqual };
9661
9427
  //# sourceMappingURL=index.js.map