@apia/execution 4.0.42 → 4.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1042,7 +1042,7 @@ declare class ApiaForm implements IApiaForm {
1042
1042
  getAllFields(): IApiaField[];
1043
1043
  clearForm(clearReadonlyFields: boolean, deleteGridsRows: boolean): void;
1044
1044
  hideModal(): void;
1045
- showAsModal(): void;
1045
+ showAsModal(size?: TModalSize): void;
1046
1046
  }
1047
1047
 
1048
1048
  declare abstract class ApiaField<Props extends typeof FieldConstants = typeof FieldConstants> implements IApiaField<Props> {
@@ -3076,6 +3076,7 @@ type TExecutionConfig = {
3076
3076
  canShare: boolean;
3077
3077
  isEntity?: boolean;
3078
3078
  };
3079
+ type TModalSize = 'editGrid' | 'sm' | 'md' | 'md-fixed' | 'lg' | 'lg-fixed' | 'xl' | 'xl-fixed' | 'xxl' | 'xxxl' | 'xxxl-fixed' | 'flex' | 'cal' | 'finder' | 'fileModal';
3079
3080
  type TExecutionEnvironment = {
3080
3081
  fieldsMapping?: FieldsMapping;
3081
3082
  window: Window;
@@ -3090,7 +3091,10 @@ declare class Execution extends EventEmitter$1<{
3090
3091
  flow: 'previous' | 'confirm' | 'next' | 'save' | 'release' | 'share' | 'viewDocs' | 'print' | 'delegate';
3091
3092
  sendToDesktop: null;
3092
3093
  hideFormModal: Form;
3093
- showFormAsModal: Form;
3094
+ showFormAsModal: {
3095
+ form: Form;
3096
+ size?: TModalSize;
3097
+ };
3094
3098
  }> {
3095
3099
  environment: TExecutionEnvironment;
3096
3100
  fieldsMapping: FieldsMapping;
@@ -3601,7 +3605,7 @@ declare class Grid extends Field<GridProps, GridDefinition, GridState> {
3601
3605
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
3602
3606
  }>[];
3603
3607
  protected rebuildGrid(xmlString: string | TApiaGridDefinition): Promise<void>;
3604
- protected runAction<T extends Record<string, any>>(behave: IApiaApiPostConfig<Record<string, any>>): Promise<TApiaApiAxiosResponse<(T & ResponseSysMessages) | null> | null>;
3608
+ protected runAction<T extends Record<string, any>>(postData: IApiaApiPostConfig<Record<string, any>>): Promise<TApiaApiAxiosResponse<(T & ResponseSysMessages) | null> | null>;
3605
3609
  private swapRows;
3606
3610
  toggleMaximize(): void;
3607
3611
  }
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import xml2js from 'xml2js';
4
4
  import he from 'he';
5
5
  import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
6
6
  import QueryString from 'qs';
7
- import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, addBoundary, formatMessage, parseAsSize, shallowEqual as shallowEqual$1, Mutex, awaitTime, noNaN as noNaN$1, getDateFormat, decodeBase64ToUtf8 as decodeBase64ToUtf8$1, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
7
+ import { arrayOrArray, EventEmitter as EventEmitter$1, isTrue, toBoolean, downloadUrl, addBoundary, formatMessage, parseAsSize, shallowEqual as shallowEqual$1, Mutex, noNaN as noNaN$1, getDateFormat, decodeBase64ToUtf8 as decodeBase64ToUtf8$1, encodeStrToBase64Utf8, uniqueId, parseXMLRequestResponse, Url, postNavigation } from '@apia/util';
8
8
  import { Cell, TableController, Row, FocusControllerPlugin } from '@apia/table2-controller';
9
9
  import dayjs from 'dayjs';
10
10
  import customParseFormat from 'dayjs/plugin/customParseFormat';
@@ -3002,8 +3002,11 @@ class UploaderApi extends EventEmitter$1 {
3002
3002
  async version(file, conf = { newFiles: [] }) {
3003
3003
  const checkLock = await this.checkLockDocument(file.docId, true);
3004
3004
  const isLocked = await this.checkWebDavLock(file.docId);
3005
- if (checkLock === true && isLocked) {
3006
- if (!this.modalConfig.oneClickUpload && conf.newFiles?.length === 0) {
3005
+ if (!(checkLock === true && isLocked))
3006
+ return;
3007
+ this.state.versioningFile = file;
3008
+ const openVersionModal = () => {
3009
+ if (!this.modalConfig.oneClickUpload) {
3007
3010
  this.modalController = new UploaderModalController(
3008
3011
  this,
3009
3012
  this.modalConfig,
@@ -3013,36 +3016,30 @@ class UploaderApi extends EventEmitter$1 {
3013
3016
  );
3014
3017
  this.modalController.openModal();
3015
3018
  }
3016
- this.state.versioningFile = file;
3017
- await this.ajaxUploadStart();
3018
- if (file.docTypeId)
3019
- this.state.selectedDocTypeId = file.docTypeId;
3020
- await this.versionFileInfo(file);
3021
- if (conf.newFiles && conf.newFiles.length > 0) {
3022
- const res = await this.saveDroppedFiles(conf.newFiles, {
3023
- langId: conf.langId,
3024
- translatingFile: conf.translatingFile,
3025
- shouldReset: false,
3026
- strictMode: true
3027
- });
3028
- if (res) {
3029
- if (!this.modalConfig.oneClickUpload) {
3030
- this.modalController = new UploaderModalController(
3031
- this,
3032
- this.modalConfig,
3033
- {
3034
- versionFile: file
3035
- }
3036
- );
3037
- this.modalController.openModal();
3038
- }
3039
- }
3040
- } else {
3041
- await this.reloadMetadata({
3042
- docId: file.docId,
3043
- docTypeId: file.docTypeId
3044
- });
3019
+ };
3020
+ if (!conf.newFiles || conf.newFiles.length === 0) {
3021
+ openVersionModal();
3022
+ }
3023
+ await this.ajaxUploadStart();
3024
+ if (file.docTypeId)
3025
+ this.state.selectedDocTypeId = file.docTypeId;
3026
+ await this.versionFileInfo(file);
3027
+ const hasNewFiles = !!(conf.newFiles && conf.newFiles.length > 0);
3028
+ if (hasNewFiles) {
3029
+ const res = await this.saveDroppedFiles(conf.newFiles, {
3030
+ langId: conf.langId,
3031
+ translatingFile: conf.translatingFile,
3032
+ shouldReset: false,
3033
+ strictMode: true
3034
+ });
3035
+ if (res) {
3036
+ openVersionModal();
3045
3037
  }
3038
+ } else {
3039
+ await this.reloadMetadata({
3040
+ docId: file.docId,
3041
+ docTypeId: file.docTypeId
3042
+ });
3046
3043
  }
3047
3044
  }
3048
3045
  async versionFileInfo(file) {
@@ -3402,7 +3399,9 @@ class UploaderApi extends EventEmitter$1 {
3402
3399
  const versioningFile = this.state.versioningFile;
3403
3400
  if (versioningFile)
3404
3401
  return files;
3405
- const uploadedFiles = this.state.inProgressFiles;
3402
+ const uploadedFiles = Object.values(this.state.files).filter(
3403
+ (file) => Number(file.docId) > 0
3404
+ );
3406
3405
  const existingFiles = [];
3407
3406
  const nonExistingFiles = [];
3408
3407
  if (conf?.langId) {
@@ -3415,7 +3414,7 @@ class UploaderApi extends EventEmitter$1 {
3415
3414
  existingFiles.push(files[0]);
3416
3415
  } else
3417
3416
  files.forEach((file) => {
3418
- if (uploadedFiles.find((search) => search.name === file.name)) {
3417
+ if (uploadedFiles.find((search) => search.docName === file.name)) {
3419
3418
  existingFiles.push(file);
3420
3419
  } else
3421
3420
  nonExistingFiles.push(file);
@@ -3548,15 +3547,6 @@ class UploaderApi extends EventEmitter$1 {
3548
3547
  }
3549
3548
  return newFiles;
3550
3549
  }
3551
- if (files.length === 1 && conf?.translatingFile === void 0 && conf?.langId === void 0) {
3552
- const actualVersioningFile = Object.values(this.state.files).find(
3553
- (c) => (c.name || c.docName) === files[0].name
3554
- );
3555
- if (actualVersioningFile) {
3556
- if (actualVersioningFile.isLockedByMe)
3557
- this.state.versioningFile = actualVersioningFile;
3558
- }
3559
- }
3560
3550
  return files;
3561
3551
  }
3562
3552
  getLoadFileSystemStructureTree() {
@@ -4431,7 +4421,8 @@ class Grid extends Field {
4431
4421
  const res = this.runAction({
4432
4422
  postData: {
4433
4423
  gridAction: "add",
4434
- addRowsCount: 1
4424
+ addRowsCount: 1,
4425
+ fireEvents: this.hasServerAjaxEventsOfType("gridAdd")
4435
4426
  }
4436
4427
  });
4437
4428
  const response = await res;
@@ -4482,7 +4473,8 @@ class Grid extends Field {
4482
4473
  return this.asyncAction(async () => {
4483
4474
  const res = this.runAction({
4484
4475
  postData: {
4485
- gridAction: "delete"
4476
+ gridAction: "delete",
4477
+ fireEvents: this.hasServerAjaxEventsOfType("gridDelete")
4486
4478
  }
4487
4479
  });
4488
4480
  const currentRows = [...this.tableController.body.rows];
@@ -4539,7 +4531,8 @@ class Grid extends Field {
4539
4531
  const res = this.runAction({
4540
4532
  postData: {
4541
4533
  gridAction: "delete",
4542
- rowId: deletingIndices
4534
+ rowId: deletingIndices,
4535
+ fireEvents: this.hasServerAjaxEventsOfType("gridDelete")
4543
4536
  }
4544
4537
  });
4545
4538
  const currentRows = [...this.tableController.body.rows];
@@ -4790,7 +4783,8 @@ class Grid extends Field {
4790
4783
  const res = this.runAction({
4791
4784
  postData: {
4792
4785
  gridAction: "down",
4793
- rowId: indices
4786
+ rowId: indices,
4787
+ fireEvents: this.hasServerAjaxEventsOfType("gridSort")
4794
4788
  }
4795
4789
  });
4796
4790
  this.swapRows(indices, "down");
@@ -4828,7 +4822,8 @@ class Grid extends Field {
4828
4822
  const res = this.runAction({
4829
4823
  postData: {
4830
4824
  gridAction: "up",
4831
- rowId: indices
4825
+ rowId: indices,
4826
+ fireEvents: this.hasServerAjaxEventsOfType("gridSort")
4832
4827
  }
4833
4828
  });
4834
4829
  this.swapRows(indices, "up");
@@ -4966,14 +4961,6 @@ class Grid extends Field {
4966
4961
  this.tableController.clearSelection();
4967
4962
  this.tableController.toggleRowSelection(newRow, true);
4968
4963
  }
4969
- for (let i = 0; i < 10; i++) {
4970
- if (newRow.cells[0]?.getTable() instanceof TableController) {
4971
- newRow.cells[0]?.focus();
4972
- break;
4973
- } else {
4974
- await awaitTime(50);
4975
- }
4976
- }
4977
4964
  return newRow;
4978
4965
  }
4979
4966
  async asyncAction(cb, mutex = true) {
@@ -5075,7 +5062,7 @@ class Grid extends Field {
5075
5062
  });
5076
5063
  this.refreshColumnsVisibilities();
5077
5064
  }
5078
- async runAction(behave) {
5065
+ async runAction(postData) {
5079
5066
  return post(
5080
5067
  this.form.execution,
5081
5068
  await makeApiaUrl(this.form.execution, {
@@ -5088,7 +5075,7 @@ class Grid extends Field {
5088
5075
  {
5089
5076
  postDataTreatment: "stringify",
5090
5077
  stringifyOptions: { arrayFormat: "repeat" },
5091
- ...behave
5078
+ ...postData
5092
5079
  }
5093
5080
  );
5094
5081
  }
@@ -7077,8 +7064,8 @@ class ApiaForm {
7077
7064
  hideModal() {
7078
7065
  __privateGet$3(this, _execution$1).emit("hideFormModal", __privateGet$3(this, _form));
7079
7066
  }
7080
- showAsModal() {
7081
- __privateGet$3(this, _execution$1).emit("showFormAsModal", __privateGet$3(this, _form));
7067
+ showAsModal(size) {
7068
+ __privateGet$3(this, _execution$1).emit("showFormAsModal", { form: __privateGet$3(this, _form), size });
7082
7069
  }
7083
7070
  }
7084
7071
  _form = new WeakMap();
@@ -7485,7 +7472,7 @@ class CustomComponent {
7485
7472
  }),
7486
7473
  {
7487
7474
  postData: typeof body === "string" ? {
7488
- payload: body
7475
+ payload: encodeStrToBase64Utf8(body)
7489
7476
  } : body,
7490
7477
  postDataTreatment: "stringify"
7491
7478
  }
@@ -9547,7 +9534,17 @@ class Execution extends EventEmitter$1 {
9547
9534
  action: "saveTask",
9548
9535
  asXML: true,
9549
9536
  react: true
9550
- })
9537
+ }),
9538
+ {
9539
+ postData: {
9540
+ ...this.observations.getConfirmParams(),
9541
+ ...this.process.getConfirmParams()
9542
+ },
9543
+ postDataTreatment: "stringify",
9544
+ stringifyOptions: {
9545
+ arrayFormat: "repeat"
9546
+ }
9547
+ }
9551
9548
  );
9552
9549
  const canClose = response?.data?.load?.canClose;
9553
9550
  if (canClose) {