@sankhyalabs/core 4.5.0 → 4.6.1

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.
@@ -19,7 +19,7 @@ import { getRecords, RecordsReducer } from "./state/slice/RecordsSlice.js";
19
19
  import { RemovedRecordsReducer } from "./state/slice/RemovedRecordsSlice.js";
20
20
  import { getSelection, getSelectionInfo, hasNext, hasPrevious, SelectionReducer } from "./state/slice/SelectionSlice.js";
21
21
  import { getField, getMetadata, UnitMetadataReducer } from "./state/slice/UnitMetadataSlice.js";
22
- import { getBlockingWaitingChanges, getWaitingChangePromisses, isWaiting, WaitingChangesReducer } from "./state/slice/WaitingChangesSlice.js";
22
+ import { getBlockingWaitingChanges, getWaitingChangePromisses, getWaitingChanges, isWaiting, WaitingChangesReducer } from "./state/slice/WaitingChangesSlice.js";
23
23
  import { canRedo, canUndo, HistReducer } from "./state/HistReducer.js";
24
24
  import { getFormattedValue } from "./formatting/PrettyFormatter.js";
25
25
  import { v4 as uuid } from "uuid";
@@ -738,8 +738,8 @@ export default class DataUnit {
738
738
  * @param executionCtx - Contexto de execução da inserção do dado no DataUnit.
739
739
  *
740
740
  */
741
- public addRecord(executionCtx?: ExecutionContext): void {
742
- this.dispatchAction(Action.RECORDS_ADDED, prepareAddedRecordId(this._stateManager, [{}], this.getParentRecordId()), executionCtx);
741
+ public async addRecord(executionCtx?: ExecutionContext): Promise<boolean> {
742
+ return this.dispatchAction(Action.RECORDS_ADDED, prepareAddedRecordId(this._stateManager, [{}], this.getParentRecordId()), executionCtx);
743
743
  }
744
744
 
745
745
  /**
@@ -822,8 +822,10 @@ export default class DataUnit {
822
822
  * @returns - Promise que será resolvida quando o novo valor for persistido no state.
823
823
  *
824
824
  */
825
- public setFieldValue(fieldName: string, newValue: any, records?: Array<string>): Promise<boolean> {
825
+ public async setFieldValue(fieldName: string, newValue: any, records?: Array<string>): Promise<boolean> {
826
826
 
827
+ if(!this.hasNewRecord() && !this.getSelectedRecord()) await this.addRecord();
828
+
827
829
  const typedValue = this.validateAndTypeValue(fieldName, newValue);
828
830
  const currentValue = this.getFieldValue(fieldName);
829
831
 
@@ -894,6 +896,16 @@ export default class DataUnit {
894
896
  this.dispatchAction(Action.WAITING_CHANGE_CANCELED, { fieldName }, undefined);
895
897
  }
896
898
 
899
+ /**
900
+ * Retorna se existe alterações pendentes.
901
+ * @returns Verdadeiro se existir pendências de modificações.
902
+ */
903
+ public hasWaitingChanges(): boolean {
904
+ const waitingChanges = getWaitingChanges(this._stateManager);
905
+ return waitingChanges ? !!waitingChanges.size : false;
906
+
907
+ }
908
+
897
909
  /**
898
910
  *
899
911
  * Seleciona o primeiro registro.
@@ -30,6 +30,7 @@ export interface FieldDescriptor {
30
30
  properties?: any;
31
31
  dependencies?: Array<FieldDependency>;
32
32
  group?: string;
33
+ order?: number;
33
34
  }
34
35
 
35
36
  export interface FieldDependency {