@apia/execution 4.0.37 → 4.0.41

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
@@ -1888,18 +1888,18 @@ declare class Form extends WithProperties<TApiaFormProperties> {
1888
1888
  isMarkedToSign: boolean;
1889
1889
  };
1890
1890
  protected _customComponents: Map<string, CustomComponent>;
1891
- protected fieldsById: Map<string, Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1891
+ protected fieldsById: Map<string, Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, {
1892
1892
  definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1893
1893
  }>>;
1894
- protected fieldsByName: Map<string, Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1894
+ protected fieldsByName: Map<string, Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, {
1895
1895
  definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1896
1896
  }>>;
1897
- protected fieldsByAttributeId: Map<string | number, FieldWithAttribute<Record<string, any>, any, TApiaFieldWithAttributeBaseProps<Record<string, any>>>>;
1898
- protected fieldsByAttributeName: Map<string, FieldWithAttribute<Record<string, any>, any, TApiaFieldWithAttributeBaseProps<Record<string, any>>>>;
1897
+ protected fieldsByAttributeId: Map<string | number, FieldWithAttribute<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, TApiaFieldWithAttributeBaseProps<Record<string, any>>>>;
1898
+ protected fieldsByAttributeName: Map<string, FieldWithAttribute<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, TApiaFieldWithAttributeBaseProps<Record<string, any>>>>;
1899
1899
  protected fieldsGroups: Map<string, Grid>;
1900
1900
  definition: TApiaForm;
1901
1901
  constructor(execution: Execution, definition: TApiaForm);
1902
- get allFields(): Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1902
+ get allFields(): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, {
1903
1903
  definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1904
1904
  }>[];
1905
1905
  get customComponents(): Map<string, CustomComponent>;
@@ -1907,30 +1907,26 @@ declare class Form extends WithProperties<TApiaFormProperties> {
1907
1907
  openForm(): void;
1908
1908
  getField(field: string, index?: number): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1909
1909
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1910
- }> | Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1911
- definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1912
- }> | FieldWithAttribute<Record<string, any>, any, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1910
+ }> | FieldWithAttribute<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1913
1911
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1914
1912
  }>[] | undefined;
1915
1913
  getFieldByAttributeId(attId: string | number, index?: number): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1916
1914
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1917
- }> | FieldWithAttribute<Record<string, any>, any, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1915
+ }> | FieldWithAttribute<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1918
1916
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1919
1917
  }>[] | undefined;
1920
1918
  getFieldByAttributeName(attName: string, index?: number): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1921
1919
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1922
- }> | FieldWithAttribute<Record<string, any>, any, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1920
+ }> | FieldWithAttribute<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, TApiaFieldWithAttributeBaseProps<Record<string, any>>> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1923
1921
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1924
1922
  }>[] | undefined;
1925
1923
  getFieldById(id: string | number, index?: number): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1926
1924
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1927
- }> | Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1928
- definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1929
1925
  }> | Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, {
1930
1926
  definition: Omit<TApiaFieldBaseDefinition<TApiaFieldCommonProperties>, "properties">;
1931
1927
  }>[] | undefined;
1932
1928
  getFieldByName(name: string, index?: number): Field | Field[] | undefined;
1933
- protected getHiddenFields(): Field<Record<string, any>, TApiaFieldBaseDefinition<Record<string, any>>, {
1929
+ protected getHiddenFields(): Field<TApiaFieldCommonProperties, TApiaFieldBaseDefinition<Record<string, any>>, {
1934
1930
  definition: Omit<TApiaFieldBaseDefinition<Record<string, any>>, "properties">;
1935
1931
  }>[];
1936
1932
  markFormToSign(): Promise<void>;
@@ -2304,7 +2300,8 @@ declare class UploaderApi extends EventEmitter$1<{
2304
2300
  shouldReset?: boolean;
2305
2301
  }): File[];
2306
2302
  parseFileDefinition: (file: TFileUploaded) => TUploaderFileInfo;
2307
- getLoadFileSystemStructureTree: () => Record<string, unknown>;
2303
+ getLoadFileSystemStructureTree(): Record<string, unknown>;
2304
+ getLoadFilesForFolderParameters(): Record<string, unknown>;
2308
2305
  }
2309
2306
 
2310
2307
  declare class UploaderModalController {
@@ -2401,6 +2398,7 @@ type TUploaderFileInfo = Omit<TFileUploaded, 'locked' | 'userLocking'> & {
2401
2398
  canEdit?: boolean;
2402
2399
  canRead?: boolean;
2403
2400
  isLocked: boolean;
2401
+ locked?: boolean;
2404
2402
  isLockedByMe: boolean;
2405
2403
  isVirtual: boolean;
2406
2404
  lockingUser: string;
@@ -2434,6 +2432,7 @@ type TFileUploaded = {
2434
2432
  size?: string;
2435
2433
  userLocking: string;
2436
2434
  virtualDoc?: boolean;
2435
+ locked?: boolean;
2437
2436
  };
2438
2437
  type TAjaxUploadStart = TApiaLoad<TApiaFunction<{
2439
2438
  general: {
@@ -3398,13 +3397,7 @@ declare class Captcha extends Field<TApiaCaptchaProperties, TApiaCaptchaDefiniti
3398
3397
  type CheckboxEvents = 'onClick';
3399
3398
  declare class Checkbox extends FieldWithAttribute<TApiaCheckboxProperties, boolean> {
3400
3399
  fireEvent(eventName: CheckboxEvents, options?: TFireEventOptions): Promise<boolean>;
3401
- protected getInitialValue({ value, properties, }: TApiaFieldWithAttributeBaseProps<TApiaCheckboxProperties>): Promise<boolean>;
3402
- setValue(newValue: boolean, options?: Partial<{
3403
- comparator: Comparator$1<any>;
3404
- format: 'd/m/Y' | 'apia';
3405
- markAsDirty: boolean;
3406
- synchronize: boolean;
3407
- }> | undefined): Promise<boolean>;
3400
+ protected getInitialValue({ value, }: TApiaFieldWithAttributeBaseProps<TApiaCheckboxProperties>): Promise<boolean>;
3408
3401
  }
3409
3402
 
3410
3403
  type EditorEvents = 'onChange';
@@ -3725,12 +3718,14 @@ declare class Radio extends FieldWithAttribute<TApiaRadioProperties, number | st
3725
3718
  constructor({ possibleValue, ...definition }: TApiaRadioButtonDefinition);
3726
3719
  init(form: Form): Promise<void>;
3727
3720
  fireEvent(eventName: RadioEvents, options?: TFireEventOptions): Promise<boolean>;
3721
+ getTextValue(value: any): any;
3728
3722
  }
3729
3723
 
3730
3724
  declare class Select extends FieldWithAttribute<TApiaSelectProperties, string, TApiaSelectDefinition> {
3731
3725
  constructor({ possibleValue, ...definition }: TApiaSelectDefinition);
3732
3726
  protected getInitialValue({ properties: { possibleValue }, }: TApiaFieldWithAttributeBaseProps<TApiaSelectProperties>): Promise<string>;
3733
3727
  protected getSynchronizePostConfiguration(value: any): IApiaApiPostConfig<any>;
3728
+ getTextValue(value: any): any;
3734
3729
  }
3735
3730
 
3736
3731
  declare class Textarea extends TranslatableField<TApiaTextareaProperties, string> {
package/dist/index.js CHANGED
@@ -10,7 +10,6 @@ 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
- import { ApiaUtil } from '@apia/components';
14
13
 
15
14
  const deepEqual = (a, b) => {
16
15
  if (Object.is(a, b))
@@ -1273,6 +1272,9 @@ class Field extends WithProperties {
1273
1272
  await asyncCreateNewField(this.form.execution, this),
1274
1273
  ...await this.getScriptEventParams(event.fncParams)
1275
1274
  );
1275
+ if (result === false) {
1276
+ break;
1277
+ }
1276
1278
  } catch (e) {
1277
1279
  console.error(e);
1278
1280
  this.form.execution.notifications.add(
@@ -1766,16 +1768,9 @@ class Checkbox extends FieldWithAttribute {
1766
1768
  return super.fireEvent(eventName, options);
1767
1769
  }
1768
1770
  getInitialValue({
1769
- value,
1770
- properties
1771
+ value
1771
1772
  }) {
1772
- return value === void 0 || value === "" ? properties.checked || value : value;
1773
- }
1774
- setValue(newValue, options) {
1775
- if (newValue !== "") {
1776
- return super.setValue(isTrue(newValue), options);
1777
- }
1778
- return Promise.resolve(false);
1773
+ return value === "" || value === void 0 ? Promise.resolve(false) : value;
1779
1774
  }
1780
1775
  }
1781
1776
 
@@ -2282,7 +2277,7 @@ const parseFileDefinition = (execution, fileDefinition, isSignRequired) => {
2282
2277
  const { lock, isLocked, lockedBy, userLocking, ...file } = fileDefinition;
2283
2278
  return {
2284
2279
  ...file,
2285
- isLocked: isLocked === "true" || isLocked === true,
2280
+ isLocked: isLocked === "true" || isLocked === true || toBoolean(lock) || file.locked === true,
2286
2281
  isLockedByMe: (lockedBy || userLocking) === getWindow(execution).CURRENT_USER_LOGIN,
2287
2282
  isMarkedToSign: file.markedToSign || toBoolean(file.sign) || isSignRequired,
2288
2283
  isVirtual: file.virtualDoc ?? false,
@@ -2359,11 +2354,6 @@ class UploaderApi extends EventEmitter$1 {
2359
2354
  canRead: file.canRead
2360
2355
  };
2361
2356
  });
2362
- __publicField$i(this, "getLoadFileSystemStructureTree", () => ({
2363
- useDocTypePermitted: true,
2364
- docTypePermittedObjId: this.docTypePermittedObjId,
2365
- docTypePermittedObjType: this.type
2366
- }));
2367
2357
  if (!getWindow(this.execution).fileApi) {
2368
2358
  getWindow(this.execution).fileApi = {};
2369
2359
  }
@@ -2428,9 +2418,6 @@ class UploaderApi extends EventEmitter$1 {
2428
2418
  }
2429
2419
  }
2430
2420
  async onVersionUpload(file, conf = { newFiles: [] }) {
2431
- this.modalController = new UploaderModalController(this, this.modalConfig, {
2432
- versionFile: file
2433
- });
2434
2421
  this.version(file, conf);
2435
2422
  }
2436
2423
  async autoLock() {
@@ -2972,7 +2959,8 @@ class UploaderApi extends EventEmitter$1 {
2972
2959
  }
2973
2960
  async ajaxDeleteDocument(id, langId) {
2974
2961
  const file = this.getDocument(id);
2975
- if (await this.checkLockDocument(file.docId) === true) {
2962
+ const isLocked = await this.checkLockDocument(file.docId);
2963
+ if (isLocked === true) {
2976
2964
  const result = await post(
2977
2965
  this.execution,
2978
2966
  makeApiaUrl(
@@ -2992,25 +2980,48 @@ class UploaderApi extends EventEmitter$1 {
2992
2980
  }
2993
2981
  }
2994
2982
  async version(file, conf = { newFiles: [] }) {
2995
- if (await this.checkLockDocument(file.docId, true) === true && await this.checkWebDavLock(file.docId)) {
2983
+ const checkLock = await this.checkLockDocument(file.docId, true);
2984
+ const isLocked = await this.checkWebDavLock(file.docId);
2985
+ if (checkLock === true && isLocked) {
2986
+ if (!this.modalConfig.oneClickUpload && conf.newFiles?.length === 0) {
2987
+ this.modalController = new UploaderModalController(
2988
+ this,
2989
+ this.modalConfig,
2990
+ {
2991
+ versionFile: file
2992
+ }
2993
+ );
2994
+ this.modalController.openModal();
2995
+ }
2996
2996
  this.state.versioningFile = file;
2997
2997
  await this.ajaxUploadStart();
2998
2998
  if (file.docTypeId)
2999
2999
  this.state.selectedDocTypeId = file.docTypeId;
3000
3000
  await this.versionFileInfo(file);
3001
3001
  if (conf.newFiles && conf.newFiles.length > 0) {
3002
- await this.saveDroppedFiles(conf.newFiles, {
3002
+ const res = await this.saveDroppedFiles(conf.newFiles, {
3003
3003
  langId: conf.langId,
3004
3004
  translatingFile: conf.translatingFile,
3005
3005
  shouldReset: false,
3006
3006
  strictMode: true
3007
3007
  });
3008
+ if (res) {
3009
+ if (!this.modalConfig.oneClickUpload) {
3010
+ this.modalController = new UploaderModalController(
3011
+ this,
3012
+ this.modalConfig,
3013
+ {
3014
+ versionFile: file
3015
+ }
3016
+ );
3017
+ this.modalController.openModal();
3018
+ }
3019
+ }
3008
3020
  } else {
3009
3021
  await this.reloadMetadata({
3010
3022
  docId: file.docId,
3011
3023
  docTypeId: file.docTypeId
3012
3024
  });
3013
- this.modalController?.openModal();
3014
3025
  }
3015
3026
  }
3016
3027
  }
@@ -3022,42 +3033,44 @@ class UploaderApi extends EventEmitter$1 {
3022
3033
  metadatas
3023
3034
  } = documentInfo.function;
3024
3035
  const isFreeMetadata = this.state.allowedTypes.find((current) => current.id === file.docTypeId)?.free ?? false;
3025
- this.modalController.state = {
3026
- description: general.docDesc,
3027
- docFolder: general.docFolder === "" ? void 0 : Number(general.docFolder),
3028
- docPath: general.docFolderPath,
3029
- permissions: {
3030
- allowAllType: general.docAllPoolPerm,
3031
- users: arrayOrArray(documentInfo.function.data.permissions?.user).map(
3032
- (current) => {
3036
+ if (this.modalController) {
3037
+ this.modalController.state = {
3038
+ description: general.docDesc,
3039
+ docFolder: general.docFolder === "" ? void 0 : Number(general.docFolder),
3040
+ docPath: general.docFolderPath,
3041
+ permissions: {
3042
+ allowAllType: general.docAllPoolPerm,
3043
+ users: arrayOrArray(
3044
+ documentInfo.function.data.permissions?.user
3045
+ ).map((current) => {
3033
3046
  const returnObject = {
3034
3047
  canUpdate: current.permType === "M",
3035
3048
  userId: current.id,
3036
3049
  userLogin: current.name
3037
3050
  };
3038
3051
  return returnObject;
3039
- }
3040
- ),
3041
- pools: arrayOrArray(documentInfo.function.data.permissions?.pool).map(
3042
- (current) => {
3052
+ }),
3053
+ pools: arrayOrArray(
3054
+ documentInfo.function.data.permissions?.pool
3055
+ ).map((current) => {
3043
3056
  const returnObject = {
3044
3057
  canUpdate: current.permType === "M",
3045
3058
  poolId: current.id,
3046
3059
  poolName: current.name
3047
3060
  };
3048
3061
  return returnObject;
3049
- }
3050
- )
3051
- },
3052
- docExpDate: general.docExpDate,
3053
- fileReqError: false,
3054
- fromDirectoryFile: null,
3055
- metadata: {
3056
- metadataArray: arrayOrArray(metadatas?.metadata),
3057
- freeMetadataArray: [],
3058
- isFreeMetadata
3059
- }
3060
- };
3062
+ })
3063
+ },
3064
+ docExpDate: general.docExpDate,
3065
+ fileReqError: false,
3066
+ fromDirectoryFile: null,
3067
+ metadata: {
3068
+ metadataArray: arrayOrArray(metadatas?.metadata),
3069
+ freeMetadataArray: [],
3070
+ isFreeMetadata
3071
+ }
3072
+ };
3073
+ }
3061
3074
  }
3062
3075
  }
3063
3076
  async pickFileById(id) {
@@ -3337,7 +3350,7 @@ class UploaderApi extends EventEmitter$1 {
3337
3350
  action: "lockDocument",
3338
3351
  ajaxUrl: this.getAjaxUrl(),
3339
3352
  docId: file.docId,
3340
- lock: file.isLocked,
3353
+ lock: file.isLocked || file.locked,
3341
3354
  isAjax: true,
3342
3355
  prefix: this.type
3343
3356
  })
@@ -3482,7 +3495,7 @@ class UploaderApi extends EventEmitter$1 {
3482
3495
  if (conf?.langId)
3483
3496
  return files;
3484
3497
  const currentFiles = this.state.inProgressFiles;
3485
- const alreadyUploadedFiles = this.filesArray.filter(
3498
+ const alreadyUploadedFiles = Object.values(this.state.files).filter(
3486
3499
  (current) => Number(current.docId) < 0
3487
3500
  );
3488
3501
  let alreadyIncludedFileNames = "";
@@ -3526,6 +3539,20 @@ class UploaderApi extends EventEmitter$1 {
3526
3539
  }
3527
3540
  return files;
3528
3541
  }
3542
+ getLoadFileSystemStructureTree() {
3543
+ return {
3544
+ useDocTypePermitted: true,
3545
+ docTypePermittedObjId: this.docTypePermittedObjId,
3546
+ docTypePermittedObjType: this.type
3547
+ };
3548
+ }
3549
+ getLoadFilesForFolderParameters() {
3550
+ return {
3551
+ useDocTypePermitted: true,
3552
+ docTypePermittedObjId: this.docTypePermittedObjId,
3553
+ docTypePermittedObjType: this.type
3554
+ };
3555
+ }
3529
3556
  }
3530
3557
 
3531
3558
  var __defProp$h = Object.defineProperty;
@@ -5013,12 +5040,15 @@ class Grid extends Field {
5013
5040
  if (field instanceof File) {
5014
5041
  field.loadFromDefinition(state.file_prp);
5015
5042
  } else if (field instanceof ModalInput) {
5016
- field.setValue({
5017
- showValue: state.qry_show_value || "",
5018
- storeValue: state.value || ""
5019
- });
5043
+ field.setValue(
5044
+ {
5045
+ showValue: state.qry_show_value || "",
5046
+ storeValue: state.value || ""
5047
+ },
5048
+ { force: true }
5049
+ );
5020
5050
  } else if (field instanceof FieldWithAttribute) {
5021
- field.setValue(state.value, { synchronize: false });
5051
+ field.setValue(state.value, { synchronize: false, force: true });
5022
5052
  }
5023
5053
  }
5024
5054
  });
@@ -5398,6 +5428,11 @@ class Radio extends FieldWithAttribute {
5398
5428
  fireEvent(eventName, options) {
5399
5429
  return super.fireEvent(eventName, options);
5400
5430
  }
5431
+ getTextValue(value) {
5432
+ return this.properties.possibleValue ? arrayOrArray(this.properties.possibleValue).find(
5433
+ (c) => c.value === value
5434
+ )?.label : value;
5435
+ }
5401
5436
  }
5402
5437
 
5403
5438
  class Select extends FieldWithAttribute {
@@ -5415,7 +5450,7 @@ class Select extends FieldWithAttribute {
5415
5450
  }) {
5416
5451
  return Promise.resolve(
5417
5452
  String(
5418
- this.state.value !== "" ? this.state.value : possibleValue?.find((c) => c.selected)?.value || possibleValue?.[0]?.value || ""
5453
+ this.state.value !== "" ? this.state.value : possibleValue?.find((c) => c.selected)?.value ?? (possibleValue?.[0]?.value || "")
5419
5454
  )
5420
5455
  );
5421
5456
  }
@@ -5423,6 +5458,11 @@ class Select extends FieldWithAttribute {
5423
5458
  const conf = super.getSynchronizePostConfiguration(String(value));
5424
5459
  return conf;
5425
5460
  }
5461
+ getTextValue(value) {
5462
+ return this.properties.possibleValue ? arrayOrArray(this.properties.possibleValue).find(
5463
+ (c) => c.value === value
5464
+ )?.label : value;
5465
+ }
5426
5466
  }
5427
5467
 
5428
5468
  class Textarea extends TranslatableField {
@@ -8989,7 +9029,7 @@ async function defaultConfirm(execution, status) {
8989
9029
  }
8990
9030
  const url = arrayOrArray(confirmResponse.data.actions?.action.param)[1];
8991
9031
  if (url === "callNavigateClose") {
8992
- ApiaUtil.instance.tabs.currentTab.close(true);
9032
+ (getWindow(execution)?.top?.ApiaUtil).tabs.currentTab.close(true);
8993
9033
  } else {
8994
9034
  const c = new Url(url);
8995
9035
  getWindow(execution).location.assign(