@sankhyalabs/core 1.0.42 → 1.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/.eslintignore +1 -1
- package/.eslintrc.cjs +34 -34
- package/README.md +54 -54
- package/dist/dataunit/DataUnit.d.ts +87 -82
- package/dist/dataunit/DataUnit.js +290 -278
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/metadata/DataType.d.ts +9 -9
- package/dist/dataunit/metadata/DataType.js +36 -36
- package/dist/dataunit/metadata/UnitMetadata.d.ts +71 -71
- package/dist/dataunit/metadata/UnitMetadata.js +31 -31
- package/dist/dataunit/state/HistReducer.d.ts +10 -10
- package/dist/dataunit/state/HistReducer.js +27 -27
- package/dist/dataunit/state/StateManager.d.ts +57 -57
- package/dist/dataunit/state/StateManager.js +96 -96
- package/dist/dataunit/state/action/DataUnitAction.d.ts +29 -28
- package/dist/dataunit/state/action/DataUnitAction.js +34 -33
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/AddedRecordsSlice.js +25 -25
- package/dist/dataunit/state/slice/ChangesSlice.d.ts +12 -12
- package/dist/dataunit/state/slice/ChangesSlice.js +76 -72
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
- package/dist/dataunit/state/slice/CurrentRecordsSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/CurrentRecordsSlice.js +45 -45
- package/dist/dataunit/state/slice/RecordsSlice.d.ts +10 -10
- package/dist/dataunit/state/slice/RecordsSlice.js +43 -43
- package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -9
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js +24 -24
- package/dist/dataunit/state/slice/SelectionSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/SelectionSlice.js +111 -111
- package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -11
- package/dist/dataunit/state/slice/UnitMetadataSlice.js +20 -20
- package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +9 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js +32 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js.map +1 -0
- package/dist/http/AuthorizedServiceCaller.d.ts +11 -11
- package/dist/http/AuthorizedServiceCaller.js +53 -53
- package/dist/http/HttpProvider.d.ts +25 -25
- package/dist/http/HttpProvider.js +73 -73
- package/dist/http/RequestMetadata.d.ts +30 -30
- package/dist/http/RequestMetadata.js +24 -24
- package/dist/http/SkwHttpProvider.d.ts +9 -9
- package/dist/http/SkwHttpProvider.js +66 -66
- package/dist/index.d.ts +16 -16
- package/dist/index.js +17 -17
- package/dist/index.js.map +1 -1
- package/dist/ui/FloatingManager.d.ts +25 -24
- package/dist/ui/FloatingManager.js +124 -122
- package/dist/ui/FloatingManager.js.map +1 -1
- package/dist/utils/ApplicationContext.d.ts +5 -5
- package/dist/utils/ApplicationContext.js +16 -16
- package/dist/utils/CriteriaModel.d.ts +109 -109
- package/dist/utils/CriteriaModel.js +173 -173
- package/dist/utils/CriteriaParameter.d.ts +69 -69
- package/dist/utils/CriteriaParameter.js +82 -82
- package/dist/utils/DateUtils.d.ts +5 -5
- package/dist/utils/DateUtils.js +42 -42
- package/dist/utils/MaskFormatter.d.ts +126 -126
- package/dist/utils/MaskFormatter.js +275 -275
- package/dist/utils/NumberUtils.d.ts +53 -53
- package/dist/utils/NumberUtils.js +141 -141
- package/dist/utils/StringUtils.d.ts +18 -18
- package/dist/utils/StringUtils.js +53 -53
- package/dist/utils/TimeFormatter.d.ts +33 -33
- package/dist/utils/TimeFormatter.js +97 -97
- package/jest.config.ts +16 -16
- package/mock/http/XMLHttpRequest-mock.js +25 -25
- package/package.json +38 -37
- package/scripts/runlink.bat +1 -0
- package/src/dataunit/DataUnit.ts +374 -356
- package/src/dataunit/metadata/DataType.ts +37 -37
- package/src/dataunit/metadata/UnitMetadata.ts +82 -82
- package/src/dataunit/state/HistReducer.ts +33 -33
- package/src/dataunit/state/StateManager.ts +141 -141
- package/src/dataunit/state/action/DataUnitAction.ts +52 -50
- package/src/dataunit/state/slice/AddedRecordsSlice.ts +32 -32
- package/src/dataunit/state/slice/ChangesSlice.ts +95 -90
- package/src/dataunit/state/slice/CurrentRecordsSlice.ts +53 -53
- package/src/dataunit/state/slice/RecordsSlice.ts +56 -56
- package/src/dataunit/state/slice/RemovedRecordsSlice.ts +29 -29
- package/src/dataunit/state/slice/SelectionSlice.ts +130 -130
- package/src/dataunit/state/slice/UnitMetadataSlice.ts +29 -29
- package/src/dataunit/state/slice/WaitingChangesSlice.ts +44 -0
- package/src/http/AuthorizedServiceCaller.ts +58 -58
- package/src/http/HttpProvider.ts +93 -93
- package/src/http/RequestMetadata.ts +41 -41
- package/src/http/SkwHttpProvider.ts +77 -77
- package/src/index.ts +45 -44
- package/src/ui/FloatingManager.ts +167 -165
- package/src/utils/ApplicationContext.ts +18 -18
- package/src/utils/CriteriaModel.ts +207 -207
- package/src/utils/CriteriaParameter.ts +107 -107
- package/src/utils/DateUtils.ts +52 -52
- package/src/utils/MaskFormatter.ts +322 -322
- package/src/utils/NumberUtils.ts +174 -174
- package/src/utils/StringUtils.ts +60 -60
- package/src/utils/TimeFormatter.ts +97 -97
- package/test/http/HttpProvider.spec.ts +34 -34
- package/test/http/SkwHttpProvider.ts.spec.ts +33 -33
- package/test/util/CriteriaModel.spec.ts +231 -231
- package/test/util/CriteriaParameter.spec.ts +51 -51
- package/test/util/MaskFormatter.spec.ts +138 -138
- package/test/util/NumberUtils.spec.ts +156 -156
- package/test/util/StringUtils.spec.ts +43 -43
- package/test/util/TimeFormatter.spec.ts +25 -25
- package/tsconfig.json +15 -15
- package/dist/application/Application.d.ts +0 -8
- package/dist/application/Application.js +0 -19
- package/dist/application/Application.js.map +0 -1
- package/dist/http/data-fetcher/HttpFetcher.d.ts +0 -14
- package/dist/http/data-fetcher/HttpFetcher.js +0 -164
- package/dist/http/data-fetcher/HttpFetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/DefaultGraphQL.d.ts +0 -3
- package/dist/http/data-fetcher/default/DefaultGraphQL.js +0 -18
- package/dist/http/data-fetcher/default/DefaultGraphQL.js.map +0 -1
- package/dist/http/data-fetcher/default/application-config-fetcher.d.ts +0 -6
- package/dist/http/data-fetcher/default/application-config-fetcher.js +0 -21
- package/dist/http/data-fetcher/default/application-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/data-unit-graphql.d.ts +0 -3
- package/dist/http/data-fetcher/default/data-unit-graphql.js +0 -18
- package/dist/http/data-fetcher/default/data-unit-graphql.js.map +0 -1
- package/dist/http/data-fetcher/default/dataunit-executor.d.ts +0 -10
- package/dist/http/data-fetcher/default/dataunit-executor.js +0 -56
- package/dist/http/data-fetcher/default/dataunit-executor.js.map +0 -1
- package/dist/http/data-fetcher/default/dataunit-fetcher.d.ts +0 -9
- package/dist/http/data-fetcher/default/dataunit-fetcher.js +0 -69
- package/dist/http/data-fetcher/default/dataunit-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/form-config-fetcher.d.ts +0 -2
- package/dist/http/data-fetcher/default/form-config-fetcher.js +0 -3
- package/dist/http/data-fetcher/default/form-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/grid-config-fetcher.d.ts +0 -2
- package/dist/http/data-fetcher/default/grid-config-fetcher.js +0 -3
- package/dist/http/data-fetcher/default/grid-config-fetcher.js.map +0 -1
- package/dist/http/data-fetcher/default/index.d.ts +0 -0
- package/dist/http/data-fetcher/default/index.js +0 -2
- package/dist/http/data-fetcher/default/index.js.map +0 -1
- package/dist/http/data-fetcher/default/sankhya-graphql.d.ts +0 -3
- package/dist/http/data-fetcher/default/sankhya-graphql.js +0 -8
- package/dist/http/data-fetcher/default/sankhya-graphql.js.map +0 -1
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.d.ts +0 -3
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.js +0 -18
- package/dist/http/data-fetcher/graphql/DefaultGraphQl.js.map +0 -1
- package/dist/http/data-fetcher/state/LoadStateManager.d.ts +0 -23
- package/dist/http/data-fetcher/state/LoadStateManager.js +0 -78
- package/dist/http/data-fetcher/state/LoadStateManager.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
-
import StateManager from "../StateManager.js";
|
|
3
|
-
declare class RemovedRecordsReducerImpl implements ActionReducer {
|
|
4
|
-
sliceName: string;
|
|
5
|
-
reduce(_stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare const RemovedRecordsReducer: RemovedRecordsReducerImpl;
|
|
8
|
-
export declare const getRemovedRecords: (stateManager: StateManager) => Array<string>;
|
|
9
|
-
export {};
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
+
import StateManager from "../StateManager.js";
|
|
3
|
+
declare class RemovedRecordsReducerImpl implements ActionReducer {
|
|
4
|
+
sliceName: string;
|
|
5
|
+
reduce(_stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const RemovedRecordsReducer: RemovedRecordsReducerImpl;
|
|
8
|
+
export declare const getRemovedRecords: (stateManager: StateManager) => Array<string>;
|
|
9
|
+
export {};
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
-
class RemovedRecordsReducerImpl {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.sliceName = "hist::removedRecords";
|
|
5
|
-
}
|
|
6
|
-
reduce(_stateManager, currentState, action) {
|
|
7
|
-
switch (action.type) {
|
|
8
|
-
case Action.RECORDS_REMOVED:
|
|
9
|
-
const { records, buffered } = action.payload;
|
|
10
|
-
if (buffered) {
|
|
11
|
-
return (currentState || []).concat(records);
|
|
12
|
-
}
|
|
13
|
-
return currentState;
|
|
14
|
-
case Action.EDITION_CANCELED:
|
|
15
|
-
case Action.DATA_SAVED:
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
return currentState;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
export const RemovedRecordsReducer = new RemovedRecordsReducerImpl();
|
|
22
|
-
export const getRemovedRecords = (stateManager) => {
|
|
23
|
-
return stateManager.select(RemovedRecordsReducer.sliceName, (state) => state);
|
|
24
|
-
};
|
|
1
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
+
class RemovedRecordsReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "hist::removedRecords";
|
|
5
|
+
}
|
|
6
|
+
reduce(_stateManager, currentState, action) {
|
|
7
|
+
switch (action.type) {
|
|
8
|
+
case Action.RECORDS_REMOVED:
|
|
9
|
+
const { records, buffered } = action.payload;
|
|
10
|
+
if (buffered) {
|
|
11
|
+
return (currentState || []).concat(records);
|
|
12
|
+
}
|
|
13
|
+
return currentState;
|
|
14
|
+
case Action.EDITION_CANCELED:
|
|
15
|
+
case Action.DATA_SAVED:
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return currentState;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export const RemovedRecordsReducer = new RemovedRecordsReducerImpl();
|
|
22
|
+
export const getRemovedRecords = (stateManager) => {
|
|
23
|
+
return stateManager.select(RemovedRecordsReducer.sliceName, (state) => state);
|
|
24
|
+
};
|
|
25
25
|
//# sourceMappingURL=RemovedRecordsSlice.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
-
import StateManager from "../StateManager.js";
|
|
3
|
-
declare class SelectionReducerImpl implements ActionReducer {
|
|
4
|
-
sliceName: string;
|
|
5
|
-
reduce(stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
-
}
|
|
7
|
-
export declare const SelectionReducer: SelectionReducerImpl;
|
|
8
|
-
export declare const getSelection: (stateManager: StateManager) => Array<string>;
|
|
9
|
-
export declare const hasNext: (stateManager: StateManager) => boolean;
|
|
10
|
-
export declare const hasPrevious: (stateManager: StateManager) => boolean;
|
|
11
|
-
export {};
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
+
import StateManager from "../StateManager.js";
|
|
3
|
+
declare class SelectionReducerImpl implements ActionReducer {
|
|
4
|
+
sliceName: string;
|
|
5
|
+
reduce(stateManager: StateManager, currentState: Array<string>, action: StateAction): Array<string> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const SelectionReducer: SelectionReducerImpl;
|
|
8
|
+
export declare const getSelection: (stateManager: StateManager) => Array<string>;
|
|
9
|
+
export declare const hasNext: (stateManager: StateManager) => boolean;
|
|
10
|
+
export declare const hasPrevious: (stateManager: StateManager) => boolean;
|
|
11
|
+
export {};
|
|
@@ -1,112 +1,112 @@
|
|
|
1
|
-
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
-
import { getCurrentRecords } from "./CurrentRecordsSlice.js";
|
|
3
|
-
class SelectionReducerImpl {
|
|
4
|
-
constructor() {
|
|
5
|
-
this.sliceName = "hist::selection";
|
|
6
|
-
}
|
|
7
|
-
reduce(stateManager, currentState, action) {
|
|
8
|
-
switch (action.type) {
|
|
9
|
-
case Action.RECORDS_ADDED:
|
|
10
|
-
case Action.RECORDS_COPIED:
|
|
11
|
-
return action.payload.map((r) => r.__record__id__);
|
|
12
|
-
case Action.DATA_SAVED:
|
|
13
|
-
return updateSavedIds(stateManager, action.payload.records);
|
|
14
|
-
case Action.RECORDS_REMOVED:
|
|
15
|
-
const removed = action.payload.records;
|
|
16
|
-
if (currentState && removed) {
|
|
17
|
-
return currentState.filter(recordId => !removed.includes(recordId));
|
|
18
|
-
}
|
|
19
|
-
return currentState;
|
|
20
|
-
case Action.NEXT_SELECTED:
|
|
21
|
-
case Action.PREVIOUS_SELECTED:
|
|
22
|
-
const currentRecords = getCurrentRecords(stateManager);
|
|
23
|
-
if (currentRecords && currentRecords.size > 0) {
|
|
24
|
-
let index;
|
|
25
|
-
if (!currentState || currentState.length === 0) {
|
|
26
|
-
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
30
|
-
}
|
|
31
|
-
if (index < currentRecords.size && index >= 0) {
|
|
32
|
-
return [Array.from(currentRecords.values())[index].__record__id__];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
case Action.SELECTION_CHANGED:
|
|
37
|
-
const { type, selection: selectionSource } = action.payload;
|
|
38
|
-
if (selectionSource && type === "index") {
|
|
39
|
-
const currentRecords = getCurrentRecords(stateManager);
|
|
40
|
-
if (currentRecords) {
|
|
41
|
-
const records = Array.from(currentRecords.values());
|
|
42
|
-
const selectionById = [];
|
|
43
|
-
selectionSource.forEach((i) => {
|
|
44
|
-
if (i > 0 && i < currentRecords.size) {
|
|
45
|
-
selectionById.push(records[i].__record__id__);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
return selectionById;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return selectionSource;
|
|
52
|
-
}
|
|
53
|
-
return currentState;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
export const SelectionReducer = new SelectionReducerImpl();
|
|
57
|
-
export const getSelection = (stateManager) => {
|
|
58
|
-
let selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
59
|
-
const currentRecords = Array.from((getCurrentRecords(stateManager) || new Map()).keys());
|
|
60
|
-
if (selection) {
|
|
61
|
-
selection = selection.filter(id => currentRecords.includes(id));
|
|
62
|
-
}
|
|
63
|
-
if (!selection || selection.length === 0) {
|
|
64
|
-
if (currentRecords && currentRecords.length > 0) {
|
|
65
|
-
return [currentRecords[0]];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return selection;
|
|
69
|
-
};
|
|
70
|
-
export const hasNext = (stateManager) => {
|
|
71
|
-
const records = getCurrentRecords(stateManager);
|
|
72
|
-
if (records) {
|
|
73
|
-
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
74
|
-
if (!selection || selection.length === 0) {
|
|
75
|
-
return records.size > 0;
|
|
76
|
-
}
|
|
77
|
-
return records.size > (getItemIndex(selection[0], records) + 1);
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
};
|
|
81
|
-
export const hasPrevious = (stateManager) => {
|
|
82
|
-
const records = getCurrentRecords(stateManager);
|
|
83
|
-
if (records) {
|
|
84
|
-
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
85
|
-
if (!selection || selection.length === 0) {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return getItemIndex(selection[0], records) > 0;
|
|
89
|
-
}
|
|
90
|
-
return false;
|
|
91
|
-
};
|
|
92
|
-
function getItemIndex(key, map) {
|
|
93
|
-
return Array.from(map.keys()).indexOf(key);
|
|
94
|
-
}
|
|
95
|
-
function updateSavedIds(stateManager, savedRecords) {
|
|
96
|
-
const currentSelection = getSelection(stateManager);
|
|
97
|
-
if (currentSelection) {
|
|
98
|
-
const newSelection = [];
|
|
99
|
-
currentSelection.forEach(id => {
|
|
100
|
-
const record = savedRecords.find(r => r.__old__id__ === id);
|
|
101
|
-
if (record) {
|
|
102
|
-
newSelection.push(record.__record__id__);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
newSelection.push(id);
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return newSelection;
|
|
109
|
-
}
|
|
110
|
-
return currentSelection;
|
|
111
|
-
}
|
|
1
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
+
import { getCurrentRecords } from "./CurrentRecordsSlice.js";
|
|
3
|
+
class SelectionReducerImpl {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.sliceName = "hist::selection";
|
|
6
|
+
}
|
|
7
|
+
reduce(stateManager, currentState, action) {
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case Action.RECORDS_ADDED:
|
|
10
|
+
case Action.RECORDS_COPIED:
|
|
11
|
+
return action.payload.map((r) => r.__record__id__);
|
|
12
|
+
case Action.DATA_SAVED:
|
|
13
|
+
return updateSavedIds(stateManager, action.payload.records);
|
|
14
|
+
case Action.RECORDS_REMOVED:
|
|
15
|
+
const removed = action.payload.records;
|
|
16
|
+
if (currentState && removed) {
|
|
17
|
+
return currentState.filter(recordId => !removed.includes(recordId));
|
|
18
|
+
}
|
|
19
|
+
return currentState;
|
|
20
|
+
case Action.NEXT_SELECTED:
|
|
21
|
+
case Action.PREVIOUS_SELECTED:
|
|
22
|
+
const currentRecords = getCurrentRecords(stateManager);
|
|
23
|
+
if (currentRecords && currentRecords.size > 0) {
|
|
24
|
+
let index;
|
|
25
|
+
if (!currentState || currentState.length === 0) {
|
|
26
|
+
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(1, currentRecords.size);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
index = getItemIndex(currentState[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
30
|
+
}
|
|
31
|
+
if (index < currentRecords.size && index >= 0) {
|
|
32
|
+
return [Array.from(currentRecords.values())[index].__record__id__];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return undefined;
|
|
36
|
+
case Action.SELECTION_CHANGED:
|
|
37
|
+
const { type, selection: selectionSource } = action.payload;
|
|
38
|
+
if (selectionSource && type === "index") {
|
|
39
|
+
const currentRecords = getCurrentRecords(stateManager);
|
|
40
|
+
if (currentRecords) {
|
|
41
|
+
const records = Array.from(currentRecords.values());
|
|
42
|
+
const selectionById = [];
|
|
43
|
+
selectionSource.forEach((i) => {
|
|
44
|
+
if (i > 0 && i < currentRecords.size) {
|
|
45
|
+
selectionById.push(records[i].__record__id__);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return selectionById;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return selectionSource;
|
|
52
|
+
}
|
|
53
|
+
return currentState;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export const SelectionReducer = new SelectionReducerImpl();
|
|
57
|
+
export const getSelection = (stateManager) => {
|
|
58
|
+
let selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
59
|
+
const currentRecords = Array.from((getCurrentRecords(stateManager) || new Map()).keys());
|
|
60
|
+
if (selection) {
|
|
61
|
+
selection = selection.filter(id => currentRecords.includes(id));
|
|
62
|
+
}
|
|
63
|
+
if (!selection || selection.length === 0) {
|
|
64
|
+
if (currentRecords && currentRecords.length > 0) {
|
|
65
|
+
return [currentRecords[0]];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return selection;
|
|
69
|
+
};
|
|
70
|
+
export const hasNext = (stateManager) => {
|
|
71
|
+
const records = getCurrentRecords(stateManager);
|
|
72
|
+
if (records) {
|
|
73
|
+
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
74
|
+
if (!selection || selection.length === 0) {
|
|
75
|
+
return records.size > 0;
|
|
76
|
+
}
|
|
77
|
+
return records.size > (getItemIndex(selection[0], records) + 1);
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
};
|
|
81
|
+
export const hasPrevious = (stateManager) => {
|
|
82
|
+
const records = getCurrentRecords(stateManager);
|
|
83
|
+
if (records) {
|
|
84
|
+
const selection = stateManager.select(SelectionReducer.sliceName, (state) => state);
|
|
85
|
+
if (!selection || selection.length === 0) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return getItemIndex(selection[0], records) > 0;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
function getItemIndex(key, map) {
|
|
93
|
+
return Array.from(map.keys()).indexOf(key);
|
|
94
|
+
}
|
|
95
|
+
function updateSavedIds(stateManager, savedRecords) {
|
|
96
|
+
const currentSelection = getSelection(stateManager);
|
|
97
|
+
if (currentSelection) {
|
|
98
|
+
const newSelection = [];
|
|
99
|
+
currentSelection.forEach(id => {
|
|
100
|
+
const record = savedRecords.find(r => r.__old__id__ === id);
|
|
101
|
+
if (record) {
|
|
102
|
+
newSelection.push(record.__record__id__);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
newSelection.push(id);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return newSelection;
|
|
109
|
+
}
|
|
110
|
+
return currentSelection;
|
|
111
|
+
}
|
|
112
112
|
//# sourceMappingURL=SelectionSlice.js.map
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
-
import { UnitMetadata, FieldDescriptor } from "../../metadata/UnitMetadata.js";
|
|
3
|
-
import StateManager from "../StateManager.js";
|
|
4
|
-
declare class UnitMetadataReducerImpl implements ActionReducer {
|
|
5
|
-
sliceName: string;
|
|
6
|
-
reduce(_stateManager: StateManager, currentState: UnitMetadata, action: StateAction): UnitMetadata;
|
|
7
|
-
}
|
|
8
|
-
export declare const UnitMetadataReducer: UnitMetadataReducerImpl;
|
|
9
|
-
export declare const getMetadata: (stateManager: StateManager) => UnitMetadata;
|
|
10
|
-
export declare const getField: (stateManager: StateManager, fieldName: string) => FieldDescriptor | undefined;
|
|
11
|
-
export {};
|
|
1
|
+
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
2
|
+
import { UnitMetadata, FieldDescriptor } from "../../metadata/UnitMetadata.js";
|
|
3
|
+
import StateManager from "../StateManager.js";
|
|
4
|
+
declare class UnitMetadataReducerImpl implements ActionReducer {
|
|
5
|
+
sliceName: string;
|
|
6
|
+
reduce(_stateManager: StateManager, currentState: UnitMetadata, action: StateAction): UnitMetadata;
|
|
7
|
+
}
|
|
8
|
+
export declare const UnitMetadataReducer: UnitMetadataReducerImpl;
|
|
9
|
+
export declare const getMetadata: (stateManager: StateManager) => UnitMetadata;
|
|
10
|
+
export declare const getField: (stateManager: StateManager, fieldName: string) => FieldDescriptor | undefined;
|
|
11
|
+
export {};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
-
class UnitMetadataReducerImpl {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.sliceName = "unitMetadata";
|
|
5
|
-
}
|
|
6
|
-
reduce(_stateManager, currentState, action) {
|
|
7
|
-
if (action.type === Action.METADATA_LOADED) {
|
|
8
|
-
return action.payload;
|
|
9
|
-
}
|
|
10
|
-
return currentState;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export const UnitMetadataReducer = new UnitMetadataReducerImpl();
|
|
14
|
-
export const getMetadata = (stateManager) => {
|
|
15
|
-
return stateManager.select(UnitMetadataReducer.sliceName, (state) => state);
|
|
16
|
-
};
|
|
17
|
-
export const getField = (stateManager, fieldName) => {
|
|
18
|
-
const md = getMetadata(stateManager);
|
|
19
|
-
return md ? md.fields.find(fmd => fmd.name === fieldName) : undefined;
|
|
20
|
-
};
|
|
1
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
+
class UnitMetadataReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "unitMetadata";
|
|
5
|
+
}
|
|
6
|
+
reduce(_stateManager, currentState, action) {
|
|
7
|
+
if (action.type === Action.METADATA_LOADED) {
|
|
8
|
+
return action.payload;
|
|
9
|
+
}
|
|
10
|
+
return currentState;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const UnitMetadataReducer = new UnitMetadataReducerImpl();
|
|
14
|
+
export const getMetadata = (stateManager) => {
|
|
15
|
+
return stateManager.select(UnitMetadataReducer.sliceName, (state) => state);
|
|
16
|
+
};
|
|
17
|
+
export const getField = (stateManager, fieldName) => {
|
|
18
|
+
const md = getMetadata(stateManager);
|
|
19
|
+
return md ? md.fields.find(fmd => fmd.name === fieldName) : undefined;
|
|
20
|
+
};
|
|
21
21
|
//# sourceMappingURL=UnitMetadataSlice.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { WaitingChange } from "../../DataUnit.js";
|
|
2
|
+
import StateManager, { ActionReducer, StateAction } from "../StateManager.js";
|
|
3
|
+
declare class WaitingCheangesReducerImpl implements ActionReducer {
|
|
4
|
+
sliceName: string;
|
|
5
|
+
reduce(stateManager: StateManager, currentState: Map<string, WaitingChange>, action: StateAction): Map<string, WaitingChange> | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const WaitingChangesReducer: WaitingCheangesReducerImpl;
|
|
8
|
+
export declare const getWaitingChanges: (stateManager: StateManager) => Map<string, WaitingChange>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
2
|
+
class WaitingCheangesReducerImpl {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.sliceName = "waitingChanges";
|
|
5
|
+
}
|
|
6
|
+
reduce(stateManager, currentState, action) {
|
|
7
|
+
let newState;
|
|
8
|
+
switch (action.type) {
|
|
9
|
+
case Action.CHANGING_DATA:
|
|
10
|
+
newState = new Map(currentState);
|
|
11
|
+
Object.entries(action.payload).forEach(([key, value]) => {
|
|
12
|
+
newState.set(key, value);
|
|
13
|
+
});
|
|
14
|
+
return newState;
|
|
15
|
+
case Action.DATA_CHANGED:
|
|
16
|
+
newState = new Map(currentState);
|
|
17
|
+
Object.entries(action.payload).forEach(([key]) => {
|
|
18
|
+
newState.delete(key);
|
|
19
|
+
});
|
|
20
|
+
return newState.size === 0 ? undefined : newState;
|
|
21
|
+
case Action.DATA_SAVED:
|
|
22
|
+
case Action.EDITION_CANCELED:
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return currentState;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export const WaitingChangesReducer = new WaitingCheangesReducerImpl();
|
|
29
|
+
export const getWaitingChanges = (stateManager) => {
|
|
30
|
+
return stateManager.select(WaitingChangesReducer.sliceName, (state) => state);
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=WaitingChangesSlice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WaitingChangesSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/WaitingChangesSlice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAIrD,MAAM,0BAA0B;IAAhC;QAEW,cAAS,GAAW,gBAAgB,CAAC;IA6BhD,CAAC;IA3BU,MAAM,CAAC,YAAyB,EAAE,YAAwC,EAAE,MAAmB;QAClG,IAAI,QAAoC,CAAC;QACzC,QAAO,MAAM,CAAC,IAAI,EAAC;YAEf,KAAK,MAAM,CAAC,aAAa;gBACrB,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;gBACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;oBACpD,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,KAAsB,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC;YAEpB,KAAK,MAAM,CAAC,YAAY;gBACpB,QAAQ,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;gBACjC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE;oBAC7C,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACzB,CAAC,CAAC,CAAC;gBAEH,OAAO,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC;YAEtD,KAAK,MAAM,CAAC,UAAU,CAAC;YACvB,KAAK,MAAM,CAAC,gBAAgB;gBACxB,OAAO,SAAS,CAAC;SACxB;QACD,OAAO,YAAY,CAAC;IACxB,CAAC;CAEJ;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,0BAA0B,EAAE,CAAC;AAEtE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA0B,EAA8B,EAAE;IACxF,OAAO,YAAY,CAAC,MAAM,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC,KAAiC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AAC9G,CAAC,CAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export declare class AuthorizedServiceCaller {
|
|
2
|
-
private serverURL;
|
|
3
|
-
private unauthorizedPath;
|
|
4
|
-
constructor(serverURL: string, unauthorizedPath: string);
|
|
5
|
-
requestService(request: AuthorizedRequest, callback?: Function): Promise<void | Response>;
|
|
6
|
-
}
|
|
7
|
-
export interface AuthorizedRequest {
|
|
8
|
-
url: string;
|
|
9
|
-
body: string;
|
|
10
|
-
method: string;
|
|
11
|
-
}
|
|
1
|
+
export declare class AuthorizedServiceCaller {
|
|
2
|
+
private serverURL;
|
|
3
|
+
private unauthorizedPath;
|
|
4
|
+
constructor(serverURL: string, unauthorizedPath: string);
|
|
5
|
+
requestService(request: AuthorizedRequest, callback?: Function): Promise<void | Response>;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthorizedRequest {
|
|
8
|
+
url: string;
|
|
9
|
+
body: string;
|
|
10
|
+
method: string;
|
|
11
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class AuthorizedServiceCaller {
|
|
11
|
-
constructor(serverURL, unauthorizedPath) {
|
|
12
|
-
this.serverURL = "http://192.168.1.218:8503"; //todo request deve fazer replace de ${serverURL} pelo conteúdo da variável
|
|
13
|
-
this.unauthorizedPath = "/";
|
|
14
|
-
this.serverURL = serverURL;
|
|
15
|
-
this.unauthorizedPath = unauthorizedPath;
|
|
16
|
-
}
|
|
17
|
-
requestService(request, callback) {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
const token = localStorage.getItem('token');
|
|
20
|
-
const body = request === null || request === void 0 ? void 0 : request.body;
|
|
21
|
-
const method = request === null || request === void 0 ? void 0 : request.method;
|
|
22
|
-
let headers;
|
|
23
|
-
if (!token) {
|
|
24
|
-
window.location.pathname = this.unauthorizedPath;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
headers = {
|
|
28
|
-
'Authorization': `${token}`,
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
'Customer-Host': 'http://localhost:8080/sankhyaw'
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
const response = yield yield fetch(this.serverURL, {
|
|
34
|
-
method: method,
|
|
35
|
-
headers: headers,
|
|
36
|
-
body: body
|
|
37
|
-
})
|
|
38
|
-
.catch(e => {
|
|
39
|
-
console.log(e);
|
|
40
|
-
});
|
|
41
|
-
if (response instanceof Response && response.status === 401) {
|
|
42
|
-
localStorage.removeItem('token');
|
|
43
|
-
window.location.pathname = this.unauthorizedPath;
|
|
44
|
-
}
|
|
45
|
-
if (callback && response instanceof Response) {
|
|
46
|
-
callback(response.json().then());
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return response;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
export class AuthorizedServiceCaller {
|
|
11
|
+
constructor(serverURL, unauthorizedPath) {
|
|
12
|
+
this.serverURL = "http://192.168.1.218:8503"; //todo request deve fazer replace de ${serverURL} pelo conteúdo da variável
|
|
13
|
+
this.unauthorizedPath = "/";
|
|
14
|
+
this.serverURL = serverURL;
|
|
15
|
+
this.unauthorizedPath = unauthorizedPath;
|
|
16
|
+
}
|
|
17
|
+
requestService(request, callback) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const token = localStorage.getItem('token');
|
|
20
|
+
const body = request === null || request === void 0 ? void 0 : request.body;
|
|
21
|
+
const method = request === null || request === void 0 ? void 0 : request.method;
|
|
22
|
+
let headers;
|
|
23
|
+
if (!token) {
|
|
24
|
+
window.location.pathname = this.unauthorizedPath;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
headers = {
|
|
28
|
+
'Authorization': `${token}`,
|
|
29
|
+
'Content-Type': 'application/json',
|
|
30
|
+
'Customer-Host': 'http://localhost:8080/sankhyaw'
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const response = yield yield fetch(this.serverURL, {
|
|
34
|
+
method: method,
|
|
35
|
+
headers: headers,
|
|
36
|
+
body: body
|
|
37
|
+
})
|
|
38
|
+
.catch(e => {
|
|
39
|
+
console.log(e);
|
|
40
|
+
});
|
|
41
|
+
if (response instanceof Response && response.status === 401) {
|
|
42
|
+
localStorage.removeItem('token');
|
|
43
|
+
window.location.pathname = this.unauthorizedPath;
|
|
44
|
+
}
|
|
45
|
+
if (callback && response instanceof Response) {
|
|
46
|
+
callback(response.json().then());
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return response;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
54
|
//# sourceMappingURL=AuthorizedServiceCaller.js.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Header } from "./RequestMetadata.js";
|
|
2
|
-
/**
|
|
3
|
-
* Abstração do XMLHttpRequest. Este serviço é responsável por realizar as requisições
|
|
4
|
-
* ao backend. Todos os métodos são estáticos.
|
|
5
|
-
*/
|
|
6
|
-
export declare class HttpProvider {
|
|
7
|
-
/**
|
|
8
|
-
* Faz uma requisição usando o método GET do HTTP para uma URL específica.
|
|
9
|
-
*
|
|
10
|
-
* @param {string} url A URL que deve ser chamada.
|
|
11
|
-
* @param {Array<Header>} headers [Opcional] Cabeçalhos HTTP.
|
|
12
|
-
* @returns {Promise<Object>} Uma promessa de que a requisição será preenchida.
|
|
13
|
-
*/
|
|
14
|
-
static get(url: string, headers?: Array<Header>): Promise<Object>;
|
|
15
|
-
/**
|
|
16
|
-
* Faz uma requisição usando o método POST do HTTP para uma URL específica.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} url A URL que deve ser chamada.
|
|
19
|
-
* @param {Object} payload Informações a serem enviadas.
|
|
20
|
-
* @param {Array<Header>} headers [Opcional] Cabeçalhos HTTP.
|
|
21
|
-
* @returns {Promise<Object>} Uma promessa de que a requisição será preenchida.
|
|
22
|
-
*/
|
|
23
|
-
static post(url: string, payload: Object, headers?: Array<Header>): Promise<any>;
|
|
24
|
-
private static dispatch;
|
|
25
|
-
}
|
|
1
|
+
import { Header } from "./RequestMetadata.js";
|
|
2
|
+
/**
|
|
3
|
+
* Abstração do XMLHttpRequest. Este serviço é responsável por realizar as requisições
|
|
4
|
+
* ao backend. Todos os métodos são estáticos.
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpProvider {
|
|
7
|
+
/**
|
|
8
|
+
* Faz uma requisição usando o método GET do HTTP para uma URL específica.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} url A URL que deve ser chamada.
|
|
11
|
+
* @param {Array<Header>} headers [Opcional] Cabeçalhos HTTP.
|
|
12
|
+
* @returns {Promise<Object>} Uma promessa de que a requisição será preenchida.
|
|
13
|
+
*/
|
|
14
|
+
static get(url: string, headers?: Array<Header>): Promise<Object>;
|
|
15
|
+
/**
|
|
16
|
+
* Faz uma requisição usando o método POST do HTTP para uma URL específica.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} url A URL que deve ser chamada.
|
|
19
|
+
* @param {Object} payload Informações a serem enviadas.
|
|
20
|
+
* @param {Array<Header>} headers [Opcional] Cabeçalhos HTTP.
|
|
21
|
+
* @returns {Promise<Object>} Uma promessa de que a requisição será preenchida.
|
|
22
|
+
*/
|
|
23
|
+
static post(url: string, payload: Object, headers?: Array<Header>): Promise<any>;
|
|
24
|
+
private static dispatch;
|
|
25
|
+
}
|