@apia/execution 4.0.44 → 4.0.45

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
@@ -1,12 +1,10 @@
1
- import * as _apia_scheduler_controller from '@apia/scheduler-controller';
2
- import { TScheduleResult, Scheduler } from '@apia/scheduler-controller';
3
- export { Scheduler } from '@apia/scheduler-controller';
4
1
  import { AxiosRequestConfig, AxiosResponse } from 'axios';
5
2
  import { IStringifyOptions } from 'qs';
6
3
  import { TableController, Row, Cell, CellState } from '@apia/table2-controller';
7
- import * as _apia_util from '@apia/util';
8
- import { DeepReadonly, NotificationDefinition, EventEmitter as EventEmitter$1, T__LEGACY_SERVER__ApiaLoad, T__LEGACY_SERVER__ApiaFunction, TApiaLoadForm, Mutex } from '@apia/util';
4
+ import { DeepReadonly, EventEmitter as EventEmitter$1, TApiaLoad, TApiaFunction, TApiaLoadForm, Mutex } from '@apia/util';
9
5
  import { MobXTree } from '@apia/tree2-controller';
6
+ import * as _apia_scheduler_controller from '@apia/scheduler-controller';
7
+ import { TScheduleResult, Scheduler } from '@apia/scheduler-controller';
10
8
 
11
9
  type TApiaButtonDefinition = TApiaFieldBaseDefinition<TApiaButtonProperties> & {
12
10
  fieldType: 'button';
@@ -521,7 +519,7 @@ type SetValueOptions = Partial<{
521
519
  markAsDirty: boolean;
522
520
  synchronize: boolean;
523
521
  force: boolean;
524
- fireEvents: boolean;
522
+ fireEvents?: boolean;
525
523
  }>;
526
524
  type FireEventParameters = Record<string, unknown>;
527
525
  type FieldValidationState = {
@@ -630,6 +628,7 @@ declare abstract class FieldWithAttribute<FieldProps extends TApiaFieldWithAttri
630
628
  protected processSynchronizeError(e: unknown): void;
631
629
  protected synchronize(newValue: ValueType): Promise<boolean>;
632
630
  protected hasValue(): boolean;
631
+ protected isValidValue(): boolean;
633
632
  validate(): Promise<boolean>;
634
633
  setError(err: string): void;
635
634
  protected getServerEventParams(evtId: number, additionalParams?: Record<string, any>): MakeApiaUrlProps;
@@ -1889,52 +1888,6 @@ declare class CustomComponent {
1889
1888
  setState<K extends keyof TCustomComponentState>(prop: K, value: TCustomComponentState[K]): void;
1890
1889
  }
1891
1890
 
1892
- declare enum ExecutionState {
1893
- RUNNING = 0,
1894
- LOADING = 1,
1895
- FINISHED = 2,
1896
- RENDERING = 3,
1897
- CONFIRMING = 4,
1898
- FINISHED_WITH_ERROR = 5
1899
- }
1900
- type TOnClose = 'clearEvalPath' | 'confirmOkOnClose' | 'confirmOkOnCloseSplash' | 'confirmOkOnSaveSplash' | 'releaseOkOnClose' | null;
1901
- type TErrMessage = {
1902
- message: {
1903
- text: string;
1904
- label?: string;
1905
- };
1906
- };
1907
- type TFetchTaskActionResponse = {
1908
- onClose?: TOnClose;
1909
- sysMessages?: TErrMessage;
1910
- sysExceptions?: TErrMessage;
1911
- type?: string;
1912
- actions?: {
1913
- action: {
1914
- param: string[];
1915
- toDo: string;
1916
- };
1917
- };
1918
- load?: {
1919
- canClose: boolean;
1920
- type: string;
1921
- text: {
1922
- label: string;
1923
- closeAll: boolean;
1924
- addClass?: string;
1925
- title?: string;
1926
- };
1927
- };
1928
- text?: {
1929
- title?: string;
1930
- label?: string;
1931
- };
1932
- };
1933
- type FieldError = {
1934
- id: string;
1935
- errorMessage: string;
1936
- };
1937
-
1938
1891
  declare class Form extends WithProperties<TApiaFormProperties> {
1939
1892
  execution: Execution;
1940
1893
  fields: TApiaFieldBaseDefinition<Record<string, any>>[];
@@ -1999,7 +1952,6 @@ declare class Form extends WithProperties<TApiaFormProperties> {
1999
1952
  fireScriptEvent(eventName: TFormEventName): Promise<boolean>;
2000
1953
  validate(): Promise<true | Field>;
2001
1954
  getProperty<K extends keyof TApiaFormProperties>(propName: K | 'readOnly'): TApiaFormProperties[K];
2002
- getErrorsList(): FieldError[];
2003
1955
  }
2004
1956
 
2005
1957
  type TTranslationState = {
@@ -2057,6 +2009,17 @@ declare abstract class TranslatableField<FieldProps extends TApiaTranslatableFie
2057
2009
  type FieldConstructor = new (definition: any) => Field<any, any, any> | FieldWithAttribute<any, any, any> | TranslatableField<any, any, any>;
2058
2010
  type FieldsMapping = Record<string, (definition: any) => FieldConstructor>;
2059
2011
 
2012
+ type NotificationIcon = string;
2013
+ type NotificationType = 'info' | 'error' | 'success' | 'warning';
2014
+ type NotificationDefinition = {
2015
+ icon?: NotificationIcon;
2016
+ id?: string | number;
2017
+ isOpen?: boolean;
2018
+ message: string;
2019
+ stackTrace?: string;
2020
+ title?: string;
2021
+ type?: NotificationType;
2022
+ };
2060
2023
  declare abstract class Notification<State extends NotificationDefinition = NotificationDefinition> {
2061
2024
  readonly props: State;
2062
2025
  protected state: State;
@@ -2067,7 +2030,7 @@ declare abstract class Notification<State extends NotificationDefinition = Notif
2067
2030
  get message(): string;
2068
2031
  get stackTrace(): string | undefined;
2069
2032
  get title(): string | undefined;
2070
- get type(): _apia_util.NotificationType | undefined;
2033
+ get type(): NotificationType | undefined;
2071
2034
  }
2072
2035
 
2073
2036
  declare class Notifications {
@@ -2077,8 +2040,8 @@ declare class Notifications {
2077
2040
  protected notifications: Notification[];
2078
2041
  add(notification: Notification): void;
2079
2042
  closeTab(): void;
2080
- getAll(): Notification<_apia_util.NotificationDefinition>[];
2081
- getById(id: string | number): Notification<_apia_util.NotificationDefinition> | undefined;
2043
+ getAll(): Notification<NotificationDefinition>[];
2044
+ getById(id: string | number): Notification<NotificationDefinition> | undefined;
2082
2045
  kill(): void;
2083
2046
  remove(notification: string | number | Notification): void;
2084
2047
  on: <K extends "closeTab" | "kill" | "notification">(event: K, cb: Callback<{
@@ -2479,7 +2442,7 @@ type TFileUploaded = {
2479
2442
  virtualDoc?: boolean;
2480
2443
  locked?: boolean;
2481
2444
  };
2482
- type TAjaxUploadStart = T__LEGACY_SERVER__ApiaLoad<T__LEGACY_SERVER__ApiaFunction<{
2445
+ type TAjaxUploadStart = TApiaLoad<TApiaFunction<{
2483
2446
  general: {
2484
2447
  isDocTypeDisabled: boolean;
2485
2448
  useDocTypePermitted: boolean;
@@ -2541,13 +2504,13 @@ type TSaveDroppedFilesConf = {
2541
2504
  translatingFile?: TUploaderFileInfo;
2542
2505
  shouldReset?: boolean;
2543
2506
  };
2544
- type TAjaxUploadFileStatus = T__LEGACY_SERVER__ApiaLoad<T__LEGACY_SERVER__ApiaFunction<{
2507
+ type TAjaxUploadFileStatus = TApiaLoad<TApiaFunction<{
2545
2508
  message: {
2546
2509
  label: string;
2547
2510
  name: string;
2548
2511
  }[];
2549
2512
  }>>;
2550
- type TProcessDroppedFiles = T__LEGACY_SERVER__ApiaLoad<T__LEGACY_SERVER__ApiaFunction<{
2513
+ type TProcessDroppedFiles = TApiaLoad<TApiaFunction<{
2551
2514
  principal: {
2552
2515
  docInfo: TDocInfo | TDocInfo[];
2553
2516
  docTypes: {
@@ -2569,7 +2532,7 @@ type TDocInfo = {
2569
2532
  docInfoTmpId: string;
2570
2533
  docInfoType: string;
2571
2534
  };
2572
- type TConfirmDropModal = T__LEGACY_SERVER__ApiaLoad<T__LEGACY_SERVER__ApiaFunction<{
2535
+ type TConfirmDropModal = TApiaLoad<TApiaFunction<{
2573
2536
  general: TFileUploaded | TFileUploaded[];
2574
2537
  fromForm: {
2575
2538
  fromForm: {
@@ -2607,7 +2570,7 @@ type TUploaderLoadCurrentFunction = {
2607
2570
  }[];
2608
2571
  };
2609
2572
  };
2610
- type TDocumentInformation = T__LEGACY_SERVER__ApiaLoad<T__LEGACY_SERVER__ApiaFunction<{
2573
+ type TDocumentInformation = TApiaLoad<TApiaFunction<{
2611
2574
  data: {
2612
2575
  onClose: string;
2613
2576
  general: TApiaDocumentDefinition;
@@ -2947,6 +2910,48 @@ declare abstract class FlowModal<T extends {
2947
2910
  abstract confirm(result: T): Promise<Status | FlowModal<any>>;
2948
2911
  }
2949
2912
 
2913
+ declare enum ExecutionState {
2914
+ RUNNING = 0,
2915
+ LOADING = 1,
2916
+ FINISHED = 2,
2917
+ RENDERING = 3,
2918
+ CONFIRMING = 4,
2919
+ FINISHED_WITH_ERROR = 5
2920
+ }
2921
+ type TOnClose = 'clearEvalPath' | 'confirmOkOnClose' | 'confirmOkOnCloseSplash' | 'confirmOkOnSaveSplash' | 'releaseOkOnClose' | null;
2922
+ type TErrMessage = {
2923
+ message: {
2924
+ text: string;
2925
+ label?: string;
2926
+ };
2927
+ };
2928
+ type TFetchTaskActionResponse = {
2929
+ onClose?: TOnClose;
2930
+ sysMessages?: TErrMessage;
2931
+ sysExceptions?: TErrMessage;
2932
+ type?: string;
2933
+ actions?: {
2934
+ action: {
2935
+ param: string[];
2936
+ toDo: string;
2937
+ };
2938
+ };
2939
+ load?: {
2940
+ canClose: boolean;
2941
+ type: string;
2942
+ text: {
2943
+ label: string;
2944
+ closeAll: boolean;
2945
+ addClass?: string;
2946
+ title?: string;
2947
+ };
2948
+ };
2949
+ text?: {
2950
+ title?: string;
2951
+ label?: string;
2952
+ };
2953
+ };
2954
+
2950
2955
  type TCheckWizardResponse = {
2951
2956
  url: string;
2952
2957
  };
@@ -3123,7 +3128,6 @@ declare class Execution extends EventEmitter$1<{
3123
3128
  hasChangedAnything: boolean;
3124
3129
  };
3125
3130
  addPendingPromise(promise: Promise<boolean>): void;
3126
- getErrorsList(): FieldError[];
3127
3131
  getAllForms(): Form[];
3128
3132
  private hasInitializedFormsTabs;
3129
3133
  initializeFormsTabs(frmParent: TFrmParent, cb: () => unknown): void;
@@ -3410,7 +3414,7 @@ declare class Checkbox extends FieldWithAttribute<TApiaCheckboxProperties, boole
3410
3414
  type EditorEvents = 'onChange';
3411
3415
  declare class Editor extends TranslatableField<TApiaEditorProperties, string> {
3412
3416
  fireEvent(eventName: EditorEvents, options?: TFireEventOptions): Promise<boolean>;
3413
- protected hasValue(): boolean;
3417
+ protected isValidValue(): boolean;
3414
3418
  protected getSynchronizePostConfiguration(value: string): IApiaApiPostConfig<any>;
3415
3419
  }
3416
3420
 
@@ -3665,7 +3669,7 @@ declare class Input extends TranslatableField<TApiaInputProperties, string, TApi
3665
3669
  setValue(newValue: string | Date | number, options?: SetValueOptions): Promise<boolean>;
3666
3670
  private validateRegex;
3667
3671
  validate(): Promise<boolean>;
3668
- protected hasValue(): boolean;
3672
+ protected isValidValue(): boolean;
3669
3673
  }
3670
3674
 
3671
3675
  declare class Label extends Field<TApiaLabelProperties, TApiaLabelDefinition> {
@@ -3723,7 +3727,7 @@ declare class Multiple extends FieldWithAttribute<TApiaMultipleProperties, strin
3723
3727
  }
3724
3728
 
3725
3729
  declare class Password extends FieldWithAttribute<TApiaPasswordProperties, string> {
3726
- protected hasValue(): boolean;
3730
+ protected isValidValue(): boolean;
3727
3731
  }
3728
3732
 
3729
3733
  type RadioEvents = 'onPopulate' | 'onChange' | 'onClick';
@@ -3742,7 +3746,7 @@ declare class Select extends FieldWithAttribute<TApiaSelectProperties, string, T
3742
3746
  }
3743
3747
 
3744
3748
  declare class Textarea extends TranslatableField<TApiaTextareaProperties, string> {
3745
- protected hasValue(): boolean;
3749
+ protected isValidValue(): boolean;
3746
3750
  protected getSynchronizePostConfiguration(value: string): IApiaApiPostConfig<any>;
3747
3751
  }
3748
3752
 
@@ -3760,6 +3764,7 @@ declare class Tree extends FieldWithAttribute<TApiaTreeProperties, TTreeValue[],
3760
3764
  protected hasValue(): boolean;
3761
3765
  setProperty<K extends keyof TApiaTreeProperties>(propName: K, propValue: TApiaTreeProperties[K]): void;
3762
3766
  init(form: Form): Promise<void>;
3767
+ protected isValidValue(): boolean;
3763
3768
  setValue(newValue: TTreeValue[], options?: Partial<{
3764
3769
  comparator: Comparator$1<any>;
3765
3770
  format: 'd/m/Y' | 'apia';
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
- export { Scheduler } from '@apia/scheduler-controller';
14
13
 
15
14
  const deepEqual = (a, b) => {
16
15
  if (Object.is(a, b))
@@ -911,7 +910,7 @@ class BouncingEmitter extends StatefulEmitter {
911
910
  }
912
911
 
913
912
  function getLabel(execution, label, replacers) {
914
- const original = getWindow(execution)?.labels?.[label];
913
+ const original = getWindow(execution).labels[label];
915
914
  if (!original) {
916
915
  return {
917
916
  text: `LblNotPrealoded: ${label}`,
@@ -1302,8 +1301,15 @@ class Field extends WithProperties {
1302
1301
  }).text
1303
1302
  );
1304
1303
  }
1304
+ const evtSrc = await asyncCreateNewField(
1305
+ this.form.execution,
1306
+ this
1307
+ );
1308
+ if (evtSrc.setValue) {
1309
+ evtSrc.setValue = (value) => evtSrc._setValue(value, { fireEvents: false });
1310
+ }
1305
1311
  result = await fn(
1306
- await asyncCreateNewField(this.form.execution, this),
1312
+ evtSrc,
1307
1313
  ...await this.getScriptEventParams(event.fncParams)
1308
1314
  );
1309
1315
  if (result === false) {
@@ -1777,6 +1783,9 @@ class FieldWithAttribute extends Field {
1777
1783
  return await syncPromise;
1778
1784
  }
1779
1785
  hasValue() {
1786
+ return this.getValue() !== "";
1787
+ }
1788
+ isValidValue() {
1780
1789
  return !!this.getValue();
1781
1790
  }
1782
1791
  async validate() {
@@ -1786,7 +1795,7 @@ class FieldWithAttribute extends Field {
1786
1795
  return false;
1787
1796
  }
1788
1797
  }
1789
- const isValid = isFieldShowAsText(this) || this.hasValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
1798
+ const isValid = isFieldShowAsText(this) || this.isValidValue() || !this.properties.required || this.properties.visibilityHidden || this.properties.disabled;
1790
1799
  this.state.validation.errorMessage = isValid ? null : labels.errorFieldRequired(this.form.execution);
1791
1800
  return !this.state.validation.errorMessage;
1792
1801
  }
@@ -2038,8 +2047,8 @@ class Editor extends TranslatableField {
2038
2047
  fireEvent(eventName, options) {
2039
2048
  return super.fireEvent(eventName, options);
2040
2049
  }
2041
- hasValue() {
2042
- return !!String(this.getValue()).trim();
2050
+ isValidValue() {
2051
+ return !!new DOMParser().parseFromString(this.getValue(), "text/html").documentElement.textContent;
2043
2052
  }
2044
2053
  getSynchronizePostConfiguration(value) {
2045
2054
  const conf = super.getSynchronizePostConfiguration(value);
@@ -4379,7 +4388,7 @@ class Grid extends Field {
4379
4388
  }));
4380
4389
  this.state.isLoading = false;
4381
4390
  this.state.isMaximized = false;
4382
- this.controller.on("columnSort", (col) => {
4391
+ this.controller.on("columnClick", (col) => {
4383
4392
  this.sortColumn(col.getState("properties").col.fldId);
4384
4393
  });
4385
4394
  }
@@ -5430,7 +5439,7 @@ class Input extends TranslatableField {
5430
5439
  return false;
5431
5440
  return super.validate();
5432
5441
  }
5433
- hasValue() {
5442
+ isValidValue() {
5434
5443
  return !!String(this.getValue()).trim();
5435
5444
  }
5436
5445
  }
@@ -5478,7 +5487,7 @@ class Multiple extends FieldWithAttribute {
5478
5487
  }
5479
5488
 
5480
5489
  class Password extends FieldWithAttribute {
5481
- hasValue() {
5490
+ isValidValue() {
5482
5491
  return !!String(this.getValue()).trim();
5483
5492
  }
5484
5493
  }
@@ -5535,7 +5544,7 @@ class Select extends FieldWithAttribute {
5535
5544
  }
5536
5545
 
5537
5546
  class Textarea extends TranslatableField {
5538
- hasValue() {
5547
+ isValidValue() {
5539
5548
  return !!String(this.getValue()).trim();
5540
5549
  }
5541
5550
  getSynchronizePostConfiguration(value) {
@@ -5644,6 +5653,9 @@ class Tree extends FieldWithAttribute {
5644
5653
  arrayOrArray(this.properties.possibleValue)
5645
5654
  );
5646
5655
  }
5656
+ isValidValue() {
5657
+ return this.state.value.length > 0;
5658
+ }
5647
5659
  async setValue(newValue, options) {
5648
5660
  const res = await super.setValue(newValue, options);
5649
5661
  if (res) {
@@ -6804,7 +6816,6 @@ class GridField extends ApiaField {
6804
6816
  __privateAdd$6(this, _mutex, new Mutex());
6805
6817
  __privateSet$6(this, _execution$2, execution);
6806
6818
  __privateSet$6(this, _field$2, field);
6807
- __privateSet$6(this, _execution$2, execution);
6808
6819
  }
6809
6820
  async addRow() {
6810
6821
  try {
@@ -8077,21 +8088,6 @@ class Form extends WithProperties {
8077
8088
  }
8078
8089
  return super.getProperty(propName);
8079
8090
  }
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
- }
8095
8091
  }
8096
8092
 
8097
8093
  function decodeBase64ToUtf8(base64String) {
@@ -9296,17 +9292,6 @@ class Execution extends EventEmitter$1 {
9296
9292
  this._pendingPromises.delete(promise);
9297
9293
  });
9298
9294
  }
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
- }
9310
9295
  getAllForms() {
9311
9296
  return [...this.forms.E.values(), ...this.forms.P.values()];
9312
9297
  }