@sankhyalabs/core 1.0.30 → 1.0.33
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/dist/dataunit/DataUnit.d.ts +13 -5
- package/dist/dataunit/DataUnit.js +79 -29
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/state/StateManager.js +0 -12
- package/dist/dataunit/state/StateManager.js.map +1 -1
- package/dist/dataunit/state/action/DataUnitAction.d.ts +1 -0
- package/dist/dataunit/state/action/DataUnitAction.js +1 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +1 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.js +6 -5
- package/dist/dataunit/state/slice/AddedRecordsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/ChangesSlice.js +11 -11
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
- package/dist/dataunit/state/slice/SelectionSlice.js +3 -0
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
- package/dist/http/data-fetcher/HttpFetcher.d.ts +1 -0
- package/dist/http/data-fetcher/HttpFetcher.js +52 -62
- package/dist/http/data-fetcher/HttpFetcher.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/dataunit/DataUnit.ts +79 -35
- package/src/dataunit/state/StateManager.ts +0 -11
- package/src/dataunit/state/action/DataUnitAction.ts +1 -0
- package/src/dataunit/state/slice/AddedRecordsSlice.ts +7 -5
- package/src/dataunit/state/slice/ChangesSlice.ts +11 -11
- package/src/dataunit/state/slice/SelectionSlice.ts +4 -1
- package/src/http/data-fetcher/HttpFetcher.ts +53 -63
- package/src/index.ts +7 -3
|
@@ -8,8 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { LoadStateManager, LoadType } from "./state/LoadStateManager";
|
|
11
|
-
import { DataType } from "./../../dataunit/metadata/DataType";
|
|
12
|
-
import { UserInterface } from "./../../dataunit/metadata/UnitMetadata";
|
|
13
11
|
import { batchRequests } from 'graphql-request';
|
|
14
12
|
export class HttpFetcher {
|
|
15
13
|
constructor() {
|
|
@@ -25,52 +23,30 @@ export class HttpFetcher {
|
|
|
25
23
|
callGraphQL(req) {
|
|
26
24
|
var _a;
|
|
27
25
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const reqKey = this.getReqKey(req);
|
|
27
|
+
req.queryID = reqKey;
|
|
28
|
+
req.values.queryID = reqKey;
|
|
28
29
|
if (HttpFetcher.loadStateManager.isPreInitialize()) {
|
|
29
|
-
const reqKey = this.getReqKey(req);
|
|
30
|
-
req.queryID = reqKey;
|
|
31
|
-
req.values.queryID = reqKey;
|
|
32
30
|
if (!HttpFetcher.watingRequestsById.has(reqKey)) {
|
|
33
31
|
HttpFetcher.watingRequestsById.set(reqKey, new WaitingRequest(req));
|
|
34
32
|
}
|
|
35
33
|
return (_a = HttpFetcher.getWatingRequest(reqKey)) === null || _a === void 0 ? void 0 : _a.promise;
|
|
36
34
|
}
|
|
37
35
|
else {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
dataType: DataType.TEXT,
|
|
53
|
-
userInterface: UserInterface.LONGTEXT,
|
|
54
|
-
required: true
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
name: "P",
|
|
58
|
-
label: "pera",
|
|
59
|
-
dataType: DataType.TEXT,
|
|
60
|
-
userInterface: UserInterface.OPTIONSELECTOR,
|
|
61
|
-
properties: { options: `{"M": "Madura", "V": "Verde", "P": "Passada"}` }
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "ME",
|
|
65
|
-
label: "ME",
|
|
66
|
-
dataType: DataType.NUMBER,
|
|
67
|
-
userInterface: UserInterface.DECIMALNUMBER,
|
|
68
|
-
properties: { precision: 4, prettyPrecision: 1 }
|
|
69
|
-
}
|
|
70
|
-
]
|
|
71
|
-
};
|
|
72
|
-
setTimeout(() => resolve(md));
|
|
73
|
-
});
|
|
36
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
let query = HttpFetcher.getQueryTemplate(req);
|
|
38
|
+
const res = yield HttpFetcher.fecthGrapql([{ document: query, variables: req.values }]);
|
|
39
|
+
if (res.errors.length > 0) {
|
|
40
|
+
reject(res);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
//resolve(res);
|
|
44
|
+
//FIXME: Precisamos trabalhar melhor a resposta, quem chamou
|
|
45
|
+
//a API não pode ficar responsavel por desempacotar... fiz uma
|
|
46
|
+
//gambiarra aqui...
|
|
47
|
+
resolve(res.data[0][reqKey]);
|
|
48
|
+
}
|
|
49
|
+
}));
|
|
74
50
|
}
|
|
75
51
|
});
|
|
76
52
|
}
|
|
@@ -85,21 +61,49 @@ export class HttpFetcher {
|
|
|
85
61
|
}
|
|
86
62
|
onApplicationLoaded() {
|
|
87
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
64
|
+
if (HttpFetcher.watingRequestsById.size > 0) {
|
|
65
|
+
const requestsBatch = [];
|
|
66
|
+
HttpFetcher.watingRequestsById.forEach((waitingReq) => __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
let query = HttpFetcher.getQueryTemplate(waitingReq.request);
|
|
68
|
+
requestsBatch.push({ document: query, variables: Object.assign({}, waitingReq.request.values) });
|
|
69
|
+
}));
|
|
70
|
+
let res = undefined;
|
|
71
|
+
let dataResponse = [];
|
|
72
|
+
let errorsResponse = [];
|
|
73
|
+
res = yield HttpFetcher.fecthGrapql(requestsBatch);
|
|
74
|
+
dataResponse = res.data;
|
|
75
|
+
errorsResponse = res.errors;
|
|
76
|
+
//Reject promises with errors from query
|
|
77
|
+
errorsResponse.forEach((errorResponse) => {
|
|
78
|
+
Object.entries(errorResponse).forEach(([key, val]) => {
|
|
79
|
+
var _a;
|
|
80
|
+
(((_a = HttpFetcher.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
//Resolve promises with data from query
|
|
84
|
+
dataResponse.forEach((data) => {
|
|
85
|
+
Object.entries(data).forEach(([key, val]) => {
|
|
86
|
+
var _a;
|
|
87
|
+
(((_a = HttpFetcher.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
HttpFetcher.watingRequestsById.clear();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
static fecthGrapql(request) {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
96
|
let res = undefined;
|
|
94
97
|
let dataResponse = [];
|
|
95
98
|
let errorsResponse = [];
|
|
96
99
|
try {
|
|
97
|
-
res = yield batchRequests('http://localhost:8082/',
|
|
100
|
+
res = yield batchRequests('http://localhost:8082/', request);
|
|
98
101
|
res.forEach((resItem) => {
|
|
99
102
|
dataResponse.push(resItem.data);
|
|
100
103
|
});
|
|
101
104
|
}
|
|
102
105
|
catch (err) {
|
|
106
|
+
//TODO: Tratar erro quando não existir err.response
|
|
103
107
|
res = err.response;
|
|
104
108
|
const req = err.request;
|
|
105
109
|
Object.entries(res).forEach(([key, val]) => {
|
|
@@ -115,21 +119,7 @@ export class HttpFetcher {
|
|
|
115
119
|
}
|
|
116
120
|
});
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
errorsResponse.forEach((errorResponse) => {
|
|
120
|
-
Object.entries(errorResponse).forEach(([key, val]) => {
|
|
121
|
-
var _a;
|
|
122
|
-
(((_a = HttpFetcher.getWatingRequest(val.request.variables[val.index].queryID)) === null || _a === void 0 ? void 0 : _a.reject) || Promise.reject)(val);
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
//Resolve primises with data from query
|
|
126
|
-
dataResponse.forEach((data) => {
|
|
127
|
-
Object.entries(data).forEach(([key, val]) => {
|
|
128
|
-
var _a;
|
|
129
|
-
(((_a = HttpFetcher.getWatingRequest(key)) === null || _a === void 0 ? void 0 : _a.resolve) || Promise.resolve)(val);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
HttpFetcher.watingRequestsById.clear();
|
|
122
|
+
return { data: dataResponse, errors: errorsResponse };
|
|
133
123
|
});
|
|
134
124
|
}
|
|
135
125
|
//TODO: Mover este metodo para o @sankhyalabs/core classe string utils.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpFetcher.js","sourceRoot":"","sources":["../../../src/http/data-fetcher/HttpFetcher.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"HttpFetcher.js","sourceRoot":"","sources":["../../../src/http/data-fetcher/HttpFetcher.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAC;AAEvE,MAAM,OAAO,WAAW;IAKpB;QACI,WAAW,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACvE,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACpE,CAAC;IAEM,MAAM,CAAC,GA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,IAAI,CAAC,GAAG,GAAG,CAAC;YACnC,IAAI,IAAI,CAAC,CAAC,CAAC,2BAA2B;SACvC;QACD,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;IAAA,CAAC;;AA7Ha,8BAAkB,GAAgC,IAAI,GAAG,EAA0B,CAAC;AAgIvG,MAAM,cAAc;IAMlB,YAAY,GAAO;QALX,aAAQ,GAAa,GAAG,EAAE,GAAE,CAAC,CAAC;QAC9B,YAAO,GAAa,GAAG,EAAE,GAAE,CAAC,CAAC;QAE7B,aAAQ,GAAQ,SAAS,CAAC;QAGhC,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAC;QACpB,IAAI,CAAC,SAAS,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC/C,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;YACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ import { HttpProvider } from "./http/HttpProvider";
|
|
|
8
8
|
import { SkwHttpProvider } from "./http/SkwHttpProvider";
|
|
9
9
|
import { RequestMetadata } from "./http/RequestMetadata";
|
|
10
10
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller";
|
|
11
|
-
import DataUnit, { SavedRecord, Record, Change } from "./dataunit/DataUnit";
|
|
11
|
+
import DataUnit, { SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor } from "./dataunit/DataUnit";
|
|
12
12
|
import { DataType } from "./dataunit/metadata/DataType";
|
|
13
|
-
import { UnitMetadata, FieldDescriptor, UserInterface } from "./dataunit/metadata/UnitMetadata";
|
|
13
|
+
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, Filter } from "./dataunit/metadata/UnitMetadata";
|
|
14
14
|
import { HttpFetcher } from "./http/data-fetcher/HttpFetcher";
|
|
15
15
|
import { LoadStateManager, LoadStatus } from "./http/data-fetcher/state/LoadStateManager";
|
|
16
16
|
import { DataUnitAction, Action } from "./dataunit/state/action/DataUnitAction";
|
|
17
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, HttpFetcher, LoadStateManager, LoadStatus, DataUnitAction, Action, Change };
|
|
17
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, Record, SavedRecord, DataType, UnitMetadata, FieldDescriptor, UserInterface, HttpFetcher, LoadStateManager, LoadStatus, DataUnitAction, Action, Change, Sort, Filter, ChangeOperation, DUActionInterceptor };
|
package/dist/index.js
CHANGED
|
@@ -8,12 +8,12 @@ import { HttpProvider } from "./http/HttpProvider";
|
|
|
8
8
|
import { SkwHttpProvider } from "./http/SkwHttpProvider";
|
|
9
9
|
import { RequestMetadata } from "./http/RequestMetadata";
|
|
10
10
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller";
|
|
11
|
-
import DataUnit, { Change } from "./dataunit/DataUnit";
|
|
11
|
+
import DataUnit, { Change, ChangeOperation } from "./dataunit/DataUnit";
|
|
12
12
|
import { DataType } from "./dataunit/metadata/DataType";
|
|
13
13
|
import { UserInterface } from "./dataunit/metadata/UnitMetadata";
|
|
14
14
|
import { HttpFetcher } from "./http/data-fetcher/HttpFetcher";
|
|
15
15
|
import { LoadStateManager, LoadStatus } from "./http/data-fetcher/state/LoadStateManager";
|
|
16
16
|
import { DataUnitAction, Action } from "./dataunit/state/action/DataUnitAction";
|
|
17
17
|
/*Classes públicas no pacote*/
|
|
18
|
-
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataType, UserInterface, HttpFetcher, LoadStateManager, LoadStatus, DataUnitAction, Action, Change };
|
|
18
|
+
export { StringUtils, MaskFormatter, NumberUtils, FloatingManager, DateUtils, TimeFormatter, SkwHttpProvider, HttpProvider, RequestMetadata, AuthorizedServiceCaller, DataUnit, DataType, UserInterface, HttpFetcher, LoadStateManager, LoadStatus, DataUnitAction, Action, Change, ChangeOperation };
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,QAAQ,EAAE,EAAsB,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AACnD,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,QAAQ,EAAE,EAAsB,MAAM,EAAE,eAAe,EAAsB,MAAM,qBAAqB,CAAC;AAChH,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAiC,aAAa,EAAgB,MAAM,kCAAkC,CAAC;AAC9G,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAEhF,8BAA8B;AAC9B,OAAO,EACH,WAAW,EACX,aAAa,EACb,WAAW,EACX,eAAe,EACf,SAAS,EACT,aAAa,EACb,eAAe,EACf,YAAY,EACZ,eAAe,EACf,uBAAuB,EACvB,QAAQ,EAGR,QAAQ,EAGR,aAAa,EACb,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,MAAM,EACN,MAAM,EAGN,eAAe,EAElB,CAAC"}
|
package/package.json
CHANGED
package/src/dataunit/DataUnit.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { RecordsReducer } from "./state/slice/RecordsSlice";
|
|
|
10
10
|
import { SelectionReducer, getSelection, hasNext, hasPrevious } from "./state/slice/SelectionSlice";
|
|
11
11
|
import { ChangesReducer, isDirty, getChangesToSave } from "./state/slice/ChangesSlice";
|
|
12
12
|
import { RemovedRecordsReducer } from "./state/slice/RemovedRecordsSlice";
|
|
13
|
-
import { AddedRecordsReducer } from "./state/slice/AddedRecordsSlice";
|
|
13
|
+
import { AddedRecordsReducer, prepareAddedRecordId } from "./state/slice/AddedRecordsSlice";
|
|
14
14
|
import { CurrentRecordsReducer, getCurrentRecords, getFieldValue } from "./state/slice/CurrentRecordsSlice";
|
|
15
15
|
|
|
16
16
|
|
|
@@ -21,6 +21,7 @@ export default class DataUnit {
|
|
|
21
21
|
private _sortingProvider?: SortingProvider;
|
|
22
22
|
private _filterProviders: Array<FilterProvider>;
|
|
23
23
|
private _stateManager: StateManager;
|
|
24
|
+
private _interceptors: Array<DUActionInterceptor>;
|
|
24
25
|
|
|
25
26
|
public metadataLoader?: (dataUnit: string) => Promise<UnitMetadata>;
|
|
26
27
|
public dataLoader?: (dataUnit: string, sort?: Array<Sort>, filters?: Array<Filter>) => Promise<Array<Record>>;
|
|
@@ -43,6 +44,7 @@ export default class DataUnit {
|
|
|
43
44
|
this._observers = [];
|
|
44
45
|
this._filterProviders = [];
|
|
45
46
|
this._sortingProvider = undefined;
|
|
47
|
+
this._interceptors = [];
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
public get name(): string {
|
|
@@ -56,34 +58,39 @@ export default class DataUnit {
|
|
|
56
58
|
return descriptor ? convertType(descriptor.dataType, newValue) : newValue;
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
private getFilters(): Array<Filter> | undefined{
|
|
61
|
+
private getFilters(): Array<Filter> | undefined {
|
|
60
62
|
let filters: Array<Filter> | undefined = undefined;
|
|
61
63
|
this._filterProviders.forEach(p => {
|
|
62
64
|
const f = p.getFilter(this.name);
|
|
63
|
-
if(f){
|
|
64
|
-
filters = (filters||[]).concat(f);
|
|
65
|
+
if (f) {
|
|
66
|
+
filters = (filters || []).concat(f);
|
|
65
67
|
}
|
|
66
68
|
});
|
|
67
69
|
return filters;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
|
-
private getSort(): Array<Sort> | undefined{
|
|
72
|
+
private getSort(): Array<Sort> | undefined {
|
|
71
73
|
return this._sortingProvider ? this._sortingProvider.getSort(this._name) : undefined;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
// Loaders
|
|
75
|
-
public loadMetadata():
|
|
77
|
+
public async loadMetadata(): Promise<UnitMetadata> {
|
|
76
78
|
this.dispatchAction(Action.LOADING_METADATA);
|
|
77
|
-
|
|
78
|
-
this.metadataLoader
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
return new Promise((resolve, fail) => {
|
|
80
|
+
if (this.metadataLoader) {
|
|
81
|
+
this.metadataLoader(this._name).then(
|
|
82
|
+
metadata => {
|
|
83
|
+
this.metadata = metadata
|
|
84
|
+
resolve(this.metadata);
|
|
85
|
+
}
|
|
86
|
+
).catch(error => fail(error));
|
|
87
|
+
}
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
90
|
|
|
84
|
-
public loadData(): Promise<Array<Record>> {
|
|
91
|
+
public async loadData(): Promise<Array<Record>> {
|
|
85
92
|
this.dispatchAction(Action.LOADING_DATA);
|
|
86
|
-
return new Promise((resolve, fail)=>{
|
|
93
|
+
return new Promise((resolve, fail) => {
|
|
87
94
|
if (this.dataLoader) {
|
|
88
95
|
const sort = this.getSort();
|
|
89
96
|
const filters = this.getFilters();
|
|
@@ -92,31 +99,38 @@ export default class DataUnit {
|
|
|
92
99
|
this.records = records;
|
|
93
100
|
resolve(this.records);
|
|
94
101
|
}
|
|
95
|
-
).catch(
|
|
102
|
+
).catch(error => fail(error));
|
|
96
103
|
}
|
|
97
104
|
});
|
|
98
105
|
}
|
|
99
106
|
|
|
100
|
-
public saveData(): void {
|
|
107
|
+
public async saveData(): Promise<void> {
|
|
101
108
|
|
|
102
109
|
const changes: Array<Change> = getChangesToSave(this._name, this._stateManager);
|
|
103
110
|
|
|
104
111
|
if (changes.length > 0) {
|
|
105
112
|
this.dispatchAction(Action.SAVING_DATA);
|
|
106
|
-
|
|
107
|
-
this.saveLoader
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
113
|
+
return new Promise((resolve, fail) => {
|
|
114
|
+
if (this.saveLoader) {
|
|
115
|
+
this.saveLoader(this._name, changes).then(
|
|
116
|
+
records => this.dispatchAction(Action.DATA_SAVED, { changes, records })
|
|
117
|
+
).catch(error => fail(error));
|
|
118
|
+
}
|
|
119
|
+
});
|
|
111
120
|
}
|
|
121
|
+
return Promise.resolve();
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
// API
|
|
115
|
-
public
|
|
125
|
+
public addInterceptor(interceptor: DUActionInterceptor): void {
|
|
126
|
+
this._interceptors.push(interceptor);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public addFilterProvider(provider: FilterProvider): void {
|
|
116
130
|
this._filterProviders.push(provider);
|
|
117
131
|
}
|
|
118
132
|
|
|
119
|
-
public set sortingProvider(provider: SortingProvider){
|
|
133
|
+
public set sortingProvider(provider: SortingProvider) {
|
|
120
134
|
this._sortingProvider = provider;
|
|
121
135
|
}
|
|
122
136
|
|
|
@@ -128,21 +142,28 @@ export default class DataUnit {
|
|
|
128
142
|
return getMetadata(this._stateManager);
|
|
129
143
|
}
|
|
130
144
|
|
|
131
|
-
public set records(r: Array<Record>){
|
|
145
|
+
public set records(r: Array<Record>) {
|
|
132
146
|
this.dispatchAction(Action.DATA_LOADED, r);
|
|
133
147
|
}
|
|
134
|
-
|
|
135
|
-
public get records(): Array<Record>{
|
|
148
|
+
|
|
149
|
+
public get records(): Array<Record> {
|
|
136
150
|
const records = getCurrentRecords(this._stateManager);
|
|
137
151
|
return records ? Array.from(records.values()) : [];
|
|
138
152
|
}
|
|
139
|
-
|
|
140
|
-
public getField(fieldName: string): FieldDescriptor | undefined{
|
|
153
|
+
|
|
154
|
+
public getField(fieldName: string): FieldDescriptor | undefined {
|
|
141
155
|
return getField(this._stateManager, fieldName);
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
public addRecord(): void {
|
|
145
|
-
this.dispatchAction(Action.RECORDS_ADDED, [{}]);
|
|
159
|
+
this.dispatchAction(Action.RECORDS_ADDED, prepareAddedRecordId(this._stateManager, [{}]));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public copySelected(): void{
|
|
163
|
+
const selectedRecords = this.getSelectedRecords();
|
|
164
|
+
if(selectedRecords){
|
|
165
|
+
this.dispatchAction(Action.RECORDS_COPIED, prepareAddedRecordId(this._stateManager, selectedRecords));
|
|
166
|
+
}
|
|
146
167
|
}
|
|
147
168
|
|
|
148
169
|
public removeSelectedRecords(): void {
|
|
@@ -178,6 +199,14 @@ export default class DataUnit {
|
|
|
178
199
|
this.dispatchAction(Action.SELECTION_CHANGED, { type: "index", selection });
|
|
179
200
|
}
|
|
180
201
|
|
|
202
|
+
public getSelectedRecords(): Array<Record>|undefined{
|
|
203
|
+
const selection: Array<string> = this.getSelection();
|
|
204
|
+
if(selection){
|
|
205
|
+
const currentRecords: Array<Record> = this.records;
|
|
206
|
+
return currentRecords?.filter(r => selection.includes(r.__record__id__));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
181
210
|
public nextRecord(): void {
|
|
182
211
|
this.dispatchAction(Action.NEXT_SELECTED);
|
|
183
212
|
}
|
|
@@ -220,11 +249,18 @@ export default class DataUnit {
|
|
|
220
249
|
|
|
221
250
|
// Actions / State manager
|
|
222
251
|
private dispatchAction(actionType: Action, payload?: any): void {
|
|
223
|
-
|
|
252
|
+
let action = new DataUnitAction(actionType, payload);
|
|
253
|
+
|
|
254
|
+
this._interceptors?.forEach(interceptor => {
|
|
255
|
+
if(action){
|
|
256
|
+
action = interceptor.interceptAction(action);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
224
259
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
260
|
+
if(action){
|
|
261
|
+
this._stateManager.process(action);
|
|
262
|
+
this._observers.forEach(f => f(action));
|
|
263
|
+
}
|
|
228
264
|
}
|
|
229
265
|
|
|
230
266
|
public subscribe(observer: (action: DataUnitAction) => void) {
|
|
@@ -236,6 +272,10 @@ export default class DataUnit {
|
|
|
236
272
|
}
|
|
237
273
|
}
|
|
238
274
|
|
|
275
|
+
export interface DUActionInterceptor{
|
|
276
|
+
interceptAction(action: DataUnitAction): DataUnitAction;
|
|
277
|
+
}
|
|
278
|
+
|
|
239
279
|
export interface Record {
|
|
240
280
|
__record__id__: string;
|
|
241
281
|
__parent__record__id__?: string;
|
|
@@ -247,9 +287,9 @@ export interface SavedRecord extends Record {
|
|
|
247
287
|
}
|
|
248
288
|
|
|
249
289
|
export enum ChangeOperation {
|
|
250
|
-
INSERT,
|
|
251
|
-
UPDATE,
|
|
252
|
-
DELETE
|
|
290
|
+
INSERT = "INSERT",
|
|
291
|
+
UPDATE = "UPDATE",
|
|
292
|
+
DELETE = "DELETE"
|
|
253
293
|
}
|
|
254
294
|
|
|
255
295
|
export class Change {
|
|
@@ -267,6 +307,10 @@ export class Change {
|
|
|
267
307
|
this._operation = operation;
|
|
268
308
|
}
|
|
269
309
|
|
|
310
|
+
public get operation(): string{
|
|
311
|
+
return this._operation.toString();
|
|
312
|
+
}
|
|
313
|
+
|
|
270
314
|
public isInsert(): boolean {
|
|
271
315
|
return this._operation === ChangeOperation.INSERT;
|
|
272
316
|
}
|
|
@@ -33,7 +33,6 @@ export default class StateManager {
|
|
|
33
33
|
public process(action: StateAction) {
|
|
34
34
|
|
|
35
35
|
const oldPresent: any = this._present;
|
|
36
|
-
let hasChange: boolean = false;
|
|
37
36
|
let hasHistChange: boolean = false;
|
|
38
37
|
this._histClean = false;
|
|
39
38
|
|
|
@@ -45,7 +44,6 @@ export default class StateManager {
|
|
|
45
44
|
const newSlice = reducer.reduce(this, oldSlice, action);
|
|
46
45
|
if (newSlice !== oldSlice) {
|
|
47
46
|
this.updateSlice(sliceName, newSlice, isHistoric);
|
|
48
|
-
hasChange = true;
|
|
49
47
|
hasHistChange ||= isHistoric;
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -57,15 +55,6 @@ export default class StateManager {
|
|
|
57
55
|
document.dispatchEvent(new CustomEvent("undoableAction", { detail: this }))
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
if (hasChange) {
|
|
61
|
-
console.log(JSON.stringify(this, (_key, value) => {
|
|
62
|
-
if (value instanceof Map) {
|
|
63
|
-
return { dataType: "Map", value: Array.from(value.entries()) };
|
|
64
|
-
} else {
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
}, 3));
|
|
68
|
-
}
|
|
69
58
|
}
|
|
70
59
|
|
|
71
60
|
public select(sliceName: string, selector: (state: any) => any): any {
|
|
@@ -11,11 +11,8 @@ class AddedRecordsReducerImpl implements ActionReducer{
|
|
|
11
11
|
public reduce(_stateManager:StateManager, currentState: Array<Record>, action: StateAction): Array<Record>|undefined {
|
|
12
12
|
switch(action.type){
|
|
13
13
|
case Action.RECORDS_ADDED:
|
|
14
|
-
|
|
15
|
-
action.payload
|
|
16
|
-
newState.push({__record__id__: "NEW_" + (newState.length + 1), ...r});
|
|
17
|
-
});
|
|
18
|
-
return newState;
|
|
14
|
+
case Action.RECORDS_COPIED:
|
|
15
|
+
return (currentState||[]).concat(action.payload);
|
|
19
16
|
case Action.DATA_SAVED:
|
|
20
17
|
case Action.EDITION_CANCELED:
|
|
21
18
|
return undefined;
|
|
@@ -28,4 +25,9 @@ export const AddedRecordsReducer = new AddedRecordsReducerImpl();
|
|
|
28
25
|
|
|
29
26
|
export const getAddedRecords = (stateManager: StateManager): Array<Record> => {
|
|
30
27
|
return stateManager.select(AddedRecordsReducer.sliceName, (state: Array<Record>) => state);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const prepareAddedRecordId = (stateManager: StateManager, source: Array<any>): Array<Record> => {
|
|
31
|
+
let index = (getAddedRecords(stateManager)||[]).length;
|
|
32
|
+
return source.map(item=>{return {...item, __record__id__: "NEW_" + (index++)}});
|
|
31
33
|
};
|
|
@@ -20,7 +20,9 @@ class ChangesReducerImpl implements ActionReducer{
|
|
|
20
20
|
if(selection){
|
|
21
21
|
const newState = new Map(currentState);
|
|
22
22
|
selection.forEach(recordId => {
|
|
23
|
-
|
|
23
|
+
const newChanges = {...newState.get(recordId), ...action.payload};
|
|
24
|
+
delete newChanges.records;
|
|
25
|
+
newState.set(recordId, newChanges);
|
|
24
26
|
});
|
|
25
27
|
return newState;
|
|
26
28
|
}
|
|
@@ -60,16 +62,14 @@ export const getChangesToSave = (dataUnit: string, stateManager: StateManager):
|
|
|
60
62
|
const changes = getChanges(stateManager);
|
|
61
63
|
const records = getRecords(stateManager);
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
result.push(new Change(dataUnit, r, c, ChangeOperation.UPDATE));
|
|
69
|
-
}
|
|
65
|
+
records?.forEach(r => {
|
|
66
|
+
if(changes){
|
|
67
|
+
const c = changes.get(r.__record__id__);
|
|
68
|
+
if (c) {
|
|
69
|
+
result.push(new Change(dataUnit, r, c, ChangeOperation.UPDATE));
|
|
70
70
|
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
73
|
|
|
74
74
|
const addedRecords = getAddedRecords(stateManager);
|
|
75
75
|
if (addedRecords) {
|
|
@@ -80,7 +80,7 @@ export const getChangesToSave = (dataUnit: string, stateManager: StateManager):
|
|
|
80
80
|
|
|
81
81
|
const removedRecords = getRemovedRecords(stateManager);
|
|
82
82
|
const recordsById: any = {};
|
|
83
|
-
records
|
|
83
|
+
records?.forEach(r=>recordsById[r.__record__id__] = r);
|
|
84
84
|
if (removedRecords) {
|
|
85
85
|
removedRecords.forEach(id => {
|
|
86
86
|
result.push(new Change(dataUnit, recordsById[id], undefined, ChangeOperation.DELETE));
|
|
@@ -2,7 +2,7 @@ import { ActionReducer, StateAction } from "../StateManager";
|
|
|
2
2
|
import { Action } from "../action/DataUnitAction";
|
|
3
3
|
import StateManager from "../StateManager";
|
|
4
4
|
import { getCurrentRecords } from "./CurrentRecordsSlice";
|
|
5
|
-
import { SavedRecord } from "../../DataUnit";
|
|
5
|
+
import { Record, SavedRecord } from "../../DataUnit";
|
|
6
6
|
|
|
7
7
|
class SelectionReducerImpl implements ActionReducer {
|
|
8
8
|
|
|
@@ -12,6 +12,9 @@ class SelectionReducerImpl implements ActionReducer {
|
|
|
12
12
|
|
|
13
13
|
switch (action.type) {
|
|
14
14
|
|
|
15
|
+
case Action.RECORDS_ADDED:
|
|
16
|
+
case Action.RECORDS_COPIED:
|
|
17
|
+
return action.payload.map((r: Record)=>r.__record__id__);
|
|
15
18
|
case Action.DATA_SAVED:
|
|
16
19
|
return updateSavedIds(stateManager, action.payload.records);
|
|
17
20
|
case Action.RECORDS_REMOVED:
|