@apia/execution 5.2.2 → 6.0.2
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 +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/main/Execution/Entity/index.d.ts +2 -1
- package/dist/main/Execution/Entity/index.js +49 -46
- package/dist/main/Execution/Entity/index.js.map +1 -1
- package/dist/main/Execution/EntityFlowModals/confirmFlow.js +4 -0
- package/dist/main/Execution/EntityFlowModals/confirmFlow.js.map +1 -1
- package/dist/main/Execution/FlowModals/confirmFlow.js +7 -3
- package/dist/main/Execution/FlowModals/confirmFlow.js.map +1 -1
- package/dist/main/Execution/FormsExecution/Field.d.ts +1 -0
- package/dist/main/Execution/FormsExecution/Field.js +34 -23
- package/dist/main/Execution/FormsExecution/Field.js.map +1 -1
- package/dist/main/Execution/FormsExecution/FieldValidationException.d.ts +9 -0
- package/dist/main/Execution/FormsExecution/FieldValidationException.d.ts.map +1 -0
- package/dist/main/Execution/FormsExecution/FieldValidationException.js +14 -0
- package/dist/main/Execution/FormsExecution/FieldValidationException.js.map +1 -0
- package/dist/main/Execution/FormsExecution/FieldWithAttribute.d.ts +2 -3
- package/dist/main/Execution/FormsExecution/FieldWithAttribute.js +12 -14
- package/dist/main/Execution/FormsExecution/FieldWithAttribute.js.map +1 -1
- package/dist/main/Execution/FormsExecution/Form.d.ts +2 -1
- package/dist/main/Execution/FormsExecution/Form.js +11 -3
- package/dist/main/Execution/FormsExecution/Form.js.map +1 -1
- package/dist/main/Execution/FormsExecution/events/setAjaxFormResponse.js +0 -8
- package/dist/main/Execution/FormsExecution/events/setAjaxFormResponse.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/Checkbox/index.d.ts +3 -0
- package/dist/main/Execution/FormsExecution/fields/Checkbox/index.js +9 -1
- package/dist/main/Execution/FormsExecution/fields/Checkbox/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/File/index.d.ts +3 -0
- package/dist/main/Execution/FormsExecution/fields/File/index.js +38 -3
- package/dist/main/Execution/FormsExecution/fields/File/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/Grid/index.d.ts +6 -2
- package/dist/main/Execution/FormsExecution/fields/Grid/index.js +82 -30
- package/dist/main/Execution/FormsExecution/fields/Grid/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/Grid/types.d.ts +4 -2
- package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.d.ts +1 -1
- package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.js +4 -2
- package/dist/main/Execution/FormsExecution/fields/GridPaginated/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/Input/index.js +2 -2
- package/dist/main/Execution/FormsExecution/fields/Input/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/ModalInput/index.d.ts +16 -10
- package/dist/main/Execution/FormsExecution/fields/ModalInput/index.js +66 -102
- package/dist/main/Execution/FormsExecution/fields/ModalInput/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/fields/Multiple/index.js +5 -0
- package/dist/main/Execution/FormsExecution/fields/Multiple/index.js.map +1 -1
- package/dist/main/Execution/FormsExecution/types.d.ts +1 -1
- package/dist/main/Execution/Uploader/FormsUploader.d.ts +9 -6
- package/dist/main/Execution/Uploader/FormsUploader.js +2 -1
- package/dist/main/Execution/Uploader/FormsUploader.js.map +1 -1
- package/dist/main/Execution/Uploader/UploaderApi.d.ts +4 -4
- package/dist/main/Execution/index.d.ts +5 -11
- package/dist/main/Execution/index.js +70 -33
- package/dist/main/Execution/index.js.map +1 -1
- package/dist/main/Execution/taskActionContext.d.ts +9 -0
- package/dist/main/Execution/taskActionContext.d.ts.map +1 -0
- package/dist/main/Execution/taskActionContext.js +20 -0
- package/dist/main/Execution/taskActionContext.js.map +1 -0
- package/dist/main/InitialData/types/fields/TApiaGridDefinition.d.ts +1 -0
- package/dist/programming/ApiaField.d.ts +6 -0
- package/dist/programming/ApiaField.js +29 -2
- package/dist/programming/ApiaField.js.map +1 -1
- package/dist/programming/ApiaFieldWithAttribute.d.ts +1 -1
- package/dist/programming/ApiaFieldWithAttribute.js +2 -2
- package/dist/programming/ApiaFieldWithAttribute.js.map +1 -1
- package/dist/programming/ApiaForm.d.ts +2 -0
- package/dist/programming/ApiaForm.js +7 -0
- package/dist/programming/ApiaForm.js.map +1 -1
- package/dist/programming/ApiaFunctions.d.ts +2 -1
- package/dist/programming/ApiaFunctions.js +6 -2
- package/dist/programming/ApiaFunctions.js.map +1 -1
- package/dist/programming/customAssistantFields.d.d.ts +10 -0
- package/dist/programming/customAssistantFields.d.d.ts.map +1 -0
- package/dist/programming/customAssistantFields.js +57 -0
- package/dist/programming/customAssistantFields.js.map +1 -0
- package/dist/programming/fields/GridField.d.ts +16 -0
- package/dist/programming/fields/GridField.js +37 -1
- package/dist/programming/fields/GridField.js.map +1 -1
- package/dist/programming/fields/ModalInput.d.ts +4 -5
- package/dist/programming/fields/ModalInput.js +6 -6
- package/dist/programming/fields/ModalInput.js.map +1 -1
- package/dist/programming/types.d.ts +6 -0
- package/dist/util/api/apiaApi.d.ts +3 -2
- package/dist/util/api/apiaApi.js +18 -0
- package/dist/util/api/apiaApi.js.map +1 -1
- package/dist/util/api/types.d.ts +16 -1
- package/package.json +7 -7
|
@@ -6,7 +6,7 @@ import { Field } from '../../Field.js';
|
|
|
6
6
|
import { parseFakeJSON } from '../../../../../util/other/parseFakeJSON.js';
|
|
7
7
|
import { GridFooterHandler } from './GridFooterHandler.js';
|
|
8
8
|
import { GridCell } from './GridCell.js';
|
|
9
|
-
import { Mutex, arrayOrArray, isTrue } from '@apia/util';
|
|
9
|
+
import { Mutex, arrayOrArray, isTrue, getValueByPath } from '@apia/util';
|
|
10
10
|
import { AdditionalCell } from './AdditionalCell.js';
|
|
11
11
|
import { setAjaxFormResponse } from '../../events/setAjaxFormResponse.js';
|
|
12
12
|
import { File } from '../File/index.js';
|
|
@@ -78,6 +78,7 @@ class Grid extends Field {
|
|
|
78
78
|
__publicField(this, "_editionModalHandler", null);
|
|
79
79
|
__publicField(this, "_footerController");
|
|
80
80
|
__publicField(this, "tableController");
|
|
81
|
+
__publicField(this, "pendingRefresh");
|
|
81
82
|
const fieldsArray = arrayOrArray(field);
|
|
82
83
|
this.initialStates = fieldsArray.map(
|
|
83
84
|
(current) => arrayOrArray(current.fieldValue || current.row)
|
|
@@ -145,10 +146,7 @@ class Grid extends Field {
|
|
|
145
146
|
}
|
|
146
147
|
async ensureRenderedRowsCount(rowsCount) {
|
|
147
148
|
const totalRowsCount = Math.max(0, Math.floor(rowsCount));
|
|
148
|
-
const targetRowsCount = this.isPaged ? Math.min(
|
|
149
|
-
this.pageSize,
|
|
150
|
-
Math.max(0, totalRowsCount - this.startIndex)
|
|
151
|
-
) : totalRowsCount;
|
|
149
|
+
const targetRowsCount = this.isPaged ? Math.min(this.pageSize, Math.max(0, totalRowsCount - this.startIndex)) : totalRowsCount;
|
|
152
150
|
for (let index = this.length; index < targetRowsCount; index++) {
|
|
153
151
|
await this.addRowFromDefinitions(
|
|
154
152
|
false,
|
|
@@ -297,10 +295,12 @@ class Grid extends Field {
|
|
|
297
295
|
/**
|
|
298
296
|
* Grid methods
|
|
299
297
|
*/
|
|
300
|
-
async addRow() {
|
|
298
|
+
async addRow(observeBeforeEvents) {
|
|
301
299
|
return this.asyncAction(async () => {
|
|
302
300
|
if (this.hasServerNoAjaxEventsOfType("gridAdd")) {
|
|
303
301
|
await this.fireServerEvent("gridAdd", {});
|
|
302
|
+
if (observeBeforeEvents)
|
|
303
|
+
throw new Error("The row result requires observation after the form reload.");
|
|
304
304
|
} else {
|
|
305
305
|
const res = this.runAction({
|
|
306
306
|
postData: {
|
|
@@ -328,11 +328,14 @@ class Grid extends Field {
|
|
|
328
328
|
...this.newRowStates[i]?.[0]
|
|
329
329
|
}))
|
|
330
330
|
);
|
|
331
|
-
|
|
331
|
+
observeBeforeEvents?.();
|
|
332
|
+
return await (observeBeforeEvents || this.hasServerAjaxEventsOfType("gridAdd") ? inlineCaller : inlineTimeout)(async () => {
|
|
332
333
|
return this.asyncAction(async () => {
|
|
333
334
|
const evs = (await res)?.data?.eventsXml;
|
|
334
335
|
if (evs) {
|
|
335
|
-
setAjaxFormResponse(this.form.execution, parseXml(evs));
|
|
336
|
+
const applied = setAjaxFormResponse(this.form.execution, parseXml(evs));
|
|
337
|
+
if (observeBeforeEvents)
|
|
338
|
+
await applied;
|
|
336
339
|
}
|
|
337
340
|
const scriptResult = await this.fireScriptEvent("gridAdd");
|
|
338
341
|
if (!scriptResult || !(await res)?.data?.success) {
|
|
@@ -341,7 +344,7 @@ class Grid extends Field {
|
|
|
341
344
|
} else {
|
|
342
345
|
return true;
|
|
343
346
|
}
|
|
344
|
-
}, !this.hasServerAjaxEventsOfType("gridAdd"));
|
|
347
|
+
}, !observeBeforeEvents && !this.hasServerAjaxEventsOfType("gridAdd"));
|
|
345
348
|
}, 0);
|
|
346
349
|
}
|
|
347
350
|
return false;
|
|
@@ -402,7 +405,8 @@ class Grid extends Field {
|
|
|
402
405
|
await this.fireServerEvent("gridDelete", {
|
|
403
406
|
gridAction: "delete",
|
|
404
407
|
rowId: deletingIndices,
|
|
405
|
-
...options
|
|
408
|
+
...options,
|
|
409
|
+
embeddedColumnlessEdition: this.usesColumnlessEmbeddedEdition()
|
|
406
410
|
});
|
|
407
411
|
} else {
|
|
408
412
|
let minIndex = Infinity;
|
|
@@ -411,7 +415,6 @@ class Grid extends Field {
|
|
|
411
415
|
minIndex = i;
|
|
412
416
|
}
|
|
413
417
|
});
|
|
414
|
-
this.cache.truncate(minIndex);
|
|
415
418
|
const res = this.runAction({
|
|
416
419
|
postData: {
|
|
417
420
|
gridAction: "delete",
|
|
@@ -420,6 +423,17 @@ class Grid extends Field {
|
|
|
420
423
|
...options
|
|
421
424
|
}
|
|
422
425
|
});
|
|
426
|
+
if (this.hasServerAjaxEventsOfType("gridDelete")) {
|
|
427
|
+
const result = await res;
|
|
428
|
+
if (!result?.data?.success) {
|
|
429
|
+
const evs = result?.data?.eventsXml;
|
|
430
|
+
if (evs) {
|
|
431
|
+
setAjaxFormResponse(this.form.execution, parseXml(evs));
|
|
432
|
+
}
|
|
433
|
+
return false;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
this.cache.truncate(minIndex);
|
|
423
437
|
const currentRows = [...this.tableController.body.rows];
|
|
424
438
|
const currentSelection = new Set(
|
|
425
439
|
this.tableController.getState("selection")
|
|
@@ -627,9 +641,10 @@ class Grid extends Field {
|
|
|
627
641
|
hiddenColumns.delete(def.id);
|
|
628
642
|
}
|
|
629
643
|
}
|
|
630
|
-
const initialRowsCount =
|
|
644
|
+
const initialRowsCount = this.resolveRowsCount(
|
|
631
645
|
this.initialStates,
|
|
632
|
-
isTrue(this.getProperty("includeFirstRow"))
|
|
646
|
+
isTrue(this.getProperty("includeFirstRow")),
|
|
647
|
+
this.definition.editionRowCount
|
|
633
648
|
);
|
|
634
649
|
for (let index = 0; index < initialRowsCount; index++) {
|
|
635
650
|
await this.addRowFromDefinitions(
|
|
@@ -673,7 +688,18 @@ class Grid extends Field {
|
|
|
673
688
|
handler.open();
|
|
674
689
|
}
|
|
675
690
|
async refresh() {
|
|
676
|
-
|
|
691
|
+
const refresh = this.asyncAction(this.actualRefreshAction.bind(this));
|
|
692
|
+
this.pendingRefresh = refresh;
|
|
693
|
+
try {
|
|
694
|
+
return await refresh;
|
|
695
|
+
} finally {
|
|
696
|
+
if (this.pendingRefresh === refresh)
|
|
697
|
+
this.pendingRefresh = void 0;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
async waitForPendingRefresh() {
|
|
701
|
+
while (this.pendingRefresh)
|
|
702
|
+
await this.pendingRefresh;
|
|
677
703
|
}
|
|
678
704
|
async sortColumn(fldId) {
|
|
679
705
|
await this.fireEvent("gridColumnSelect", {
|
|
@@ -772,23 +798,44 @@ class Grid extends Field {
|
|
|
772
798
|
this.calculateMustShowAdditionalColumn();
|
|
773
799
|
}
|
|
774
800
|
async validate() {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const
|
|
784
|
-
if (
|
|
785
|
-
|
|
786
|
-
firstInvalid
|
|
801
|
+
await this.mutex.acquire();
|
|
802
|
+
try {
|
|
803
|
+
if (this.properties.displayNone)
|
|
804
|
+
return true;
|
|
805
|
+
let isValid = true;
|
|
806
|
+
let firstInvalid = null;
|
|
807
|
+
for await (const row of this.tableController.body.rows) {
|
|
808
|
+
for await (const cell of row.cells) {
|
|
809
|
+
const field = cell.getState("properties")?.field;
|
|
810
|
+
if (field instanceof Field) {
|
|
811
|
+
const result = !field.state.validation.businessError && await field.validate();
|
|
812
|
+
if (!result && isValid && !firstInvalid) {
|
|
813
|
+
isValid = false;
|
|
814
|
+
firstInvalid = field;
|
|
815
|
+
}
|
|
787
816
|
}
|
|
788
817
|
}
|
|
789
818
|
}
|
|
819
|
+
return isValid || firstInvalid;
|
|
820
|
+
} finally {
|
|
821
|
+
this.mutex.release();
|
|
790
822
|
}
|
|
791
|
-
|
|
823
|
+
}
|
|
824
|
+
usesColumnlessEmbeddedEdition() {
|
|
825
|
+
return this.fieldsDefinitions.length === 0 && Boolean(this.getProperty("gridForm")) && getValueByPath(
|
|
826
|
+
getWindow(this.getForm().execution),
|
|
827
|
+
"config.execution.components.dataGrid.editionGridView"
|
|
828
|
+
) === "embedded" && !this.getProperty("cssClass")?.split(/\s+/).includes("standAlone");
|
|
829
|
+
}
|
|
830
|
+
resolveRowsCount(states, includeFirstRow, editionRowCount) {
|
|
831
|
+
if (states.length > 0 || !this.usesColumnlessEmbeddedEdition() || editionRowCount === void 0) {
|
|
832
|
+
return getGridStatesRowCount(states, includeFirstRow);
|
|
833
|
+
}
|
|
834
|
+
const totalRows = Number(editionRowCount);
|
|
835
|
+
if (!Number.isSafeInteger(totalRows) || totalRows < 0) {
|
|
836
|
+
throw new Error("Invalid grid edition row count.");
|
|
837
|
+
}
|
|
838
|
+
return this.isPaged ? Math.min(this.pageSize, Math.max(0, totalRows - this.startIndex)) : totalRows;
|
|
792
839
|
}
|
|
793
840
|
async actualRefreshAction() {
|
|
794
841
|
const previousVisibilityHidden = this.properties.visibilityHidden;
|
|
@@ -912,11 +959,12 @@ class Grid extends Field {
|
|
|
912
959
|
const statesArray = fieldsArray.map(
|
|
913
960
|
(field) => arrayOrArray(field.fieldValue || field.row)
|
|
914
961
|
);
|
|
915
|
-
const rowCount =
|
|
962
|
+
const rowCount = this.resolveRowsCount(
|
|
916
963
|
statesArray,
|
|
917
964
|
isTrue(
|
|
918
965
|
xml.properties.includeFirstRow ?? this.getProperty("includeFirstRow")
|
|
919
|
-
)
|
|
966
|
+
),
|
|
967
|
+
xml.editionRowCount
|
|
920
968
|
);
|
|
921
969
|
this.properties.pages = xml.pages || this.properties.pages;
|
|
922
970
|
this.properties.currentPage = xml.curPage || this.properties.currentPage;
|
|
@@ -1039,7 +1087,11 @@ class Grid extends Field {
|
|
|
1039
1087
|
{
|
|
1040
1088
|
postDataTreatment: "stringify",
|
|
1041
1089
|
stringifyOptions: { arrayFormat: "repeat" },
|
|
1042
|
-
...postData
|
|
1090
|
+
...postData,
|
|
1091
|
+
postData: {
|
|
1092
|
+
...postData.postData,
|
|
1093
|
+
embeddedColumnlessEdition: this.usesColumnlessEmbeddedEdition() && postData.postData?.gridAction === "delete" ? true : void 0
|
|
1094
|
+
}
|
|
1043
1095
|
}
|
|
1044
1096
|
);
|
|
1045
1097
|
}
|