@sankhyalabs/core 4.1.1 → 4.2.1
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/.docs/classes/Change.md +11 -11
- package/.docs/classes/DataUnit.md +104 -49
- package/.docs/enums/Action.md +14 -3
- package/.docs/enums/ChangeOperation.md +4 -4
- package/.docs/interfaces/AllRecord.md +96 -0
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/QuickFilter.md +2 -2
- package/.docs/interfaces/Record.md +6 -4
- package/.docs/interfaces/SavedRecord.md +5 -5
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/modules.md +1 -0
- package/dist/dataunit/DataUnit.d.ts +37 -10
- package/dist/dataunit/DataUnit.js +45 -16
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/state/action/DataUnitAction.d.ts +1 -0
- package/dist/dataunit/state/action/DataUnitAction.js +1 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js +1 -1
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/SelectionSlice.d.ts +4 -3
- package/dist/dataunit/state/slice/SelectionSlice.js +29 -23
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/JSUtils.js +2 -2
- package/dist/utils/JSUtils.js.map +1 -1
- package/package.json +1 -1
- package/src/dataunit/DataUnit.ts +58 -22
- package/src/dataunit/state/action/DataUnitAction.ts +2 -0
- package/src/dataunit/state/slice/CurrentRecordsSlice.ts +1 -1
- package/src/dataunit/state/slice/SelectionSlice.ts +40 -33
- package/src/index.ts +3 -2
- package/src/utils/JSUtils.ts +4 -4
|
@@ -15,7 +15,7 @@ class SelectionReducerImpl {
|
|
|
15
15
|
const removed = action.payload.records;
|
|
16
16
|
if (currentState && removed) {
|
|
17
17
|
const currentSelection = currentState.currentSelection;
|
|
18
|
-
const record = currentSelection.filter(
|
|
18
|
+
const record = currentSelection.filter((selectedRecord) => !removed.includes(selectedRecord.__record__id__));
|
|
19
19
|
if (record.length === 0) {
|
|
20
20
|
const currentRecords = getCurrentRecords(stateManager);
|
|
21
21
|
let removedIndex = action.payload.removedIndex.slice(-1)[0];
|
|
@@ -26,9 +26,9 @@ class SelectionReducerImpl {
|
|
|
26
26
|
else {
|
|
27
27
|
removedIndex++;
|
|
28
28
|
}
|
|
29
|
-
currentRecords.forEach((value
|
|
29
|
+
currentRecords.forEach((value) => {
|
|
30
30
|
if (currentIndex === removedIndex) {
|
|
31
|
-
record.push(
|
|
31
|
+
record.push(value);
|
|
32
32
|
}
|
|
33
33
|
currentIndex++;
|
|
34
34
|
});
|
|
@@ -46,10 +46,10 @@ class SelectionReducerImpl {
|
|
|
46
46
|
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
index = getItemIndex(currentSelection[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
49
|
+
index = getItemIndex(currentSelection[0].__record__id__, currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
50
50
|
}
|
|
51
51
|
if (index < currentRecords.size && index >= 0) {
|
|
52
|
-
return { currentSelection: [Array.from(currentRecords.values())[index]
|
|
52
|
+
return { currentSelection: [Array.from(currentRecords.values())[index]] };
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
return undefined;
|
|
@@ -59,16 +59,29 @@ class SelectionReducerImpl {
|
|
|
59
59
|
const currentRecords = getCurrentRecords(stateManager);
|
|
60
60
|
if (currentRecords) {
|
|
61
61
|
const records = Array.from(currentRecords.values());
|
|
62
|
-
const
|
|
62
|
+
const selectionRecord = [];
|
|
63
63
|
selectionSource.forEach((i) => {
|
|
64
64
|
if (i >= 0 && i < currentRecords.size) {
|
|
65
|
-
|
|
65
|
+
selectionRecord.push(records[i]);
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
|
-
return { currentSelection:
|
|
68
|
+
return { currentSelection: selectionRecord };
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
return { currentSelection:
|
|
71
|
+
return { currentSelection: selectionSource };
|
|
72
|
+
case Action.SELECTION_REMOVED:
|
|
73
|
+
if (currentState != undefined) {
|
|
74
|
+
const { unselection } = action.payload;
|
|
75
|
+
const currentSelection = currentState.currentSelection;
|
|
76
|
+
const selectionFiltered = currentSelection === null || currentSelection === void 0 ? void 0 : currentSelection.filter((selectedRecord) => {
|
|
77
|
+
return !(unselection || [])
|
|
78
|
+
.some((unselectedRecord) => {
|
|
79
|
+
return unselectedRecord.__record__id__ === selectedRecord.__record__id__;
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
return { currentSelection: selectionFiltered };
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
72
85
|
case Action.EDITION_CANCELED:
|
|
73
86
|
if (currentState === null || currentState === void 0 ? void 0 : currentState.lastSelection) {
|
|
74
87
|
return { currentSelection: currentState.lastSelection };
|
|
@@ -79,7 +92,7 @@ class SelectionReducerImpl {
|
|
|
79
92
|
}
|
|
80
93
|
export const SelectionReducer = new SelectionReducerImpl();
|
|
81
94
|
export const getSelection = (stateManager) => {
|
|
82
|
-
|
|
95
|
+
const selection = getCurrentSelection(stateManager);
|
|
83
96
|
if (!selection || selection.length === 0) {
|
|
84
97
|
return [];
|
|
85
98
|
}
|
|
@@ -92,7 +105,7 @@ export const hasNext = (stateManager) => {
|
|
|
92
105
|
if (!selection || selection.length === 0) {
|
|
93
106
|
return records.size > 0;
|
|
94
107
|
}
|
|
95
|
-
return records.size > (getItemIndex(selection[0], records) + 1);
|
|
108
|
+
return records.size > (getItemIndex(selection[0].__record__id__, records) + 1);
|
|
96
109
|
}
|
|
97
110
|
return false;
|
|
98
111
|
};
|
|
@@ -103,17 +116,10 @@ export const hasPrevious = (stateManager) => {
|
|
|
103
116
|
if (!selection || selection.length === 0) {
|
|
104
117
|
return false;
|
|
105
118
|
}
|
|
106
|
-
return getItemIndex(selection[0], records) > 0;
|
|
119
|
+
return getItemIndex(selection[0].__record__id__, records) > 0;
|
|
107
120
|
}
|
|
108
121
|
return false;
|
|
109
122
|
};
|
|
110
|
-
function getFilteredSelection(selection, stateManager) {
|
|
111
|
-
if (selection) {
|
|
112
|
-
const records = getCurrentRecords(stateManager);
|
|
113
|
-
return selection.filter(id => records.has(id));
|
|
114
|
-
}
|
|
115
|
-
return selection;
|
|
116
|
-
}
|
|
117
123
|
function getItemIndex(key, map) {
|
|
118
124
|
return Array.from(map.keys()).indexOf(key);
|
|
119
125
|
}
|
|
@@ -121,13 +127,13 @@ function updateSavedIds(stateManager, savedRecords) {
|
|
|
121
127
|
const currentSelection = getSelection(stateManager);
|
|
122
128
|
if (currentSelection) {
|
|
123
129
|
const newSelection = [];
|
|
124
|
-
currentSelection.forEach(
|
|
125
|
-
const record = savedRecords.find(r => r.__old__id__ ===
|
|
130
|
+
currentSelection.forEach(recordSelection => {
|
|
131
|
+
const record = savedRecords.find(r => r.__old__id__ === recordSelection.__record__id__);
|
|
126
132
|
if (record) {
|
|
127
|
-
newSelection.push(record
|
|
133
|
+
newSelection.push(record);
|
|
128
134
|
}
|
|
129
135
|
else {
|
|
130
|
-
newSelection.push(
|
|
136
|
+
newSelection.push(recordSelection);
|
|
131
137
|
}
|
|
132
138
|
});
|
|
133
139
|
return newSelection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectionSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/SelectionSlice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAG7D,MAAM,oBAAoB;IAA1B;QAEW,c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AY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;aAC7B;iBAAM;gBACH,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;aACtC;QACL,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;KACvB;IACD,OAAO,gBAAgB,CAAC;AAC5B,CAAC;AAED,SAAS,mBAAmB,CAAC,YAA0B;;IACnD,OAAO,MAAA,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,KAAqB,EAAE,EAAE,CAAC,KAAK,CAAC,0CAAE,gBAAgB,CAAC;AAC/G,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { HttpProvider } from "./http/HttpProvider.js";
|
|
|
9
9
|
import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
|
|
10
10
|
import { RequestMetadata } from "./http/RequestMetadata.js";
|
|
11
11
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
|
|
12
|
-
import DataUnit, { SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter } from "./dataunit/DataUnit.js";
|
|
12
|
+
import DataUnit, { SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, AllRecord } from "./dataunit/DataUnit.js";
|
|
13
13
|
import { DataType } from "./dataunit/metadata/DataType.js";
|
|
14
14
|
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
|
|
15
15
|
import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
|
|
@@ -27,4 +27,4 @@ import { ElementIDUtils, IElementIDInfo } from "./utils/ElementIDUtils.js";
|
|
|
27
27
|
import { UserAgentUtils } from "./utils/UserAgentUtils/index.js";
|
|
28
28
|
import { JSUtils } from "./utils/JSUtils.js";
|
|
29
29
|
import { DataUnitStorage } from "./dataunit/DataUnitStorage.js";
|
|
30
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DependencyType, ChildDescriptor, ChildLink, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, ExecutionContext, PaginationInfo, SortingProvider, SortMode, LoadDataRequest, LoadDataResponse, ElementIDUtils, IElementIDInfo, UserAgentUtils, JSUtils };
|
|
30
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, ArrayUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataUnitStorage, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, DependencyType, ChildDescriptor, ChildLink, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor, ApplicationContext, WaitingChange, PageRequest, QuickFilter, ReadyUtil, ObjectUtils, WarningException, WaitingChangeException, ErrorException, ErrorTracking, ExecutionContext, PaginationInfo, SortingProvider, SortMode, LoadDataRequest, LoadDataResponse, ElementIDUtils, IElementIDInfo, UserAgentUtils, JSUtils, AllRecord };
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,eAAe,MAAM,yBAAyB,CAAC;AACtD,OAAO,SAAS,MAA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C,CAAC;AACrG,OAAO,kBAAkB,MAAM,+BAA+B,CAAC;AAC/D,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,WAAW,MAAM,wBAAwB,CAAC;AACjD,OAAO,gBAAgB,MAAM,kCAAkC,CAAC;AAChE,OAAO,sBAAsB,MAAM,wCAAwC,CAAC;AAC5E,OAAO,cAAc,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D,OAAO,EAAE,cAAc,EAAkB,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAGhE,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EACR,eAAe,EAGf,QAAQ,EAGR,aAAa,EACb,cAAc,EAGd,cAAc,EACd,MAAM,EACN,MAAM,EAGN,eAAe,EAEf,kBAAkB,EAIlB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,aAAa,EAIb,QAAQ,EAGR,cAAc,EAEd,cAAc,EACd,OAAO,EAEV,CAAC"}
|
package/dist/utils/JSUtils.js
CHANGED
|
@@ -42,12 +42,12 @@ export class JSUtils {
|
|
|
42
42
|
* @returns - Retorna um valor booleando informando se a string está encodada com base64.
|
|
43
43
|
*/
|
|
44
44
|
static isBase64(str) {
|
|
45
|
-
str = str.replaceAll("\n", "");
|
|
45
|
+
str = (str || '').replaceAll("\n", "");
|
|
46
46
|
if (str === '' || str.trim() === '') {
|
|
47
47
|
return false;
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
return btoa(atob(str)) == str;
|
|
50
|
+
return window.btoa(window.atob(str)) == str;
|
|
51
51
|
}
|
|
52
52
|
catch (err) {
|
|
53
53
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JSUtils.js","sourceRoot":"","sources":["../../src/utils/JSUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,OAAO;IAElB;;;;;;;OAOG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAa,EAAE,UAAkB,GAAG;QACvD,IAAI,KAAU,CAAC;QACf,OAAO,CAAC,GAAG,IAAS,EAAE,EAAE;YACtB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAA0B;QACvD,IAAI,OAAO,IAAI,SAAS,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE;YAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvE,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,MAAK,UAAU,CAAC;SAC7C;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"JSUtils.js","sourceRoot":"","sources":["../../src/utils/JSUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,OAAO;IAElB;;;;;;;OAOG;IACI,MAAM,CAAC,QAAQ,CAAC,QAAa,EAAE,UAAkB,GAAG;QACvD,IAAI,KAAU,CAAC;QACf,OAAO,CAAC,GAAG,IAAS,EAAE,EAAE;YACtB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,gBAAgB,CAAC,OAA0B;QACvD,IAAI,OAAO,IAAI,SAAS,EAAE;YACxB,OAAO,KAAK,CAAC;SACd;QAED,IAAI,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE;YAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,IAAI,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACvE,OAAO,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,YAAY,MAAK,UAAU,CAAC;SAC7C;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,QAAQ,CAAC,GAAW;QAChC,GAAG,GAAG,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvC,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAC;YAAE,OAAO,KAAK,CAAC;SAAE;QACrD,IAAI;YACA,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;SAC/C;QAAC,OAAO,GAAG,EAAE;YACV,OAAO,KAAK,CAAC;SAChB;IACH,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -440,8 +440,8 @@ export default class DataUnit {
|
|
|
440
440
|
public async removeSelectedRecords(buffered: boolean = false): Promise<Array<string>> {
|
|
441
441
|
const selection = getSelection(this._stateManager);
|
|
442
442
|
if (selection) {
|
|
443
|
-
const records = this.
|
|
444
|
-
return this.removeRecords(selection, records, buffered);
|
|
443
|
+
const records = this.getSelection() || [];
|
|
444
|
+
return this.removeRecords(selection.map(sel => sel.__record__id__), records, buffered);
|
|
445
445
|
}
|
|
446
446
|
return Promise.resolve(selection);
|
|
447
447
|
}
|
|
@@ -737,7 +737,7 @@ export default class DataUnit {
|
|
|
737
737
|
*
|
|
738
738
|
*/
|
|
739
739
|
public copySelected(executionCtx?: ExecutionContext): void {
|
|
740
|
-
const selectedRecords = this.
|
|
740
|
+
const selectedRecords = this.getSelection();
|
|
741
741
|
if (selectedRecords) {
|
|
742
742
|
this.dispatchAction(Action.RECORDS_COPIED, prepareCopiedRecord(this._stateManager, selectedRecords, this.getParentRecordId()), executionCtx);
|
|
743
743
|
}
|
|
@@ -876,26 +876,53 @@ export default class DataUnit {
|
|
|
876
876
|
}
|
|
877
877
|
|
|
878
878
|
/**
|
|
879
|
+
* Obtém todos os registros selecionados.
|
|
879
880
|
*
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
* @returns - Registros selecionados.
|
|
883
|
-
*
|
|
881
|
+
* @returns - Lista de todos os registros selecionados.
|
|
884
882
|
*/
|
|
885
|
-
public getSelection(): Array<
|
|
883
|
+
public getSelection(): Array<Record> {
|
|
886
884
|
return getSelection(this._stateManager);
|
|
887
885
|
}
|
|
888
886
|
|
|
889
887
|
/**
|
|
890
888
|
*
|
|
891
|
-
* Seleciona múltiplos registros
|
|
889
|
+
* Seleciona múltiplos registros.
|
|
892
890
|
*
|
|
893
|
-
* @param selection -
|
|
891
|
+
* @param selection - Registros para selecionar.
|
|
894
892
|
* @param executionCtx - Contexto de execução da seleção dos registros do DataUnit.
|
|
895
893
|
*
|
|
894
|
+
* @returns - Verdadeiro se ação executada.
|
|
895
|
+
*
|
|
896
896
|
*/
|
|
897
|
-
public setSelection(selection: Array<
|
|
898
|
-
this.dispatchAction(Action.SELECTION_CHANGED, { type: "id", selection }, executionCtx);
|
|
897
|
+
public setSelection(selection: Array<Record>, executionCtx?: ExecutionContext): Promise<boolean> {
|
|
898
|
+
return this.dispatchAction(Action.SELECTION_CHANGED, { type: "id", selection }, executionCtx);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
*
|
|
903
|
+
* Remove a seleção de múltiplos registros.
|
|
904
|
+
*
|
|
905
|
+
* @param unselection - Registros para remover a seleção.
|
|
906
|
+
* @param executionCtx - Contexto de execução da remoção da seleção dos registros do DataUnit.
|
|
907
|
+
*
|
|
908
|
+
* @returns - Verdadeiro se ação executada.
|
|
909
|
+
*
|
|
910
|
+
*/
|
|
911
|
+
public setUnselection(unselection: Array<Record>, executionCtx?: ExecutionContext): Promise<boolean> {
|
|
912
|
+
return this.dispatchAction(Action.SELECTION_REMOVED, { type: "id", unselection }, executionCtx);
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
*
|
|
917
|
+
* Remove a seleção de todos os registros.
|
|
918
|
+
*
|
|
919
|
+
* @param executionCtx - Contexto de execução da remoção da seleção dos registros do DataUnit.
|
|
920
|
+
*
|
|
921
|
+
* @returns - Verdadeiro se ação executada.
|
|
922
|
+
*
|
|
923
|
+
*/
|
|
924
|
+
public clearSelection(executionCtx?: ExecutionContext): Promise<boolean> {
|
|
925
|
+
return this.dispatchAction(Action.SELECTION_REMOVED, { type: "id", unselection: this.getSelection() }, executionCtx);
|
|
899
926
|
}
|
|
900
927
|
|
|
901
928
|
/**
|
|
@@ -932,23 +959,27 @@ export default class DataUnit {
|
|
|
932
959
|
* @param selection - Índices desejados para a seleção.
|
|
933
960
|
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
934
961
|
*
|
|
962
|
+
* @returns - Verdadeiro se ação executada.
|
|
963
|
+
*
|
|
935
964
|
*/
|
|
936
|
-
public setSelectionByIndex(selection: Array<number>, executionCtx?: ExecutionContext):
|
|
937
|
-
this.dispatchAction(Action.SELECTION_CHANGED, { type: "index", selection }, executionCtx);
|
|
965
|
+
public setSelectionByIndex(selection: Array<number>, executionCtx?: ExecutionContext): Promise<boolean> {
|
|
966
|
+
return this.dispatchAction(Action.SELECTION_CHANGED, { type: "index", selection }, executionCtx);
|
|
938
967
|
}
|
|
939
968
|
|
|
940
969
|
/**
|
|
941
970
|
*
|
|
942
|
-
* Obtém
|
|
971
|
+
* Obtém os registros selecionados da página atual.
|
|
943
972
|
*
|
|
944
|
-
* @returns - Lista de registros selecionados.
|
|
973
|
+
* @returns - Lista de registros selecionados da página atual.
|
|
945
974
|
*
|
|
946
975
|
*/
|
|
947
976
|
public getSelectedRecords(): Array<Record> | undefined {
|
|
948
|
-
const selection: Array<
|
|
977
|
+
const selection: Array<Record> = this.getSelection();
|
|
949
978
|
if (selection) {
|
|
950
979
|
const currentRecords: Array<Record> = this.records;
|
|
951
|
-
return currentRecords?.filter(record =>
|
|
980
|
+
return currentRecords?.filter((record: Record) => {
|
|
981
|
+
return selection.some((sel: Record) => sel.__record__id__ === record.__record__id__);
|
|
982
|
+
});
|
|
952
983
|
}
|
|
953
984
|
}
|
|
954
985
|
|
|
@@ -960,9 +991,9 @@ export default class DataUnit {
|
|
|
960
991
|
*
|
|
961
992
|
*/
|
|
962
993
|
public getSelectedRecord(): Record | undefined {
|
|
963
|
-
const selection: Array<
|
|
964
|
-
if(!selection) return;
|
|
965
|
-
return this.records.find(record => (selection as Array<
|
|
994
|
+
const selection: Array<Record> = this.getSelection();
|
|
995
|
+
if (!selection) return;
|
|
996
|
+
return this.records.find(record => (selection as Array<Record>).some(sel => sel.__record__id__ === record.__record__id__));
|
|
966
997
|
}
|
|
967
998
|
|
|
968
999
|
/**
|
|
@@ -1356,7 +1387,7 @@ export default class DataUnit {
|
|
|
1356
1387
|
if(!this.dataLoader) return;
|
|
1357
1388
|
if(!this.recordLoader) return;
|
|
1358
1389
|
|
|
1359
|
-
this.recordLoader(this, selection).then(response => {
|
|
1390
|
+
this.recordLoader(this, selection?.map(sel => sel.__record__id__)).then(response => {
|
|
1360
1391
|
this.dispatchAction(Action.RECORD_LOADED, response)
|
|
1361
1392
|
}).catch(cause => {
|
|
1362
1393
|
const {errorCode} = cause;
|
|
@@ -1471,6 +1502,11 @@ export interface SavedRecord extends Record {
|
|
|
1471
1502
|
__old__id__?: string;
|
|
1472
1503
|
}
|
|
1473
1504
|
|
|
1505
|
+
export interface AllRecord extends Record {
|
|
1506
|
+
filter: Array<Filter>;
|
|
1507
|
+
sort: Array<Sort>;
|
|
1508
|
+
}
|
|
1509
|
+
|
|
1474
1510
|
export enum ChangeOperation {
|
|
1475
1511
|
INSERT = "INSERT",
|
|
1476
1512
|
COPY = "COPY",
|
|
@@ -68,7 +68,7 @@ export const getFieldValue = (stateManager: StateManager, fieldName: string): an
|
|
|
68
68
|
if(selection && selection.length > 0){
|
|
69
69
|
const currentRecords = getCurrentRecords(stateManager);
|
|
70
70
|
if(currentRecords){
|
|
71
|
-
const record = currentRecords.get(selection[0]);
|
|
71
|
+
const record = currentRecords.get(selection[0].__record__id__);
|
|
72
72
|
return record ? record[fieldName] : undefined;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
@@ -22,7 +22,7 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
22
22
|
|
|
23
23
|
if (currentState && removed) {
|
|
24
24
|
const currentSelection = currentState.currentSelection;
|
|
25
|
-
const record = currentSelection.filter(
|
|
25
|
+
const record = currentSelection.filter((selectedRecord: Record) => !removed.includes(selectedRecord.__record__id__));
|
|
26
26
|
|
|
27
27
|
if(record.length === 0) {
|
|
28
28
|
const currentRecords = getCurrentRecords(stateManager);
|
|
@@ -35,9 +35,9 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
35
35
|
removedIndex++
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
currentRecords.forEach((value
|
|
38
|
+
currentRecords.forEach((value) => {
|
|
39
39
|
if(currentIndex === removedIndex) {
|
|
40
|
-
record.push(
|
|
40
|
+
record.push(value);
|
|
41
41
|
}
|
|
42
42
|
currentIndex++;
|
|
43
43
|
})
|
|
@@ -57,10 +57,10 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
57
57
|
if (!currentState || currentSelection.length === 0) {
|
|
58
58
|
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
|
|
59
59
|
} else {
|
|
60
|
-
index = getItemIndex(currentSelection[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
60
|
+
index = getItemIndex(currentSelection[0].__record__id__, currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
61
61
|
}
|
|
62
62
|
if (index < currentRecords.size && index >= 0) {
|
|
63
|
-
return { currentSelection: [Array.from(currentRecords.values())[index]
|
|
63
|
+
return { currentSelection: [Array.from(currentRecords.values())[index]] };
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -73,17 +73,34 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
73
73
|
const currentRecords = getCurrentRecords(stateManager);
|
|
74
74
|
if (currentRecords) {
|
|
75
75
|
const records = Array.from(currentRecords.values());
|
|
76
|
-
const
|
|
76
|
+
const selectionRecord: Array<Record> = [];
|
|
77
77
|
selectionSource.forEach((i: number) => {
|
|
78
78
|
if (i >= 0 && i < currentRecords.size) {
|
|
79
|
-
|
|
79
|
+
selectionRecord.push(records[i]);
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
return {currentSelection:
|
|
82
|
+
return {currentSelection: selectionRecord};
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
return {currentSelection:
|
|
86
|
+
return {currentSelection: selectionSource};
|
|
87
|
+
|
|
88
|
+
case Action.SELECTION_REMOVED:
|
|
89
|
+
if (currentState != undefined) {
|
|
90
|
+
const { unselection } = action.payload;
|
|
91
|
+
const currentSelection = currentState.currentSelection;
|
|
92
|
+
const selectionFiltered = currentSelection?.filter((selectedRecord: Record) => {
|
|
93
|
+
return !((unselection || []) as Array<Record>)
|
|
94
|
+
.some((unselectedRecord: Record) => {
|
|
95
|
+
return unselectedRecord.__record__id__ === selectedRecord.__record__id__;
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {currentSelection: selectionFiltered};
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return undefined;
|
|
103
|
+
|
|
87
104
|
case Action.EDITION_CANCELED:
|
|
88
105
|
if(currentState?.lastSelection){
|
|
89
106
|
return { currentSelection: currentState.lastSelection };
|
|
@@ -96,8 +113,8 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
96
113
|
|
|
97
114
|
export const SelectionReducer = new SelectionReducerImpl();
|
|
98
115
|
|
|
99
|
-
export const getSelection = (stateManager: StateManager): Array<
|
|
100
|
-
|
|
116
|
+
export const getSelection = (stateManager: StateManager): Array<Record> => {
|
|
117
|
+
const selection: Array<Record> = getCurrentSelection(stateManager);
|
|
101
118
|
|
|
102
119
|
if (!selection || selection.length === 0) {
|
|
103
120
|
return [];
|
|
@@ -113,7 +130,7 @@ export const hasNext = (stateManager: StateManager): boolean => {
|
|
|
113
130
|
if (!selection || selection.length === 0) {
|
|
114
131
|
return records.size > 0;
|
|
115
132
|
}
|
|
116
|
-
return records.size > (getItemIndex(selection[0], records) + 1);
|
|
133
|
+
return records.size > (getItemIndex(selection[0].__record__id__, records) + 1);
|
|
117
134
|
}
|
|
118
135
|
return false;
|
|
119
136
|
};
|
|
@@ -125,35 +142,25 @@ export const hasPrevious = (stateManager: StateManager): boolean => {
|
|
|
125
142
|
if (!selection || selection.length === 0) {
|
|
126
143
|
return false;
|
|
127
144
|
}
|
|
128
|
-
return getItemIndex(selection[0], records) > 0;
|
|
145
|
+
return getItemIndex(selection[0].__record__id__, records) > 0;
|
|
129
146
|
}
|
|
130
147
|
return false;
|
|
131
148
|
};
|
|
132
149
|
|
|
133
|
-
function getFilteredSelection(selection: Array<string>, stateManager: StateManager): Array<string>{
|
|
134
|
-
|
|
135
|
-
if(selection){
|
|
136
|
-
const records = getCurrentRecords(stateManager);
|
|
137
|
-
return selection.filter(id => records.has(id));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return selection;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
150
|
function getItemIndex(key: string, map: Map<string, any>): number {
|
|
144
151
|
return Array.from(map.keys()).indexOf(key);
|
|
145
152
|
}
|
|
146
153
|
|
|
147
|
-
function updateSavedIds(stateManager:StateManager, savedRecords:Array<SavedRecord>): Array<
|
|
148
|
-
const currentSelection: Array<
|
|
154
|
+
function updateSavedIds(stateManager:StateManager, savedRecords:Array<SavedRecord>): Array<Record>{
|
|
155
|
+
const currentSelection: Array<Record> = getSelection(stateManager);
|
|
149
156
|
if(currentSelection){
|
|
150
|
-
const newSelection: Array<
|
|
151
|
-
currentSelection.forEach(
|
|
152
|
-
const record = savedRecords.find(r => r.__old__id__ ===
|
|
157
|
+
const newSelection: Array<Record> = [];
|
|
158
|
+
currentSelection.forEach(recordSelection => {
|
|
159
|
+
const record = savedRecords.find(r => r.__old__id__ === recordSelection.__record__id__);
|
|
153
160
|
if(record){
|
|
154
|
-
newSelection.push(record
|
|
161
|
+
newSelection.push(record);
|
|
155
162
|
} else {
|
|
156
|
-
newSelection.push(
|
|
163
|
+
newSelection.push(recordSelection);
|
|
157
164
|
}
|
|
158
165
|
});
|
|
159
166
|
return newSelection;
|
|
@@ -161,10 +168,10 @@ function updateSavedIds(stateManager:StateManager, savedRecords:Array<SavedRecor
|
|
|
161
168
|
return currentSelection;
|
|
162
169
|
}
|
|
163
170
|
|
|
164
|
-
function getCurrentSelection(stateManager: StateManager):Array<
|
|
171
|
+
function getCurrentSelection(stateManager: StateManager):Array<Record>{
|
|
165
172
|
return stateManager.select(SelectionReducer.sliceName, (state: SelectionState) => state)?.currentSelection;
|
|
166
173
|
}
|
|
167
174
|
interface SelectionState{
|
|
168
|
-
currentSelection: Array<
|
|
169
|
-
lastSelection?: Array<
|
|
175
|
+
currentSelection: Array<Record>;
|
|
176
|
+
lastSelection?: Array<Record>;
|
|
170
177
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { HttpProvider } from "./http/HttpProvider.js";
|
|
|
9
9
|
import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
|
|
10
10
|
import { RequestMetadata } from "./http/RequestMetadata.js";
|
|
11
11
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
|
|
12
|
-
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter} from "./dataunit/DataUnit.js";
|
|
12
|
+
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, AllRecord} from "./dataunit/DataUnit.js";
|
|
13
13
|
import { DataType } from "./dataunit/metadata/DataType.js";
|
|
14
14
|
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
|
|
15
15
|
import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
|
|
@@ -79,5 +79,6 @@ export {
|
|
|
79
79
|
ElementIDUtils,
|
|
80
80
|
IElementIDInfo,
|
|
81
81
|
UserAgentUtils,
|
|
82
|
-
JSUtils
|
|
82
|
+
JSUtils,
|
|
83
|
+
AllRecord
|
|
83
84
|
};
|
package/src/utils/JSUtils.ts
CHANGED
|
@@ -46,11 +46,11 @@ export class JSUtils{
|
|
|
46
46
|
*
|
|
47
47
|
* @returns - Retorna um valor booleando informando se a string está encodada com base64.
|
|
48
48
|
*/
|
|
49
|
-
public static isBase64(str:string): boolean {
|
|
50
|
-
str = str.replaceAll("\n", "");
|
|
51
|
-
if (str ==='' || str.trim() ===''){ return false; }
|
|
49
|
+
public static isBase64(str: string): boolean {
|
|
50
|
+
str = (str || '').replaceAll("\n", "");
|
|
51
|
+
if (str === '' || str.trim() === ''){ return false; }
|
|
52
52
|
try {
|
|
53
|
-
return btoa(atob(str)) == str;
|
|
53
|
+
return window.btoa(window.atob(str)) == str;
|
|
54
54
|
} catch (err) {
|
|
55
55
|
return false;
|
|
56
56
|
}
|