@sankhyalabs/core 2.3.6 → 2.4.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/ApplicationContext.md +24 -10
- package/.docs/classes/ArrayUtils.md +24 -14
- package/.docs/classes/Change.md +40 -18
- package/.docs/classes/DataUnit.md +418 -225
- package/.docs/classes/DateUtils.md +95 -36
- package/.docs/classes/ElementIDUtils.md +70 -37
- package/.docs/classes/ErrorException.md +12 -4
- package/.docs/classes/ErrorTracking.md +13 -5
- package/.docs/classes/FloatingManager.md +104 -63
- package/.docs/classes/MaskFormatter-1.md +17 -17
- package/.docs/classes/NumberUtils.md +74 -35
- package/.docs/classes/ObjectUtils.md +34 -12
- package/.docs/classes/ReadyUtil.md +18 -6
- package/.docs/classes/StringUtils.md +108 -52
- package/.docs/classes/TimeFormatter.md +9 -9
- package/.docs/classes/UserAgentUtils.md +12 -2
- package/.docs/classes/WaitingChangeException.md +9 -3
- package/.docs/classes/WarningException.md +12 -4
- package/.docs/enums/ChangeOperation.md +4 -4
- package/.docs/enums/DataType.md +5 -5
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/LoadDataRequest.md +17 -5
- package/.docs/interfaces/LoadDataResponse.md +8 -2
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/PaginationInfo.md +17 -5
- package/.docs/interfaces/QuickFilter.md +2 -2
- package/.docs/interfaces/Record.md +2 -2
- package/.docs/interfaces/SavedRecord.md +3 -3
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/modules/MaskFormatter.md +2 -2
- package/.releaserc +1 -1
- package/.reusable-default-scripts.yml +4 -2
- package/build.env +0 -2
- package/dist/dataunit/DataUnit.d.ts +516 -7
- package/dist/dataunit/DataUnit.js +511 -3
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/loading/LoadDataRequest.d.ts +6 -0
- package/dist/dataunit/loading/LoadDataResponse.d.ts +3 -0
- package/dist/dataunit/loading/PaginationInfo.d.ts +6 -0
- package/dist/dataunit/metadata/DataType.d.ts +44 -0
- package/dist/dataunit/metadata/DataType.js +45 -0
- package/dist/dataunit/metadata/DataType.js.map +1 -1
- package/dist/exceptions/ErrorException.d.ts +6 -0
- package/dist/exceptions/ErrorException.js +3 -0
- package/dist/exceptions/ErrorException.js.map +1 -1
- package/dist/exceptions/WaitingChangeException.d.ts +5 -0
- package/dist/exceptions/WaitingChangeException.js +3 -0
- package/dist/exceptions/WaitingChangeException.js.map +1 -1
- package/dist/exceptions/WarningException.d.ts +6 -0
- package/dist/exceptions/WarningException.js +3 -0
- package/dist/exceptions/WarningException.js.map +1 -1
- package/dist/traking/ErrorTraking.d.ts +15 -0
- package/dist/traking/ErrorTraking.js +15 -0
- package/dist/traking/ErrorTraking.js.map +1 -1
- package/dist/ui/FloatingManager.d.ts +114 -0
- package/dist/ui/FloatingManager.js +128 -0
- package/dist/ui/FloatingManager.js.map +1 -1
- package/dist/utils/ApplicationContext.d.ts +21 -0
- package/dist/utils/ApplicationContext.js +21 -0
- package/dist/utils/ApplicationContext.js.map +1 -1
- package/dist/utils/ArrayUtils.d.ts +19 -4
- package/dist/utils/ArrayUtils.js +19 -4
- package/dist/utils/ArrayUtils.js.map +1 -1
- package/dist/utils/CriteriaModel.d.ts +2 -4
- package/dist/utils/CriteriaModel.js +3 -5
- package/dist/utils/CriteriaModel.js.map +1 -1
- package/dist/utils/DateUtils.d.ts +63 -0
- package/dist/utils/DateUtils.js +63 -1
- package/dist/utils/DateUtils.js.map +1 -1
- package/dist/utils/ElementIDUtils.d.ts +51 -0
- package/dist/utils/ElementIDUtils.js +51 -0
- package/dist/utils/ElementIDUtils.js.map +1 -1
- package/dist/utils/MaskFormatter.d.ts +45 -24
- package/dist/utils/MaskFormatter.js +99 -25
- package/dist/utils/MaskFormatter.js.map +1 -1
- package/dist/utils/NumberUtils.d.ts +39 -31
- package/dist/utils/NumberUtils.js +39 -31
- package/dist/utils/NumberUtils.js.map +1 -1
- package/dist/utils/ObjectUtils.d.ts +27 -0
- package/dist/utils/ObjectUtils.js +27 -0
- package/dist/utils/ObjectUtils.js.map +1 -1
- package/dist/utils/ReadyUtil.d.ts +16 -0
- package/dist/utils/ReadyUtil.js +16 -0
- package/dist/utils/ReadyUtil.js.map +1 -1
- package/dist/utils/StringUtils.d.ts +72 -28
- package/dist/utils/StringUtils.js +72 -28
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeFormatter.d.ts +9 -9
- package/dist/utils/TimeFormatter.js +10 -10
- package/dist/utils/TimeFormatter.js.map +1 -1
- package/dist/utils/UserAgentUtils/index.d.ts +11 -0
- package/dist/utils/UserAgentUtils/index.js +11 -0
- package/dist/utils/UserAgentUtils/index.js.map +1 -1
- package/package.json +1 -1
- package/publish-docs.sh +1 -2
- package/src/dataunit/DataUnit.ts +520 -10
- package/src/dataunit/loading/LoadDataRequest.ts +10 -0
- package/src/dataunit/loading/LoadDataResponse.ts +4 -0
- package/src/dataunit/loading/PaginationInfo.ts +11 -1
- package/src/dataunit/metadata/DataType.ts +47 -1
- package/src/exceptions/ErrorException.ts +8 -0
- package/src/exceptions/WaitingChangeException.ts +6 -1
- package/src/exceptions/WarningException.ts +8 -1
- package/src/traking/ErrorTraking.ts +17 -0
- package/src/ui/FloatingManager.ts +138 -7
- package/src/utils/ApplicationContext.ts +21 -0
- package/src/utils/ArrayUtils.ts +19 -5
- package/src/utils/CriteriaModel.ts +3 -5
- package/src/utils/DateUtils.ts +70 -6
- package/src/utils/ElementIDUtils.ts +52 -4
- package/src/utils/MaskFormatter.ts +103 -27
- package/src/utils/NumberUtils.ts +40 -36
- package/src/utils/ObjectUtils.ts +28 -0
- package/src/utils/ReadyUtil.ts +16 -0
- package/src/utils/StringUtils.ts +73 -29
- package/src/utils/TimeFormatter.ts +10 -10
- package/src/utils/UserAgentUtils/index.ts +12 -0
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -21,6 +21,9 @@ import { getField, getMetadata, UnitMetadataReducer } from "./state/slice/UnitMe
|
|
|
21
21
|
import { getBlockingWaitingChanges, getWaitingChangePromisses, isWaiting, WaitingChangesReducer } from "./state/slice/WaitingChangesSlice.js";
|
|
22
22
|
import { canRedo, canUndo, HistReducer } from "./state/HistReducer.js";
|
|
23
23
|
|
|
24
|
+
/***
|
|
25
|
+
* `DataUnit`: Atua como uma camada de abstração entre o back-end e a interface do usuário.
|
|
26
|
+
*/
|
|
24
27
|
export default class DataUnit {
|
|
25
28
|
|
|
26
29
|
private _name: string;
|
|
@@ -31,11 +34,11 @@ export default class DataUnit {
|
|
|
31
34
|
private _interceptors: Array<DUActionInterceptor>;
|
|
32
35
|
private _pageSize: number;
|
|
33
36
|
|
|
34
|
-
public metadataLoader?: (
|
|
35
|
-
public dataLoader?: (
|
|
36
|
-
public saveLoader?: (
|
|
37
|
-
public removeLoader?: (
|
|
38
|
-
public recordLoader?: (
|
|
37
|
+
public metadataLoader?: (DataUnit: DataUnit) => Promise<UnitMetadata>;
|
|
38
|
+
public dataLoader?: (DataUnit: DataUnit, request: LoadDataRequest) => Promise<LoadDataResponse>;
|
|
39
|
+
public saveLoader?: (DataUnit: DataUnit, changes: Array<Change>) => Promise<Array<SavedRecord>>;
|
|
40
|
+
public removeLoader?: (DataUnit: DataUnit, recordIds: Array<string>) => Promise<Array<string>>;
|
|
41
|
+
public recordLoader?: (DataUnit: DataUnit, recordIds: Array<string>) => Promise<Array<Record>>;
|
|
39
42
|
|
|
40
43
|
constructor(name: string) {
|
|
41
44
|
this._name = name;
|
|
@@ -60,16 +63,40 @@ export default class DataUnit {
|
|
|
60
63
|
this._interceptors = [];
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* Obtém o nome de identificação do DataUnit (geralmente em formato de URI - Uniform Resource Identifier).
|
|
69
|
+
*
|
|
70
|
+
* @returns - Nome de identificação do DataUnit.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
63
73
|
public get name(): string {
|
|
64
74
|
return this._name;
|
|
65
75
|
}
|
|
66
76
|
|
|
67
|
-
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* Obtém o valor convertido de acordo com o tipo do campo.
|
|
80
|
+
*
|
|
81
|
+
* @param fieldName - Identificador do campo.
|
|
82
|
+
* @param newValue - Novo valor que será atribuído ao campo pós validação.
|
|
83
|
+
*
|
|
84
|
+
* @returns - Novo valor convertido em um tipo valido.
|
|
85
|
+
*
|
|
86
|
+
*/
|
|
68
87
|
private validateAndTypeValue(fieldName: string, newValue: any): any {
|
|
69
88
|
const descriptor: FieldDescriptor | undefined = this.getField(fieldName);
|
|
70
89
|
return descriptor ? convertType(descriptor.dataType, newValue) : newValue;
|
|
71
90
|
}
|
|
72
91
|
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
*
|
|
95
|
+
* Obtém todos os filtros de dados.
|
|
96
|
+
*
|
|
97
|
+
* @returns - Lista de filtros.
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
73
100
|
private getFilters(): Array<Filter> | undefined {
|
|
74
101
|
let filters: Array<Filter> | undefined = undefined;
|
|
75
102
|
this._filterProviders.forEach(p => {
|
|
@@ -81,10 +108,26 @@ export default class DataUnit {
|
|
|
81
108
|
return filters;
|
|
82
109
|
}
|
|
83
110
|
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
* Obtém a estrutura de ordenação das colunas dos dados.
|
|
114
|
+
*
|
|
115
|
+
* @returns - Lista dos ordenáveis por prioridade.
|
|
116
|
+
*
|
|
117
|
+
*/
|
|
84
118
|
private getSort(): Array<Sort> | undefined {
|
|
85
119
|
return this._sortingProvider ? this._sortingProvider.getSort(this._name) : undefined;
|
|
86
120
|
}
|
|
87
121
|
|
|
122
|
+
/**
|
|
123
|
+
*
|
|
124
|
+
* Obtém chave única para identificação do FilterProvider.
|
|
125
|
+
*
|
|
126
|
+
* @param provider - Interface FilterProvider na qual será retornada uma chave correspondente.
|
|
127
|
+
*
|
|
128
|
+
* @returns - A chave do provider.
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
88
131
|
private getFielterProviderKey(provider: FilterProvider): string {
|
|
89
132
|
if (provider.getKey) {
|
|
90
133
|
return provider.getKey();
|
|
@@ -92,6 +135,16 @@ export default class DataUnit {
|
|
|
92
135
|
return StringUtils.hashCode(provider.getFilter.toString());
|
|
93
136
|
}
|
|
94
137
|
|
|
138
|
+
/**
|
|
139
|
+
*
|
|
140
|
+
* Executa o carregamento dos registros.
|
|
141
|
+
*
|
|
142
|
+
* @param request - Dados da requisição para carregamento dos registros.
|
|
143
|
+
* @param executionCtx - Contexto de execução do carregamento dos registros do DataUnit.
|
|
144
|
+
*
|
|
145
|
+
* @returns - Registros do DataUnit.
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
95
148
|
private executeLoadData(request: LoadDataRequest, executionCtx?: ExecutionContext): Promise<LoadDataResponse> {
|
|
96
149
|
return new Promise(async (resolve, fail) => {
|
|
97
150
|
if (await this.dispatchAction(Action.LOADING_DATA, request, executionCtx)) {
|
|
@@ -111,6 +164,15 @@ export default class DataUnit {
|
|
|
111
164
|
}
|
|
112
165
|
|
|
113
166
|
// Loaders
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* Carrega os metadados do DataUnit.
|
|
170
|
+
*
|
|
171
|
+
* @param executionCtx - Contexto de execução do carregamento dos metadados do DataUnit.
|
|
172
|
+
*
|
|
173
|
+
* @returns - Metadados carregados.
|
|
174
|
+
*
|
|
175
|
+
*/
|
|
114
176
|
public async loadMetadata(executionCtx?: ExecutionContext): Promise<UnitMetadata | void> {
|
|
115
177
|
if (await this.dispatchAction(Action.LOADING_METADATA, undefined, executionCtx)) {
|
|
116
178
|
return new Promise((resolve, fail) => {
|
|
@@ -129,6 +191,16 @@ export default class DataUnit {
|
|
|
129
191
|
}
|
|
130
192
|
}
|
|
131
193
|
|
|
194
|
+
/**
|
|
195
|
+
*
|
|
196
|
+
* Carrega os registros do DataUnit.
|
|
197
|
+
*
|
|
198
|
+
* @param quickFilter - Filtros a serem aplicados.
|
|
199
|
+
* @param executionCtx - Contexto de execução do carregamento dos registros.
|
|
200
|
+
*
|
|
201
|
+
* @returns - Registros requisitados.
|
|
202
|
+
*
|
|
203
|
+
*/
|
|
132
204
|
public async loadData(quickFilter?: QuickFilter, executionCtx?: ExecutionContext): Promise<LoadDataResponse> {
|
|
133
205
|
|
|
134
206
|
const loadDataRequest: LoadDataRequest = {
|
|
@@ -145,6 +217,16 @@ export default class DataUnit {
|
|
|
145
217
|
return this.executeLoadData(loadDataRequest, executionCtx);
|
|
146
218
|
}
|
|
147
219
|
|
|
220
|
+
/**
|
|
221
|
+
*
|
|
222
|
+
* Alterna entre os registros por número de página.
|
|
223
|
+
*
|
|
224
|
+
* @param page - Número da página desejada.
|
|
225
|
+
* @param executionCtx - Contexto de execução do carregamento dos registros do DataUnit.
|
|
226
|
+
*
|
|
227
|
+
* @returns - Registros da página desejada.
|
|
228
|
+
*
|
|
229
|
+
*/
|
|
148
230
|
public async gotoPage(page: number, executionCtx?: ExecutionContext): Promise<LoadDataResponse | void> {
|
|
149
231
|
|
|
150
232
|
let request = getCurrentRequest(this._stateManager);
|
|
@@ -165,14 +247,41 @@ export default class DataUnit {
|
|
|
165
247
|
}
|
|
166
248
|
}
|
|
167
249
|
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* Vai para os registros da página seguinte.
|
|
253
|
+
*
|
|
254
|
+
* @param executionCtx - Contexto de execução do carregamento dos registros do DataUnit.
|
|
255
|
+
*
|
|
256
|
+
* @returns - Registros da página seguinte.
|
|
257
|
+
*
|
|
258
|
+
*/
|
|
168
259
|
public async nextPage(executionCtx?: ExecutionContext): Promise<LoadDataResponse | void> {
|
|
169
260
|
return this.gotoPage(getCurrentPage(this._stateManager) + 1, executionCtx);
|
|
170
261
|
}
|
|
171
262
|
|
|
263
|
+
/**
|
|
264
|
+
*
|
|
265
|
+
* Vai para os registros da página anterior.
|
|
266
|
+
*
|
|
267
|
+
* @param executionCtx - Contexto de execução do carregamento dos registros do DataUnit.
|
|
268
|
+
*
|
|
269
|
+
* @returns - Registros da página anterior.
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
172
272
|
public async previousPage(executionCtx?: ExecutionContext): Promise<LoadDataResponse | void> {
|
|
173
273
|
return this.gotoPage(getCurrentPage(this._stateManager) - 1, executionCtx);
|
|
174
274
|
}
|
|
175
275
|
|
|
276
|
+
/**
|
|
277
|
+
*
|
|
278
|
+
* Salva o estado do registro do DataUnit.
|
|
279
|
+
*
|
|
280
|
+
* @param executionCtx - Contexto de execução da persistencia do registro do DataUnit.
|
|
281
|
+
*
|
|
282
|
+
* @returns - Resposta da solicitação.
|
|
283
|
+
*
|
|
284
|
+
*/
|
|
176
285
|
public async saveData(executionCtx?: ExecutionContext): Promise<void> {
|
|
177
286
|
const blockingWaitingChanges = getBlockingWaitingChanges(this._stateManager);
|
|
178
287
|
|
|
@@ -209,6 +318,15 @@ export default class DataUnit {
|
|
|
209
318
|
return Promise.resolve();
|
|
210
319
|
}
|
|
211
320
|
|
|
321
|
+
/**
|
|
322
|
+
*
|
|
323
|
+
* Remove o registro selecionado.
|
|
324
|
+
*
|
|
325
|
+
* @param buffered - Se será utilizado buffer na solicitação.
|
|
326
|
+
*
|
|
327
|
+
* @returns - ID's dos registros removidos.
|
|
328
|
+
*
|
|
329
|
+
*/
|
|
212
330
|
public async removeSelectedRecords(buffered: boolean = false): Promise<Array<string>> {
|
|
213
331
|
const selection = getSelection(this._stateManager);
|
|
214
332
|
if (selection) {
|
|
@@ -218,6 +336,18 @@ export default class DataUnit {
|
|
|
218
336
|
return Promise.resolve(selection);
|
|
219
337
|
}
|
|
220
338
|
|
|
339
|
+
/**
|
|
340
|
+
*
|
|
341
|
+
* Efetua requisição para remoção dos registros.
|
|
342
|
+
*
|
|
343
|
+
* @param recordIds - Lista de IDs dos registros que serão removidos.
|
|
344
|
+
* @param cachedRecords - Dados dos registros que serão removidos.
|
|
345
|
+
* @param buffered - Se será utilizado buffer na solicitação.
|
|
346
|
+
* @param executionCtx - Contexto de execução da remoção do registro do DataUnit.
|
|
347
|
+
*
|
|
348
|
+
* @returns - ID's dos registros removidos.
|
|
349
|
+
*
|
|
350
|
+
*/
|
|
221
351
|
public async removeRecords(recordIds: Array<string>, cachedRecords: Array<Record>, buffered: boolean = false, executionCtx?: ExecutionContext): Promise<Array<string>> {
|
|
222
352
|
if (recordIds) {
|
|
223
353
|
if (buffered || !this.removeLoader) {
|
|
@@ -257,74 +387,193 @@ export default class DataUnit {
|
|
|
257
387
|
}
|
|
258
388
|
|
|
259
389
|
// API
|
|
390
|
+
/**
|
|
391
|
+
*
|
|
392
|
+
* Obtém o valor do campo em seu formato/tipo correto a partir de uma string.
|
|
393
|
+
*
|
|
394
|
+
* @param fieldName - Nome do campo que terá o tipo identificado para conversão.
|
|
395
|
+
* @param value - Texto que será convertido de acordo com o tipo identificado no campo.
|
|
396
|
+
*
|
|
397
|
+
* @returns - Valor convertido ou ele mesmo.
|
|
398
|
+
*
|
|
399
|
+
*/
|
|
260
400
|
public valueFromString(fieldName: string, value: string): any {
|
|
261
401
|
const descriptor = this.getField(fieldName);
|
|
262
402
|
return descriptor ? convertType(descriptor.dataType, value) : value;
|
|
263
403
|
}
|
|
264
404
|
|
|
405
|
+
/**
|
|
406
|
+
*
|
|
407
|
+
* Converte o valor informado para texto de acordo com o tipo do campo informado.
|
|
408
|
+
*
|
|
409
|
+
* @param fieldName - Nome do campo utilizado para buscar o tipo de dado com o padrão de conversão para string.
|
|
410
|
+
* @param value - Valor a ser convertido.
|
|
411
|
+
*
|
|
412
|
+
* @returns - Valor informado convertido.
|
|
413
|
+
*
|
|
414
|
+
*/
|
|
265
415
|
public valueToString(fieldName: string, value: any): string {
|
|
266
416
|
const descriptor = this.getField(fieldName);
|
|
267
417
|
return toString(descriptor?.dataType, value);
|
|
268
418
|
}
|
|
269
419
|
|
|
420
|
+
/**
|
|
421
|
+
*
|
|
422
|
+
* Adiciona um interceptor correspondente a uma ação do DataUnit para fazer um processamento customizado.
|
|
423
|
+
*
|
|
424
|
+
* @param interceptor - Interceptor a ser adicionado.
|
|
425
|
+
*
|
|
426
|
+
*/
|
|
270
427
|
public addInterceptor(interceptor: DUActionInterceptor): void {
|
|
271
428
|
this._interceptors.push(interceptor);
|
|
272
429
|
}
|
|
273
430
|
|
|
431
|
+
/**
|
|
432
|
+
*
|
|
433
|
+
* Remove um interceptor da lista de interceptors.
|
|
434
|
+
*
|
|
435
|
+
* @param interceptor - Interceptor a ser removido.
|
|
436
|
+
*
|
|
437
|
+
*/
|
|
274
438
|
public removeInterceptor(interceptor: DUActionInterceptor) {
|
|
275
439
|
this._interceptors = this._interceptors.filter(i => i !== interceptor);
|
|
276
440
|
}
|
|
277
441
|
|
|
442
|
+
/**
|
|
443
|
+
*
|
|
444
|
+
* Adiciona um FilterProvider.
|
|
445
|
+
*
|
|
446
|
+
* @param provider - FilterProvider que será adicionado.
|
|
447
|
+
*
|
|
448
|
+
*/
|
|
278
449
|
public addFilterProvider(provider: FilterProvider): void {
|
|
279
450
|
this._filterProviders.set(this.getFielterProviderKey(provider), provider);
|
|
280
451
|
}
|
|
281
452
|
|
|
453
|
+
/**
|
|
454
|
+
*
|
|
455
|
+
* Obtém informações de paginação dos registros.
|
|
456
|
+
*
|
|
457
|
+
* @returns - Informações da paginação de registros.
|
|
458
|
+
*/
|
|
282
459
|
public getPaginationInfo(): PaginationInfo | void {
|
|
283
460
|
return getPaginationInfo(this._stateManager);
|
|
284
461
|
}
|
|
285
462
|
|
|
463
|
+
/**
|
|
464
|
+
*
|
|
465
|
+
* Define a lógica de ordenação dos registros.
|
|
466
|
+
*
|
|
467
|
+
* @param provider - Objeto usado para definir a propriedade sortingProvider da instância da classe.
|
|
468
|
+
*
|
|
469
|
+
*/
|
|
286
470
|
public set sortingProvider(provider: SortingProvider) {
|
|
287
471
|
this._sortingProvider = provider;
|
|
288
472
|
}
|
|
289
473
|
|
|
474
|
+
/**
|
|
475
|
+
*
|
|
476
|
+
* Define a propriedade metadata da instância da classe com um novo valor e chama o método dispatchAction para notificar os observers da aplicação sobre a mudança.
|
|
477
|
+
*
|
|
478
|
+
*/
|
|
290
479
|
public set metadata(md: UnitMetadata) {
|
|
291
480
|
this.dispatchAction(Action.METADATA_LOADED, md, undefined);
|
|
292
481
|
}
|
|
293
482
|
|
|
483
|
+
/**
|
|
484
|
+
*
|
|
485
|
+
* Obtém os metadados do DataUnit.
|
|
486
|
+
*
|
|
487
|
+
*/
|
|
294
488
|
public get metadata(): UnitMetadata {
|
|
295
489
|
return getMetadata(this._stateManager);
|
|
296
490
|
}
|
|
297
491
|
|
|
492
|
+
/**
|
|
493
|
+
*
|
|
494
|
+
* Define a propriedade records da instância da classe com um novo valor e chama o método dispatchAction para notificar os observers da aplicação sobre a mudança.
|
|
495
|
+
*
|
|
496
|
+
*/
|
|
298
497
|
public set records(r: Array<Record>) {
|
|
299
498
|
this.dispatchAction(Action.DATA_LOADED, { records: this.records }, undefined);
|
|
300
499
|
}
|
|
301
500
|
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
* Obtém todos os registros atuais.
|
|
504
|
+
*
|
|
505
|
+
* @returns - Todos os registros atuais.
|
|
506
|
+
*
|
|
507
|
+
*/
|
|
302
508
|
public get records(): Array<Record> {
|
|
303
509
|
const records = getCurrentRecords(this._stateManager);
|
|
304
510
|
return records ? Array.from(records.values()) : [];
|
|
305
511
|
}
|
|
306
512
|
|
|
513
|
+
/**
|
|
514
|
+
*
|
|
515
|
+
* Define a quantidade de registros que será exibido por página.
|
|
516
|
+
*
|
|
517
|
+
* @param size - Quantidade de registros que será exibido por página.
|
|
518
|
+
*
|
|
519
|
+
*/
|
|
307
520
|
public set pageSize(size: number) {
|
|
308
521
|
this._pageSize = size;
|
|
309
522
|
}
|
|
310
523
|
|
|
524
|
+
/**
|
|
525
|
+
*
|
|
526
|
+
* Obtém a quantidade de registros que está sendo exibido por página.
|
|
527
|
+
*
|
|
528
|
+
* @returns - Quantidade de registros exibidos por página.
|
|
529
|
+
*
|
|
530
|
+
*/
|
|
311
531
|
public get pageSize(): number {
|
|
312
532
|
return this._pageSize;
|
|
313
533
|
}
|
|
314
534
|
|
|
535
|
+
/**
|
|
536
|
+
*
|
|
537
|
+
* Obtém os registros modificados e ainda não salvos no DataUnit.
|
|
538
|
+
*
|
|
539
|
+
* @returns - Lista dos registros em edição.
|
|
540
|
+
*
|
|
541
|
+
*/
|
|
315
542
|
public getModifiedRecords(): Array<Record> {
|
|
316
543
|
const modified = getModifiedRecords(this._stateManager);
|
|
317
544
|
return modified || [];
|
|
318
545
|
}
|
|
319
546
|
|
|
547
|
+
/**
|
|
548
|
+
*
|
|
549
|
+
* Obtém metadados de um campo específico.
|
|
550
|
+
*
|
|
551
|
+
* @param fieldName - Identificador do campo.
|
|
552
|
+
*
|
|
553
|
+
* @returns - Metadados do campo informado.
|
|
554
|
+
*/
|
|
320
555
|
public getField(fieldName: string): FieldDescriptor | undefined {
|
|
321
556
|
return getField(this._stateManager, fieldName);
|
|
322
557
|
}
|
|
323
558
|
|
|
559
|
+
/**
|
|
560
|
+
*
|
|
561
|
+
* Adiciona um novo registro.
|
|
562
|
+
*
|
|
563
|
+
* @param executionCtx - Contexto de execução da inserção do dado no DataUnit.
|
|
564
|
+
*
|
|
565
|
+
*/
|
|
324
566
|
public addRecord(executionCtx?: ExecutionContext): void {
|
|
325
567
|
this.dispatchAction(Action.RECORDS_ADDED, prepareAddedRecordId(this._stateManager, [{}]), executionCtx);
|
|
326
568
|
}
|
|
327
569
|
|
|
570
|
+
/**
|
|
571
|
+
*
|
|
572
|
+
* Efetua a cópia do registro selecionado.
|
|
573
|
+
*
|
|
574
|
+
* @param executionCtx - Contexto de execução da cópia do dado do DataUnit.
|
|
575
|
+
*
|
|
576
|
+
*/
|
|
328
577
|
public copySelected(executionCtx?: ExecutionContext): void {
|
|
329
578
|
const selectedRecords = this.getSelectedRecords();
|
|
330
579
|
if (selectedRecords) {
|
|
@@ -332,14 +581,41 @@ export default class DataUnit {
|
|
|
332
581
|
}
|
|
333
582
|
}
|
|
334
583
|
|
|
584
|
+
/**
|
|
585
|
+
*
|
|
586
|
+
* Retorna se a alteração no campo já foi concluída ou se ainda está incompleta.
|
|
587
|
+
*
|
|
588
|
+
* @param fieldName - Identificador do campo a ser verificado.
|
|
589
|
+
*
|
|
590
|
+
* @returns - Verdadeiro se ainda está pendente.
|
|
591
|
+
*
|
|
592
|
+
*/
|
|
335
593
|
public waitingForChange(fieldName: string): boolean {
|
|
336
594
|
return isWaiting(this._stateManager, fieldName);
|
|
337
595
|
}
|
|
338
596
|
|
|
597
|
+
/**
|
|
598
|
+
*
|
|
599
|
+
* Obtém valor do campo desejado.
|
|
600
|
+
*
|
|
601
|
+
* @param fieldName - Identificador do campo a ser buscado.
|
|
602
|
+
*
|
|
603
|
+
* @returns - Valor do campo.
|
|
604
|
+
*
|
|
605
|
+
*/
|
|
339
606
|
public getFieldValue(fieldName: string): any {
|
|
340
607
|
return getFieldValue(this._stateManager, fieldName);
|
|
341
608
|
}
|
|
342
609
|
|
|
610
|
+
/**
|
|
611
|
+
*
|
|
612
|
+
* Insere valor no campo desejado.
|
|
613
|
+
*
|
|
614
|
+
* @param fieldName -Identificador do campo a ser modificado.
|
|
615
|
+
* @param newValue - Valor a ser inserido no campo.
|
|
616
|
+
* @param records - Indica quais registros foram afetados pela alteração no valor do campo.
|
|
617
|
+
*
|
|
618
|
+
*/
|
|
343
619
|
public setFieldValue(fieldName: string, newValue: any, records?: Array<string>): void {
|
|
344
620
|
|
|
345
621
|
const typedValue = this.validateAndTypeValue(fieldName, newValue);
|
|
@@ -350,38 +626,98 @@ export default class DataUnit {
|
|
|
350
626
|
}
|
|
351
627
|
}
|
|
352
628
|
|
|
629
|
+
/**
|
|
630
|
+
*
|
|
631
|
+
* Inicia alteração no campo.
|
|
632
|
+
*
|
|
633
|
+
* @param fieldName - Identificador do campo a ser modificado.
|
|
634
|
+
* @param waitingChange - Informa que uma mudança irá iniciar.
|
|
635
|
+
*
|
|
636
|
+
*/
|
|
353
637
|
public startChange(fieldName: string, waitingChange: WaitingChange): void {
|
|
354
638
|
this.dispatchAction(Action.CHANGING_DATA, { [fieldName]: waitingChange }, undefined);
|
|
355
639
|
}
|
|
356
640
|
|
|
641
|
+
/**
|
|
642
|
+
*
|
|
643
|
+
* Cancela o início de uma alteração no campo.
|
|
644
|
+
*
|
|
645
|
+
* @param fieldName - Identificador do campo.
|
|
646
|
+
*
|
|
647
|
+
*/
|
|
357
648
|
public cancelWaitingChange(fieldName: string): void {
|
|
358
649
|
this.dispatchAction(Action.WAITING_CHANGE_CANCELED, { fieldName }, undefined);
|
|
359
650
|
}
|
|
360
651
|
|
|
652
|
+
/**
|
|
653
|
+
*
|
|
654
|
+
* Obtém registros selecionados.
|
|
655
|
+
*
|
|
656
|
+
* @returns - Registros selecionados.
|
|
657
|
+
*
|
|
658
|
+
*/
|
|
361
659
|
public getSelection(): Array<string> {
|
|
362
660
|
return getSelection(this._stateManager);
|
|
363
661
|
}
|
|
364
662
|
|
|
663
|
+
/**
|
|
664
|
+
*
|
|
665
|
+
* Seleciona múltiplos registros por ID.
|
|
666
|
+
*
|
|
667
|
+
* @param selection - IDs para selecionar.
|
|
668
|
+
* @param executionCtx - Contexto de execução da seleção dos registros do DataUnit.
|
|
669
|
+
*
|
|
670
|
+
*/
|
|
365
671
|
public setSelection(selection: Array<string>, executionCtx?: ExecutionContext): void {
|
|
366
672
|
this.dispatchAction(Action.SELECTION_CHANGED, { type: "id", selection }, executionCtx);
|
|
367
673
|
}
|
|
368
674
|
|
|
675
|
+
/**
|
|
676
|
+
*
|
|
677
|
+
* Seleciona o primeiro registro.
|
|
678
|
+
*
|
|
679
|
+
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
680
|
+
*
|
|
681
|
+
*/
|
|
369
682
|
public selectFirst(executionCtx?: ExecutionContext): void {
|
|
370
683
|
if (this.records.length > 0) {
|
|
371
684
|
this.setSelectionByIndex([0], executionCtx);
|
|
372
685
|
}
|
|
373
686
|
}
|
|
374
687
|
|
|
688
|
+
/**
|
|
689
|
+
*
|
|
690
|
+
* Seleciona o último registro.
|
|
691
|
+
*
|
|
692
|
+
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
693
|
+
*
|
|
694
|
+
*/
|
|
375
695
|
public selectLast(executionCtx?: ExecutionContext): void {
|
|
376
696
|
if (this.records.length > 0) {
|
|
377
697
|
this.setSelectionByIndex([this.records.length - 1], executionCtx);
|
|
378
698
|
}
|
|
379
699
|
}
|
|
380
700
|
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
*
|
|
704
|
+
* Seleciona múltiplos registros por índice.
|
|
705
|
+
*
|
|
706
|
+
* @param selection - Índices desejados para a seleção.
|
|
707
|
+
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
708
|
+
*
|
|
709
|
+
*/
|
|
381
710
|
public setSelectionByIndex(selection: Array<number>, executionCtx?: ExecutionContext): void {
|
|
382
711
|
this.dispatchAction(Action.SELECTION_CHANGED, { type: "index", selection }, executionCtx);
|
|
383
712
|
}
|
|
384
713
|
|
|
714
|
+
/**
|
|
715
|
+
*
|
|
716
|
+
* Obtém todos os registros selecionados.
|
|
717
|
+
*
|
|
718
|
+
* @returns - Lista de registros selecionados.
|
|
719
|
+
*
|
|
720
|
+
*/
|
|
385
721
|
public getSelectedRecords(): Array<Record> | undefined {
|
|
386
722
|
const selection: Array<string> = this.getSelection();
|
|
387
723
|
if (selection) {
|
|
@@ -390,6 +726,14 @@ export default class DataUnit {
|
|
|
390
726
|
}
|
|
391
727
|
}
|
|
392
728
|
|
|
729
|
+
/**
|
|
730
|
+
*
|
|
731
|
+
* Seleciona o próximo registro.
|
|
732
|
+
*
|
|
733
|
+
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
734
|
+
*
|
|
735
|
+
*
|
|
736
|
+
*/
|
|
393
737
|
public nextRecord(executionCtx?: ExecutionContext): void {
|
|
394
738
|
if(!hasNext(this._stateManager)){
|
|
395
739
|
if(hasMorePages(this._stateManager)){
|
|
@@ -410,6 +754,13 @@ export default class DataUnit {
|
|
|
410
754
|
}
|
|
411
755
|
}
|
|
412
756
|
|
|
757
|
+
/**
|
|
758
|
+
*
|
|
759
|
+
* Seleciona o registro anterior.
|
|
760
|
+
*
|
|
761
|
+
* @param executionCtx - Contexto de execução da seleção do registro do DataUnit.
|
|
762
|
+
*
|
|
763
|
+
*/
|
|
413
764
|
public previousRecord(executionCtx?: ExecutionContext): void {
|
|
414
765
|
if(!hasPrevious(this._stateManager)){
|
|
415
766
|
if(hasPreviousPages(this._stateManager)){
|
|
@@ -430,18 +781,46 @@ export default class DataUnit {
|
|
|
430
781
|
}
|
|
431
782
|
}
|
|
432
783
|
|
|
784
|
+
/**
|
|
785
|
+
*
|
|
786
|
+
* Cancela edição do registro atual.
|
|
787
|
+
*
|
|
788
|
+
* @param executionCtx - Contexto de execução do cancelamento da seleção dos registros.
|
|
789
|
+
*
|
|
790
|
+
*/
|
|
433
791
|
public cancelEdition(executionCtx?: ExecutionContext): void {
|
|
434
792
|
this.dispatchAction(Action.EDITION_CANCELED, undefined, executionCtx);
|
|
435
793
|
}
|
|
436
794
|
|
|
795
|
+
/**
|
|
796
|
+
*
|
|
797
|
+
* Retorna se existe algum tipo de alteração pendente.
|
|
798
|
+
*
|
|
799
|
+
* @returns Verdadeiro se existir alterações pendentes.
|
|
800
|
+
*
|
|
801
|
+
*/
|
|
437
802
|
public isDirty(): boolean {
|
|
438
803
|
return isDirty(this._stateManager);
|
|
439
804
|
}
|
|
440
805
|
|
|
806
|
+
/**
|
|
807
|
+
*
|
|
808
|
+
* Retorna se existe algum registro em modo de edição.
|
|
809
|
+
*
|
|
810
|
+
* @returns Verdadeiro se existir alterações de registros pendentes.
|
|
811
|
+
*
|
|
812
|
+
*/
|
|
441
813
|
public hasDirtyRecords(): boolean {
|
|
442
814
|
return hasDirtyRecords(this._stateManager);
|
|
443
815
|
}
|
|
444
816
|
|
|
817
|
+
/**
|
|
818
|
+
*
|
|
819
|
+
* Retorna se existir uma pagina seguinte a atual na paginação.
|
|
820
|
+
*
|
|
821
|
+
* @returns Verdadeiro se existir uma próxima página.
|
|
822
|
+
*
|
|
823
|
+
*/
|
|
445
824
|
public hasNext(): boolean {
|
|
446
825
|
let result = hasNext(this._stateManager);
|
|
447
826
|
if(!result){
|
|
@@ -450,6 +829,13 @@ export default class DataUnit {
|
|
|
450
829
|
return result;
|
|
451
830
|
}
|
|
452
831
|
|
|
832
|
+
/**
|
|
833
|
+
*
|
|
834
|
+
* Retorna se existe uma página anterior a atual na paginação.
|
|
835
|
+
*
|
|
836
|
+
* @returns Verdadeiro se existir uma página anterior.
|
|
837
|
+
*
|
|
838
|
+
*/
|
|
453
839
|
public hasPrevious(): boolean {
|
|
454
840
|
let result = hasPrevious(this._stateManager);
|
|
455
841
|
if(!result){
|
|
@@ -458,27 +844,74 @@ export default class DataUnit {
|
|
|
458
844
|
return result;
|
|
459
845
|
}
|
|
460
846
|
|
|
847
|
+
/**
|
|
848
|
+
*
|
|
849
|
+
* Retorna se a informação do estado anterior está salva, permitindo desfazer a ação.
|
|
850
|
+
*
|
|
851
|
+
* @returns Verdadeiro se for possível desfazer a ação.
|
|
852
|
+
*
|
|
853
|
+
*/
|
|
461
854
|
public canUndo(): boolean {
|
|
462
855
|
return canUndo(this._stateManager);
|
|
463
856
|
}
|
|
464
857
|
|
|
858
|
+
/**
|
|
859
|
+
*
|
|
860
|
+
* Retorna se a informação do estado futuro está salva, permitindo refazer a ação.
|
|
861
|
+
*
|
|
862
|
+
* @returns Verdadeiro se for possível refazer a ação.
|
|
863
|
+
*
|
|
864
|
+
*/
|
|
465
865
|
public canRedo(): boolean {
|
|
466
866
|
return canRedo(this._stateManager);
|
|
467
867
|
}
|
|
468
868
|
|
|
869
|
+
/**
|
|
870
|
+
*
|
|
871
|
+
* Desfaz a última ação.
|
|
872
|
+
*
|
|
873
|
+
* @param executionCtx - Contexto de execução de desfazer a última ação.
|
|
874
|
+
*
|
|
875
|
+
*
|
|
876
|
+
*/
|
|
469
877
|
public undo(executionCtx?: ExecutionContext) {
|
|
470
878
|
this.dispatchAction(Action.CHANGE_UNDONE, undefined, executionCtx);
|
|
471
879
|
}
|
|
472
880
|
|
|
881
|
+
/**
|
|
882
|
+
*
|
|
883
|
+
* Refaz a última ação.
|
|
884
|
+
*
|
|
885
|
+
* @param executionCtx - Contexto de execução de refazer a última ação.
|
|
886
|
+
*
|
|
887
|
+
*/
|
|
473
888
|
public redo(executionCtx?: ExecutionContext) {
|
|
474
889
|
this.dispatchAction(Action.CHANGE_REDONE, undefined, executionCtx);
|
|
475
890
|
}
|
|
476
891
|
|
|
892
|
+
/**
|
|
893
|
+
*
|
|
894
|
+
* Obtém a representação textual do DataUnit, nesse caso, o nome do DataUnit.
|
|
895
|
+
*
|
|
896
|
+
* @returns - Valor contido na propriedade name.
|
|
897
|
+
*
|
|
898
|
+
*/
|
|
477
899
|
public toString() {
|
|
478
900
|
return this.name;
|
|
479
901
|
}
|
|
480
902
|
|
|
481
903
|
// Actions / State manager
|
|
904
|
+
/**
|
|
905
|
+
*
|
|
906
|
+
* Lança ação do DataUnit para que sejam processadas.
|
|
907
|
+
*
|
|
908
|
+
* @param actionType - Tipo de ação que será executada.
|
|
909
|
+
* @param payload - Dados que serão processados na ação.
|
|
910
|
+
* @param executionCtx - Contexto de execução de lançar a ação que será executada.
|
|
911
|
+
*
|
|
912
|
+
* @returns - Verdadeiro se ação iniciada.
|
|
913
|
+
*
|
|
914
|
+
*/
|
|
482
915
|
private async dispatchAction(actionType: Action, payload?: any, executionCtx?: ExecutionContext): Promise<boolean> {
|
|
483
916
|
return new Promise(async resolve => {
|
|
484
917
|
let action = new DataUnitAction(actionType, payload);
|
|
@@ -500,6 +933,16 @@ export default class DataUnit {
|
|
|
500
933
|
});
|
|
501
934
|
}
|
|
502
935
|
|
|
936
|
+
/**
|
|
937
|
+
*
|
|
938
|
+
* Notifica os interceptors de que uma ação foi executada, para que cada interceptor possa fazer sua respectiva tratativa dos dados.
|
|
939
|
+
*
|
|
940
|
+
* @param action - Ação que foi executada.
|
|
941
|
+
* @param interceptors - Interceptors que serão notificados.
|
|
942
|
+
*
|
|
943
|
+
* @returns - Ação executada no DataUnit.
|
|
944
|
+
*
|
|
945
|
+
*/
|
|
503
946
|
private async intercept(action: DataUnitAction, interceptors: IterableIterator<DUActionInterceptor>): Promise<DataUnitAction> {
|
|
504
947
|
return new Promise(async resolve => {
|
|
505
948
|
let ite;
|
|
@@ -510,7 +953,14 @@ export default class DataUnit {
|
|
|
510
953
|
});
|
|
511
954
|
}
|
|
512
955
|
|
|
513
|
-
|
|
956
|
+
/**
|
|
957
|
+
*
|
|
958
|
+
* Processa as ações no DataUnit e notifica os observers.
|
|
959
|
+
*
|
|
960
|
+
* @param action - Ações em execução no DataUnit.
|
|
961
|
+
*
|
|
962
|
+
*/
|
|
963
|
+
private doDispatchAction(action: DataUnitAction): void {
|
|
514
964
|
this._stateManager.process(action);
|
|
515
965
|
this._observers.forEach(f => {
|
|
516
966
|
/*
|
|
@@ -525,14 +975,36 @@ export default class DataUnit {
|
|
|
525
975
|
});
|
|
526
976
|
}
|
|
527
977
|
|
|
978
|
+
/**
|
|
979
|
+
*
|
|
980
|
+
* Adiciona um novo observer no DataUnit.
|
|
981
|
+
* Ela vai ser chamada sempre que uma ação for despachada (dispatchAction()).
|
|
982
|
+
*
|
|
983
|
+
* @param observer - Função que recebe como parâmetro as ações que serão monitoradas.
|
|
984
|
+
*
|
|
985
|
+
*/
|
|
528
986
|
public subscribe(observer: (action: DataUnitAction) => void) {
|
|
529
987
|
this._observers.push(observer);
|
|
530
988
|
}
|
|
531
989
|
|
|
990
|
+
/**
|
|
991
|
+
*
|
|
992
|
+
* Remove um observer existente.
|
|
993
|
+
*
|
|
994
|
+
* @param observer - Observer que se deseja remover.
|
|
995
|
+
*
|
|
996
|
+
*/
|
|
532
997
|
public unsubscribe(observer: Function) {
|
|
533
998
|
this._observers = this._observers.filter(f => f !== observer);
|
|
534
999
|
}
|
|
535
1000
|
|
|
1001
|
+
/**
|
|
1002
|
+
*
|
|
1003
|
+
* Recarrega registro selecionado com dados atualizados do servidor.
|
|
1004
|
+
*
|
|
1005
|
+
* @returns - Dados atualizados do registro selecionado.
|
|
1006
|
+
*
|
|
1007
|
+
*/
|
|
536
1008
|
public reloadCurrentRecord(): Promise<Array<Record>>{
|
|
537
1009
|
return new Promise(async (resolve, fail) => {
|
|
538
1010
|
const selection = this.getSelection();
|
|
@@ -572,39 +1044,77 @@ export enum ChangeOperation {
|
|
|
572
1044
|
DELETE = "DELETE",
|
|
573
1045
|
}
|
|
574
1046
|
|
|
1047
|
+
/***
|
|
1048
|
+
* `Change`: Dados que representam uma alteração.
|
|
1049
|
+
*/
|
|
575
1050
|
export class Change {
|
|
576
1051
|
|
|
577
|
-
public
|
|
1052
|
+
public DataUnit: string;
|
|
578
1053
|
public record: Record;
|
|
579
1054
|
public sourceId: string | undefined;
|
|
580
1055
|
public updatingFields: any;
|
|
581
1056
|
|
|
582
1057
|
private _operation: ChangeOperation;
|
|
583
1058
|
|
|
584
|
-
constructor(
|
|
585
|
-
this.
|
|
1059
|
+
constructor(DataUnit: string, record: Record, updates: any, operation: ChangeOperation, sourceId?: string) {
|
|
1060
|
+
this.DataUnit = DataUnit;
|
|
586
1061
|
this.record = record;
|
|
587
1062
|
this.sourceId = sourceId;
|
|
588
1063
|
this.updatingFields = updates;
|
|
589
1064
|
this._operation = operation;
|
|
590
1065
|
}
|
|
591
1066
|
|
|
1067
|
+
/**
|
|
1068
|
+
*
|
|
1069
|
+
* Obtém o tipo de operação que está sendo realizada.
|
|
1070
|
+
*
|
|
1071
|
+
* @returns - Ação que está sendo executada.
|
|
1072
|
+
*
|
|
1073
|
+
*/
|
|
592
1074
|
public get operation(): string {
|
|
593
1075
|
return this._operation.toString();
|
|
594
1076
|
}
|
|
595
1077
|
|
|
1078
|
+
/**
|
|
1079
|
+
*
|
|
1080
|
+
* Retorna se o DataUnit está em uma operação de inserção.
|
|
1081
|
+
*
|
|
1082
|
+
* @returns - Verdadeiro se a operação for de inserção.
|
|
1083
|
+
*
|
|
1084
|
+
*/
|
|
596
1085
|
public isInsert(): boolean {
|
|
597
1086
|
return this._operation === ChangeOperation.INSERT;
|
|
598
1087
|
}
|
|
599
1088
|
|
|
1089
|
+
/**
|
|
1090
|
+
*
|
|
1091
|
+
* Retorna se o DataUnit está em uma operação de cópia.
|
|
1092
|
+
*
|
|
1093
|
+
* @returns - Verdadeiro se a operação for de cópia.
|
|
1094
|
+
*
|
|
1095
|
+
*/
|
|
600
1096
|
public isCopy(): boolean {
|
|
601
1097
|
return this._operation === ChangeOperation.COPY;
|
|
602
1098
|
}
|
|
603
1099
|
|
|
1100
|
+
/**
|
|
1101
|
+
*
|
|
1102
|
+
* Retorna se o DataUnit está em uma operação de deleção.
|
|
1103
|
+
*
|
|
1104
|
+
* @returns - Verdadeiro se a operação for de deleção.
|
|
1105
|
+
*
|
|
1106
|
+
*/
|
|
604
1107
|
public isDelete(): boolean {
|
|
605
1108
|
return this._operation === ChangeOperation.DELETE;
|
|
606
1109
|
}
|
|
607
1110
|
|
|
1111
|
+
/**
|
|
1112
|
+
*
|
|
1113
|
+
* Retorna se o DataUnit está em uma operação de atualização.
|
|
1114
|
+
*
|
|
1115
|
+
* @returns - Verdadeiro se a operação for de atualização.
|
|
1116
|
+
*
|
|
1117
|
+
*/
|
|
608
1118
|
public isUpdate(): boolean {
|
|
609
1119
|
return this._operation === ChangeOperation.UPDATE;
|
|
610
1120
|
}
|