@sankhyalabs/core 5.20.0-dev.5 → 5.20.0-dev.51
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/README.md +3 -1
- package/.docs/classes/ApplicationContext.md +31 -32
- package/.docs/classes/ArrayUtils.md +95 -83
- package/.docs/classes/AuthorizedServiceCaller.md +25 -34
- package/.docs/classes/Change.md +59 -74
- package/.docs/classes/DataUnit.md +1180 -1086
- package/.docs/classes/DataUnitAction.md +25 -42
- package/.docs/classes/DataUnitStorage.md +40 -43
- package/.docs/classes/DateUtils.md +140 -133
- package/.docs/classes/ElementIDUtils.md +123 -122
- package/.docs/classes/ErrorException.md +67 -88
- package/.docs/classes/ErrorTracking.md +20 -23
- package/.docs/classes/FieldComparator.md +35 -39
- package/.docs/classes/FloatingManager.md +195 -198
- package/.docs/classes/HTMLBuilder.md +14 -20
- package/.docs/classes/HttpProvider.md +45 -41
- package/.docs/classes/IDBRepository.md +201 -196
- package/.docs/classes/JSUtils.md +65 -66
- package/.docs/classes/KeyboardManager.md +95 -87
- package/.docs/classes/{MaskFormatter-1.md → MaskFormatter.md} +93 -128
- package/.docs/classes/NumberUtils.md +163 -152
- package/.docs/classes/ObjectUtils.md +206 -70
- package/.docs/classes/OnboardingUtils.md +36 -51
- package/.docs/classes/OverflowWatcher.md +533 -0
- package/.docs/classes/PromiseSync.md +25 -42
- package/.docs/classes/ReadyUtil.md +31 -41
- package/.docs/classes/RequestMetadata.md +29 -30
- package/.docs/classes/SearchUtils.md +18 -20
- package/.docs/classes/SelectionInfo.md +73 -74
- package/.docs/classes/ServiceCanceledException.md +193 -0
- package/.docs/classes/SkwHttpProvider.md +33 -45
- package/.docs/classes/StringUtils.md +297 -322
- package/.docs/classes/TimeFormatter.md +43 -44
- package/.docs/classes/UserAgentUtils.md +17 -20
- package/.docs/classes/VersionUtils.md +15 -18
- package/.docs/classes/WaitingChangeException.md +63 -84
- package/.docs/classes/WarningException.md +67 -88
- package/.docs/enumerations/Action.md +317 -0
- package/.docs/enumerations/ChangeOperation.md +47 -0
- package/.docs/enumerations/DataType.md +57 -0
- package/.docs/enumerations/DependencyType.md +37 -0
- package/.docs/enumerations/OverflowDirection.md +29 -0
- package/.docs/enumerations/SelectionMode.md +27 -0
- package/.docs/enumerations/SortMode.md +27 -0
- package/.docs/enumerations/UserInterface.md +177 -0
- package/.docs/functions/defaultDataLoader.md +25 -0
- package/.docs/{modules.md → globals.md} +27 -36
- package/.docs/interfaces/ChildDescriptor.md +12 -16
- package/.docs/interfaces/ChildLink.md +9 -12
- package/.docs/interfaces/DUActionInterceptor.md +10 -14
- package/.docs/interfaces/ExecutionContext.md +17 -32
- package/.docs/interfaces/FieldDescriptor.md +52 -66
- package/.docs/interfaces/Filter.md +13 -17
- package/.docs/interfaces/IElementIDInfo.md +11 -14
- package/.docs/interfaces/ILoadResult.md +11 -16
- package/.docs/interfaces/IRepository.md +106 -93
- package/.docs/interfaces/IRepositoryIndex.md +23 -30
- package/.docs/interfaces/LoadDataRequest.md +36 -45
- package/.docs/interfaces/LoadDataResponse.md +11 -14
- package/.docs/interfaces/OverFlowWatcherParams.md +67 -0
- package/.docs/interfaces/PageRequest.md +16 -20
- package/.docs/interfaces/PaginationInfo.md +24 -31
- package/.docs/interfaces/PromiseSyncCallback.md +13 -17
- package/.docs/interfaces/QuickFilter.md +17 -21
- package/.docs/interfaces/Record.md +26 -33
- package/.docs/interfaces/SavedRecord.md +33 -41
- package/.docs/interfaces/Sort.md +12 -16
- package/.docs/interfaces/SortingProvider.md +10 -13
- package/.docs/interfaces/UnitMetadata.md +16 -21
- package/.docs/interfaces/WaitingChange.md +16 -20
- package/.docs/namespaces/MaskFormatter/README.md +17 -0
- package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +13 -0
- package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +13 -0
- package/.docs/type-aliases/DataUnitEventOptions.md +17 -0
- package/.docs/type-aliases/OnOverflowCallBack.md +25 -0
- package/.docs/variables/OVERFLOWED_CLASS_NAME.md +13 -0
- package/dist/dataunit/DataUnit.d.ts +67 -6
- package/dist/dataunit/DataUnit.js +151 -32
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/DataUnitHelper.js +6 -5
- package/dist/dataunit/DataUnitHelper.js.map +1 -1
- package/dist/dataunit/formatting/PrettyFormatter.js +10 -6
- package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
- package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
- package/dist/dataunit/metadata/DataType.js +13 -1
- package/dist/dataunit/metadata/DataType.js.map +1 -1
- package/dist/dataunit/state/action/DataUnitAction.d.ts +5 -1
- package/dist/dataunit/state/action/DataUnitAction.js +4 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/ChangesSlice.js +12 -11
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js +2 -0
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/LoadingProperties.d.ts +9 -0
- package/dist/dataunit/state/slice/LoadingProperties.js +31 -0
- package/dist/dataunit/state/slice/LoadingProperties.js.map +1 -0
- package/dist/dataunit/state/slice/RecordsSlice.js +1 -1
- package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/SelectionSlice.js +4 -4
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
- package/dist/exceptions/ServiceCanceledException.d.ts +14 -0
- package/dist/exceptions/ServiceCanceledException.js +13 -0
- package/dist/exceptions/ServiceCanceledException.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/repository/IRepository.d.ts +6 -0
- package/dist/repository/indexeddb/IDBRepository.d.ts +1 -0
- package/dist/repository/indexeddb/IDBRepository.js +3 -0
- package/dist/repository/indexeddb/IDBRepository.js.map +1 -1
- package/dist/utils/DateUtils.js +3 -0
- package/dist/utils/DateUtils.js.map +1 -1
- package/dist/utils/ElementUtils.d.ts +2 -0
- package/dist/utils/ElementUtils.js +9 -0
- package/dist/utils/ElementUtils.js.map +1 -0
- package/dist/utils/MaskFormatter.d.ts +2 -1
- package/dist/utils/MaskFormatter.js +5 -1
- package/dist/utils/MaskFormatter.js.map +1 -1
- package/dist/utils/ObjectUtils.d.ts +38 -0
- package/dist/utils/ObjectUtils.js +51 -0
- package/dist/utils/ObjectUtils.js.map +1 -1
- package/dist/utils/OnboardingUtils.js +1 -1
- package/dist/utils/OnboardingUtils.js.map +1 -1
- package/dist/utils/OverflowWatcher/index.d.ts +59 -0
- package/dist/utils/OverflowWatcher/index.js +188 -0
- package/dist/utils/OverflowWatcher/index.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.d.ts +6 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js +2 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.d.ts +7 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js +9 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js.map +1 -0
- package/dist/utils/SortingUtils.d.ts +9 -0
- package/dist/utils/SortingUtils.js +24 -0
- package/dist/utils/SortingUtils.js.map +1 -0
- package/jest.config.ts +3 -1
- package/package.json +12 -4
- package/reports/test-report.xml +175 -0
- package/setupTests.js +7 -0
- package/sonar-project.properties +10 -0
- package/src/dataunit/DataUnit.ts +179 -46
- package/src/dataunit/DataUnitHelper.ts +6 -5
- package/src/dataunit/formatting/PrettyFormatter.ts +10 -6
- package/src/dataunit/loading/LoadDataRequest.ts +1 -1
- package/src/dataunit/metadata/DataType.ts +13 -1
- package/src/dataunit/state/action/DataUnitAction.ts +5 -1
- package/src/dataunit/state/slice/ChangesSlice.ts +15 -14
- package/src/dataunit/state/slice/InvalidFieldsSlice.ts +2 -0
- package/src/dataunit/state/slice/LoadingProperties.ts +37 -0
- package/src/dataunit/state/slice/RecordsSlice.ts +1 -1
- package/src/dataunit/state/slice/SelectionSlice.ts +4 -4
- package/src/dataunit/state/slice/test/RecordsSlice.spec.ts +45 -0
- package/src/dataunit/test/DataUnit.spec.ts +44 -0
- package/src/exceptions/ServiceCanceledException.ts +25 -0
- package/src/index.ts +10 -1
- package/src/repository/IRepository.ts +7 -0
- package/src/repository/indexeddb/IDBRepository.ts +4 -0
- package/src/utils/DateUtils.ts +3 -0
- package/src/utils/ElementUtils.ts +10 -0
- package/src/utils/MaskFormatter.ts +5 -1
- package/src/utils/ObjectUtils.ts +56 -0
- package/src/utils/OnboardingUtils.ts +1 -1
- package/src/utils/OverflowWatcher/index.ts +243 -0
- package/src/utils/OverflowWatcher/types/overflow-callback.ts +6 -0
- package/src/utils/OverflowWatcher/types/overflow-direction.ts +7 -0
- package/src/utils/SortingUtils.ts +30 -0
- package/src/utils/test/objectUtils.spec.ts +109 -0
- package/test/dataunit/formatting/PrettyFormatter.spec.ts +177 -0
- package/test/util/ElementUtils.spec.ts +34 -0
- package/test/util/OverflowWatcher.spec.ts +152 -0
- package/.docs/.nojekyll +0 -1
- package/.docs/enums/Action.md +0 -305
- package/.docs/enums/ChangeOperation.md +0 -52
- package/.docs/enums/DataType.md +0 -63
- package/.docs/enums/DependencyType.md +0 -41
- package/.docs/enums/SelectionMode.md +0 -30
- package/.docs/enums/SortMode.md +0 -30
- package/.docs/enums/UserInterface.md +0 -195
- package/.docs/modules/MaskFormatter.md +0 -37
|
@@ -35,6 +35,8 @@ export enum Action{
|
|
|
35
35
|
|
|
36
36
|
SAVING_DATA = "savingData",
|
|
37
37
|
DATA_SAVED = "dataSaved",
|
|
38
|
+
SAVING_ERROR = "savingError",
|
|
39
|
+
SAVING_CANCELED = "savingCanceled",
|
|
38
40
|
|
|
39
41
|
REMOVING_RECORDS = "removingRecords",
|
|
40
42
|
RECORDS_REMOVED = "recordsRemoved",
|
|
@@ -63,6 +65,8 @@ export enum Action{
|
|
|
63
65
|
CHILD_CHANGED = "childChanged",
|
|
64
66
|
|
|
65
67
|
FIELD_INVALIDATED = "fieldInvalidated",
|
|
66
|
-
INVALIDATE_CLEAN = "invalidateClean"
|
|
68
|
+
INVALIDATE_CLEAN = "invalidateClean",
|
|
67
69
|
|
|
70
|
+
LOADING_PROPERTY_ADDED = "loadingPropertyAdded",
|
|
71
|
+
LOADING_PROPERTIES_CLEANED = "loadingPropertiesCleaned"
|
|
68
72
|
}
|
|
@@ -94,27 +94,28 @@ export const getChangedFieldValue = (fieldName: string, record: Record, stateMan
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export const getChangesToSave = (dataUnit: string, stateManager: StateManager): Array<Change> => {
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
|
|
99
98
|
const changes = getChanges(stateManager);
|
|
100
99
|
const selectedRecords = getSelectionRecords(stateManager) || [];
|
|
101
|
-
const records:
|
|
100
|
+
const records: Map<string, Record> = new Map(
|
|
102
101
|
getRecords(stateManager)
|
|
103
102
|
.concat(
|
|
104
|
-
selectedRecords
|
|
105
|
-
.filter(record => !isAddedRecord(record.__record__id__, stateManager)
|
|
106
|
-
)
|
|
103
|
+
selectedRecords.filter(record => !isAddedRecord(record.__record__id__, stateManager))
|
|
107
104
|
)
|
|
105
|
+
.map(r => [r.__record__id__, r])
|
|
108
106
|
);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
107
|
+
|
|
108
|
+
const result: Array<Change> = [];
|
|
109
|
+
|
|
110
|
+
if(changes != undefined){
|
|
111
|
+
Array.from(changes.entries())
|
|
112
|
+
.forEach(([recordId, change]) =>{
|
|
113
|
+
const record = records.get(recordId);
|
|
114
|
+
if(record != undefined){
|
|
115
|
+
result.push(new Change(dataUnit, record, change, ChangeOperation.UPDATE, record.__record__source__id__));
|
|
115
116
|
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
118
119
|
|
|
119
120
|
const addedRecords = getAddedRecords(stateManager);
|
|
120
121
|
if (addedRecords) {
|
|
@@ -15,6 +15,8 @@ class InvalidFieldsReducerImpl implements ActionReducer{
|
|
|
15
15
|
return makeInvalid(currentState, action.payload);
|
|
16
16
|
case Action.INVALIDATE_CLEAN:
|
|
17
17
|
return clearRecord(currentState, action.payload);
|
|
18
|
+
case Action.EDITION_CANCELED:
|
|
19
|
+
return undefined;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
return currentState;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { ActionReducer, StateAction } from "../StateManager.js";
|
|
3
|
+
import { Action } from "../action/DataUnitAction.js";
|
|
4
|
+
import StateManager from "../StateManager.js";
|
|
5
|
+
|
|
6
|
+
class LoadingPropertiesImpl implements ActionReducer{
|
|
7
|
+
|
|
8
|
+
public sliceName: string = "loadingProperties";
|
|
9
|
+
|
|
10
|
+
public reduce(_stateManager:StateManager, currentState: Map<string, string>, action: StateAction): Map<string, string>|undefined {
|
|
11
|
+
switch(action.type){
|
|
12
|
+
case Action.LOADING_PROPERTY_ADDED:
|
|
13
|
+
return buildNewState(currentState, action.payload);
|
|
14
|
+
case Action.LOADING_PROPERTIES_CLEANED:
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return currentState;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const LoadingPropertiesReducer = new LoadingPropertiesImpl();
|
|
22
|
+
|
|
23
|
+
export const getLoadingProperties = (stateManager: StateManager): Map<string, string>|undefined => {
|
|
24
|
+
return stateManager.select(LoadingPropertiesReducer.sliceName, (state: Map<string, string>) => state);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function buildNewState(currentState: Map<string, string>, payload: any): Map<string, string>{
|
|
28
|
+
const newState = new Map(currentState);
|
|
29
|
+
if(payload != undefined){
|
|
30
|
+
for (const [key, value] of Object.entries(payload)) {
|
|
31
|
+
if(typeof key === "string" && typeof value === "string"){
|
|
32
|
+
newState.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return newState;
|
|
37
|
+
}
|
|
@@ -47,7 +47,7 @@ class RecordsReducerImpl implements ActionReducer {
|
|
|
47
47
|
newRecords.push(newRecord);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
return
|
|
50
|
+
return Array.from(recordsMap.values()).concat(newRecords);
|
|
51
51
|
|
|
52
52
|
case Action.RECORD_LOADED:
|
|
53
53
|
action.payload.forEach((record: any) => {
|
|
@@ -31,7 +31,7 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
31
31
|
if (currentRecords && currentRecords.size > 0) {
|
|
32
32
|
let index: number;
|
|
33
33
|
if (!currentState || currentSelection.length === 0) {
|
|
34
|
-
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(
|
|
34
|
+
index = action.type === Action.PREVIOUS_SELECTED ? 0 : Math.min(0, currentRecords.size);
|
|
35
35
|
} else {
|
|
36
36
|
index = getItemIndex(currentSelection[0], currentRecords) + (action.type === Action.PREVIOUS_SELECTED ? -1 : 1);
|
|
37
37
|
}
|
|
@@ -68,7 +68,7 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
68
68
|
if(currentState?.lastSelection){
|
|
69
69
|
return { currentSelection: currentState.lastSelection };
|
|
70
70
|
}
|
|
71
|
-
return { currentSelection: [] }
|
|
71
|
+
return { currentSelection: currentState?.currentSelection || [] }
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
return currentState;
|
|
@@ -94,8 +94,8 @@ export const getSelection = (stateManager: StateManager): Array<string> => {
|
|
|
94
94
|
export const getSelectionInfo = (stateManager: StateManager): SelectionInfo => {
|
|
95
95
|
|
|
96
96
|
const selection = getSelectionState(stateManager);
|
|
97
|
+
const currentRequest = getCurrentRequest(stateManager);
|
|
97
98
|
if(selection && selection.mode === SelectionMode.ALL_RECORDS){
|
|
98
|
-
const currentRequest = getCurrentRequest(stateManager);
|
|
99
99
|
const paginationInfo: PaginationInfo | undefined = getPaginationInfo(stateManager);
|
|
100
100
|
return new SelectionInfo(
|
|
101
101
|
[],
|
|
@@ -106,7 +106,7 @@ export const getSelectionInfo = (stateManager: StateManager): SelectionInfo => {
|
|
|
106
106
|
);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
return new SelectionInfo(getSelectionRecords(stateManager) || [], SelectionMode.SOME_RECORDS, undefined);
|
|
109
|
+
return new SelectionInfo(getSelectionRecords(stateManager) || [], SelectionMode.SOME_RECORDS, undefined, undefined, currentRequest?.sort);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export const hasNext = (stateManager: StateManager): boolean => {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import * as RecordsReducerModule from '../RecordsSlice';
|
|
3
|
+
import StateManager from '../../StateManager';
|
|
4
|
+
import { Record } from '../../../DataUnit';
|
|
5
|
+
import { Action } from '../../action/DataUnitAction';
|
|
6
|
+
|
|
7
|
+
jest.spyOn(RecordsReducerModule, "getRecords").mockImplementation(() => [
|
|
8
|
+
{
|
|
9
|
+
__record__id__: '0',
|
|
10
|
+
}, {
|
|
11
|
+
__record__id__: '1',
|
|
12
|
+
}]);
|
|
13
|
+
|
|
14
|
+
describe('RecordsSlice', () => {
|
|
15
|
+
let stateManager: StateManager;
|
|
16
|
+
let currentState: Array<Record>;
|
|
17
|
+
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
stateManager = new StateManager([RecordsReducerModule.RecordsReducer]);
|
|
20
|
+
currentState = [{
|
|
21
|
+
__record__id__: '0',
|
|
22
|
+
}, {
|
|
23
|
+
__record__id__: '1',
|
|
24
|
+
}]
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should return newlines at the end', () => {
|
|
28
|
+
let records = RecordsReducerModule.RecordsReducer.reduce(stateManager, currentState, {
|
|
29
|
+
type: Action.DATA_SAVED,
|
|
30
|
+
payload: {
|
|
31
|
+
records: [
|
|
32
|
+
{__record__id__: '0'},
|
|
33
|
+
{__record__id__: '2'},
|
|
34
|
+
{__record__id__: '1'},
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
expect(records).toEqual([
|
|
39
|
+
{__record__id__: '0'},
|
|
40
|
+
{__record__id__: '1'},
|
|
41
|
+
{__record__id__: '2'}
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import DataUnit from '../DataUnit';
|
|
2
|
+
import { Action } from '../state/action/DataUnitAction';
|
|
3
|
+
|
|
4
|
+
describe('DataUnit', () => {
|
|
5
|
+
|
|
6
|
+
let dataUnit: DataUnit;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
dataUnit = new DataUnit();
|
|
10
|
+
|
|
11
|
+
dataUnit['dispatchAction'] = jest.fn();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should return false when not waiting to reload', () => {
|
|
15
|
+
expect(dataUnit.isWaitingToReload()).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should set waitingToReload to true', () => {
|
|
19
|
+
dataUnit.setWaitingToReload(true);
|
|
20
|
+
expect(dataUnit.isWaitingToReload()).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should set waitingToReload to false', () => {
|
|
24
|
+
dataUnit.setWaitingToReload(true);
|
|
25
|
+
dataUnit.setWaitingToReload(false);
|
|
26
|
+
expect(dataUnit.isWaitingToReload()).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should dispatch SAVING_CANCELED action with correct fields and recordId', () => {
|
|
30
|
+
const fields = [
|
|
31
|
+
{ name: 'field1', message: 'error1' },
|
|
32
|
+
{ name: 'field2', message: 'error2' }
|
|
33
|
+
];
|
|
34
|
+
const recordId = '12345';
|
|
35
|
+
|
|
36
|
+
dataUnit.savingCanceled(fields, recordId);
|
|
37
|
+
|
|
38
|
+
expect(dataUnit['dispatchAction']).toHaveBeenCalledWith(
|
|
39
|
+
Action.SAVING_CANCELED,
|
|
40
|
+
{ fields, recordId },
|
|
41
|
+
undefined
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ServiceCanceledException`: Exceção lançada quando ocorre o cancelamento de um serviço.
|
|
3
|
+
*/
|
|
4
|
+
export default class ServiceCanceledException extends Error {
|
|
5
|
+
|
|
6
|
+
/** Nome da exceção. */
|
|
7
|
+
public name: string;
|
|
8
|
+
|
|
9
|
+
/** Titulo do erro. */
|
|
10
|
+
public title: string;
|
|
11
|
+
|
|
12
|
+
/** Descrição do erro. */
|
|
13
|
+
public message: string;
|
|
14
|
+
|
|
15
|
+
/** Código do erro, indica o erro disparado pelo backend. */
|
|
16
|
+
public errorCode: string;
|
|
17
|
+
|
|
18
|
+
constructor(title: string, message: string, errorCode: string = "") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "Service Canceled";
|
|
21
|
+
this.title = title;
|
|
22
|
+
this.message = message;
|
|
23
|
+
this.errorCode = errorCode;
|
|
24
|
+
}
|
|
25
|
+
}
|
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, SelectionMode, SelectionInfo} from "./dataunit/DataUnit.js";
|
|
12
|
+
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo, DataUnitEventOptions} 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";
|
|
@@ -19,6 +19,7 @@ import ObjectUtils from "./utils/ObjectUtils.js";
|
|
|
19
19
|
import WarningException from "./exceptions/WarningException.js";
|
|
20
20
|
import WaitingChangeException from "./exceptions/WaitingChangeException.js";
|
|
21
21
|
import ErrorException from "./exceptions/ErrorException.js";
|
|
22
|
+
import ServiceCanceledException from "./exceptions/ServiceCanceledException.js";
|
|
22
23
|
import { ErrorTracking } from "./traking/ErrorTraking.js";
|
|
23
24
|
import { PaginationInfo } from "./dataunit/loading/PaginationInfo.js";
|
|
24
25
|
import { LoadDataRequest } from "./dataunit/loading/LoadDataRequest.js";
|
|
@@ -39,6 +40,7 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js"
|
|
|
39
40
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
40
41
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
41
42
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
43
|
+
import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
42
44
|
|
|
43
45
|
/*Classes públicas no pacote*/
|
|
44
46
|
export {
|
|
@@ -106,4 +108,11 @@ export {
|
|
|
106
108
|
defaultDataLoader,
|
|
107
109
|
KeyboardManager,
|
|
108
110
|
SearchUtils,
|
|
111
|
+
OverflowWatcher,
|
|
112
|
+
OnOverflowCallBack,
|
|
113
|
+
OverflowDirection,
|
|
114
|
+
OverFlowWatcherParams,
|
|
115
|
+
OVERFLOWED_CLASS_NAME,
|
|
116
|
+
DataUnitEventOptions,
|
|
117
|
+
ServiceCanceledException
|
|
109
118
|
};
|
|
@@ -79,4 +79,11 @@ export interface IRepository<T>{
|
|
|
79
79
|
* @returns Promessa de quantidade
|
|
80
80
|
*/
|
|
81
81
|
count(): Promise<number>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Retorna todos os registros que estão em cache no momento
|
|
85
|
+
*
|
|
86
|
+
* @returns Todos registros que estão em cache no momento
|
|
87
|
+
*/
|
|
88
|
+
getFromCache(): Array<T> | undefined
|
|
82
89
|
}
|
|
@@ -320,6 +320,10 @@ export class IDBRepository<T> implements IRepository<T>{
|
|
|
320
320
|
const tx = db.transaction(this._addedStoreName);
|
|
321
321
|
return tx.objectStore(this._addedStoreName).getAll();
|
|
322
322
|
}
|
|
323
|
+
|
|
324
|
+
public getFromCache(): Array<T> | undefined{
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
/**
|
package/src/utils/DateUtils.ts
CHANGED
|
@@ -39,6 +39,9 @@ export default class DateUtils{
|
|
|
39
39
|
* @returns - Uma string com as horas no formato HH:MM ou HH:MM:SS.
|
|
40
40
|
*/
|
|
41
41
|
public static formatTime(date: Date, showSeconds: boolean = false): string{
|
|
42
|
+
if (date == null){
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
42
45
|
const timeOptions:Intl.DateTimeFormatOptions = {hour: "2-digit", minute: "2-digit", second: showSeconds ? "2-digit" : undefined};
|
|
43
46
|
return new Intl.DateTimeFormat("pt-BR", timeOptions).format(date);
|
|
44
47
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OverflowDirection } from './OverflowWatcher/types/overflow-direction.js';
|
|
2
|
+
|
|
3
|
+
export function calcMarginSize(el:Element, scrollDirection: OverflowDirection){
|
|
4
|
+
const computedStyle = getComputedStyle(el);
|
|
5
|
+
if(OverflowDirection.HORIZONTAL === scrollDirection){
|
|
6
|
+
return (parseInt(computedStyle.marginLeft || '0') + parseInt(computedStyle.marginRight || '0'));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return (parseInt(computedStyle.marginTop || '0') + parseInt(computedStyle.marginBottom || '0'));
|
|
10
|
+
}
|
|
@@ -96,9 +96,13 @@ export class MaskFormatter {
|
|
|
96
96
|
* Formata a string passada baseada na máscara definda pelo atributo mask.
|
|
97
97
|
*
|
|
98
98
|
* @param value Valor a ser formatado.
|
|
99
|
+
* @param trimBefore Executa um trim para remover espaços em branco.
|
|
99
100
|
* @return O valor processado de acordo com o padrão.
|
|
100
101
|
*/
|
|
101
|
-
public format(value: string): string {
|
|
102
|
+
public format(value: string, trimBefore: boolean = false): string {
|
|
103
|
+
if(trimBefore){
|
|
104
|
+
value = value.trim();
|
|
105
|
+
}
|
|
102
106
|
let result: string = '';
|
|
103
107
|
const index: Array<number> = [0];
|
|
104
108
|
|
package/src/utils/ObjectUtils.ts
CHANGED
|
@@ -84,4 +84,60 @@ export default class ObjectUtils{
|
|
|
84
84
|
public static equals(obj1: any, obj2: any): any {
|
|
85
85
|
return ObjectUtils.objectToString(obj1) === ObjectUtils.objectToString(obj2);
|
|
86
86
|
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Compara se o valor de dois items são equivalentes.
|
|
90
|
+
* Comparando tanto o valor do item em si, quanto sua propriedade "value"
|
|
91
|
+
*
|
|
92
|
+
* @param obj1 - Objeto a ser comparado.
|
|
93
|
+
* @param obj2 - Objeto a ser comparado.
|
|
94
|
+
* @param propToCompare - propriedade que deve ser comparada.
|
|
95
|
+
* @returns - Se o objeto 1 é equivalente ao objeto 2.
|
|
96
|
+
*
|
|
97
|
+
* * @example
|
|
98
|
+
* hasEquivalentProps('123', {value: '123', label: teste}, 'value') | Retorna: true
|
|
99
|
+
* @example
|
|
100
|
+
* hasEquivalentProps('xpto', {value: '123', label: teste}, 'propName') | Retorna: false
|
|
101
|
+
*/
|
|
102
|
+
public static hasEquivalentProps(obj1: any, obj2: any, propToCompare:string = "value"): boolean{
|
|
103
|
+
return this.getComparableProp(obj1, propToCompare) == this.getComparableProp(obj2, propToCompare);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private static getComparableProp(value: any, propToCompare:string = "value"): boolean{
|
|
107
|
+
if (typeof value === 'object' && value !== null && propToCompare in value) {
|
|
108
|
+
return value[propToCompare];
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Verifica se o objeto está vazio (sem atributos).
|
|
115
|
+
*
|
|
116
|
+
* @param obj - Objeto a ser verificado.
|
|
117
|
+
* @returns - True caso o objeto esteja vazio.
|
|
118
|
+
*/
|
|
119
|
+
public static isEmpty(obj: object): boolean{
|
|
120
|
+
return Object.keys(obj).length === 0 && obj.constructor === Object;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Verifica se o objeto NÃO está vazio (sem atributos).
|
|
125
|
+
*
|
|
126
|
+
* @param obj - Objeto a ser verificado.
|
|
127
|
+
* @returns - True caso o objeto NÃO esteja vazio
|
|
128
|
+
*/
|
|
129
|
+
public static isNotEmpty(obj: object): boolean{
|
|
130
|
+
return !this.isEmpty(obj);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Busca a propriedade de um objeto baseado em seu caminho.
|
|
135
|
+
*
|
|
136
|
+
* @param obj - Objeto a ser verificado.
|
|
137
|
+
* @param keyPath - Caminho da propriedade a ser buscada.
|
|
138
|
+
* @returns - O valor da propriedade caso ela exista.
|
|
139
|
+
*/
|
|
140
|
+
public static getProp(obj: Record<string, any>, keyPath: string): Record<string, any> | undefined {
|
|
141
|
+
return keyPath.split('.').reduce((previous, current) => previous?.[current], obj);
|
|
142
|
+
}
|
|
87
143
|
}
|
|
@@ -32,7 +32,7 @@ export class OnboardingUtils {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
private register(ctx: EnvironmentContext){
|
|
35
|
-
(window as any).userGuiding.identify(`${ctx.userID}-${ctx.userName}-${ctx.clientGaId}`, ctx);
|
|
35
|
+
(window as any).userGuiding.identify(`${encodeURIComponent(ctx.userID)}-${encodeURIComponent(ctx.userName)}-${encodeURIComponent(ctx.clientGaId)}`, ctx);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|