@sankhyalabs/core 0.0.0-bugfix-dev-KB-68936.0 → 0.0.0-bugfix-dev-kb-67792.0
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 +119 -165
- package/.docs/classes/DateUtils.md +8 -8
- package/.docs/classes/SelectionInfo.md +12 -12
- package/.docs/classes/ServiceCanceledException.md +193 -0
- package/.docs/enumerations/ChangeOperation.md +4 -4
- package/.docs/enumerations/SelectionMode.md +2 -2
- package/.docs/globals.md +1 -0
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/QuickFilter.md +3 -3
- package/.docs/interfaces/Record.md +4 -4
- package/.docs/interfaces/SavedRecord.md +5 -5
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
- package/dist/dataunit/DataUnit.d.ts +0 -10
- package/dist/dataunit/DataUnit.js +10 -17
- package/dist/dataunit/DataUnit.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 +2 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/DateUtils.js +3 -0
- package/dist/utils/DateUtils.js.map +1 -1
- package/package.json +1 -1
- package/reports/test-report.xml +92 -92
- package/src/dataunit/DataUnit.ts +12 -21
- package/src/exceptions/ServiceCanceledException.ts +25 -0
- package/src/index.ts +3 -1
- package/src/utils/DateUtils.ts +3 -0
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -27,6 +27,7 @@ import { DataUnitStorage } from "./DataUnitStorage.js";
|
|
|
27
27
|
import { getInvalidFieldMessage, InvalidFieldsReducer } from "./state/slice/InvalidFieldsSlice.js";
|
|
28
28
|
import { getLoadingProperties, LoadingPropertiesReducer } from "./state/slice/LoadingProperties.js";
|
|
29
29
|
import SortingUtils from "../utils/SortingUtils.js";
|
|
30
|
+
import ServiceCanceledException from "../exceptions/ServiceCanceledException.js";
|
|
30
31
|
|
|
31
32
|
/***
|
|
32
33
|
* `DataUnit`: Atua como uma camada de abstração entre o back-end e a interface do usuário.
|
|
@@ -51,7 +52,6 @@ export default class DataUnit {
|
|
|
51
52
|
private _savingLockers: Promise<any>[] = [];
|
|
52
53
|
private _defaultSorting: Array<Sort>;
|
|
53
54
|
private _allowReleaseCallbacks: boolean;
|
|
54
|
-
private _waitingToReload: boolean = false;
|
|
55
55
|
|
|
56
56
|
public metadataLoader?: (dataUnit: DataUnit) => Promise<UnitMetadata>;
|
|
57
57
|
public dataLoader?: (dataUnit: DataUnit, request: LoadDataRequest) => Promise<LoadDataResponse>;
|
|
@@ -150,21 +150,6 @@ export default class DataUnit {
|
|
|
150
150
|
return this._uuid;
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Retorna se o dataUnit está com recarregamento pendente.
|
|
155
|
-
*/
|
|
156
|
-
public isWaitingToReload(): boolean {
|
|
157
|
-
return this._waitingToReload;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Define se o dataUnit tem um recarregamento pendente.
|
|
162
|
-
* @param isWaiting
|
|
163
|
-
*/
|
|
164
|
-
public setWaitingToReload(isWaiting: boolean){
|
|
165
|
-
this._waitingToReload = isWaiting;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
153
|
/**
|
|
169
154
|
*
|
|
170
155
|
* Obtém o nome de identificação do DataUnit (geralmente em formato de URI - Uniform Resource Identifier).
|
|
@@ -501,7 +486,12 @@ export default class DataUnit {
|
|
|
501
486
|
const {errorCode} = cause;
|
|
502
487
|
this.dispatchAction(Action.SAVING_ERROR);
|
|
503
488
|
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
504
|
-
|
|
489
|
+
if(cause instanceof ServiceCanceledException){
|
|
490
|
+
console.debug("Service canceled: " + cause.message)
|
|
491
|
+
resolve()
|
|
492
|
+
} else{
|
|
493
|
+
fail(new ErrorException("Erro ao salvar alterações", cause, errorCode))
|
|
494
|
+
}
|
|
505
495
|
});
|
|
506
496
|
} else {
|
|
507
497
|
this.dispatchAction(Action.LOADING_PROPERTIES_CLEANED);
|
|
@@ -606,7 +596,7 @@ export default class DataUnit {
|
|
|
606
596
|
const removedIndex: Array<number> = recordIds
|
|
607
597
|
.map(id => currentRecordsKeys.indexOf(id))
|
|
608
598
|
.filter(index => index > -1)
|
|
609
|
-
.sort();
|
|
599
|
+
.sort((a, b) => a - b);
|
|
610
600
|
|
|
611
601
|
const nextIndex = Math.min(removedIndex.slice(-1)[0] + 1, currentRecordsKeys.length);
|
|
612
602
|
const selectionAfterRemove = currentRecordsKeys[nextIndex] ? [currentRecordsKeys[nextIndex]] : [];
|
|
@@ -983,15 +973,16 @@ export default class DataUnit {
|
|
|
983
973
|
*
|
|
984
974
|
*/
|
|
985
975
|
public async setFieldValue(fieldName: string, newValue: any, records?: Array<string>, options?:DataUnitEventOptions): Promise<boolean> {
|
|
986
|
-
if(!this.hasNewRecord() && !this.getSelectedRecord()) await this.addRecord();
|
|
987
976
|
|
|
977
|
+
if(!this.hasNewRecord() && !this.getSelectedRecord()) await this.addRecord();
|
|
978
|
+
|
|
988
979
|
const typedValue = this.validateAndTypeValue(fieldName, newValue);
|
|
989
980
|
const currentValue = this.getFieldValue(fieldName);
|
|
990
981
|
|
|
991
|
-
if(
|
|
982
|
+
if(ObjectUtils.hasEquivalentProps(currentValue, typedValue)){
|
|
992
983
|
return Promise.resolve(false);
|
|
993
984
|
}
|
|
994
|
-
|
|
985
|
+
|
|
995
986
|
if(newValue instanceof Promise){
|
|
996
987
|
const promise:Promise<boolean> = new Promise(accept => {
|
|
997
988
|
newValue.then(resolvedValue => {
|
|
@@ -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
|
@@ -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";
|
|
@@ -112,5 +113,6 @@ export {
|
|
|
112
113
|
OverflowDirection,
|
|
113
114
|
OverFlowWatcherParams,
|
|
114
115
|
OVERFLOWED_CLASS_NAME,
|
|
115
|
-
DataUnitEventOptions
|
|
116
|
+
DataUnitEventOptions,
|
|
117
|
+
ServiceCanceledException
|
|
116
118
|
};
|
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
|
}
|