@apia/execution 4.0.43 → 4.0.44

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
@@ -10,6 +10,7 @@ import dayjs from 'dayjs';
10
10
  import customParseFormat from 'dayjs/plugin/customParseFormat';
11
11
  import { MobXTree } from '@apia/tree2-controller';
12
12
  import { Scheduler } from '@apia/scheduler-controller';
13
+ export { Scheduler } from '@apia/scheduler-controller';
13
14
 
14
15
  const deepEqual = (a, b) => {
15
16
  if (Object.is(a, b))
@@ -403,44 +404,63 @@ function replaceLabelHtmlValues(o) {
403
404
  }
404
405
  return o;
405
406
  }
406
- const parseXml = (xml, behaveConfig) => {
407
- let objJS;
408
- if (typeof xml === "object" && !(xml instanceof XMLDocument)) {
409
- return xml;
410
- }
411
- const parser = new xml2js.Parser({
412
- trim: !behaveConfig?.avoidTrimXml,
413
- normalize: !behaveConfig?.avoidNormalize,
407
+ function customBooleanProcessor(value, name) {
408
+ if (name === "value")
409
+ return value;
410
+ return parseBooleans(value);
411
+ }
412
+ function getDefaultXmlParserOptions(behaveConfig) {
413
+ return {
414
+ trim: true,
415
+ normalize: true,
414
416
  explicitRoot: false,
415
417
  mergeAttrs: true,
416
418
  explicitArray: false,
417
419
  charkey: "label",
418
420
  attrValueProcessors: [
419
- parseBooleans,
421
+ customBooleanProcessor,
420
422
  processStringObj,
421
423
  processAjaxEventResponse
422
424
  ],
423
425
  tagNameProcessors: [processAjaxEventTagNames],
424
426
  attrNameProcessors: [processAjaxEventAttrNames]
425
- });
426
- parser.parseString(
427
- xml,
428
- (err, result) => {
429
- if (err) {
430
- console.warn("Error Parsing XML data", err);
431
- objJS = err;
432
- } else {
433
- if (result?.code === "-1" && result.exceptions) {
434
- throw new InvalidSessionException();
427
+ };
428
+ }
429
+ function getDefaultXmlPostProcessor() {
430
+ return (xml, parser) => {
431
+ let objJS;
432
+ parser.parseString(
433
+ xml,
434
+ (err, result) => {
435
+ if (err) {
436
+ console.warn("Error Parsing XML data", err);
437
+ objJS = err;
438
+ } else {
439
+ if (result?.code === "-1" && result.exceptions) {
440
+ throw new InvalidSessionException();
441
+ }
442
+ objJS = result;
435
443
  }
436
- objJS = result;
437
444
  }
445
+ );
446
+ if (objJS) {
447
+ return typeof objJS === "object" && objJS ? replaceLabelHtmlValues(objJS) : objJS;
438
448
  }
439
- );
440
- if (objJS) {
441
- return typeof objJS === "object" && objJS ? replaceLabelHtmlValues(objJS) : objJS;
449
+ return {};
450
+ };
451
+ }
452
+ function getDefaultXmlParser(behaveConfig) {
453
+ return (xml, _behaveConfig) => {
454
+ const parser = new xml2js.Parser(getDefaultXmlParserOptions());
455
+ return getDefaultXmlPostProcessor()(xml, parser);
456
+ };
457
+ }
458
+ const parseXml = (xml, behaveConfig) => {
459
+ if (typeof xml === "object" && !(xml instanceof XMLDocument)) {
460
+ return xml;
442
461
  }
443
- return {};
462
+ const parser = behaveConfig?.xmlParser ?? getDefaultXmlParser();
463
+ return parser(xml, behaveConfig);
444
464
  };
445
465
 
446
466
  function getWindow(execution) {
@@ -891,7 +911,7 @@ class BouncingEmitter extends StatefulEmitter {
891
911
  }
892
912
 
893
913
  function getLabel(execution, label, replacers) {
894
- const original = getWindow(execution).labels[label];
914
+ const original = getWindow(execution)?.labels?.[label];
895
915
  if (!original) {
896
916
  return {
897
917
  text: `LblNotPrealoded: ${label}`,
@@ -1381,6 +1401,11 @@ class Field extends WithProperties {
1381
1401
  try {
1382
1402
  let result = await this.fireScriptEvent(eventName);
1383
1403
  if (result) {
1404
+ try {
1405
+ await this.form.execution.waitForPendingSyncs();
1406
+ } catch (e) {
1407
+ console.warn("waitForPendingSyncs failed or timed out", e);
1408
+ }
1384
1409
  result = await this.fireServerEvent(eventName, params);
1385
1410
  }
1386
1411
  return result;
@@ -1641,13 +1666,7 @@ class FieldWithAttribute extends Field {
1641
1666
  async getInitialValue({
1642
1667
  value
1643
1668
  }) {
1644
- if (value === void 0 || value === null) {
1645
- return this.state.value = "";
1646
- } else if (typeof value === "boolean") {
1647
- return this.state.value = String(value);
1648
- } else {
1649
- return this.state.value = value;
1650
- }
1669
+ return value;
1651
1670
  }
1652
1671
  getValidationState() {
1653
1672
  return this.state.validation;
@@ -1672,7 +1691,10 @@ class FieldWithAttribute extends Field {
1672
1691
  if (options?.markAsDirty !== false) {
1673
1692
  this.form.execution.state.hasChangedAnything = true;
1674
1693
  }
1675
- return this.fireEvent("onChange", { force: options?.force });
1694
+ if (options?.fireEvents !== false) {
1695
+ return this.fireEvent("onChange", { force: options?.force });
1696
+ }
1697
+ return true;
1676
1698
  }
1677
1699
  return Promise.resolve(false);
1678
1700
  });
@@ -1711,40 +1733,50 @@ class FieldWithAttribute extends Field {
1711
1733
  async synchronize(newValue) {
1712
1734
  if (newValue === this.lastSynchronizationValue)
1713
1735
  return true;
1714
- try {
1715
- const postData = this.getSynchronizePostConfiguration(newValue);
1716
- const result = (await asyncRetry(
1717
- async () => {
1718
- try {
1719
- return await post(
1720
- this.form.execution,
1721
- await this.getSynchronizeUrl(),
1722
- postData
1723
- );
1724
- } catch (e) {
1725
- this.form.execution.notifications.add(
1726
- new MessageNotification({ message: String(e) })
1727
- );
1728
- return null;
1729
- }
1730
- },
1731
- (result2) => !!result2?.data?.success,
1732
- { retries: 10, timeout: 500 }
1733
- ))?.data?.success || false;
1734
- if (result) {
1735
- this.lastSynchronizationValue = newValue;
1736
- this.state.validation.dirty = false;
1737
- return true;
1736
+ const syncPromise = (async () => {
1737
+ try {
1738
+ const postData = this.getSynchronizePostConfiguration(newValue);
1739
+ const response = await asyncRetry(
1740
+ async () => {
1741
+ try {
1742
+ const res = await post(
1743
+ this.form.execution,
1744
+ await this.getSynchronizeUrl(),
1745
+ postData
1746
+ );
1747
+ return res;
1748
+ } catch (e) {
1749
+ this.form.execution.notifications.add(
1750
+ new MessageNotification({ message: String(e) })
1751
+ );
1752
+ return null;
1753
+ }
1754
+ },
1755
+ (result2) => {
1756
+ const success = !!result2?.data?.success;
1757
+ return success;
1758
+ },
1759
+ { retries: 10, timeout: 500 }
1760
+ );
1761
+ const result = response?.data?.success || false;
1762
+ if (result) {
1763
+ this.lastSynchronizationValue = newValue;
1764
+ this.state.validation.dirty = false;
1765
+ return true;
1766
+ }
1767
+ } catch (e) {
1768
+ console.error("synchronize error:", e);
1769
+ this.processSynchronizeError(e);
1738
1770
  }
1739
- } catch (e) {
1740
- this.processSynchronizeError(e);
1771
+ return false;
1772
+ })();
1773
+ try {
1774
+ this.form.execution.addPendingPromise(syncPromise);
1775
+ } catch {
1741
1776
  }
1742
- return false;
1777
+ return await syncPromise;
1743
1778
  }
1744
1779
  hasValue() {
1745
- return this.getValue() !== "";
1746
- }
1747
- isValidValue() {
1748
1780
  return !!this.getValue();
1749
1781
  }
1750
1782
  async validate() {
@@ -1754,7 +1786,7 @@ class FieldWithAttribute extends Field {
1754
1786
  return false;
1755
1787
  }
1756
1788
  }
1757
- const isValid = isFieldShowAsText(this) || this.isValidValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
1789
+ const isValid = isFieldShowAsText(this) || this.hasValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
1758
1790
  this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired(this.form.execution);
1759
1791
  return !this.state.validation.errorMessage;
1760
1792
  }
@@ -1790,7 +1822,10 @@ class Checkbox extends FieldWithAttribute {
1790
1822
  getInitialValue({
1791
1823
  value
1792
1824
  }) {
1793
- return value === "" || value === void 0 ? Promise.resolve(false) : value;
1825
+ if (value === "" || value === void 0) {
1826
+ return Promise.resolve(false);
1827
+ }
1828
+ return Promise.resolve(toBoolean(value));
1794
1829
  }
1795
1830
  }
1796
1831
 
@@ -2003,8 +2038,8 @@ class Editor extends TranslatableField {
2003
2038
  fireEvent(eventName, options) {
2004
2039
  return super.fireEvent(eventName, options);
2005
2040
  }
2006
- isValidValue() {
2007
- return !!new DOMParser().parseFromString(this.getValue(), "text/html").documentElement.textContent;
2041
+ hasValue() {
2042
+ return !!String(this.getValue()).trim();
2008
2043
  }
2009
2044
  getSynchronizePostConfiguration(value) {
2010
2045
  const conf = super.getSynchronizePostConfiguration(value);
@@ -2329,6 +2364,7 @@ class UploaderApi extends EventEmitter$1 {
2329
2364
  translatedFiles: /* @__PURE__ */ new Map(),
2330
2365
  hasAllDocTypes: false
2331
2366
  });
2367
+ __publicField$i(this, "getCheckSignatureParameters", returnExactlyTheSame);
2332
2368
  __publicField$i(this, "getAjaxUploadFileStatusParameters", returnExactlyTheSame);
2333
2369
  __publicField$i(this, "getAjaxUploadStartParameters", returnExactlyTheSame);
2334
2370
  __publicField$i(this, "getConfirmDropModalParameters", returnExactlyTheSame);
@@ -2560,6 +2596,7 @@ class UploaderApi extends EventEmitter$1 {
2560
2596
  this.modalController.state.isReadonly = false;
2561
2597
  }
2562
2598
  this.state.inProgressFiles = [];
2599
+ this.state.versioningFile = null;
2563
2600
  this.state.hiddenFiles = [];
2564
2601
  }
2565
2602
  clearState() {
@@ -2895,14 +2932,17 @@ class UploaderApi extends EventEmitter$1 {
2895
2932
  if (Number(file.docId) >= 0)
2896
2933
  res = await get(
2897
2934
  this.execution,
2898
- makeApiaUrl(this.execution, {
2899
- action: "viewDocSigns",
2900
- docId: file.docId,
2901
- lock: false,
2902
- isAjax: true,
2903
- prefix: this.type,
2904
- react: true
2905
- })
2935
+ makeApiaUrl(
2936
+ this.execution,
2937
+ this.getCheckSignatureParameters({
2938
+ action: "viewDocSigns",
2939
+ docId: file.docId,
2940
+ lock: false,
2941
+ isAjax: true,
2942
+ prefix: this.type,
2943
+ react: true
2944
+ })
2945
+ )
2906
2946
  );
2907
2947
  return res;
2908
2948
  }
@@ -3099,6 +3139,7 @@ class UploaderApi extends EventEmitter$1 {
3099
3139
  const document = documentInfo.function.data.general;
3100
3140
  const { permissions } = documentInfo.function.data;
3101
3141
  if (this.modalController) {
3142
+ this.setCurrentDocTypeId(document.docTypeId);
3102
3143
  this.modalController.addDirectoryFile(document);
3103
3144
  this.modalController.state.description = document.docDesc;
3104
3145
  this.modalController.state.docExpDate = document.docExpDate;
@@ -3274,7 +3315,7 @@ class UploaderApi extends EventEmitter$1 {
3274
3315
  } else {
3275
3316
  this.state.files = { ...currentFiles, ...newFiles };
3276
3317
  }
3277
- this.state.inProgressFiles = [];
3318
+ this.clearFiles();
3278
3319
  this.emit("fileUploaded", null);
3279
3320
  return true;
3280
3321
  }
@@ -3947,6 +3988,11 @@ class File extends FieldWithAttribute {
3947
3988
  }
3948
3989
  }
3949
3990
  }
3991
+ async downloadDocument() {
3992
+ await this.uploader.downloadDocument(
3993
+ Object.values(this.uploader.state.files)[0].docId
3994
+ );
3995
+ }
3950
3996
  }
3951
3997
 
3952
3998
  function noNaN(number, defaultReturn = 0) {
@@ -4333,7 +4379,7 @@ class Grid extends Field {
4333
4379
  }));
4334
4380
  this.state.isLoading = false;
4335
4381
  this.state.isMaximized = false;
4336
- this.controller.on("columnClick", (col) => {
4382
+ this.controller.on("columnSort", (col) => {
4337
4383
  this.sortColumn(col.getState("properties").col.fldId);
4338
4384
  });
4339
4385
  }
@@ -4375,7 +4421,7 @@ class Grid extends Field {
4375
4421
  }
4376
4422
  get selectedIndices() {
4377
4423
  return [...this.tableController.getState("selection").values()].map(
4378
- (c) => c.index
4424
+ (c) => c.getIndex()
4379
4425
  );
4380
4426
  }
4381
4427
  get selectedItems() {
@@ -4509,7 +4555,7 @@ class Grid extends Field {
4509
4555
  if (await this.fireScriptEvent("gridDelete")) {
4510
4556
  if (void 0 === index) {
4511
4557
  index = [...this.controller.getState("selection")].map((c) => {
4512
- return c.index;
4558
+ return c.getIndex();
4513
4559
  });
4514
4560
  } else {
4515
4561
  this.controller.setSelection(arrayOrArray(index));
@@ -4674,7 +4720,7 @@ class Grid extends Field {
4674
4720
  return null;
4675
4721
  }
4676
4722
  getSelectedRows() {
4677
- return this.tableController.getSelectedRows().map((c) => this.getRow(c.index));
4723
+ return this.tableController.getSelectedRows().map((c) => this.getRow(c.getIndex()));
4678
4724
  }
4679
4725
  refreshColumnsVisibilities() {
4680
4726
  const shownColumns = /* @__PURE__ */ new Set();
@@ -4682,19 +4728,20 @@ class Grid extends Field {
4682
4728
  for (const row of this.tableController.body.rows) {
4683
4729
  const cell = row.cells[i];
4684
4730
  const field = cell.getState("properties")?.field;
4685
- if (!(field && (field.properties.visibilityHidden || field instanceof Hidden)) || cell instanceof AdditionalCell) {
4731
+ if (!(field && (field.properties.visibilityHidden || field instanceof Hidden))) {
4686
4732
  shownColumns.add(cell.getState("colName"));
4687
4733
  break;
4688
4734
  }
4689
4735
  }
4690
4736
  }
4691
- this.tableController.setHiddenColumns(
4692
- new Set(
4693
- this.tableController.head.rows[0].cells.filter(
4694
- (c) => !(c instanceof AdditionalCell || shownColumns.has(c.getState("colName")))
4695
- ).map((c) => c.getState("colName"))
4696
- )
4697
- );
4737
+ for (const column of new Set(
4738
+ this.tableController.head.rows[0].cells.map((c) => c.getState("colName"))
4739
+ )) {
4740
+ this.tableController.toggleColumnVisibility(
4741
+ column,
4742
+ shownColumns.has(column)
4743
+ );
4744
+ }
4698
4745
  }
4699
4746
  async init(form) {
4700
4747
  await super.init(form);
@@ -4741,11 +4788,14 @@ class Grid extends Field {
4741
4788
  style: { width, maxWidth: width },
4742
4789
  title: col.title
4743
4790
  },
4744
- properties: { col }
4791
+ properties: { col },
4792
+ isHidden: hiddenColumns.has(col.fldId)
4745
4793
  })
4746
4794
  );
4747
4795
  });
4748
- this.controller.setHiddenColumns(hiddenColumns);
4796
+ for (const column of hiddenColumns) {
4797
+ this.tableController.toggleColumnVisibility(column, false);
4798
+ }
4749
4799
  this.controller.head.addRow(headerRow);
4750
4800
  getDocument(this.form.execution).addEventListener?.("keydown", (ev) => {
4751
4801
  if (ev.code === "Escape") {
@@ -4906,9 +4956,9 @@ class Grid extends Field {
4906
4956
  newRow.addCell(
4907
4957
  new AdditionalCell(
4908
4958
  this,
4909
- () => newRow.index,
4959
+ () => newRow.getIndex(),
4910
4960
  () => {
4911
- this.deleteRows(newRow.index);
4961
+ this.deleteRows(newRow.getIndex());
4912
4962
  },
4913
4963
  this.properties.gridForm ? (handler) => {
4914
4964
  this.openEditionModal(handler);
@@ -4997,6 +5047,7 @@ class Grid extends Field {
4997
5047
  );
4998
5048
  this.properties.pages = xml.pages || this.properties.pages;
4999
5049
  this.properties.currentPage = xml.curPage || this.properties.currentPage;
5050
+ this.properties.visibilityHidden = xml.properties.visibilityHidden ?? this.properties.visibilityHidden;
5000
5051
  if (statesArray[0].length > this.controller.body.rows.length) {
5001
5052
  for (let i = this.controller.body.rows.length; i < statesArray[0].length; i++) {
5002
5053
  const parsedFieldGroups = fieldsArray.map((field, columnIndex) => {
@@ -5115,7 +5166,10 @@ class GridPaginated extends Grid {
5115
5166
  */
5116
5167
  get finalIndex() {
5117
5168
  const pageSize = this.properties.pageSize;
5118
- return noNaN$1(this.properties.currentPage * pageSize - 1, 0);
5169
+ return noNaN$1(
5170
+ (this.properties.currentPage - 1) * pageSize - 1 + this.controller.body.rows.length,
5171
+ 0
5172
+ );
5119
5173
  }
5120
5174
  addRow() {
5121
5175
  return this.asyncAction(async () => {
@@ -5144,12 +5198,14 @@ class GridPaginated extends Grid {
5144
5198
  return false;
5145
5199
  });
5146
5200
  }
5147
- async deleteRows(index) {
5201
+ actualDeleteRows(props) {
5202
+ let index = props.index;
5203
+ const action = props.action ?? "delete";
5148
5204
  return this.asyncAction(async () => {
5149
5205
  if (await this.fireScriptEvent("gridDelete")) {
5150
5206
  if (void 0 === index) {
5151
5207
  index = [...this.controller.getState("selection")].map((c) => {
5152
- return c.index;
5208
+ return c.getIndex();
5153
5209
  });
5154
5210
  } else {
5155
5211
  this.controller.setSelection(arrayOrArray(index));
@@ -5157,13 +5213,13 @@ class GridPaginated extends Grid {
5157
5213
  const deletingIndices = arrayOrArray(index).sort((a, b) => b - a).map((c) => c + this.startIndex);
5158
5214
  if (this.hasServerNoAjaxEventsOfType("gridDelete")) {
5159
5215
  await this.fireServerEvent("gridDelete", {
5160
- gridAction: "delete",
5216
+ gridAction: action,
5161
5217
  rowId: deletingIndices
5162
5218
  });
5163
5219
  } else {
5164
5220
  const res = await this.runAction({
5165
5221
  postData: {
5166
- gridAction: "delete",
5222
+ gridAction: action,
5167
5223
  rowId: deletingIndices
5168
5224
  }
5169
5225
  });
@@ -5191,6 +5247,12 @@ class GridPaginated extends Grid {
5191
5247
  return false;
5192
5248
  });
5193
5249
  }
5250
+ async deleteAllRows() {
5251
+ return this.actualDeleteRows({ action: "deleteAllRows" });
5252
+ }
5253
+ async deleteRows(index) {
5254
+ return this.actualDeleteRows({ index });
5255
+ }
5194
5256
  async gotoPage(page) {
5195
5257
  return this.asyncAction(async () => {
5196
5258
  const res = await this.runAction({
@@ -5232,7 +5294,7 @@ class GridPaginated extends Grid {
5232
5294
  await setAjaxFormResponse(this.form.execution, parseXml(evs));
5233
5295
  }
5234
5296
  if (res?.data?.success) {
5235
- const currentSelectionIndices = this.controller.getSelectedRows().map((c) => c.index);
5297
+ const currentSelectionIndices = this.controller.getSelectedRows().map((c) => c.getIndex());
5236
5298
  const currentPage = this.currentPage;
5237
5299
  this.rebuildGrid(res.data.gridXml);
5238
5300
  this.controller.clearSelection();
@@ -5273,7 +5335,7 @@ class GridPaginated extends Grid {
5273
5335
  await setAjaxFormResponse(this.form.execution, parseXml(evs));
5274
5336
  }
5275
5337
  if (res?.data?.success) {
5276
- const currentSelectionIndices = this.controller.getSelectedRows().map((c) => c.index);
5338
+ const currentSelectionIndices = this.controller.getSelectedRows().map((c) => c.getIndex());
5277
5339
  const currentPage = this.currentPage;
5278
5340
  this.rebuildGrid(res.data.gridXml);
5279
5341
  this.controller.clearSelection();
@@ -5368,7 +5430,7 @@ class Input extends TranslatableField {
5368
5430
  return false;
5369
5431
  return super.validate();
5370
5432
  }
5371
- isValidValue() {
5433
+ hasValue() {
5372
5434
  return !!String(this.getValue()).trim();
5373
5435
  }
5374
5436
  }
@@ -5416,7 +5478,7 @@ class Multiple extends FieldWithAttribute {
5416
5478
  }
5417
5479
 
5418
5480
  class Password extends FieldWithAttribute {
5419
- isValidValue() {
5481
+ hasValue() {
5420
5482
  return !!String(this.getValue()).trim();
5421
5483
  }
5422
5484
  }
@@ -5473,7 +5535,7 @@ class Select extends FieldWithAttribute {
5473
5535
  }
5474
5536
 
5475
5537
  class Textarea extends TranslatableField {
5476
- isValidValue() {
5538
+ hasValue() {
5477
5539
  return !!String(this.getValue()).trim();
5478
5540
  }
5479
5541
  getSynchronizePostConfiguration(value) {
@@ -5563,7 +5625,7 @@ class Tree extends FieldWithAttribute {
5563
5625
  this.state.value = getValuesArray(this.properties.possibleValue);
5564
5626
  this.controller = new MobXTree({
5565
5627
  onSelect: (ev) => {
5566
- if (isFieldShowAsText(this) || this.properties.disabled) {
5628
+ if (isFieldShowAsText(this) || this.properties.disabled || this.properties.readOnly || this.properties.readonly || this.getParentGrid()?.properties.readonly) {
5567
5629
  return false;
5568
5630
  } else {
5569
5631
  const selection = [...ev.values()].map((c) => c.id);
@@ -5582,9 +5644,6 @@ class Tree extends FieldWithAttribute {
5582
5644
  arrayOrArray(this.properties.possibleValue)
5583
5645
  );
5584
5646
  }
5585
- isValidValue() {
5586
- return this.state.value.length > 0;
5587
- }
5588
5647
  async setValue(newValue, options) {
5589
5648
  const res = await super.setValue(newValue, options);
5590
5649
  if (res) {
@@ -6058,6 +6117,9 @@ class ApiaFieldWithAttribute extends ApiaField {
6058
6117
  setValue(v) {
6059
6118
  __privateGet$g(this, _field$c).setValue(v);
6060
6119
  }
6120
+ _setValue(v, options) {
6121
+ __privateGet$g(this, _field$c).setValue(v, options);
6122
+ }
6061
6123
  getLabel() {
6062
6124
  return __privateGet$g(this, _field$c).attribute.title;
6063
6125
  }
@@ -6742,6 +6804,7 @@ class GridField extends ApiaField {
6742
6804
  __privateAdd$6(this, _mutex, new Mutex());
6743
6805
  __privateSet$6(this, _execution$2, execution);
6744
6806
  __privateSet$6(this, _field$2, field);
6807
+ __privateSet$6(this, _execution$2, execution);
6745
6808
  }
6746
6809
  async addRow() {
6747
6810
  try {
@@ -6809,6 +6872,11 @@ class GridField extends ApiaField {
6809
6872
  })
6810
6873
  );
6811
6874
  }
6875
+ getSelectedIndexes(useAbsoluteIndex) {
6876
+ return __privateGet$6(this, _field$2).controller.getSelectedRows().map(
6877
+ (row) => row.getIndex() + (useAbsoluteIndex ? +noNaN$1(__privateGet$6(this, _field$2).startIndex) : 0)
6878
+ );
6879
+ }
6812
6880
  getAllColumns() {
6813
6881
  return __privateGet$6(this, _field$2).getAllColumns().map(
6814
6882
  (c) => c.map((f) => createNewField(__privateGet$6(this, _field$2).getForm().execution, f))
@@ -6930,6 +6998,9 @@ class FileUploaderField extends ApiaFieldWithAttribute {
6930
6998
  }
6931
6999
  return null;
6932
7000
  }
7001
+ async downloadDocument() {
7002
+ await __privateGet$5(this, _field$1).downloadDocument();
7003
+ }
6933
7004
  }
6934
7005
  _field$1 = new WeakMap();
6935
7006
 
@@ -7264,6 +7335,13 @@ class ApiaFunctions {
7264
7335
  viewAdmEntity(entName, entNum) {
7265
7336
  this.admEntity(entName, entNum);
7266
7337
  }
7338
+ changeTab(index) {
7339
+ if (window.tabsController)
7340
+ window.tabsController.tabsList.forEach((tab, i) => {
7341
+ if (arrayOrArray(index).includes(i))
7342
+ tab.open();
7343
+ });
7344
+ }
7267
7345
  }
7268
7346
  _execution = new WeakMap();
7269
7347
 
@@ -7999,6 +8077,21 @@ class Form extends WithProperties {
7999
8077
  }
8000
8078
  return super.getProperty(propName);
8001
8079
  }
8080
+ getErrorsList() {
8081
+ const errors = [];
8082
+ this.allFields.forEach((f) => {
8083
+ if (f instanceof FieldWithAttribute) {
8084
+ const fieldErrors = f.state.validation.errorMessage;
8085
+ if (fieldErrors) {
8086
+ errors.push({
8087
+ id: `${f.getForm().definition.frmParent}_${f.getForm().definition.id}_${f.definition.id}`,
8088
+ errorMessage: fieldErrors
8089
+ });
8090
+ }
8091
+ }
8092
+ });
8093
+ return errors;
8094
+ }
8002
8095
  }
8003
8096
 
8004
8097
  function decodeBase64ToUtf8(base64String) {
@@ -8376,9 +8469,9 @@ class Entity {
8376
8469
  }
8377
8470
  deleteAssociation() {
8378
8471
  const selectedRows = this.controller.getState("selection");
8379
- const lastIdx = Array.from(selectedRows).pop()?.index;
8472
+ const lastIdx = Array.from(selectedRows).pop()?.getIndex();
8380
8473
  [...selectedRows.values()].forEach((row) => {
8381
- this.state.associations = this.state?.associations.filter((_, idx) => row.index !== idx) ?? [];
8474
+ this.state.associations = this.state?.associations.filter((_, idx) => row.getIndex() !== idx) ?? [];
8382
8475
  this.controller.body.removeRow(row);
8383
8476
  });
8384
8477
  if (lastIdx)
@@ -8457,7 +8550,8 @@ class Observations {
8457
8550
  this.execution,
8458
8551
  makeApiaUrl(this.execution, {
8459
8552
  action: "getObservationsData",
8460
- isAjax: true
8553
+ isAjax: true,
8554
+ isTask: !window.isMonitor ? true : false
8461
8555
  })
8462
8556
  );
8463
8557
  if (!res?.data?.obData) {
@@ -8472,18 +8566,30 @@ class Observations {
8472
8566
  chkRemAlert: false
8473
8567
  };
8474
8568
  this.state.newObservation = newObservation;
8569
+ this.areObservationsChecked();
8475
8570
  }
8476
8571
  }
8477
8572
  getConfirmParams() {
8478
- return {
8573
+ const params = {
8479
8574
  txtComment: this.state.newObservation?.commentValue,
8480
8575
  chkAddAlert: this.state.newObservation?.chkAddAlert === true ? "on" : void 0,
8481
8576
  chkAddAllAlert: this.state.newObservation?.chkAddAllAlert === true ? "on" : void 0,
8482
8577
  chkRemAlert: this.state.newObservation?.chkRemAlert === true ? "on" : void 0
8483
8578
  };
8579
+ const obs = this.state.observations ?? [];
8580
+ for (const o of obs) {
8581
+ if (!o || !o.name)
8582
+ continue;
8583
+ params[o.name] = o.checked === true ? "on" : void 0;
8584
+ }
8585
+ return params;
8484
8586
  }
8485
8587
  setPriority(newPriority) {
8486
8588
  }
8589
+ areObservationsChecked() {
8590
+ const isChecked = this.state.observations?.some((o) => o.checked === true);
8591
+ return isChecked;
8592
+ }
8487
8593
  }
8488
8594
 
8489
8595
  let FlowModal$1 = class FlowModal {
@@ -8740,6 +8846,25 @@ async function defaultConfirm$1(execution, status) {
8740
8846
  postDataTreatment: "stringify",
8741
8847
  stringifyOptions: {
8742
8848
  arrayFormat: "repeat"
8849
+ },
8850
+ xmlParser: (xml) => {
8851
+ const processStringObjPreserveValue = (value, key) => {
8852
+ if (key === "value" && typeof value === "string") {
8853
+ return value;
8854
+ }
8855
+ return processStringObj(value, key);
8856
+ };
8857
+ const baseOptions = getDefaultXmlParserOptions();
8858
+ baseOptions.attrValueProcessors = [
8859
+ customBooleanProcessor,
8860
+ processStringObjPreserveValue,
8861
+ processAjaxEventResponse
8862
+ ];
8863
+ const parser = new xml2js.Parser(baseOptions);
8864
+ return getDefaultXmlPostProcessor()(
8865
+ xml,
8866
+ parser
8867
+ );
8743
8868
  }
8744
8869
  }
8745
8870
  );
@@ -9113,6 +9238,7 @@ class Execution extends EventEmitter$1 {
9113
9238
  __publicField(this, "_stepCount", 1);
9114
9239
  __publicField(this, "notifications");
9115
9240
  __publicField(this, "lastModalReturn", []);
9241
+ __publicField(this, "_pendingPromises", /* @__PURE__ */ new Set());
9116
9242
  __publicField(this, "formsById", {
9117
9243
  E: /* @__PURE__ */ new Map(),
9118
9244
  P: /* @__PURE__ */ new Map()
@@ -9164,6 +9290,23 @@ class Execution extends EventEmitter$1 {
9164
9290
  this.notifications = new Notifications(this);
9165
9291
  makeObservable(this, { state: observable });
9166
9292
  }
9293
+ addPendingPromise(promise) {
9294
+ this._pendingPromises.add(promise);
9295
+ promise.finally(() => {
9296
+ this._pendingPromises.delete(promise);
9297
+ });
9298
+ }
9299
+ getErrorsList() {
9300
+ const entityErrors = [];
9301
+ this.forms.E.forEach((form) => {
9302
+ entityErrors.push(...form.getErrorsList());
9303
+ });
9304
+ const processErrors = [];
9305
+ this.forms.P.forEach((form) => {
9306
+ processErrors.push(...form.getErrorsList());
9307
+ });
9308
+ return [...entityErrors, ...processErrors];
9309
+ }
9167
9310
  getAllForms() {
9168
9311
  return [...this.forms.E.values(), ...this.forms.P.values()];
9169
9312
  }
@@ -9259,21 +9402,21 @@ class Execution extends EventEmitter$1 {
9259
9402
  for (let i = 1; i < Number(getWindow(this).STEP_QTY) + 1; i++) {
9260
9403
  if (i < this._currentStep) {
9261
9404
  this._steps.push({
9262
- title: `Step ${i}`,
9405
+ title: `${getLabel(this, "lblTraStep").text} ${i}`,
9263
9406
  stepNumber: i,
9264
9407
  status: "completed"
9265
9408
  });
9266
9409
  }
9267
9410
  if (i > this._currentStep && i <= this._stepCount) {
9268
9411
  this._steps.push({
9269
- title: `Step ${i}`,
9412
+ title: `${getLabel(this, "lblTraStep").text} ${i}`,
9270
9413
  stepNumber: i,
9271
9414
  status: "pending"
9272
9415
  });
9273
9416
  }
9274
9417
  if (i === this._currentStep) {
9275
9418
  this._steps.push({
9276
- title: `Step ${i}`,
9419
+ title: `${getLabel(this, "lblTraStep").text} ${i}`,
9277
9420
  stepNumber: i,
9278
9421
  status: "current"
9279
9422
  });
@@ -9533,7 +9676,8 @@ class Execution extends EventEmitter$1 {
9533
9676
  makeApiaUrl(this, {
9534
9677
  action: "saveTask",
9535
9678
  asXML: true,
9536
- react: true
9679
+ react: true,
9680
+ currentTab: getCurrentTabsString(this)
9537
9681
  }),
9538
9682
  {
9539
9683
  postData: {
@@ -9622,6 +9766,12 @@ class Execution extends EventEmitter$1 {
9622
9766
  unlock();
9623
9767
  }
9624
9768
  }
9769
+ async waitForPendingSyncs() {
9770
+ if (this._pendingPromises.size === 0)
9771
+ return;
9772
+ const pending = Array.from(this._pendingPromises);
9773
+ await Promise.allSettled(pending);
9774
+ }
9625
9775
  }
9626
9776
 
9627
9777
  export { ActionsController, AdditionalCell, ApiaAttribute, ApiaField, ApiaFieldWithAttribute, ApiaForm, ApiaFunctions, BouncingEmitter, Button, ButtonField, Captcha, CaptchaField, CheckField, Checkbox, CustomComponent, GridField as DataGridField, Editor, EditorField, EventEmitter, Execution, ExecutionState, Field, FieldWithAttribute, File, FileUploaderField, FlowModal$1 as FlowModal, Form, FormsUploader, Grid, GridCell, GridField, GridPaginated, HeaderCell, Hidden, HiddenField, IProperty, Image, ImageField, Input, InputField, InvalidSessionException, Label, Link, LinkField, MessageNotification, ModalInput, ModalInputField, Multiple, MultipleField, Notifications, Password, PasswordField, Radio, RadioField, SchedulerField, Select, SelectField, ShowConfirmMessage, ShowPathSelection, ShowPoolSelection, ShowSign$1 as ShowSign, ShowSignSelection$1 as ShowSignSelection, StatefulEmitter, StatusNotification, AreaField as TextAreaField, TextField, Textarea, Title, TranslatableField, Translation, Tree, TreeField, UploaderApi, UploaderModalController, createNewField, deepEqual, get, getLabel, isHtmlResponse, isJsonResponse, isOneClickUploadEnabled, isXmlResponse, makeApiaUrl, parseFakeJSON$1 as parseFakeJSON, parseFileDefinition, parseSuccessfulResponse, parseXml, post, returnExactlyTheSame, shallowEqual };