@apia/execution 4.0.37 → 4.0.40

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>;
@@ -2401,6 +2397,7 @@ type TUploaderFileInfo = Omit<TFileUploaded, 'locked' | 'userLocking'> & {
2401
2397
  canEdit?: boolean;
2402
2398
  canRead?: boolean;
2403
2399
  isLocked: boolean;
2400
+ locked?: boolean;
2404
2401
  isLockedByMe: boolean;
2405
2402
  isVirtual: boolean;
2406
2403
  lockingUser: string;
@@ -2434,6 +2431,7 @@ type TFileUploaded = {
2434
2431
  size?: string;
2435
2432
  userLocking: string;
2436
2433
  virtualDoc?: boolean;
2434
+ locked?: boolean;
2437
2435
  };
2438
2436
  type TAjaxUploadStart = TApiaLoad<TApiaFunction<{
2439
2437
  general: {
@@ -3725,12 +3723,14 @@ declare class Radio extends FieldWithAttribute<TApiaRadioProperties, number | st
3725
3723
  constructor({ possibleValue, ...definition }: TApiaRadioButtonDefinition);
3726
3724
  init(form: Form): Promise<void>;
3727
3725
  fireEvent(eventName: RadioEvents, options?: TFireEventOptions): Promise<boolean>;
3726
+ getTextValue(value: any): any;
3728
3727
  }
3729
3728
 
3730
3729
  declare class Select extends FieldWithAttribute<TApiaSelectProperties, string, TApiaSelectDefinition> {
3731
3730
  constructor({ possibleValue, ...definition }: TApiaSelectDefinition);
3732
3731
  protected getInitialValue({ properties: { possibleValue }, }: TApiaFieldWithAttributeBaseProps<TApiaSelectProperties>): Promise<string>;
3733
3732
  protected getSynchronizePostConfiguration(value: any): IApiaApiPostConfig<any>;
3733
+ getTextValue(value: any): any;
3734
3734
  }
3735
3735
 
3736
3736
  declare class Textarea extends TranslatableField<TApiaTextareaProperties, string> {
package/dist/index.js CHANGED
@@ -1273,6 +1273,9 @@ class Field extends WithProperties {
1273
1273
  await asyncCreateNewField(this.form.execution, this),
1274
1274
  ...await this.getScriptEventParams(event.fncParams)
1275
1275
  );
1276
+ if (result === false) {
1277
+ break;
1278
+ }
1276
1279
  } catch (e) {
1277
1280
  console.error(e);
1278
1281
  this.form.execution.notifications.add(
@@ -2282,7 +2285,7 @@ const parseFileDefinition = (execution, fileDefinition, isSignRequired) => {
2282
2285
  const { lock, isLocked, lockedBy, userLocking, ...file } = fileDefinition;
2283
2286
  return {
2284
2287
  ...file,
2285
- isLocked: isLocked === "true" || isLocked === true,
2288
+ isLocked: isLocked === "true" || isLocked === true || toBoolean(lock) || file.locked === true,
2286
2289
  isLockedByMe: (lockedBy || userLocking) === getWindow(execution).CURRENT_USER_LOGIN,
2287
2290
  isMarkedToSign: file.markedToSign || toBoolean(file.sign) || isSignRequired,
2288
2291
  isVirtual: file.virtualDoc ?? false,
@@ -2428,9 +2431,6 @@ class UploaderApi extends EventEmitter$1 {
2428
2431
  }
2429
2432
  }
2430
2433
  async onVersionUpload(file, conf = { newFiles: [] }) {
2431
- this.modalController = new UploaderModalController(this, this.modalConfig, {
2432
- versionFile: file
2433
- });
2434
2434
  this.version(file, conf);
2435
2435
  }
2436
2436
  async autoLock() {
@@ -2972,7 +2972,8 @@ class UploaderApi extends EventEmitter$1 {
2972
2972
  }
2973
2973
  async ajaxDeleteDocument(id, langId) {
2974
2974
  const file = this.getDocument(id);
2975
- if (await this.checkLockDocument(file.docId) === true) {
2975
+ const isLocked = await this.checkLockDocument(file.docId);
2976
+ if (isLocked === true) {
2976
2977
  const result = await post(
2977
2978
  this.execution,
2978
2979
  makeApiaUrl(
@@ -2992,7 +2993,19 @@ class UploaderApi extends EventEmitter$1 {
2992
2993
  }
2993
2994
  }
2994
2995
  async version(file, conf = { newFiles: [] }) {
2995
- if (await this.checkLockDocument(file.docId, true) === true && await this.checkWebDavLock(file.docId)) {
2996
+ const checkLock = await this.checkLockDocument(file.docId, true);
2997
+ const isLocked = await this.checkWebDavLock(file.docId);
2998
+ if (checkLock === true && isLocked) {
2999
+ if (!this.modalConfig.oneClickUpload) {
3000
+ this.modalController = new UploaderModalController(
3001
+ this,
3002
+ this.modalConfig,
3003
+ {
3004
+ versionFile: file
3005
+ }
3006
+ );
3007
+ this.modalController.openModal();
3008
+ }
2996
3009
  this.state.versioningFile = file;
2997
3010
  await this.ajaxUploadStart();
2998
3011
  if (file.docTypeId)
@@ -3010,7 +3023,6 @@ class UploaderApi extends EventEmitter$1 {
3010
3023
  docId: file.docId,
3011
3024
  docTypeId: file.docTypeId
3012
3025
  });
3013
- this.modalController?.openModal();
3014
3026
  }
3015
3027
  }
3016
3028
  }
@@ -3022,42 +3034,44 @@ class UploaderApi extends EventEmitter$1 {
3022
3034
  metadatas
3023
3035
  } = documentInfo.function;
3024
3036
  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) => {
3037
+ if (this.modalController) {
3038
+ this.modalController.state = {
3039
+ description: general.docDesc,
3040
+ docFolder: general.docFolder === "" ? void 0 : Number(general.docFolder),
3041
+ docPath: general.docFolderPath,
3042
+ permissions: {
3043
+ allowAllType: general.docAllPoolPerm,
3044
+ users: arrayOrArray(
3045
+ documentInfo.function.data.permissions?.user
3046
+ ).map((current) => {
3033
3047
  const returnObject = {
3034
3048
  canUpdate: current.permType === "M",
3035
3049
  userId: current.id,
3036
3050
  userLogin: current.name
3037
3051
  };
3038
3052
  return returnObject;
3039
- }
3040
- ),
3041
- pools: arrayOrArray(documentInfo.function.data.permissions?.pool).map(
3042
- (current) => {
3053
+ }),
3054
+ pools: arrayOrArray(
3055
+ documentInfo.function.data.permissions?.pool
3056
+ ).map((current) => {
3043
3057
  const returnObject = {
3044
3058
  canUpdate: current.permType === "M",
3045
3059
  poolId: current.id,
3046
3060
  poolName: current.name
3047
3061
  };
3048
3062
  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
- };
3063
+ })
3064
+ },
3065
+ docExpDate: general.docExpDate,
3066
+ fileReqError: false,
3067
+ fromDirectoryFile: null,
3068
+ metadata: {
3069
+ metadataArray: arrayOrArray(metadatas?.metadata),
3070
+ freeMetadataArray: [],
3071
+ isFreeMetadata
3072
+ }
3073
+ };
3074
+ }
3061
3075
  }
3062
3076
  }
3063
3077
  async pickFileById(id) {
@@ -3337,7 +3351,7 @@ class UploaderApi extends EventEmitter$1 {
3337
3351
  action: "lockDocument",
3338
3352
  ajaxUrl: this.getAjaxUrl(),
3339
3353
  docId: file.docId,
3340
- lock: file.isLocked,
3354
+ lock: file.isLocked || file.locked,
3341
3355
  isAjax: true,
3342
3356
  prefix: this.type
3343
3357
  })
@@ -5398,6 +5412,11 @@ class Radio extends FieldWithAttribute {
5398
5412
  fireEvent(eventName, options) {
5399
5413
  return super.fireEvent(eventName, options);
5400
5414
  }
5415
+ getTextValue(value) {
5416
+ return this.state.properties.possibleValue ? arrayOrArray(this.state.properties.possibleValue).find(
5417
+ (c) => c.value === value
5418
+ )?.label : value;
5419
+ }
5401
5420
  }
5402
5421
 
5403
5422
  class Select extends FieldWithAttribute {
@@ -5415,7 +5434,7 @@ class Select extends FieldWithAttribute {
5415
5434
  }) {
5416
5435
  return Promise.resolve(
5417
5436
  String(
5418
- this.state.value !== "" ? this.state.value : possibleValue?.find((c) => c.selected)?.value || possibleValue?.[0]?.value || ""
5437
+ this.state.value !== "" ? this.state.value : possibleValue?.find((c) => c.selected)?.value ?? (possibleValue?.[0]?.value || "")
5419
5438
  )
5420
5439
  );
5421
5440
  }
@@ -5423,6 +5442,11 @@ class Select extends FieldWithAttribute {
5423
5442
  const conf = super.getSynchronizePostConfiguration(String(value));
5424
5443
  return conf;
5425
5444
  }
5445
+ getTextValue(value) {
5446
+ return this.state.properties.possibleValue ? arrayOrArray(this.state.properties.possibleValue).find(
5447
+ (c) => c.value === value
5448
+ )?.label : value;
5449
+ }
5426
5450
  }
5427
5451
 
5428
5452
  class Textarea extends TranslatableField {