@sankhyalabs/core 5.20.0-dev.81 → 5.20.0-dev.82

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.
@@ -55,6 +55,7 @@ export default class DataUnit {
55
55
  private _allowReleaseCallbacks: boolean;
56
56
  private _waitingToReload: boolean = false;
57
57
  private _cancelPagination: boolean = false;
58
+ private _isMultipleEdition: boolean = false;
58
59
 
59
60
  public metadataLoader?: (dataUnit: DataUnit) => Promise<UnitMetadata>;
60
61
  public dataLoader?: (dataUnit: DataUnit, request: LoadDataRequest) => Promise<LoadDataResponse>;
@@ -183,6 +184,21 @@ export default class DataUnit {
183
184
  this._cancelPagination = cancelPagination;
184
185
  }
185
186
 
187
+ /**
188
+ * Informa se o DataUnit está no modo de edição de múltiplos registros.
189
+ */
190
+ public get isMultipleEdition(): boolean {
191
+ return this._isMultipleEdition;
192
+ }
193
+
194
+ /**
195
+ * Define se o DataUnit está no modo de edição de múltiplos registros.
196
+ */
197
+ public set isMultipleEdition(isMultipleEdition) {
198
+ this._isMultipleEdition = isMultipleEdition;
199
+ this.dispatchAction(Action.MULTIPLE_EDITION_CHANGED, {isMultipleEdition});
200
+ }
201
+
186
202
  /**
187
203
  *
188
204
  * Obtém o nome de identificação do DataUnit (geralmente em formato de URI - Uniform Resource Identifier).
@@ -1031,7 +1047,7 @@ export default class DataUnit {
1031
1047
  const typedValue = this.validateAndTypeValue(fieldName, newValue);
1032
1048
  const currentValue = this.getFieldValue(fieldName);
1033
1049
 
1034
- if(!(newValue instanceof Promise) && ObjectUtils.hasEquivalentProps(currentValue, typedValue)){
1050
+ if(this.areEquivalentValues(newValue, currentValue, typedValue)) {
1035
1051
  return Promise.resolve(false);
1036
1052
  }
1037
1053
 
@@ -1046,7 +1062,7 @@ export default class DataUnit {
1046
1062
  return promise;
1047
1063
  }
1048
1064
 
1049
- if (currentValue !== typedValue) {
1065
+ if (this.isMultipleEdition || currentValue !== typedValue) {
1050
1066
  const promise = this.dispatchAction(Action.DATA_CHANGED, { [fieldName]: typedValue, records }, undefined, options);
1051
1067
  this._savingLockers.push(promise);
1052
1068
  return promise;
@@ -1055,6 +1071,12 @@ export default class DataUnit {
1055
1071
  return Promise.resolve(false);
1056
1072
  }
1057
1073
 
1074
+ private areEquivalentValues(newValue: any, currentValue: any, typedValue: any) {
1075
+ return !(newValue instanceof Promise)
1076
+ && ObjectUtils.hasEquivalentProps(currentValue, typedValue)
1077
+ && !this.isMultipleEdition;
1078
+ }
1079
+
1058
1080
  /**
1059
1081
  *
1060
1082
  * Marca campos como inválidos.
@@ -26,6 +26,8 @@ export interface ExecutionContext{
26
26
 
27
27
  export enum Action{
28
28
 
29
+ MULTIPLE_EDITION_CHANGED = "multipleEditionChanged",
30
+
29
31
  LOADING_METADATA = "loadingMetadata",
30
32
  METADATA_LOADED = "metadataLoaded",
31
33