@sankhyalabs/core 5.10.0-dev.5 → 5.10.0-dev.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SnapshotSlice.js","sourceRoot":"","sources":["../../../../src/dataunit/state/slice/SnapshotSlice.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,mBAAmB;IAAzB;QAEW,cAAS,GAAW,UAAU,CAAC;IAK1C,CAAC;IAHU,MAAM,CAAC,YAA0B,EAAE,eAAyB;QAChE,OAAO,aAAa,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;IACvD,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,mBAAmB,EAAE,CAAC;AAEzD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,YAA0B,EAAwB,EAAE;IAC5E,OAAO,YAAY,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,EAAE,CAAC,KAAe,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;AACtF,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA0B,EAAuB,EAAE;IACjF,MAAM,QAAQ,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,GAAG,EAAE,CAAC;AACnD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,YAA0B,EAA6B,EAAE;IACz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avaScript da Sankhya.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -13,7 +13,13 @@ import { LoadDataResponse } from "./loading/LoadDataResponse.js";
13
13
  import { PaginationInfo } from "./loading/PaginationInfo.js";
14
14
  import { AddedRecordsReducer, getAddedRecords, prepareAddedRecordId, prepareCopiedRecord } from "./state/slice/AddedRecordsSlice.js";
15
15
  import { ChangesReducer, getChangesToSave, isDirty, hasDirtyRecords } from "./state/slice/ChangesSlice.js";
16
- import { SnapshotReducer, getCurrentRecords, getFieldValue, getModifiedRecords } from "./state/slice/SnapshotSlice.js";
16
+ import {
17
+ SnapshotReducer,
18
+ getCurrentRecords,
19
+ getFieldValue,
20
+ getModifiedRecords,
21
+ getSelectionRecords,
22
+ } from './state/slice/SnapshotSlice.js';
17
23
  import { getCurrentPage, getLastPage, getPaginationInfo, getCurrentRequest, LoadingControlReducer, hasMorePages, hasPreviousPages } from "./state/slice/LoadingControlSlice.js";
18
24
  import { getRecords, RecordsReducer } from "./state/slice/RecordsSlice.js";
19
25
  import { RemovedRecordsReducer } from "./state/slice/RemovedRecordsSlice.js";
@@ -1091,9 +1097,9 @@ export default class DataUnit {
1091
1097
  *
1092
1098
  */
1093
1099
  public getSelectedRecord(): Record | undefined {
1094
- const selection: Array<string> = getSelection(this._stateManager);
1095
- if (!selection) return;
1096
- return this.records.find(record => (selection as Array<string>).includes(record.__record__id__));
1100
+ const selection = getSelectionRecords(this._stateManager);
1101
+ if (!selection || selection.length == 0) return;
1102
+ return selection[0];
1097
1103
  }
1098
1104
 
1099
1105
  /**
@@ -2,12 +2,12 @@
2
2
  import { ActionReducer, StateAction } from "../StateManager.js";
3
3
  import { Action } from "../action/DataUnitAction.js";
4
4
  import StateManager from "../StateManager.js";
5
- import { getSelection } from "./SelectionSlice.js";
6
5
  import { getRecords } from "./RecordsSlice.js";
7
6
  import { getRemovedRecords } from "./RemovedRecordsSlice.js";
8
7
  import { getAddedRecords } from "./AddedRecordsSlice.js";
9
8
  import { Change, ChangeOperation, Record } from "../../DataUnit.js";
10
9
  import { getWaitingChanges } from "./WaitingChangesSlice.js";
10
+ import { getSelectionRecords } from './SnapshotSlice.js';
11
11
 
12
12
  class ChangesReducerImpl implements ActionReducer{
13
13
 
@@ -32,8 +32,8 @@ class ChangesReducerImpl implements ActionReducer{
32
32
  }
33
33
  );
34
34
  return changes;
35
- case Action.DATA_CHANGED:
36
- const selection: Array<string> = action.payload.records || getSelection(stateManager);
35
+ case Action.DATA_CHANGED:
36
+ const selection: Array<string> = action.payload.records || getSelectionRecords(stateManager)?.map(record => record.__record__id__);
37
37
  if(selection){
38
38
  const newState = new Map(currentState);
39
39
  selection.forEach(recordId => {
@@ -85,7 +85,7 @@ export const getChangesToSave = (dataUnit: string, stateManager: StateManager):
85
85
  const result: Array<Change> = [];
86
86
 
87
87
  const changes = getChanges(stateManager);
88
- const records = getRecords(stateManager);
88
+ const records = getSelectionRecords(stateManager);
89
89
 
90
90
  records?.forEach(r => {
91
91
  if(changes){
@@ -40,18 +40,18 @@ class RecordsReducerImpl implements ActionReducer {
40
40
  savedRecords.forEach(sr => {
41
41
  const recordId = sr.__old__id__ || sr.__record__id__;
42
42
  const newRecord: Record = { ...sr };
43
- delete newRecord["__old__id__"];
44
43
  if(recordsMap.has(recordId)){
45
44
  recordsMap.set(recordId, newRecord);
46
- } else {
45
+ } else if(this.isNewRecord(newRecord)){
47
46
  newRecords.push(newRecord);
48
47
  }
48
+ delete newRecord["__old__id__"];
49
49
  });
50
50
  return newRecords.concat(Array.from(recordsMap.values()));
51
51
 
52
52
  case Action.RECORD_LOADED:
53
53
  action.payload.forEach((record: any) => {
54
- for(let i = 0; i < currentState.length; i++){
54
+ for(let i = 0; i < currentState.length; i++){
55
55
  if(currentState[i].__record__id__ === record.__record__id__){
56
56
  currentState[i] = record;
57
57
  }
@@ -60,6 +60,11 @@ class RecordsReducerImpl implements ActionReducer {
60
60
  }
61
61
  return currentState;
62
62
  }
63
+
64
+ private isNewRecord(record: Record){
65
+ return (!Object.prototype.hasOwnProperty.call(record,"__old__id__")
66
+ || record["__old__id__"] !== record["__record__id__"]);
67
+ }
63
68
  }
64
69
 
65
70
  export const RecordsReducer = new RecordsReducerImpl();
@@ -28,6 +28,11 @@ export const getCurrentRecords = (stateManager: StateManager): Map<string, Recor
28
28
  return snapshot ? snapshot.records : new Map();
29
29
  };
30
30
 
31
+ export const getSelectionRecordsMap = (stateManager: StateManager): Map<string, Record> => {
32
+ const snapshot = getSnapshot(stateManager);
33
+ return snapshot ? snapshot.selectionRecords : new Map();
34
+ };
35
+
31
36
  export const getSelectionRecords = (stateManager: StateManager): Array<Record> | undefined => {
32
37
  const snapshot = getSnapshot(stateManager);
33
38
  return snapshot ? Array.from(snapshot.selectionRecords.values()) : undefined;
@@ -35,7 +40,7 @@ export const getSelectionRecords = (stateManager: StateManager): Array<Record> |
35
40
 
36
41
  export const getModifiedRecords = (stateManager: StateManager): Array<Record> | undefined => {
37
42
 
38
- const currentRecords = getCurrentRecords(stateManager);
43
+ const currentRecords = buildCurrentRecords(stateManager);
39
44
  if(!currentRecords){
40
45
  return undefined
41
46
  }
@@ -58,9 +63,9 @@ export const getModifiedRecords = (stateManager: StateManager): Array<Record> |
58
63
  export const getFieldValue = (stateManager: StateManager, fieldName: string): any => {
59
64
  const selection = getSelection(stateManager);
60
65
  if(selection && selection.length > 0){
61
- const currentRecords = getCurrentRecords(stateManager);
66
+ const currentRecords = getSelectionRecords(stateManager);
62
67
  if(currentRecords){
63
- const record = currentRecords.get(selection[0]);
68
+ const record = currentRecords.find(record => record.__record__id__ === selection[0]);
64
69
  return record ? record[fieldName] : undefined;
65
70
  }
66
71
  }
@@ -89,6 +94,11 @@ function buildSnapshot(oldSnapshot: Snapshot, stateManager: StateManager): Snaps
89
94
  const changes = getChanges(stateManager);
90
95
  const snapshotRecords: Map<string, Record> = new Map(records.map(source => [source.__record__id__, {...source, ...changes?.get(source.__record__id__)}]));
91
96
  const selectionRecords: Map<string, Record> = new Map(oldSnapshot?.selectionRecords);
97
+
98
+ for (let [chave, valor] of selectionRecords) {
99
+ selectionRecords.set(chave, {...valor, ...changes?.get(chave)});
100
+ }
101
+
92
102
  const selection: Array<string> = getSelection(stateManager);
93
103
 
94
104
  if(selection && selection.length > 0){
@@ -110,4 +120,20 @@ function buildSnapshot(oldSnapshot: Snapshot, stateManager: StateManager): Snaps
110
120
  records: snapshotRecords,
111
121
  selectionRecords
112
122
  }
123
+ }
124
+
125
+ function buildCurrentRecords(stateManager: StateManager) {
126
+ const currentRecords = getCurrentRecords(stateManager);
127
+ const selectionRecords = getSelectionRecordsMap(stateManager);
128
+
129
+ /**
130
+ * Precisamos verificar tanto os registros da seleção quanto os da página atual, pois o usuário pode estar tentando
131
+ * editar um registro que não está na página atual ou que não está selecionado.
132
+ */
133
+ selectionRecords.forEach(record => {
134
+ if (!currentRecords.has(record.__record__id__)) {
135
+ currentRecords.set(record.__record__id__, record);
136
+ }
137
+ });
138
+ return currentRecords;
113
139
  }