@archbase/data 4.0.1 → 4.0.3
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/index.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { isDate as
|
|
2
|
-
import { EventEmitter as
|
|
3
|
-
import { uniqueId as
|
|
4
|
-
import { archbaseI18next as
|
|
5
|
-
import { ADVANCED as
|
|
6
|
-
import { useState as
|
|
7
|
-
import { produce as
|
|
1
|
+
import { isDate as ve, parseISO as Ie } from "date-fns";
|
|
2
|
+
import { EventEmitter as Be } from "events";
|
|
3
|
+
import { uniqueId as $e, cloneDeep as Ne } from "lodash";
|
|
4
|
+
import { archbaseI18next as R, ArchbaseDataSourceError as g, ArchbaseObjectHelper as Re, processErrorMessage as G, QUICK as we, NORMAL as Ee, ADVANCED as Se, ArchbaseFilterDSL as Fe, QueryFilterEntity as he, detectDataSourceVersion as pe, MigrationMetrics as He, ARCHBASE_IOC_API_TYPE as We, ArchbaseJacksonParser as ie } from "@archbase/core";
|
|
5
|
+
import { ADVANCED as jt, ARCHBASE_IOC_API_TYPE as kt, FILTER_TYPE as Ut, NORMAL as _t, QUICK as Gt, useArchbaseBool as qt } from "@archbase/core";
|
|
6
|
+
import { useState as T, useCallback as l, useRef as ce, useMemo as z, useEffect as q, useReducer as ze } from "react";
|
|
7
|
+
import { produce as Q } from "immer";
|
|
8
8
|
import "reflect-metadata";
|
|
9
|
-
import
|
|
9
|
+
import X from "axios";
|
|
10
10
|
import * as ne from "inversify";
|
|
11
|
-
import { useContainer as
|
|
12
|
-
import { create as
|
|
13
|
-
import { createTrackedSelector as
|
|
14
|
-
var
|
|
15
|
-
class
|
|
11
|
+
import { useContainer as Me } from "inversify-react";
|
|
12
|
+
import { create as je } from "zustand";
|
|
13
|
+
import { createTrackedSelector as ke } from "react-tracked";
|
|
14
|
+
var a = /* @__PURE__ */ ((n) => (n[n.dataChanged = 0] = "dataChanged", n[n.recordChanged = 1] = "recordChanged", n[n.refreshData = 2] = "refreshData", n[n.fieldChanged = 3] = "fieldChanged", n[n.beforeClose = 4] = "beforeClose", n[n.afterClose = 5] = "afterClose", n[n.beforeOpen = 6] = "beforeOpen", n[n.afterOpen = 7] = "afterOpen", n[n.beforeAppend = 8] = "beforeAppend", n[n.afterAppend = 9] = "afterAppend", n[n.beforeRemove = 10] = "beforeRemove", n[n.afterRemove = 11] = "afterRemove", n[n.beforeInsert = 12] = "beforeInsert", n[n.afterInsert = 13] = "afterInsert", n[n.beforeEdit = 14] = "beforeEdit", n[n.afterEdit = 15] = "afterEdit", n[n.beforeSave = 16] = "beforeSave", n[n.afterSave = 17] = "afterSave", n[n.beforeCancel = 18] = "beforeCancel", n[n.afterCancel = 19] = "afterCancel", n[n.afterScroll = 20] = "afterScroll", n[n.onError = 21] = "onError", n[n.onFieldError = 22] = "onFieldError", n))(a || {});
|
|
15
|
+
class Ue {
|
|
16
16
|
eventEmitter;
|
|
17
17
|
listenersDisable = !1;
|
|
18
18
|
constructor() {
|
|
19
|
-
this.eventEmitter = new
|
|
19
|
+
this.eventEmitter = new Be();
|
|
20
20
|
}
|
|
21
21
|
disabledAllListeners() {
|
|
22
22
|
return this.listenersDisable = !0, this;
|
|
@@ -46,7 +46,7 @@ class ke {
|
|
|
46
46
|
return this.eventEmitter.removeAllListeners(e), this;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class ye {
|
|
50
50
|
fieldEventListeners;
|
|
51
51
|
records;
|
|
52
52
|
filteredRecords;
|
|
@@ -79,14 +79,14 @@ class Ie {
|
|
|
79
79
|
validator;
|
|
80
80
|
getIdentity;
|
|
81
81
|
constructor(e, t, r) {
|
|
82
|
-
this.name = e, this.label = r || e, this.records = [], this.filteredRecords = [], this.loadOptions(t), this.fieldEventListeners = {}, this.emitter = new
|
|
82
|
+
this.name = e, this.label = r || e, this.records = [], this.filteredRecords = [], this.loadOptions(t), this.fieldEventListeners = {}, this.emitter = new Ue(), this.uuid = $e(), this.validator = t.validator, this.getIdentity = t.getIdentity;
|
|
83
83
|
}
|
|
84
84
|
loadOptions(e) {
|
|
85
85
|
this.records = e.records, this.filters = [], e.filters && (this.filters = e.filters), this.currentRecord = void 0, this.currentRecordIndex = -1, this.filteredRecords = this.applyFilters(), this.filteredRecords.length > 0 && (this.currentRecordIndex = 0, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.grandTotalRecords = e.grandTotalRecords, this.currentPageIndex = e.currentPage, this.totalPages = e.totalPages, this.pageSize = e.pageSize, this.active = !0, this.filter = e.filter, this.sort = e.sort, this.originFilter = e.originFilter, this.originSort = e.originSort, this.originGlobalFilter = e.originGlobalFilter, this.defaultSortFields = e.defaultSortFields ? e.defaultSortFields : [];
|
|
86
86
|
}
|
|
87
87
|
validateDataSourceActive(e) {
|
|
88
88
|
if (!this.isActive()) {
|
|
89
|
-
const t =
|
|
89
|
+
const t = R.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: e });
|
|
90
90
|
throw this.publishEventError(t, {}), new g(t);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
@@ -99,7 +99,7 @@ class Ie {
|
|
|
99
99
|
*/
|
|
100
100
|
clear() {
|
|
101
101
|
if (!this.isActive()) {
|
|
102
|
-
const e =
|
|
102
|
+
const e = R.t("archbase:operationNotAllowed", { dataSourceName: this.name, operation: "clear" });
|
|
103
103
|
throw this.publishEventError(e, {}), new g(e);
|
|
104
104
|
}
|
|
105
105
|
this.emitter.emit("beforeClose"), this.emit({
|
|
@@ -151,7 +151,7 @@ class Ie {
|
|
|
151
151
|
}
|
|
152
152
|
goToRecord(e) {
|
|
153
153
|
if (this.validateDataSourceActive("goToRecord"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
154
|
-
const t =
|
|
154
|
+
const t = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
155
155
|
throw this.publishEventError(t, {}), new g(t);
|
|
156
156
|
}
|
|
157
157
|
e <= this.getTotalRecords() - 1 && (this.currentRecordIndex = e, this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -190,7 +190,7 @@ class Ie {
|
|
|
190
190
|
}
|
|
191
191
|
append(e) {
|
|
192
192
|
if (this.validateDataSourceActive("append"), this.inserting || this.editing) {
|
|
193
|
-
const t =
|
|
193
|
+
const t = R.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
|
|
194
194
|
throw this.publishEventError(t, {}), new g(t);
|
|
195
195
|
}
|
|
196
196
|
return this.emitter.emit("beforeAppend", e), this.emit({ type: 8, record: e }), this.records.push(e), this.filteredRecords = this.applyFilters(), this.grandTotalRecords++, this.filteredRecords.forEach((t, r) => {
|
|
@@ -209,7 +209,7 @@ class Ie {
|
|
|
209
209
|
}
|
|
210
210
|
insert(e) {
|
|
211
211
|
if (this.validateDataSourceActive("insert"), this.inserting || this.editing) {
|
|
212
|
-
const r =
|
|
212
|
+
const r = R.t("archbase:insertRecordIsNotAllowed", { dataSourceName: this.name });
|
|
213
213
|
throw this.publishEventError(r, {}), new g(r);
|
|
214
214
|
}
|
|
215
215
|
this.emitter.emit("beforeInsert"), this.emit({
|
|
@@ -228,26 +228,26 @@ class Ie {
|
|
|
228
228
|
}
|
|
229
229
|
edit() {
|
|
230
230
|
if (this.validateDataSourceActive("edit"), this.inserting || this.editing) {
|
|
231
|
-
const e =
|
|
231
|
+
const e = R.t("archbase:editRecordIsNotAllowed", { dataSourceName: this.name });
|
|
232
232
|
throw this.publishEventError(e, {}), new g(e);
|
|
233
233
|
}
|
|
234
234
|
if (this.isEmpty() || !this.currentRecord) {
|
|
235
|
-
const e =
|
|
235
|
+
const e = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
236
236
|
throw this.publishEventError(e, {}), new g(e);
|
|
237
237
|
}
|
|
238
238
|
if (this.isBOF()) {
|
|
239
|
-
const e =
|
|
239
|
+
const e = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
240
240
|
throw this.publishEventError(e, {}), new g(e);
|
|
241
241
|
}
|
|
242
242
|
if (this.isEOF()) {
|
|
243
|
-
const e =
|
|
243
|
+
const e = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
244
244
|
throw this.publishEventError(e, {}), new g(e);
|
|
245
245
|
}
|
|
246
246
|
return this.emitter.emit("beforeEdit", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
247
247
|
type: 14,
|
|
248
248
|
record: this.currentRecord,
|
|
249
249
|
index: this.getCurrentIndex()
|
|
250
|
-
}), this.editing = !0, this.currentRecord =
|
|
250
|
+
}), this.editing = !0, this.currentRecord = Ne(this.currentRecord), this.emitter.emit("afterEdit", this.currentRecord, this.getCurrentIndex()), this.emit({
|
|
251
251
|
type: 15,
|
|
252
252
|
record: this.currentRecord,
|
|
253
253
|
index: this.getCurrentIndex()
|
|
@@ -255,19 +255,19 @@ class Ie {
|
|
|
255
255
|
}
|
|
256
256
|
async remove(e) {
|
|
257
257
|
if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
|
|
258
|
-
const s =
|
|
258
|
+
const s = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
259
259
|
throw this.publishEventError(s, {}), new g(s);
|
|
260
260
|
}
|
|
261
261
|
if (this.isEmpty() || !this.currentRecord) {
|
|
262
|
-
const s =
|
|
262
|
+
const s = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
263
263
|
throw this.publishEventError(s, {}), new g(s);
|
|
264
264
|
}
|
|
265
265
|
if (this.isBOF()) {
|
|
266
|
-
const s =
|
|
266
|
+
const s = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
267
267
|
throw this.publishEventError(s, {}), new g(s);
|
|
268
268
|
}
|
|
269
269
|
if (this.isEOF()) {
|
|
270
|
-
const s =
|
|
270
|
+
const s = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
271
271
|
throw this.publishEventError(s, {}), new g(s);
|
|
272
272
|
}
|
|
273
273
|
this.emitter.emit("beforeRemove", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
@@ -306,7 +306,7 @@ class Ie {
|
|
|
306
306
|
publishEventErrors = (e) => {
|
|
307
307
|
e.forEach((t) => {
|
|
308
308
|
if (t.fieldName) {
|
|
309
|
-
const r =
|
|
309
|
+
const r = R.t(t.errorMessage, { keySeparator: !1 });
|
|
310
310
|
this.emitter.emit("onFieldError", t.fieldName, r), this.emit({
|
|
311
311
|
type: 22,
|
|
312
312
|
fieldName: t.fieldName,
|
|
@@ -314,7 +314,7 @@ class Ie {
|
|
|
314
314
|
originalError: t
|
|
315
315
|
});
|
|
316
316
|
} else
|
|
317
|
-
this.publishEventError(
|
|
317
|
+
this.publishEventError(R.t(t.errorMessage, { keySeparator: !1 }), t);
|
|
318
318
|
});
|
|
319
319
|
};
|
|
320
320
|
publishEventError = (e, t) => {
|
|
@@ -329,7 +329,7 @@ class Ie {
|
|
|
329
329
|
const e = this.validator.validateEntity(this.currentRecord);
|
|
330
330
|
if (e && e.length > 0)
|
|
331
331
|
if (this.publishEventErrors(e), e[0].fieldName) {
|
|
332
|
-
const t =
|
|
332
|
+
const t = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
333
333
|
throw new g(t);
|
|
334
334
|
} else
|
|
335
335
|
throw new g(e[0].errorMessage);
|
|
@@ -338,11 +338,11 @@ class Ie {
|
|
|
338
338
|
}
|
|
339
339
|
async save(e) {
|
|
340
340
|
if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
|
|
341
|
-
const r =
|
|
341
|
+
const r = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
342
342
|
throw this.publishEventError(r, {}), new g(r);
|
|
343
343
|
}
|
|
344
344
|
if (!this.currentRecord) {
|
|
345
|
-
const r =
|
|
345
|
+
const r = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
346
346
|
throw this.publishEventError(r, {}), new g(r);
|
|
347
347
|
}
|
|
348
348
|
if (this.emitter.emit("beforeSave", this.currentRecord, this.getCurrentIndex()), this.emit({
|
|
@@ -353,7 +353,7 @@ class Ie {
|
|
|
353
353
|
const r = this.validator.validateEntity(this.currentRecord);
|
|
354
354
|
if (r && r.length > 0)
|
|
355
355
|
if (this.publishEventErrors(r), r[0].fieldName) {
|
|
356
|
-
const i =
|
|
356
|
+
const i = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
357
357
|
throw new g(i);
|
|
358
358
|
} else
|
|
359
359
|
throw new g(r[0].errorMessage);
|
|
@@ -371,7 +371,7 @@ class Ie {
|
|
|
371
371
|
}
|
|
372
372
|
cancel() {
|
|
373
373
|
if (this.validateDataSourceActive("cancel"), !this.inserting && !this.editing) {
|
|
374
|
-
const e =
|
|
374
|
+
const e = R.t("archbase:notAllowCancelRecord", { dataSourceName: this.name });
|
|
375
375
|
throw this.publishEventError(e, {}), new g(e);
|
|
376
376
|
}
|
|
377
377
|
return this.emitter.emit("beforeCancel", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
@@ -401,7 +401,7 @@ class Ie {
|
|
|
401
401
|
}
|
|
402
402
|
getFieldValue(e, t = "") {
|
|
403
403
|
if (this.validateDataSourceActive("getFieldValue"), !e) {
|
|
404
|
-
const s =
|
|
404
|
+
const s = R.t("archbase:invalidFieldName", { dataSourceName: this.name });
|
|
405
405
|
throw this.publishEventError(s, {}), new g(s);
|
|
406
406
|
}
|
|
407
407
|
if (this.isEmpty() || this.isBOF() || this.isEOF() && !this.inserting)
|
|
@@ -414,20 +414,20 @@ class Ie {
|
|
|
414
414
|
fieldValueByName(e, t) {
|
|
415
415
|
if (e === void 0)
|
|
416
416
|
return;
|
|
417
|
-
const r =
|
|
417
|
+
const r = Re.getNestedProperty(e, t);
|
|
418
418
|
if (r !== void 0)
|
|
419
|
-
return
|
|
419
|
+
return ve(r) ? Ie(r) : r;
|
|
420
420
|
}
|
|
421
421
|
setFieldValue(e, t) {
|
|
422
422
|
if (this.validateDataSourceActive("setFieldValue"), this.isEmpty() || !this.currentRecord)
|
|
423
423
|
return this;
|
|
424
424
|
if (!(this.inserting || this.editing || this.isBOF() || this.isEOF())) {
|
|
425
|
-
const o =
|
|
425
|
+
const o = R.t("archbase:recordNotBeingEdited", { dataSourceName: this.name });
|
|
426
426
|
throw this.publishEventError(o, {}), new g(o);
|
|
427
427
|
}
|
|
428
428
|
let r = t;
|
|
429
|
-
const i =
|
|
430
|
-
return
|
|
429
|
+
const i = Re.getNestedProperty(this.currentRecord, e);
|
|
430
|
+
return ve(t) && (r = Ie(t)), e.split(".").length > 1 ? Re.setNestedProperty(this.currentRecord, e, r) : this.currentRecord[e] = r, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitFieldChangeEvent(e, i, r), this.emitter.emit("fieldChanged", this.currentRecord, this.getCurrentIndex(), e, i, r), this.emit({
|
|
431
431
|
type: 3,
|
|
432
432
|
record: this.currentRecord,
|
|
433
433
|
index: this.getCurrentIndex(),
|
|
@@ -489,7 +489,7 @@ class Ie {
|
|
|
489
489
|
}
|
|
490
490
|
next() {
|
|
491
491
|
if (this.validateDataSourceActive("next"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
492
|
-
const e =
|
|
492
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
493
493
|
throw this.publishEventError(e, {}), new g(e);
|
|
494
494
|
}
|
|
495
495
|
return this.currentRecordIndex + 1 > this.getTotalRecords() - 1 ? (this.currentRecordIndex++, this.currentRecord = void 0) : (this.currentRecordIndex++, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -499,7 +499,7 @@ class Ie {
|
|
|
499
499
|
}
|
|
500
500
|
prior() {
|
|
501
501
|
if (this.validateDataSourceActive("prior"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
502
|
-
const e =
|
|
502
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
503
503
|
throw this.publishEventError(e, {}), new g(e);
|
|
504
504
|
}
|
|
505
505
|
return this.currentRecordIndex - 1 < 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -509,7 +509,7 @@ class Ie {
|
|
|
509
509
|
}
|
|
510
510
|
first() {
|
|
511
511
|
if (this.validateDataSourceActive("first"), this.inserting || this.editing) {
|
|
512
|
-
const e =
|
|
512
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
513
513
|
throw this.publishEventError(e, {}), new g(e);
|
|
514
514
|
}
|
|
515
515
|
return this.getTotalRecords() === 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex = 0, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -519,7 +519,7 @@ class Ie {
|
|
|
519
519
|
}
|
|
520
520
|
last() {
|
|
521
521
|
if (this.validateDataSourceActive("last"), this.inserting || this.editing) {
|
|
522
|
-
const e =
|
|
522
|
+
const e = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
523
523
|
throw this.publishEventError(e, {}), new g(e);
|
|
524
524
|
}
|
|
525
525
|
return this.getTotalRecords() === 0 ? (this.currentRecordIndex = -1, this.currentRecord = void 0) : (this.currentRecordIndex = this.getTotalRecords() - 1, this.currentRecord = this.filteredRecords[this.currentRecordIndex], this.emitter.emit("afterScroll"), this.emit({
|
|
@@ -531,7 +531,7 @@ class Ie {
|
|
|
531
531
|
if (e === this.currentRecordIndex)
|
|
532
532
|
return this.currentRecord;
|
|
533
533
|
if (this.validateDataSourceActive("gotoRecord"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
534
|
-
const t =
|
|
534
|
+
const t = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
535
535
|
throw this.publishEventError(t, {}), new g(t);
|
|
536
536
|
}
|
|
537
537
|
if (e < 0 || e >= this.filteredRecords.length) {
|
|
@@ -545,7 +545,7 @@ class Ie {
|
|
|
545
545
|
}
|
|
546
546
|
gotoRecordByData(e) {
|
|
547
547
|
if (this.validateDataSourceActive("gotoRecordByData"), this.inserting || this.editing || this.isBOF() || this.isEOF()) {
|
|
548
|
-
const r =
|
|
548
|
+
const r = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
549
549
|
throw this.publishEventError(r, {}), new g(r);
|
|
550
550
|
}
|
|
551
551
|
if (this.isEmpty())
|
|
@@ -565,7 +565,7 @@ class Ie {
|
|
|
565
565
|
}
|
|
566
566
|
locate(e) {
|
|
567
567
|
if (!this.isBrowsing()) {
|
|
568
|
-
const i =
|
|
568
|
+
const i = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
569
569
|
throw this.publishEventError(i, {}), new g(i);
|
|
570
570
|
}
|
|
571
571
|
if (this.isEmpty())
|
|
@@ -579,7 +579,7 @@ class Ie {
|
|
|
579
579
|
}
|
|
580
580
|
locateByFilter(e) {
|
|
581
581
|
if (this.validateDataSourceActive("locate"), this.inserting || this.editing) {
|
|
582
|
-
const r =
|
|
582
|
+
const r = R.t("archbase:notAllowedBrowseRecords", { dataSourceName: this.name });
|
|
583
583
|
throw this.publishEventError(r, {}), new g(r);
|
|
584
584
|
}
|
|
585
585
|
if (this.isEmpty())
|
|
@@ -613,8 +613,8 @@ class Ie {
|
|
|
613
613
|
i = o === 0 ? s : `${i}.${s}`;
|
|
614
614
|
const c = this.fieldEventListeners[`field:${i}`];
|
|
615
615
|
if (c) {
|
|
616
|
-
const
|
|
617
|
-
|
|
616
|
+
const u = c.indexOf(t);
|
|
617
|
+
u !== -1 && c.splice(u, 1);
|
|
618
618
|
}
|
|
619
619
|
}), this;
|
|
620
620
|
}
|
|
@@ -624,7 +624,7 @@ class Ie {
|
|
|
624
624
|
for (const o of i) {
|
|
625
625
|
s = s ? `${s}.${o}` : o;
|
|
626
626
|
const c = this.fieldEventListeners[`field:${s}`];
|
|
627
|
-
c && c.forEach((
|
|
627
|
+
c && c.forEach((u) => u(s, t, r));
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
/**
|
|
@@ -641,29 +641,29 @@ class Ie {
|
|
|
641
641
|
}));
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
|
-
class
|
|
644
|
+
class Ae extends ye {
|
|
645
645
|
service;
|
|
646
646
|
constructor(e, t, r, i) {
|
|
647
647
|
super(t, r, i), this.service = e;
|
|
648
648
|
}
|
|
649
649
|
async save(e) {
|
|
650
650
|
if (this.validateDataSourceActive("save"), !this.inserting && !this.editing) {
|
|
651
|
-
const t =
|
|
651
|
+
const t = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
652
652
|
throw this.publishEventError(t, {}), new g(t);
|
|
653
653
|
}
|
|
654
654
|
if (!this.currentRecord) {
|
|
655
|
-
const t =
|
|
655
|
+
const t = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
656
656
|
throw this.publishEventError(t, {}), new g(t);
|
|
657
657
|
}
|
|
658
658
|
if (this.emitter.emit("beforeSave", this.currentRecord), this.emit({
|
|
659
|
-
type:
|
|
659
|
+
type: a.beforeSave,
|
|
660
660
|
record: this.currentRecord,
|
|
661
661
|
index: this.getCurrentIndex()
|
|
662
662
|
}), this.validator) {
|
|
663
663
|
const t = this.validator.validateEntity(this.currentRecord);
|
|
664
664
|
if (t && t.length > 0)
|
|
665
665
|
if (this.publishEventErrors(t), t[0].fieldName) {
|
|
666
|
-
const r =
|
|
666
|
+
const r = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
667
667
|
throw new g(r);
|
|
668
668
|
} else
|
|
669
669
|
throw new g(t[0].errorMessage);
|
|
@@ -674,16 +674,16 @@ class Ce extends Ie {
|
|
|
674
674
|
const s = this.getIdentity ? this.getIdentity(r) : r.id, o = this.getIdentity ? this.getIdentity(this.currentRecord) : this.currentRecord.id;
|
|
675
675
|
(r === this.currentRecord || s !== void 0 && s === o) && (t = i);
|
|
676
676
|
}), this.currentRecord = await this.service.save(this.currentRecord), this.editing && (this.filteredRecords = [...this.filteredRecords], this.filteredRecords[this.getCurrentIndex()] = this.currentRecord), this.records = [...this.records], t >= 0 ? this.records[t] = this.currentRecord : this.records.push(this.currentRecord), this.editing = !1, this.inserting = !1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.emitter.emit("afterSave", this.currentRecord), this.emit({
|
|
677
|
-
type:
|
|
677
|
+
type: a.afterSave,
|
|
678
678
|
record: this.currentRecord,
|
|
679
679
|
index: this.getCurrentIndex()
|
|
680
680
|
}), e && e();
|
|
681
681
|
} catch (t) {
|
|
682
682
|
t.response && t.response.data && t.response.data.apierror && t.response.data.apierror.subErrors && t.response.data.apierror.subErrors.forEach((i) => {
|
|
683
683
|
if (i.field) {
|
|
684
|
-
const s =
|
|
684
|
+
const s = R.t(i.message, { defaultValue: i.message });
|
|
685
685
|
this.emitter.emit("onFieldError", i.field, s), this.emit({
|
|
686
|
-
type:
|
|
686
|
+
type: a.onFieldError,
|
|
687
687
|
fieldName: i.field,
|
|
688
688
|
error: s,
|
|
689
689
|
originalError: i.message
|
|
@@ -692,7 +692,7 @@ class Ce extends Ie {
|
|
|
692
692
|
});
|
|
693
693
|
const r = G(t);
|
|
694
694
|
throw this.emitter.emit("onError", r, t), this.emit({
|
|
695
|
-
type:
|
|
695
|
+
type: a.onError,
|
|
696
696
|
error: r,
|
|
697
697
|
originalError: t
|
|
698
698
|
}), e && e(r), new g(r);
|
|
@@ -701,25 +701,25 @@ class Ce extends Ie {
|
|
|
701
701
|
}
|
|
702
702
|
async remove(e) {
|
|
703
703
|
if (this.validateDataSourceActive("remove"), this.inserting || this.editing) {
|
|
704
|
-
const t =
|
|
704
|
+
const t = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
705
705
|
throw this.publishEventError(t, {}), new g(
|
|
706
706
|
t
|
|
707
707
|
);
|
|
708
708
|
}
|
|
709
709
|
if (this.isEmpty() || !this.currentRecord) {
|
|
710
|
-
const t =
|
|
710
|
+
const t = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
711
711
|
throw this.publishEventError(t, {}), new g(t);
|
|
712
712
|
}
|
|
713
713
|
if (this.isBOF()) {
|
|
714
|
-
const t =
|
|
714
|
+
const t = R.t("archbase:BOFDataSource", { dataSourceName: this.name });
|
|
715
715
|
throw this.publishEventError(t, {}), new g(t);
|
|
716
716
|
}
|
|
717
717
|
if (this.isEOF()) {
|
|
718
|
-
const t =
|
|
718
|
+
const t = R.t("archbase:EOFDataSource", { dataSourceName: this.name });
|
|
719
719
|
throw this.publishEventError(t, {}), new g(t);
|
|
720
720
|
}
|
|
721
721
|
this.emitter.emit("beforeRemove", this.currentRecord, this.currentRecordIndex), this.emit({
|
|
722
|
-
type:
|
|
722
|
+
type: a.beforeRemove,
|
|
723
723
|
record: this.currentRecord,
|
|
724
724
|
index: this.getCurrentIndex()
|
|
725
725
|
});
|
|
@@ -729,25 +729,25 @@ class Ce extends Ie {
|
|
|
729
729
|
const r = this.currentRecord, i = this.currentRecordIndex;
|
|
730
730
|
return this.records = [...this.records], this.filteredRecords = [...this.filteredRecords], this.records.forEach((s, o) => {
|
|
731
731
|
this.currentRecord === s && (t = o);
|
|
732
|
-
}), t >= 0 && this.records.splice(t, 1), this.records !== this.filteredRecords && this.filteredRecords.splice(this.getCurrentIndex(), 1), this.grandTotalRecords--, this.filteredRecords.length === 0 ? (this.currentRecord = void 0, this.currentRecordIndex = -1) : (this.currentRecordIndex > this.filteredRecords.length - 1 && this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.editing = !1, this.inserting = !1, this.emitter.emit("afterScroll"), this.emit({ type:
|
|
733
|
-
type:
|
|
732
|
+
}), t >= 0 && this.records.splice(t, 1), this.records !== this.filteredRecords && this.filteredRecords.splice(this.getCurrentIndex(), 1), this.grandTotalRecords--, this.filteredRecords.length === 0 ? (this.currentRecord = void 0, this.currentRecordIndex = -1) : (this.currentRecordIndex > this.filteredRecords.length - 1 && this.currentRecordIndex--, this.currentRecord = this.filteredRecords[this.currentRecordIndex]), this.editing = !1, this.inserting = !1, this.emitter.emit("afterScroll"), this.emit({ type: a.afterScroll }), this.emitter.emit("afterRemove", r, i), this.emit({
|
|
733
|
+
type: a.afterRemove,
|
|
734
734
|
record: r,
|
|
735
735
|
index: i
|
|
736
736
|
}), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), e && e(), r;
|
|
737
737
|
} catch (t) {
|
|
738
738
|
const r = G(t);
|
|
739
739
|
throw this.emitter.emit("onError", r, t), this.emit({
|
|
740
|
-
type:
|
|
740
|
+
type: a.onError,
|
|
741
741
|
error: r,
|
|
742
742
|
originalError: t
|
|
743
743
|
}), e && e(r), new g(r);
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
746
|
applyRemoteFilter(e, t, r) {
|
|
747
|
-
return e && e.filter.filterType ===
|
|
747
|
+
return e && e.filter.filterType === we && e.filter.quickFilterText && e.filter.quickFilterText !== "" ? this.getDataWithQuickFilter(e, t) : e && (e.filter.filterType === Ee || e.filter.filterType === Se) ? this.getDataWithFilter(e, t) : this.getDataWithoutFilter(t);
|
|
748
748
|
}
|
|
749
749
|
async getDataWithFilter(e, t) {
|
|
750
|
-
const r = new
|
|
750
|
+
const r = new Fe();
|
|
751
751
|
r.buildFrom(e.filter, e.sort);
|
|
752
752
|
const i = r.toJSON();
|
|
753
753
|
let s;
|
|
@@ -770,7 +770,7 @@ class Ce extends Ie {
|
|
|
770
770
|
return e && e.sort ? e.sort.quickFilterSort : this.defaultSortFields;
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
|
-
class
|
|
773
|
+
class _e {
|
|
774
774
|
id;
|
|
775
775
|
companyId;
|
|
776
776
|
filter;
|
|
@@ -788,13 +788,13 @@ class Ue {
|
|
|
788
788
|
Object.assign(this, e);
|
|
789
789
|
}
|
|
790
790
|
}
|
|
791
|
-
class Ge extends
|
|
791
|
+
class Ge extends ye {
|
|
792
792
|
getFilterById(e) {
|
|
793
793
|
if (this.locate({ id: e }))
|
|
794
794
|
return this.convertCurrentRecordToFilter();
|
|
795
795
|
}
|
|
796
796
|
convertCurrentRecordToFilter() {
|
|
797
|
-
return new
|
|
797
|
+
return new he({
|
|
798
798
|
id: this.getFieldValue("id"),
|
|
799
799
|
name: this.getFieldValue("name"),
|
|
800
800
|
description: this.getFieldValue("description"),
|
|
@@ -808,7 +808,7 @@ class Ge extends Ie {
|
|
|
808
808
|
}
|
|
809
809
|
async addNewFilter(e, t) {
|
|
810
810
|
this.insert(
|
|
811
|
-
new
|
|
811
|
+
new _e({
|
|
812
812
|
id: e.id,
|
|
813
813
|
name: e.name,
|
|
814
814
|
description: e.description,
|
|
@@ -842,7 +842,7 @@ class Ge extends Ie {
|
|
|
842
842
|
}
|
|
843
843
|
getFilters() {
|
|
844
844
|
return this.getTotalRecords() > 0 ? this.browseRecords().map(
|
|
845
|
-
(e) => new
|
|
845
|
+
(e) => new he({
|
|
846
846
|
id: e.id,
|
|
847
847
|
name: e.name,
|
|
848
848
|
description: e.description,
|
|
@@ -875,13 +875,13 @@ class qe {
|
|
|
875
875
|
Object.assign(this, e);
|
|
876
876
|
}
|
|
877
877
|
}
|
|
878
|
-
class
|
|
878
|
+
class Je extends Ae {
|
|
879
879
|
getFilterById(e) {
|
|
880
880
|
if (this.locate({ id: e }))
|
|
881
881
|
return this.convertCurrentRecordToFilter();
|
|
882
882
|
}
|
|
883
883
|
convertCurrentRecordToFilter() {
|
|
884
|
-
return new
|
|
884
|
+
return new he({
|
|
885
885
|
id: this.getFieldValue("id"),
|
|
886
886
|
name: this.getFieldValue("name"),
|
|
887
887
|
description: this.getFieldValue("description"),
|
|
@@ -932,7 +932,7 @@ class _e extends Ce {
|
|
|
932
932
|
}
|
|
933
933
|
getFilters() {
|
|
934
934
|
return this.getTotalRecords() > 0 ? this.browseRecords().map(
|
|
935
|
-
(e) => new
|
|
935
|
+
(e) => new he({
|
|
936
936
|
id: e.id,
|
|
937
937
|
name: e.name,
|
|
938
938
|
description: e.description,
|
|
@@ -946,41 +946,41 @@ class _e extends Ce {
|
|
|
946
946
|
) : [];
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
function
|
|
950
|
-
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, o] =
|
|
951
|
-
c((
|
|
952
|
-
}, []), [
|
|
953
|
-
let
|
|
954
|
-
e && t && (
|
|
955
|
-
}, [e, t, r, i]),
|
|
956
|
-
e && t && ((
|
|
957
|
-
}, [e, t,
|
|
958
|
-
i ? (
|
|
959
|
-
}, [e, t, i]),
|
|
960
|
-
const
|
|
961
|
-
|
|
949
|
+
function yt(n, e, t, r) {
|
|
950
|
+
const i = e && ("appendToFieldArray" in e || "updateFieldArrayItem" in e), [s, o] = T(r), [, c] = T(0), u = l(() => {
|
|
951
|
+
c((f) => f + 1);
|
|
952
|
+
}, []), [p, C] = T(r), [W, M] = T(0), P = l(() => {
|
|
953
|
+
let f = r;
|
|
954
|
+
e && t && (f = e.getFieldValue(t), f == null && (f = r)), i ? (C(f), M((b) => b + 1)) : o(f);
|
|
955
|
+
}, [e, t, r, i]), L = l((f) => {
|
|
956
|
+
e && t && ((f.type === a.dataChanged || f.type === a.recordChanged || f.type === a.afterScroll || f.type === a.afterCancel || f.type === a.afterEdit) && (P(), i || u()), f.type === a.onFieldError && f.fieldName === t && console.warn(`[${n}] Field error:`, f.error));
|
|
957
|
+
}, [e, t, P, u, i, n]), N = l((f, b) => {
|
|
958
|
+
i ? (C(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f)) : (o(f), e && !e.isBrowsing() && t && e.getFieldValue(t) !== f && e.setFieldValue(t, f));
|
|
959
|
+
}, [e, t, i]), d = l(() => {
|
|
960
|
+
const f = pe(e);
|
|
961
|
+
He.trackV2Usage(n, f);
|
|
962
962
|
}, [n, e]);
|
|
963
|
-
return
|
|
964
|
-
process.env.NODE_ENV === "production" &&
|
|
963
|
+
return ce(() => {
|
|
964
|
+
process.env.NODE_ENV === "production" && d();
|
|
965
965
|
}).current, {
|
|
966
966
|
// Detecção de versão
|
|
967
967
|
isDataSourceV2: i,
|
|
968
|
-
dataSourceVersion:
|
|
968
|
+
dataSourceVersion: pe(e),
|
|
969
969
|
// Estados
|
|
970
|
-
currentValue: i ?
|
|
971
|
-
v1State: { currentValue: s, setCurrentValue: o, forceUpdate:
|
|
972
|
-
v2State: { v2Value:
|
|
970
|
+
currentValue: i ? p : s,
|
|
971
|
+
v1State: { currentValue: s, setCurrentValue: o, forceUpdate: u },
|
|
972
|
+
v2State: { v2Value: p, setV2Value: C, v2ShouldUpdate: W },
|
|
973
973
|
// Funções
|
|
974
|
-
loadDataSourceFieldValue:
|
|
975
|
-
dataSourceEvent:
|
|
976
|
-
handleValueChange:
|
|
974
|
+
loadDataSourceFieldValue: P,
|
|
975
|
+
dataSourceEvent: L,
|
|
976
|
+
handleValueChange: N,
|
|
977
977
|
// Utilitários
|
|
978
978
|
isReadOnly: e ? e.isBrowsing() : !1,
|
|
979
979
|
isEditing: e ? e.isEditing() : !1,
|
|
980
|
-
trackUsage:
|
|
980
|
+
trackUsage: d
|
|
981
981
|
};
|
|
982
982
|
}
|
|
983
|
-
const
|
|
983
|
+
const vt = {
|
|
984
984
|
/**
|
|
985
985
|
* Valida se o componente está seguindo o padrão corretamente
|
|
986
986
|
*/
|
|
@@ -991,13 +991,13 @@ const yt = {
|
|
|
991
991
|
/**
|
|
992
992
|
* Testa se o comportamento V1 está preservado
|
|
993
993
|
*/
|
|
994
|
-
testV1Compatibility: (n, e) => !e ||
|
|
994
|
+
testV1Compatibility: (n, e) => !e || pe(e) !== "V1" || [
|
|
995
995
|
"isBrowsing",
|
|
996
996
|
"isEditing",
|
|
997
997
|
"getFieldValue",
|
|
998
998
|
"setFieldValue"
|
|
999
999
|
].every((r) => typeof e[r] == "function") ? !0 : (console.error(`[${n}] V1 DataSource missing required methods`), !1)
|
|
1000
|
-
},
|
|
1000
|
+
}, It = `
|
|
1001
1001
|
// Em qualquer componente que use DataSource:
|
|
1002
1002
|
|
|
1003
1003
|
import { useArchbaseV1V2Compatibility } from '../core/patterns/ArchbaseV1V2CompatibilityPattern';
|
|
@@ -1050,7 +1050,7 @@ export function MyComponent<T, ID>({ dataSource, dataField, value, onChangeValue
|
|
|
1050
1050
|
);
|
|
1051
1051
|
}
|
|
1052
1052
|
`;
|
|
1053
|
-
class
|
|
1053
|
+
class U {
|
|
1054
1054
|
name;
|
|
1055
1055
|
label;
|
|
1056
1056
|
records = [];
|
|
@@ -1098,24 +1098,24 @@ class k {
|
|
|
1098
1098
|
// =================== Navigation ===================
|
|
1099
1099
|
first() {
|
|
1100
1100
|
return this.records.length > 0 && (this.currentIndex = 0, this.emit({
|
|
1101
|
-
type:
|
|
1101
|
+
type: a.afterScroll
|
|
1102
1102
|
})), this;
|
|
1103
1103
|
}
|
|
1104
1104
|
last() {
|
|
1105
1105
|
return this.records.length > 0 && (this.currentIndex = this.records.length - 1, this.emit({
|
|
1106
|
-
type:
|
|
1106
|
+
type: a.afterScroll
|
|
1107
1107
|
})), this;
|
|
1108
1108
|
}
|
|
1109
1109
|
next() {
|
|
1110
1110
|
return this.currentIndex < this.records.length - 1 && (this.currentIndex++, this.emit({
|
|
1111
|
-
type:
|
|
1111
|
+
type: a.recordChanged,
|
|
1112
1112
|
record: this.getCurrentRecord(),
|
|
1113
1113
|
index: this.currentIndex
|
|
1114
1114
|
})), this;
|
|
1115
1115
|
}
|
|
1116
1116
|
prior() {
|
|
1117
1117
|
return this.currentIndex > 0 && (this.currentIndex--, this.emit({
|
|
1118
|
-
type:
|
|
1118
|
+
type: a.recordChanged,
|
|
1119
1119
|
record: this.getCurrentRecord(),
|
|
1120
1120
|
index: this.currentIndex
|
|
1121
1121
|
})), this;
|
|
@@ -1123,7 +1123,7 @@ class k {
|
|
|
1123
1123
|
goToRecord(e) {
|
|
1124
1124
|
if (e >= 0 && e < this.records.length)
|
|
1125
1125
|
return this.currentIndex = e, this.emit({
|
|
1126
|
-
type:
|
|
1126
|
+
type: a.recordChanged,
|
|
1127
1127
|
record: this.getCurrentRecord(),
|
|
1128
1128
|
index: this.currentIndex
|
|
1129
1129
|
}), this.getCurrentRecord();
|
|
@@ -1154,27 +1154,27 @@ class k {
|
|
|
1154
1154
|
if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord())
|
|
1155
1155
|
throw new Error(`No records to edit in DataSource ${this.name}`);
|
|
1156
1156
|
return this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
|
|
1157
|
-
type:
|
|
1157
|
+
type: a.beforeEdit,
|
|
1158
1158
|
record: this.getCurrentRecord(),
|
|
1159
1159
|
index: this.currentIndex
|
|
1160
1160
|
}), this.emit({
|
|
1161
|
-
type:
|
|
1161
|
+
type: a.afterEdit,
|
|
1162
1162
|
record: this.getCurrentRecord(),
|
|
1163
1163
|
index: this.currentIndex
|
|
1164
1164
|
}), this;
|
|
1165
1165
|
}
|
|
1166
1166
|
cancel() {
|
|
1167
1167
|
return this.validateDataSourceActive("cancel"), this.state === "edit" && this.originalRecord ? (this.records = [...this.records], this.records[this.currentIndex] = { ...this.originalRecord }) : this.state === "insert" && (this.records = this.records.slice(0, -1), this.records.length > 0 ? this.currentIndex = Math.min(this.currentIndex, this.records.length - 1) : this.currentIndex = -1), this.state = "browse", this.originalRecord = null, this.emit({
|
|
1168
|
-
type:
|
|
1168
|
+
type: a.afterCancel,
|
|
1169
1169
|
record: this.getCurrentRecord(),
|
|
1170
1170
|
index: this.currentIndex
|
|
1171
1171
|
}), this;
|
|
1172
1172
|
}
|
|
1173
1173
|
insert(e) {
|
|
1174
1174
|
return this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
|
|
1175
|
-
type:
|
|
1175
|
+
type: a.beforeInsert
|
|
1176
1176
|
}), this.records = [...this.records, e], this.currentIndex = this.records.length - 1, this.notifyStateChange(), this.emit({
|
|
1177
|
-
type:
|
|
1177
|
+
type: a.afterInsert,
|
|
1178
1178
|
record: e,
|
|
1179
1179
|
index: this.currentIndex
|
|
1180
1180
|
}), this;
|
|
@@ -1186,7 +1186,7 @@ class k {
|
|
|
1186
1186
|
throw new Error(`No record to save in DataSource ${this.name}`);
|
|
1187
1187
|
const t = this.getCurrentRecord();
|
|
1188
1188
|
if (this.emit({
|
|
1189
|
-
type:
|
|
1189
|
+
type: a.beforeSave,
|
|
1190
1190
|
record: t,
|
|
1191
1191
|
index: this.getCurrentIndex()
|
|
1192
1192
|
}), this.validator) {
|
|
@@ -1195,7 +1195,7 @@ class k {
|
|
|
1195
1195
|
throw new Error(r[0].errorMessage);
|
|
1196
1196
|
}
|
|
1197
1197
|
return this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
|
|
1198
|
-
type:
|
|
1198
|
+
type: a.afterSave,
|
|
1199
1199
|
record: t,
|
|
1200
1200
|
index: this.getCurrentIndex()
|
|
1201
1201
|
}), e && e(), t;
|
|
@@ -1207,11 +1207,11 @@ class k {
|
|
|
1207
1207
|
throw new Error(`No records to remove in DataSource ${this.name}`);
|
|
1208
1208
|
const t = this.getCurrentRecord(), r = this.currentIndex;
|
|
1209
1209
|
return this.emit({
|
|
1210
|
-
type:
|
|
1210
|
+
type: a.beforeRemove,
|
|
1211
1211
|
record: t,
|
|
1212
1212
|
index: r
|
|
1213
|
-
}), this.records = this.records.filter((i, s) => s !== this.currentIndex), this.records.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.records.length && (this.currentIndex = this.records.length - 1), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type:
|
|
1214
|
-
type:
|
|
1213
|
+
}), this.records = this.records.filter((i, s) => s !== this.currentIndex), this.records.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.records.length && (this.currentIndex = this.records.length - 1), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type: a.afterScroll }), this.emit({
|
|
1214
|
+
type: a.afterRemove,
|
|
1215
1215
|
record: t,
|
|
1216
1216
|
index: r
|
|
1217
1217
|
}), e && e(), t;
|
|
@@ -1224,19 +1224,16 @@ class k {
|
|
|
1224
1224
|
if (r === t)
|
|
1225
1225
|
return this;
|
|
1226
1226
|
const i = [...this.records];
|
|
1227
|
-
return this.records =
|
|
1227
|
+
return this.records = Q(this.records, (s) => {
|
|
1228
1228
|
const o = s[this.currentIndex];
|
|
1229
1229
|
o && this.setNestedValue(o, e, t);
|
|
1230
1230
|
}), this.notifyStateChange(i), this.emit({
|
|
1231
|
-
type:
|
|
1231
|
+
type: a.fieldChanged,
|
|
1232
1232
|
fieldName: e,
|
|
1233
1233
|
oldValue: r,
|
|
1234
1234
|
newValue: t,
|
|
1235
1235
|
record: this.getCurrentRecord(),
|
|
1236
1236
|
index: this.currentIndex
|
|
1237
|
-
}), this.emit({
|
|
1238
|
-
type: d.dataChanged,
|
|
1239
|
-
data: this.records
|
|
1240
1237
|
}), this;
|
|
1241
1238
|
}
|
|
1242
1239
|
getFieldValue(e) {
|
|
@@ -1256,14 +1253,14 @@ class k {
|
|
|
1256
1253
|
if (!Array.isArray(r))
|
|
1257
1254
|
throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
|
|
1258
1255
|
const i = [...this.records];
|
|
1259
|
-
this.records =
|
|
1256
|
+
this.records = Q(this.records, (s) => {
|
|
1260
1257
|
const o = s[this.currentIndex];
|
|
1261
1258
|
if (o) {
|
|
1262
1259
|
const c = this.getNestedValue(o, e);
|
|
1263
1260
|
c && c.push(t);
|
|
1264
1261
|
}
|
|
1265
1262
|
}), this.notifyStateChange(i), this.emit({
|
|
1266
|
-
type:
|
|
1263
|
+
type: a.fieldChanged,
|
|
1267
1264
|
fieldName: e,
|
|
1268
1265
|
oldValue: r,
|
|
1269
1266
|
newValue: [...r, t],
|
|
@@ -1278,14 +1275,14 @@ class k {
|
|
|
1278
1275
|
if (!Array.isArray(i) || t < 0 || t >= i.length)
|
|
1279
1276
|
return;
|
|
1280
1277
|
const s = [...this.records];
|
|
1281
|
-
this.records =
|
|
1278
|
+
this.records = Q(this.records, (o) => {
|
|
1282
1279
|
const c = o[this.currentIndex];
|
|
1283
1280
|
if (c) {
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1281
|
+
const u = this.getNestedValue(c, e);
|
|
1282
|
+
u[t] !== void 0 && r(u[t]);
|
|
1286
1283
|
}
|
|
1287
1284
|
}), this.notifyStateChange(s), this.emit({
|
|
1288
|
-
type:
|
|
1285
|
+
type: a.fieldChanged,
|
|
1289
1286
|
fieldName: e,
|
|
1290
1287
|
oldValue: i,
|
|
1291
1288
|
newValue: this.getFieldValue(e),
|
|
@@ -1302,11 +1299,11 @@ class k {
|
|
|
1302
1299
|
if (t < 0 || t >= r.length)
|
|
1303
1300
|
return;
|
|
1304
1301
|
const i = [...this.records];
|
|
1305
|
-
this.records =
|
|
1302
|
+
this.records = Q(this.records, (s) => {
|
|
1306
1303
|
const o = s[this.currentIndex];
|
|
1307
1304
|
o && this.getNestedValue(o, e).splice(t, 1);
|
|
1308
1305
|
}), this.notifyStateChange(i), this.emit({
|
|
1309
|
-
type:
|
|
1306
|
+
type: a.fieldChanged,
|
|
1310
1307
|
fieldName: e,
|
|
1311
1308
|
oldValue: r,
|
|
1312
1309
|
newValue: this.getFieldValue(e),
|
|
@@ -1321,11 +1318,11 @@ class k {
|
|
|
1321
1318
|
if (!Array.isArray(i))
|
|
1322
1319
|
throw new Error(`Field ${String(e)} is not an array`);
|
|
1323
1320
|
const s = [...this.records];
|
|
1324
|
-
this.records =
|
|
1321
|
+
this.records = Q(this.records, (o) => {
|
|
1325
1322
|
const c = o[this.currentIndex];
|
|
1326
1323
|
c && this.getNestedValue(c, e).splice(t, 0, r);
|
|
1327
1324
|
}), this.notifyStateChange(s), this.emit({
|
|
1328
|
-
type:
|
|
1325
|
+
type: a.fieldChanged,
|
|
1329
1326
|
fieldName: e,
|
|
1330
1327
|
oldValue: i,
|
|
1331
1328
|
newValue: this.getFieldValue(e),
|
|
@@ -1351,7 +1348,7 @@ class k {
|
|
|
1351
1348
|
}
|
|
1352
1349
|
clear() {
|
|
1353
1350
|
this.records = [], this.currentIndex = -1, this.state = "browse", this.originalRecord = null, this.emit({
|
|
1354
|
-
type:
|
|
1351
|
+
type: a.dataChanged,
|
|
1355
1352
|
data: this.records
|
|
1356
1353
|
});
|
|
1357
1354
|
}
|
|
@@ -1361,7 +1358,7 @@ class k {
|
|
|
1361
1358
|
*/
|
|
1362
1359
|
setData(e) {
|
|
1363
1360
|
this.records = [...e.records || []], this.currentIndex = this.records.length > 0 ? 0 : -1, this.state = "browse", this.originalRecord = null, this.emit({
|
|
1364
|
-
type:
|
|
1361
|
+
type: a.dataChanged,
|
|
1365
1362
|
data: this.records
|
|
1366
1363
|
});
|
|
1367
1364
|
}
|
|
@@ -1399,7 +1396,7 @@ class k {
|
|
|
1399
1396
|
gotoRecordByData(e) {
|
|
1400
1397
|
const t = this.records.findIndex((r) => r === e);
|
|
1401
1398
|
return t >= 0 ? (this.currentIndex = t, this.emit({
|
|
1402
|
-
type:
|
|
1399
|
+
type: a.recordChanged,
|
|
1403
1400
|
record: this.getCurrentRecord(),
|
|
1404
1401
|
index: this.currentIndex
|
|
1405
1402
|
}), !0) : !1;
|
|
@@ -1412,7 +1409,7 @@ class k {
|
|
|
1412
1409
|
}
|
|
1413
1410
|
addFieldChangeListener(e, t) {
|
|
1414
1411
|
const r = (i) => {
|
|
1415
|
-
i.type ===
|
|
1412
|
+
i.type === a.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
|
|
1416
1413
|
};
|
|
1417
1414
|
return this.addListener(r), this;
|
|
1418
1415
|
}
|
|
@@ -1439,7 +1436,7 @@ class k {
|
|
|
1439
1436
|
}
|
|
1440
1437
|
if (i)
|
|
1441
1438
|
return this.currentIndex = t, this.emit({
|
|
1442
|
-
type:
|
|
1439
|
+
type: a.recordChanged,
|
|
1443
1440
|
record: this.getCurrentRecord(),
|
|
1444
1441
|
index: this.currentIndex
|
|
1445
1442
|
}), !0;
|
|
@@ -1450,7 +1447,7 @@ class k {
|
|
|
1450
1447
|
for (let t = 0; t < this.records.length; t++)
|
|
1451
1448
|
if (e(this.records[t]))
|
|
1452
1449
|
return this.currentIndex = t, this.emit({
|
|
1453
|
-
type:
|
|
1450
|
+
type: a.recordChanged,
|
|
1454
1451
|
record: this.getCurrentRecord(),
|
|
1455
1452
|
index: this.currentIndex
|
|
1456
1453
|
}), !0;
|
|
@@ -1482,7 +1479,7 @@ class k {
|
|
|
1482
1479
|
setRecords(e) {
|
|
1483
1480
|
const t = [...this.records];
|
|
1484
1481
|
this.records = [...e], e.length > 0 ? this.currentIndex = 0 : this.currentIndex = -1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(t), this.emit({
|
|
1485
|
-
type:
|
|
1482
|
+
type: a.dataChanged,
|
|
1486
1483
|
data: this.records
|
|
1487
1484
|
});
|
|
1488
1485
|
}
|
|
@@ -1525,7 +1522,7 @@ class k {
|
|
|
1525
1522
|
return i;
|
|
1526
1523
|
}
|
|
1527
1524
|
}
|
|
1528
|
-
class
|
|
1525
|
+
class Qe {
|
|
1529
1526
|
name;
|
|
1530
1527
|
label;
|
|
1531
1528
|
service;
|
|
@@ -1579,27 +1576,27 @@ class Je {
|
|
|
1579
1576
|
// =================== Navigation ===================
|
|
1580
1577
|
first() {
|
|
1581
1578
|
this.filteredRecords.length > 0 && (this.currentIndex = 0, this.emit({
|
|
1582
|
-
type:
|
|
1579
|
+
type: a.afterScroll
|
|
1583
1580
|
}));
|
|
1584
1581
|
}
|
|
1585
1582
|
last() {
|
|
1586
1583
|
this.filteredRecords.length > 0 && (this.currentIndex = this.filteredRecords.length - 1, this.emit({
|
|
1587
|
-
type:
|
|
1584
|
+
type: a.afterScroll
|
|
1588
1585
|
}));
|
|
1589
1586
|
}
|
|
1590
1587
|
next() {
|
|
1591
1588
|
this.currentIndex < this.filteredRecords.length - 1 && (this.currentIndex++, this.emit({
|
|
1592
|
-
type:
|
|
1589
|
+
type: a.afterScroll
|
|
1593
1590
|
}));
|
|
1594
1591
|
}
|
|
1595
1592
|
prior() {
|
|
1596
1593
|
this.currentIndex > 0 && (this.currentIndex--, this.emit({
|
|
1597
|
-
type:
|
|
1594
|
+
type: a.afterScroll
|
|
1598
1595
|
}));
|
|
1599
1596
|
}
|
|
1600
1597
|
goToRecord(e) {
|
|
1601
1598
|
e >= 0 && e < this.filteredRecords.length && (this.currentIndex = e, this.emit({
|
|
1602
|
-
type:
|
|
1599
|
+
type: a.afterScroll
|
|
1603
1600
|
}));
|
|
1604
1601
|
}
|
|
1605
1602
|
isFirst() {
|
|
@@ -1626,15 +1623,15 @@ class Je {
|
|
|
1626
1623
|
}
|
|
1627
1624
|
edit() {
|
|
1628
1625
|
if (this.validateDataSourceActive("edit"), this.isEmpty() || !this.getCurrentRecord()) {
|
|
1629
|
-
const e =
|
|
1626
|
+
const e = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
1630
1627
|
throw this.publishEventError(e, {}), new g(e);
|
|
1631
1628
|
}
|
|
1632
1629
|
this.state = "edit", this.originalRecord = JSON.parse(JSON.stringify(this.getCurrentRecord())), this.emit({
|
|
1633
|
-
type:
|
|
1630
|
+
type: a.beforeEdit,
|
|
1634
1631
|
record: this.getCurrentRecord(),
|
|
1635
1632
|
index: this.currentIndex
|
|
1636
1633
|
}), this.emit({
|
|
1637
|
-
type:
|
|
1634
|
+
type: a.afterEdit,
|
|
1638
1635
|
record: this.getCurrentRecord(),
|
|
1639
1636
|
index: this.currentIndex
|
|
1640
1637
|
});
|
|
@@ -1649,16 +1646,16 @@ class Je {
|
|
|
1649
1646
|
} else
|
|
1650
1647
|
this.state === "insert" && (this.filteredRecords = this.filteredRecords.slice(0, -1), this.records = this.records.slice(0, -1), this.grandTotalRecords--, this.filteredRecords.length > 0 ? this.currentIndex = Math.min(this.currentIndex, this.filteredRecords.length - 1) : this.currentIndex = -1);
|
|
1651
1648
|
this.state = "browse", this.originalRecord = null, this.emit({
|
|
1652
|
-
type:
|
|
1649
|
+
type: a.afterCancel,
|
|
1653
1650
|
record: this.getCurrentRecord(),
|
|
1654
1651
|
index: this.currentIndex
|
|
1655
1652
|
});
|
|
1656
1653
|
}
|
|
1657
1654
|
insert(e) {
|
|
1658
1655
|
this.validateDataSourceActive("insert"), this.state = "insert", this.emit({
|
|
1659
|
-
type:
|
|
1656
|
+
type: a.beforeInsert
|
|
1660
1657
|
}), this.filteredRecords = [...this.filteredRecords, e], this.records = [...this.records, e], this.currentIndex = this.filteredRecords.length - 1, this.grandTotalRecords++, this.notifyStateChange(), this.emit({
|
|
1661
|
-
type:
|
|
1658
|
+
type: a.afterInsert,
|
|
1662
1659
|
record: e,
|
|
1663
1660
|
index: this.currentIndex
|
|
1664
1661
|
});
|
|
@@ -1666,40 +1663,40 @@ class Je {
|
|
|
1666
1663
|
// =================== Remote CRUD Operations ===================
|
|
1667
1664
|
async save(e) {
|
|
1668
1665
|
if (this.validateDataSourceActive("save"), !this.isInserting() && !this.isEditing()) {
|
|
1669
|
-
const r =
|
|
1666
|
+
const r = R.t("archbase:saveRecordIsNotAllowed", { dataSourceName: this.name });
|
|
1670
1667
|
throw this.publishEventError(r, {}), new g(r);
|
|
1671
1668
|
}
|
|
1672
1669
|
if (!this.getCurrentRecord()) {
|
|
1673
|
-
const r =
|
|
1670
|
+
const r = R.t("archbase:noRecordToSave", { dataSourceName: this.name });
|
|
1674
1671
|
throw this.publishEventError(r, {}), new g(r);
|
|
1675
1672
|
}
|
|
1676
1673
|
const t = this.getCurrentRecord();
|
|
1677
1674
|
if (this.emit({
|
|
1678
|
-
type:
|
|
1675
|
+
type: a.beforeSave,
|
|
1679
1676
|
record: t,
|
|
1680
1677
|
index: this.getCurrentIndex()
|
|
1681
1678
|
}), this.validator) {
|
|
1682
1679
|
const r = this.validator.validateEntity(t);
|
|
1683
1680
|
if (r && r.length > 0)
|
|
1684
1681
|
if (this.publishEventErrors(r), r[0].fieldName) {
|
|
1685
|
-
const i =
|
|
1682
|
+
const i = R.t("archbase:errorSavingRecord", { dataSourceName: this.label });
|
|
1686
1683
|
throw new g(i);
|
|
1687
1684
|
} else
|
|
1688
1685
|
throw new g(r[0].errorMessage);
|
|
1689
1686
|
}
|
|
1690
1687
|
try {
|
|
1691
1688
|
const r = await this.service.save(t);
|
|
1692
|
-
this.filteredRecords =
|
|
1689
|
+
this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1693
1690
|
s[this.currentIndex] = r;
|
|
1694
1691
|
});
|
|
1695
1692
|
let i = -1;
|
|
1696
1693
|
return this.records.forEach((s, o) => {
|
|
1697
|
-
const c = this.service.getId(s),
|
|
1698
|
-
(s === t || c !== void 0 && c ===
|
|
1699
|
-
}), this.records =
|
|
1694
|
+
const c = this.service.getId(s), u = this.service.getId(t);
|
|
1695
|
+
(s === t || c !== void 0 && c === u) && (i = o);
|
|
1696
|
+
}), this.records = Q(this.records, (s) => {
|
|
1700
1697
|
i >= 0 ? s[i] = r : s.push(r);
|
|
1701
1698
|
}), this.state = "browse", this.originalRecord = null, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({
|
|
1702
|
-
type:
|
|
1699
|
+
type: a.afterSave,
|
|
1703
1700
|
record: r,
|
|
1704
1701
|
index: this.getCurrentIndex()
|
|
1705
1702
|
}), e && e(), r;
|
|
@@ -1709,16 +1706,16 @@ class Je {
|
|
|
1709
1706
|
}
|
|
1710
1707
|
async remove(e) {
|
|
1711
1708
|
if (this.validateDataSourceActive("remove"), this.isInserting() || this.isEditing()) {
|
|
1712
|
-
const i =
|
|
1709
|
+
const i = R.t("archbase:removingRecordIsNotAllowed", { dataSourceName: this.name });
|
|
1713
1710
|
throw this.publishEventError(i, {}), new g(i);
|
|
1714
1711
|
}
|
|
1715
1712
|
if (this.isEmpty() || !this.getCurrentRecord()) {
|
|
1716
|
-
const i =
|
|
1713
|
+
const i = R.t("archbase:noRecordsToEdit", { dataSourceName: this.name });
|
|
1717
1714
|
throw this.publishEventError(i, {}), new g(i);
|
|
1718
1715
|
}
|
|
1719
1716
|
const t = this.getCurrentRecord(), r = this.currentIndex;
|
|
1720
1717
|
this.emit({
|
|
1721
|
-
type:
|
|
1718
|
+
type: a.beforeRemove,
|
|
1722
1719
|
record: t,
|
|
1723
1720
|
index: r
|
|
1724
1721
|
});
|
|
@@ -1727,15 +1724,15 @@ class Je {
|
|
|
1727
1724
|
const i = this.records.findIndex(
|
|
1728
1725
|
(s) => this.service.getId(s) === this.service.getId(t)
|
|
1729
1726
|
);
|
|
1730
|
-
return i >= 0 && (this.records = this.records.filter((s, o) => o !== i)), this.grandTotalRecords--, this.filteredRecords.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.filteredRecords.length && (this.currentIndex = this.filteredRecords.length - 1), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type:
|
|
1731
|
-
type:
|
|
1727
|
+
return i >= 0 && (this.records = this.records.filter((s, o) => o !== i)), this.grandTotalRecords--, this.filteredRecords.length === 0 ? this.currentIndex = -1 : this.currentIndex >= this.filteredRecords.length && (this.currentIndex = this.filteredRecords.length - 1), this.lastDataBrowsingOn = (/* @__PURE__ */ new Date()).getTime(), this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(), this.emit({ type: a.afterScroll }), this.emit({
|
|
1728
|
+
type: a.afterRemove,
|
|
1732
1729
|
record: t,
|
|
1733
1730
|
index: r
|
|
1734
1731
|
}), e && e(), t;
|
|
1735
1732
|
} catch (i) {
|
|
1736
1733
|
const s = G(i);
|
|
1737
1734
|
throw this.emit({
|
|
1738
|
-
type:
|
|
1735
|
+
type: a.onError,
|
|
1739
1736
|
error: s,
|
|
1740
1737
|
originalError: i
|
|
1741
1738
|
}), e && e(s), new g(s);
|
|
@@ -1749,7 +1746,7 @@ class Je {
|
|
|
1749
1746
|
if (r === t)
|
|
1750
1747
|
return;
|
|
1751
1748
|
const i = [...this.filteredRecords];
|
|
1752
|
-
if (this.filteredRecords =
|
|
1749
|
+
if (this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1753
1750
|
const o = s[this.currentIndex];
|
|
1754
1751
|
o && this.setNestedValue(o, e, t);
|
|
1755
1752
|
}), this.state === "edit" || this.state === "insert") {
|
|
@@ -1758,21 +1755,18 @@ class Je {
|
|
|
1758
1755
|
const o = this.records.findIndex(
|
|
1759
1756
|
(c) => this.service.getId(c) === s
|
|
1760
1757
|
);
|
|
1761
|
-
o >= 0 && (this.records =
|
|
1758
|
+
o >= 0 && (this.records = Q(this.records, (c) => {
|
|
1762
1759
|
this.setNestedValue(c[o], e, t);
|
|
1763
1760
|
}));
|
|
1764
1761
|
}
|
|
1765
1762
|
}
|
|
1766
1763
|
this.notifyStateChange(i), this.emit({
|
|
1767
|
-
type:
|
|
1764
|
+
type: a.fieldChanged,
|
|
1768
1765
|
fieldName: e,
|
|
1769
1766
|
oldValue: r,
|
|
1770
1767
|
newValue: t,
|
|
1771
1768
|
record: this.getCurrentRecord(),
|
|
1772
1769
|
index: this.currentIndex
|
|
1773
|
-
}), this.emit({
|
|
1774
|
-
type: d.dataChanged,
|
|
1775
|
-
data: this.filteredRecords
|
|
1776
1770
|
});
|
|
1777
1771
|
}
|
|
1778
1772
|
getFieldValue(e) {
|
|
@@ -1792,14 +1786,14 @@ class Je {
|
|
|
1792
1786
|
if (!Array.isArray(r))
|
|
1793
1787
|
throw new Error(`Field ${String(e)} is not an array (found: ${typeof r})`);
|
|
1794
1788
|
const i = [...this.filteredRecords];
|
|
1795
|
-
this.filteredRecords =
|
|
1789
|
+
this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1796
1790
|
const o = s[this.currentIndex];
|
|
1797
1791
|
if (o) {
|
|
1798
1792
|
const c = this.getNestedValue(o, e);
|
|
1799
1793
|
c && c.push(t);
|
|
1800
1794
|
}
|
|
1801
1795
|
}), this.notifyStateChange(i), this.emit({
|
|
1802
|
-
type:
|
|
1796
|
+
type: a.fieldChanged,
|
|
1803
1797
|
fieldName: e,
|
|
1804
1798
|
oldValue: r,
|
|
1805
1799
|
newValue: [...r, t],
|
|
@@ -1814,14 +1808,14 @@ class Je {
|
|
|
1814
1808
|
if (!Array.isArray(i) || t < 0 || t >= i.length)
|
|
1815
1809
|
return;
|
|
1816
1810
|
const s = [...this.filteredRecords];
|
|
1817
|
-
this.filteredRecords =
|
|
1811
|
+
this.filteredRecords = Q(this.filteredRecords, (o) => {
|
|
1818
1812
|
const c = o[this.currentIndex];
|
|
1819
1813
|
if (c) {
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1814
|
+
const u = this.getNestedValue(c, e);
|
|
1815
|
+
u[t] !== void 0 && r(u[t]);
|
|
1822
1816
|
}
|
|
1823
1817
|
}), this.notifyStateChange(s), this.emit({
|
|
1824
|
-
type:
|
|
1818
|
+
type: a.fieldChanged,
|
|
1825
1819
|
fieldName: e,
|
|
1826
1820
|
oldValue: i,
|
|
1827
1821
|
newValue: this.getFieldValue(e),
|
|
@@ -1838,11 +1832,11 @@ class Je {
|
|
|
1838
1832
|
if (t < 0 || t >= r.length)
|
|
1839
1833
|
return;
|
|
1840
1834
|
const i = [...this.filteredRecords];
|
|
1841
|
-
this.filteredRecords =
|
|
1835
|
+
this.filteredRecords = Q(this.filteredRecords, (s) => {
|
|
1842
1836
|
const o = s[this.currentIndex];
|
|
1843
1837
|
o && this.getNestedValue(o, e).splice(t, 1);
|
|
1844
1838
|
}), this.notifyStateChange(i), this.emit({
|
|
1845
|
-
type:
|
|
1839
|
+
type: a.fieldChanged,
|
|
1846
1840
|
fieldName: e,
|
|
1847
1841
|
oldValue: r,
|
|
1848
1842
|
newValue: this.getFieldValue(e),
|
|
@@ -1857,11 +1851,11 @@ class Je {
|
|
|
1857
1851
|
if (!Array.isArray(i))
|
|
1858
1852
|
throw new Error(`Field ${String(e)} is not an array`);
|
|
1859
1853
|
const s = [...this.filteredRecords];
|
|
1860
|
-
this.filteredRecords =
|
|
1854
|
+
this.filteredRecords = Q(this.filteredRecords, (o) => {
|
|
1861
1855
|
const c = o[this.currentIndex];
|
|
1862
1856
|
c && this.getNestedValue(c, e).splice(t, 0, r);
|
|
1863
1857
|
}), this.notifyStateChange(s), this.emit({
|
|
1864
|
-
type:
|
|
1858
|
+
type: a.fieldChanged,
|
|
1865
1859
|
fieldName: e,
|
|
1866
1860
|
oldValue: i,
|
|
1867
1861
|
newValue: this.getFieldValue(e),
|
|
@@ -1899,6 +1893,25 @@ class Je {
|
|
|
1899
1893
|
}
|
|
1900
1894
|
console.log("[V2 refreshData] Chamando getDataWithoutFilter para página:", t), this.getDataWithoutFilter(t);
|
|
1901
1895
|
}
|
|
1896
|
+
/**
|
|
1897
|
+
* Carrega um registro específico pelo ID.
|
|
1898
|
+
* Útil para cenários onde se deseja editar um registro específico.
|
|
1899
|
+
*
|
|
1900
|
+
* @param id ID do registro a ser carregado
|
|
1901
|
+
* @returns Promise com o registro carregado ou undefined se não encontrado
|
|
1902
|
+
*/
|
|
1903
|
+
async loadById(e) {
|
|
1904
|
+
try {
|
|
1905
|
+
console.log("[V2 loadById] Buscando registro com ID:", e);
|
|
1906
|
+
const t = await this.service.findOne(e);
|
|
1907
|
+
if (t)
|
|
1908
|
+
return console.log("[V2 loadById] Registro encontrado:", t), this.grandTotalRecords = 1, this.setRecords([t]), t;
|
|
1909
|
+
console.log("[V2 loadById] Registro não encontrado"), this.grandTotalRecords = 0, this.setRecords([]);
|
|
1910
|
+
return;
|
|
1911
|
+
} catch (t) {
|
|
1912
|
+
throw console.error("[V2 loadById] Erro ao buscar registro:", t), this.handleRemoteError(t), t;
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1902
1915
|
/**
|
|
1903
1916
|
* Carrega dados com filtro RSQL
|
|
1904
1917
|
*/
|
|
@@ -1942,7 +1955,7 @@ class Je {
|
|
|
1942
1955
|
return;
|
|
1943
1956
|
}
|
|
1944
1957
|
const s = e.filter.filterType, o = e.filter.quickFilterText;
|
|
1945
|
-
s ===
|
|
1958
|
+
s === we && o && o !== "" ? this.getDataWithQuickFilter(e, t, r) : s === Ee || s === Se ? this.getDataWithFilter(e, t, r) : this.getDataWithoutFilter(t, r);
|
|
1946
1959
|
}
|
|
1947
1960
|
// =================== Event Management ===================
|
|
1948
1961
|
addListener(e) {
|
|
@@ -1951,6 +1964,24 @@ class Je {
|
|
|
1951
1964
|
removeListener(e) {
|
|
1952
1965
|
this.listeners.delete(e);
|
|
1953
1966
|
}
|
|
1967
|
+
/**
|
|
1968
|
+
* Adiciona um listener para mudanças em um campo específico.
|
|
1969
|
+
* Permite que componentes escutem apenas mudanças no campo que exibem,
|
|
1970
|
+
* evitando re-renders desnecessários.
|
|
1971
|
+
*/
|
|
1972
|
+
addFieldChangeListener(e, t) {
|
|
1973
|
+
const r = (i) => {
|
|
1974
|
+
i.type === a.fieldChanged && "fieldName" in i && i.fieldName === e && t(e, i.oldValue, i.newValue);
|
|
1975
|
+
};
|
|
1976
|
+
return this.addListener(r), this;
|
|
1977
|
+
}
|
|
1978
|
+
/**
|
|
1979
|
+
* Remove um listener de campo específico.
|
|
1980
|
+
* Nota: A remoção exata não é suportada nesta versão simplificada.
|
|
1981
|
+
*/
|
|
1982
|
+
removeFieldChangeListener(e, t) {
|
|
1983
|
+
return this;
|
|
1984
|
+
}
|
|
1954
1985
|
emit(e) {
|
|
1955
1986
|
this.listeners.forEach((t) => {
|
|
1956
1987
|
try {
|
|
@@ -1996,7 +2027,7 @@ class Je {
|
|
|
1996
2027
|
return o === c;
|
|
1997
2028
|
}));
|
|
1998
2029
|
return r >= 0 ? (this.currentIndex = r, this.emit({
|
|
1999
|
-
type:
|
|
2030
|
+
type: a.afterScroll
|
|
2000
2031
|
}), !0) : !1;
|
|
2001
2032
|
}
|
|
2002
2033
|
/**
|
|
@@ -2016,13 +2047,13 @@ class Je {
|
|
|
2016
2047
|
(i) => this.service.getId(i) === t
|
|
2017
2048
|
);
|
|
2018
2049
|
return r >= 0 ? (this.currentIndex = r, this.emit({
|
|
2019
|
-
type:
|
|
2050
|
+
type: a.afterScroll
|
|
2020
2051
|
}), !0) : !1;
|
|
2021
2052
|
}
|
|
2022
2053
|
setRecords(e, t) {
|
|
2023
2054
|
const r = [...this.filteredRecords];
|
|
2024
2055
|
this.records = [...e], this.filteredRecords = [...e], t !== void 0 ? this.grandTotalRecords = t : this.grandTotalRecords < e.length && (this.grandTotalRecords = e.length), e.length > 0 ? this.currentIndex = 0 : this.currentIndex = -1, this.lastDataChangedAt = (/* @__PURE__ */ new Date()).getTime(), this.notifyStateChange(r), this.emit({
|
|
2025
|
-
type:
|
|
2056
|
+
type: a.dataChanged,
|
|
2026
2057
|
data: this.filteredRecords
|
|
2027
2058
|
});
|
|
2028
2059
|
}
|
|
@@ -2047,7 +2078,7 @@ class Je {
|
|
|
2047
2078
|
}
|
|
2048
2079
|
publishEventError(e, t) {
|
|
2049
2080
|
this.emit({
|
|
2050
|
-
type:
|
|
2081
|
+
type: a.onError,
|
|
2051
2082
|
error: e,
|
|
2052
2083
|
originalError: t
|
|
2053
2084
|
}), this.onError && this.onError(e, t);
|
|
@@ -2055,7 +2086,7 @@ class Je {
|
|
|
2055
2086
|
publishEventErrors(e) {
|
|
2056
2087
|
e.forEach((t) => {
|
|
2057
2088
|
t.fieldName && (this.emit({
|
|
2058
|
-
type:
|
|
2089
|
+
type: a.onFieldError,
|
|
2059
2090
|
fieldName: t.fieldName,
|
|
2060
2091
|
error: t.errorMessage,
|
|
2061
2092
|
originalError: t
|
|
@@ -2065,7 +2096,7 @@ class Je {
|
|
|
2065
2096
|
handleSaveError(e, t) {
|
|
2066
2097
|
e.response && e.response.data && e.response.data.apierror && e.response.data.apierror.subErrors && e.response.data.apierror.subErrors.forEach((i) => {
|
|
2067
2098
|
i.field && (this.emit({
|
|
2068
|
-
type:
|
|
2099
|
+
type: a.onFieldError,
|
|
2069
2100
|
fieldName: i.field,
|
|
2070
2101
|
error: i.message,
|
|
2071
2102
|
originalError: i.message
|
|
@@ -2073,7 +2104,7 @@ class Je {
|
|
|
2073
2104
|
});
|
|
2074
2105
|
const r = G(e);
|
|
2075
2106
|
this.emit({
|
|
2076
|
-
type:
|
|
2107
|
+
type: a.onError,
|
|
2077
2108
|
error: r,
|
|
2078
2109
|
originalError: e
|
|
2079
2110
|
}), this.onError && this.onError(r, e), t && t(r);
|
|
@@ -2103,7 +2134,7 @@ class Je {
|
|
|
2103
2134
|
// =================== Remote Data Loading ===================
|
|
2104
2135
|
async getDataWithFilter(e, t, r) {
|
|
2105
2136
|
try {
|
|
2106
|
-
const i = new
|
|
2137
|
+
const i = new Fe();
|
|
2107
2138
|
i.buildFrom(e.filter, e.sort);
|
|
2108
2139
|
const s = i.toJSON();
|
|
2109
2140
|
let o;
|
|
@@ -2148,135 +2179,134 @@ class Je {
|
|
|
2148
2179
|
handleRemoteError(e, t) {
|
|
2149
2180
|
const r = G(e);
|
|
2150
2181
|
this.emit({
|
|
2151
|
-
type:
|
|
2182
|
+
type: a.onError,
|
|
2152
2183
|
error: r,
|
|
2153
2184
|
originalError: e
|
|
2154
2185
|
}), this.onError && this.onError(r, e), t && t();
|
|
2155
2186
|
}
|
|
2156
2187
|
}
|
|
2157
|
-
function
|
|
2158
|
-
const e =
|
|
2188
|
+
function xe(n) {
|
|
2189
|
+
const e = ce(null), [t, r] = T(null), [i, s] = T(-1), [o, c] = T(0), [u, p] = T(!0), [C, W] = T(!1), [M, P] = T(!1), [L, N] = T(!1), d = z(() => (e.current || (e.current = new U(n)), e.current), []), f = l((F) => {
|
|
2159
2190
|
switch (F.type) {
|
|
2160
|
-
case
|
|
2161
|
-
case
|
|
2162
|
-
r(
|
|
2191
|
+
case a.dataChanged:
|
|
2192
|
+
case a.recordChanged:
|
|
2193
|
+
r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
|
|
2163
2194
|
break;
|
|
2164
|
-
case
|
|
2165
|
-
r(a.getCurrentRecord()), u();
|
|
2195
|
+
case a.fieldChanged:
|
|
2166
2196
|
break;
|
|
2167
|
-
case
|
|
2168
|
-
r(
|
|
2197
|
+
case a.afterScroll:
|
|
2198
|
+
r(d.getCurrentRecord()), s(d.getCurrentIndex());
|
|
2169
2199
|
break;
|
|
2170
|
-
case
|
|
2171
|
-
case
|
|
2172
|
-
|
|
2200
|
+
case a.beforeEdit:
|
|
2201
|
+
case a.beforeInsert:
|
|
2202
|
+
N(!0);
|
|
2173
2203
|
break;
|
|
2174
|
-
case
|
|
2175
|
-
case
|
|
2176
|
-
case
|
|
2177
|
-
case
|
|
2178
|
-
|
|
2204
|
+
case a.afterEdit:
|
|
2205
|
+
case a.afterInsert:
|
|
2206
|
+
case a.afterSave:
|
|
2207
|
+
case a.afterCancel:
|
|
2208
|
+
N(!1), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting());
|
|
2179
2209
|
break;
|
|
2180
|
-
case
|
|
2181
|
-
case
|
|
2182
|
-
|
|
2210
|
+
case a.onError:
|
|
2211
|
+
case a.onFieldError:
|
|
2212
|
+
N(!1);
|
|
2183
2213
|
break;
|
|
2184
2214
|
}
|
|
2185
|
-
}, [
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
}), [
|
|
2189
|
-
const
|
|
2190
|
-
|
|
2191
|
-
}, [
|
|
2192
|
-
|
|
2193
|
-
}, [
|
|
2194
|
-
|
|
2195
|
-
}, [
|
|
2196
|
-
|
|
2197
|
-
}, [
|
|
2198
|
-
|
|
2199
|
-
}, [
|
|
2200
|
-
|
|
2201
|
-
}, [
|
|
2202
|
-
|
|
2203
|
-
}, [
|
|
2204
|
-
|
|
2205
|
-
}, [
|
|
2206
|
-
|
|
2207
|
-
}, [
|
|
2208
|
-
|
|
2209
|
-
}, [
|
|
2210
|
-
|
|
2211
|
-
}, [
|
|
2212
|
-
|
|
2213
|
-
}, [
|
|
2214
|
-
|
|
2215
|
-
}, [
|
|
2216
|
-
if (
|
|
2217
|
-
return
|
|
2218
|
-
const
|
|
2219
|
-
return Array.isArray(
|
|
2220
|
-
}, [
|
|
2221
|
-
if (
|
|
2222
|
-
return
|
|
2223
|
-
const
|
|
2224
|
-
return Array.isArray(
|
|
2225
|
-
}, [
|
|
2226
|
-
...
|
|
2215
|
+
}, [d]);
|
|
2216
|
+
q(() => (d.addListener(f), r(d.getCurrentRecord()), s(d.getCurrentIndex()), c(d.getTotalRecords()), p(d.isBrowsing()), W(d.isEditing()), P(d.isInserting()), () => {
|
|
2217
|
+
d.removeListener(f);
|
|
2218
|
+
}), [d, f]);
|
|
2219
|
+
const b = l((F, k) => {
|
|
2220
|
+
d.setFieldValue(F, k);
|
|
2221
|
+
}, [d]), V = l((F) => d.getFieldValue(F), [d]), K = l(() => {
|
|
2222
|
+
d instanceof U, d.edit();
|
|
2223
|
+
}, [d]), m = l(async () => await d.save(), [d]), h = l(() => {
|
|
2224
|
+
d instanceof U, d.cancel();
|
|
2225
|
+
}, [d]), Y = l((F) => {
|
|
2226
|
+
d instanceof U, d.insert(F);
|
|
2227
|
+
}, [d]), Z = l(async (F) => await d.remove(F), [d]), E = l(() => {
|
|
2228
|
+
d instanceof U, d.first();
|
|
2229
|
+
}, [d]), j = l(() => {
|
|
2230
|
+
d instanceof U, d.last();
|
|
2231
|
+
}, [d]), ee = l(() => {
|
|
2232
|
+
d instanceof U, d.next();
|
|
2233
|
+
}, [d]), D = l(() => {
|
|
2234
|
+
d instanceof U, d.prior();
|
|
2235
|
+
}, [d]), S = l((F) => {
|
|
2236
|
+
d instanceof U, d.goToRecord(F);
|
|
2237
|
+
}, [d]), A = l((F, k) => {
|
|
2238
|
+
d instanceof U && d.appendToFieldArray(F, k);
|
|
2239
|
+
}, [d]), B = l((F, k, de) => {
|
|
2240
|
+
d instanceof U && d.updateFieldArrayItem(F, k, de);
|
|
2241
|
+
}, [d]), y = l((F, k) => {
|
|
2242
|
+
d instanceof U && d.removeFromFieldArray(F, k);
|
|
2243
|
+
}, [d]), w = l((F, k, de) => {
|
|
2244
|
+
d instanceof U && d.insertIntoFieldArray(F, k, de);
|
|
2245
|
+
}, [d]), x = l((F) => {
|
|
2246
|
+
if (d instanceof U)
|
|
2247
|
+
return d.getFieldArray(F);
|
|
2248
|
+
const k = d.getFieldValue(F);
|
|
2249
|
+
return Array.isArray(k) ? k : [];
|
|
2250
|
+
}, [d]), $ = l((F) => {
|
|
2251
|
+
if (d instanceof U)
|
|
2252
|
+
return d.isFieldArray(F);
|
|
2253
|
+
const k = d.getFieldValue(F);
|
|
2254
|
+
return Array.isArray(k);
|
|
2255
|
+
}, [d]), v = z(() => i < o - 1, [i, o]), J = z(() => i > 0, [i]), te = z(() => o === 0, [o]), oe = z(() => i === 0, [i]), ae = z(() => i === o - 1, [i, o]), O = z(() => u, [u]), _ = z(() => C, [C]), re = z(() => M, [M]), ue = l(() => process.env.NODE_ENV === "development" ? {
|
|
2256
|
+
...d.getDebugSnapshot(),
|
|
2227
2257
|
hookState: {
|
|
2228
2258
|
currentRecord: t,
|
|
2229
2259
|
currentIndex: i,
|
|
2230
2260
|
totalRecords: o,
|
|
2231
|
-
isBrowsing:
|
|
2232
|
-
isEditing:
|
|
2233
|
-
isInserting:
|
|
2234
|
-
isLoading:
|
|
2261
|
+
isBrowsing: O,
|
|
2262
|
+
isEditing: _,
|
|
2263
|
+
isInserting: re,
|
|
2264
|
+
isLoading: L
|
|
2235
2265
|
}
|
|
2236
|
-
} : null, [
|
|
2266
|
+
} : null, [d, t, i, o, O, _, re, L]);
|
|
2237
2267
|
return {
|
|
2238
2268
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2239
|
-
dataSource:
|
|
2269
|
+
dataSource: d,
|
|
2240
2270
|
// Estado reativo
|
|
2241
2271
|
currentRecord: t,
|
|
2242
2272
|
currentIndex: i,
|
|
2243
2273
|
totalRecords: o,
|
|
2244
|
-
isLoading:
|
|
2274
|
+
isLoading: L,
|
|
2245
2275
|
// Estado derivado
|
|
2246
|
-
canNext:
|
|
2247
|
-
canPrior:
|
|
2248
|
-
isEmpty:
|
|
2249
|
-
isFirst:
|
|
2250
|
-
isLast:
|
|
2251
|
-
isBrowsing:
|
|
2252
|
-
isEditing:
|
|
2253
|
-
isInserting:
|
|
2276
|
+
canNext: v,
|
|
2277
|
+
canPrior: J,
|
|
2278
|
+
isEmpty: te,
|
|
2279
|
+
isFirst: oe,
|
|
2280
|
+
isLast: ae,
|
|
2281
|
+
isBrowsing: O,
|
|
2282
|
+
isEditing: _,
|
|
2283
|
+
isInserting: re,
|
|
2254
2284
|
// Operações básicas
|
|
2255
|
-
setFieldValue:
|
|
2256
|
-
getFieldValue:
|
|
2257
|
-
edit:
|
|
2258
|
-
save:
|
|
2259
|
-
cancel:
|
|
2260
|
-
insert:
|
|
2261
|
-
remove:
|
|
2285
|
+
setFieldValue: b,
|
|
2286
|
+
getFieldValue: V,
|
|
2287
|
+
edit: K,
|
|
2288
|
+
save: m,
|
|
2289
|
+
cancel: h,
|
|
2290
|
+
insert: Y,
|
|
2291
|
+
remove: Z,
|
|
2262
2292
|
// Navegação
|
|
2263
|
-
first:
|
|
2264
|
-
last:
|
|
2265
|
-
next:
|
|
2266
|
-
prior:
|
|
2267
|
-
goToRecord:
|
|
2293
|
+
first: E,
|
|
2294
|
+
last: j,
|
|
2295
|
+
next: ee,
|
|
2296
|
+
prior: D,
|
|
2297
|
+
goToRecord: S,
|
|
2268
2298
|
// Operações de array (V2)
|
|
2269
|
-
appendToFieldArray:
|
|
2270
|
-
updateFieldArrayItem:
|
|
2271
|
-
removeFromFieldArray:
|
|
2272
|
-
insertIntoFieldArray:
|
|
2273
|
-
getFieldArray:
|
|
2274
|
-
isFieldArray:
|
|
2299
|
+
appendToFieldArray: A,
|
|
2300
|
+
updateFieldArrayItem: B,
|
|
2301
|
+
removeFromFieldArray: y,
|
|
2302
|
+
insertIntoFieldArray: w,
|
|
2303
|
+
getFieldArray: x,
|
|
2304
|
+
isFieldArray: $,
|
|
2275
2305
|
// Debug
|
|
2276
|
-
getDebugInfo:
|
|
2306
|
+
getDebugInfo: ue
|
|
2277
2307
|
};
|
|
2278
2308
|
}
|
|
2279
|
-
function
|
|
2309
|
+
function wt(n) {
|
|
2280
2310
|
const {
|
|
2281
2311
|
dataSource: e,
|
|
2282
2312
|
currentRecord: t,
|
|
@@ -2285,18 +2315,18 @@ function It(n) {
|
|
|
2285
2315
|
canNext: s,
|
|
2286
2316
|
canPrior: o,
|
|
2287
2317
|
isEmpty: c,
|
|
2288
|
-
isFirst:
|
|
2289
|
-
isLast:
|
|
2290
|
-
isBrowsing:
|
|
2291
|
-
first:
|
|
2292
|
-
last:
|
|
2293
|
-
next:
|
|
2294
|
-
prior:
|
|
2295
|
-
goToRecord:
|
|
2296
|
-
getFieldValue:
|
|
2297
|
-
getFieldArray:
|
|
2298
|
-
isFieldArray:
|
|
2299
|
-
} =
|
|
2318
|
+
isFirst: u,
|
|
2319
|
+
isLast: p,
|
|
2320
|
+
isBrowsing: C,
|
|
2321
|
+
first: W,
|
|
2322
|
+
last: M,
|
|
2323
|
+
next: P,
|
|
2324
|
+
prior: L,
|
|
2325
|
+
goToRecord: N,
|
|
2326
|
+
getFieldValue: d,
|
|
2327
|
+
getFieldArray: f,
|
|
2328
|
+
isFieldArray: b
|
|
2329
|
+
} = xe(n);
|
|
2300
2330
|
return {
|
|
2301
2331
|
dataSource: e,
|
|
2302
2332
|
currentRecord: t,
|
|
@@ -2305,179 +2335,191 @@ function It(n) {
|
|
|
2305
2335
|
canNext: s,
|
|
2306
2336
|
canPrior: o,
|
|
2307
2337
|
isEmpty: c,
|
|
2308
|
-
isFirst:
|
|
2309
|
-
isLast:
|
|
2310
|
-
isBrowsing:
|
|
2311
|
-
first:
|
|
2312
|
-
last:
|
|
2313
|
-
next:
|
|
2314
|
-
prior:
|
|
2315
|
-
goToRecord:
|
|
2316
|
-
getFieldValue:
|
|
2317
|
-
getFieldArray:
|
|
2318
|
-
isFieldArray:
|
|
2338
|
+
isFirst: u,
|
|
2339
|
+
isLast: p,
|
|
2340
|
+
isBrowsing: C,
|
|
2341
|
+
first: W,
|
|
2342
|
+
last: M,
|
|
2343
|
+
next: P,
|
|
2344
|
+
prior: L,
|
|
2345
|
+
goToRecord: N,
|
|
2346
|
+
getFieldValue: d,
|
|
2347
|
+
getFieldArray: f,
|
|
2348
|
+
isFieldArray: b
|
|
2319
2349
|
};
|
|
2320
2350
|
}
|
|
2321
|
-
function
|
|
2322
|
-
return
|
|
2351
|
+
function Et(n) {
|
|
2352
|
+
return xe(n);
|
|
2323
2353
|
}
|
|
2324
|
-
function
|
|
2325
|
-
const e =
|
|
2326
|
-
switch (
|
|
2327
|
-
case
|
|
2328
|
-
case
|
|
2329
|
-
case
|
|
2330
|
-
|
|
2354
|
+
function Ce(n) {
|
|
2355
|
+
const { id: e, loadOnStart: t = !0 } = n, r = ce(null), [i, s] = T(void 0), [o, c] = T(-1), [u, p] = T(0), [C, W] = T(0), [M, P] = T(!0), [L, N] = T(!1), [d, f] = T(!1), [b, V] = T(!1), [K, m] = T(null), h = z(() => (r.current || (r.current = new Qe(n)), r.current), []), Y = l((I) => {
|
|
2356
|
+
switch (I.type) {
|
|
2357
|
+
case a.dataChanged:
|
|
2358
|
+
case a.recordChanged:
|
|
2359
|
+
case a.refreshData:
|
|
2360
|
+
s(h.getCurrentRecord()), c(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), V(!1), m(null);
|
|
2331
2361
|
break;
|
|
2332
|
-
case
|
|
2333
|
-
r(h.getCurrentRecord()), S();
|
|
2362
|
+
case a.fieldChanged:
|
|
2334
2363
|
break;
|
|
2335
|
-
case
|
|
2336
|
-
|
|
2364
|
+
case a.afterScroll:
|
|
2365
|
+
s(h.getCurrentRecord()), c(h.getCurrentIndex());
|
|
2337
2366
|
break;
|
|
2338
|
-
case
|
|
2339
|
-
case
|
|
2340
|
-
case
|
|
2341
|
-
case
|
|
2342
|
-
|
|
2367
|
+
case a.beforeEdit:
|
|
2368
|
+
case a.beforeInsert:
|
|
2369
|
+
case a.beforeSave:
|
|
2370
|
+
case a.beforeRemove:
|
|
2371
|
+
V(!0), m(null);
|
|
2343
2372
|
break;
|
|
2344
|
-
case
|
|
2345
|
-
case
|
|
2346
|
-
case
|
|
2347
|
-
case
|
|
2348
|
-
case
|
|
2349
|
-
|
|
2373
|
+
case a.afterEdit:
|
|
2374
|
+
case a.afterInsert:
|
|
2375
|
+
case a.afterSave:
|
|
2376
|
+
case a.afterCancel:
|
|
2377
|
+
case a.afterRemove:
|
|
2378
|
+
V(!1), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), m(null);
|
|
2350
2379
|
break;
|
|
2351
|
-
case
|
|
2352
|
-
|
|
2380
|
+
case a.onError:
|
|
2381
|
+
V(!1), m(I.error);
|
|
2353
2382
|
break;
|
|
2354
|
-
case
|
|
2355
|
-
|
|
2383
|
+
case a.onFieldError:
|
|
2384
|
+
V(!1);
|
|
2356
2385
|
break;
|
|
2357
2386
|
}
|
|
2358
|
-
}, [h
|
|
2359
|
-
|
|
2360
|
-
h.removeListener(
|
|
2361
|
-
}), [h,
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2387
|
+
}, [h]);
|
|
2388
|
+
q(() => (h.addListener(Y), s(h.getCurrentRecord()), c(h.getCurrentIndex()), p(h.getTotalRecords()), W(h.getGrandTotalRecords()), P(h.isBrowsing()), N(h.isEditing()), f(h.isInserting()), () => {
|
|
2389
|
+
h.removeListener(Y);
|
|
2390
|
+
}), [h, Y]), q(() => {
|
|
2391
|
+
t && (e != null ? (V(!0), m(null), h.loadById(e).catch((I) => {
|
|
2392
|
+
m(I.message || "Erro ao carregar registro"), V(!1);
|
|
2393
|
+
})) : (V(!0), m(null), h.refreshData()));
|
|
2394
|
+
}, [e, t, h]);
|
|
2395
|
+
const Z = l((I, H) => {
|
|
2396
|
+
h.setFieldValue(I, H);
|
|
2397
|
+
}, [h]), E = l((I) => h.getFieldValue(I), [h]), j = l(() => {
|
|
2365
2398
|
h.edit();
|
|
2366
2399
|
}, [h]), ee = l(async () => {
|
|
2367
2400
|
try {
|
|
2368
|
-
return
|
|
2369
|
-
} catch (
|
|
2370
|
-
throw
|
|
2401
|
+
return m(null), await h.save();
|
|
2402
|
+
} catch (I) {
|
|
2403
|
+
throw m(I.message || "Erro ao salvar"), I;
|
|
2371
2404
|
}
|
|
2372
2405
|
}, [h]), D = l(() => {
|
|
2373
2406
|
h.cancel();
|
|
2374
|
-
}, [h]),
|
|
2375
|
-
h.insert(
|
|
2376
|
-
}, [h]), A = l(async (
|
|
2407
|
+
}, [h]), S = l((I) => {
|
|
2408
|
+
h.insert(I);
|
|
2409
|
+
}, [h]), A = l(async (I) => {
|
|
2377
2410
|
try {
|
|
2378
|
-
return
|
|
2379
|
-
} catch (
|
|
2380
|
-
throw
|
|
2411
|
+
return m(null), await h.remove(I);
|
|
2412
|
+
} catch (H) {
|
|
2413
|
+
throw m(H.message || "Erro ao remover"), H;
|
|
2381
2414
|
}
|
|
2382
|
-
}, [h]),
|
|
2415
|
+
}, [h]), B = l(() => {
|
|
2383
2416
|
h.first();
|
|
2384
|
-
}, [h]),
|
|
2417
|
+
}, [h]), y = l(() => {
|
|
2385
2418
|
h.last();
|
|
2386
|
-
}, [h]),
|
|
2419
|
+
}, [h]), w = l(() => {
|
|
2387
2420
|
h.next();
|
|
2388
2421
|
}, [h]), x = l(() => {
|
|
2389
2422
|
h.prior();
|
|
2390
|
-
}, [h]),
|
|
2391
|
-
h.goToRecord(
|
|
2392
|
-
}, [h]),
|
|
2393
|
-
h.appendToFieldArray(w, M);
|
|
2394
|
-
}, [h]), q = l((w, M, se) => {
|
|
2395
|
-
h.updateFieldArrayItem(w, M, se);
|
|
2396
|
-
}, [h]), te = l((w, M) => {
|
|
2397
|
-
h.removeFromFieldArray(w, M);
|
|
2398
|
-
}, [h]), oe = l((w, M, se) => {
|
|
2399
|
-
h.insertIntoFieldArray(w, M, se);
|
|
2400
|
-
}, [h]), ae = l((w) => h.getFieldArray(w), [h]), B = l((w) => h.isFieldArray(w), [h]), K = l((w, M, se) => {
|
|
2401
|
-
u(!0), V(null);
|
|
2423
|
+
}, [h]), $ = l((I) => {
|
|
2424
|
+
h.goToRecord(I);
|
|
2425
|
+
}, [h]), v = l(async (I) => {
|
|
2402
2426
|
try {
|
|
2403
|
-
|
|
2404
|
-
|
|
2427
|
+
return V(!0), m(null), await h.loadById(I);
|
|
2428
|
+
} catch (H) {
|
|
2429
|
+
throw m(H.message || "Erro ao carregar registro"), H;
|
|
2430
|
+
} finally {
|
|
2431
|
+
V(!1);
|
|
2432
|
+
}
|
|
2433
|
+
}, [h]), J = l((I, H) => {
|
|
2434
|
+
h.appendToFieldArray(I, H);
|
|
2435
|
+
}, [h]), te = l((I, H, se) => {
|
|
2436
|
+
h.updateFieldArrayItem(I, H, se);
|
|
2437
|
+
}, [h]), oe = l((I, H) => {
|
|
2438
|
+
h.removeFromFieldArray(I, H);
|
|
2439
|
+
}, [h]), ae = l((I, H, se) => {
|
|
2440
|
+
h.insertIntoFieldArray(I, H, se);
|
|
2441
|
+
}, [h]), O = l((I) => h.getFieldArray(I), [h]), _ = l((I) => h.isFieldArray(I), [h]), re = l((I, H, se) => {
|
|
2442
|
+
V(!0), m(null);
|
|
2443
|
+
try {
|
|
2444
|
+
h.applyRemoteFilter(I, H, () => {
|
|
2445
|
+
V(!1), se && se();
|
|
2405
2446
|
});
|
|
2406
|
-
} catch (
|
|
2407
|
-
|
|
2447
|
+
} catch (Le) {
|
|
2448
|
+
V(!1), m(Le.message || "Erro ao aplicar filtro");
|
|
2408
2449
|
}
|
|
2409
|
-
}, [h]),
|
|
2450
|
+
}, [h]), ue = l(async (I) => {
|
|
2410
2451
|
try {
|
|
2411
|
-
|
|
2412
|
-
} catch (
|
|
2413
|
-
throw
|
|
2452
|
+
V(!0), m(null), h.refreshData(I);
|
|
2453
|
+
} catch (H) {
|
|
2454
|
+
throw V(!1), m(H.message || "Erro ao atualizar dados"), H;
|
|
2414
2455
|
}
|
|
2415
|
-
}, [h]),
|
|
2416
|
-
h.setPageSize(
|
|
2417
|
-
}, [h]),
|
|
2456
|
+
}, [h]), F = l((I) => {
|
|
2457
|
+
h.setPageSize(I);
|
|
2458
|
+
}, [h]), k = l(() => h.getPageSize(), [h]), de = z(() => o < u - 1, [o, u]), De = z(() => o > 0, [o]), Ve = z(() => u === 0, [u]), Te = z(() => o === 0, [o]), Oe = z(() => o === u - 1, [o, u]), ge = z(() => M, [M]), fe = z(() => L, [L]), me = z(() => d, [d]), Pe = l(() => process.env.NODE_ENV === "development" ? {
|
|
2418
2459
|
...h.getDebugSnapshot(),
|
|
2419
2460
|
hookState: {
|
|
2420
|
-
currentRecord:
|
|
2421
|
-
currentIndex:
|
|
2422
|
-
totalRecords:
|
|
2423
|
-
grandTotalRecords:
|
|
2424
|
-
isBrowsing:
|
|
2425
|
-
isEditing:
|
|
2426
|
-
isInserting:
|
|
2427
|
-
isLoading:
|
|
2428
|
-
error:
|
|
2429
|
-
}
|
|
2430
|
-
} : null, [h,
|
|
2461
|
+
currentRecord: i,
|
|
2462
|
+
currentIndex: o,
|
|
2463
|
+
totalRecords: u,
|
|
2464
|
+
grandTotalRecords: C,
|
|
2465
|
+
isBrowsing: ge,
|
|
2466
|
+
isEditing: fe,
|
|
2467
|
+
isInserting: me,
|
|
2468
|
+
isLoading: b,
|
|
2469
|
+
error: K
|
|
2470
|
+
}
|
|
2471
|
+
} : null, [h, i, o, u, C, ge, fe, me, b, K]);
|
|
2431
2472
|
return {
|
|
2432
2473
|
// DataSource instance (para casos onde acesso direto é necessário)
|
|
2433
2474
|
dataSource: h,
|
|
2434
2475
|
// Estado reativo
|
|
2435
|
-
currentRecord:
|
|
2436
|
-
currentIndex:
|
|
2437
|
-
totalRecords:
|
|
2438
|
-
grandTotalRecords:
|
|
2439
|
-
isLoading:
|
|
2440
|
-
error:
|
|
2476
|
+
currentRecord: i,
|
|
2477
|
+
currentIndex: o,
|
|
2478
|
+
totalRecords: u,
|
|
2479
|
+
grandTotalRecords: C,
|
|
2480
|
+
isLoading: b,
|
|
2481
|
+
error: K,
|
|
2441
2482
|
// Estado derivado
|
|
2442
|
-
canNext:
|
|
2443
|
-
canPrior:
|
|
2444
|
-
isEmpty:
|
|
2445
|
-
isFirst:
|
|
2446
|
-
isLast:
|
|
2447
|
-
isBrowsing:
|
|
2448
|
-
isEditing:
|
|
2449
|
-
isInserting:
|
|
2483
|
+
canNext: de,
|
|
2484
|
+
canPrior: De,
|
|
2485
|
+
isEmpty: Ve,
|
|
2486
|
+
isFirst: Te,
|
|
2487
|
+
isLast: Oe,
|
|
2488
|
+
isBrowsing: ge,
|
|
2489
|
+
isEditing: fe,
|
|
2490
|
+
isInserting: me,
|
|
2450
2491
|
// Operações básicas
|
|
2451
2492
|
setFieldValue: Z,
|
|
2452
|
-
getFieldValue:
|
|
2453
|
-
edit:
|
|
2493
|
+
getFieldValue: E,
|
|
2494
|
+
edit: j,
|
|
2454
2495
|
save: ee,
|
|
2455
2496
|
cancel: D,
|
|
2456
|
-
insert:
|
|
2497
|
+
insert: S,
|
|
2457
2498
|
remove: A,
|
|
2458
2499
|
// Navegação
|
|
2459
|
-
first:
|
|
2460
|
-
last:
|
|
2461
|
-
next:
|
|
2500
|
+
first: B,
|
|
2501
|
+
last: y,
|
|
2502
|
+
next: w,
|
|
2462
2503
|
prior: x,
|
|
2463
|
-
goToRecord:
|
|
2504
|
+
goToRecord: $,
|
|
2505
|
+
loadById: v,
|
|
2464
2506
|
// Operações de array (V2)
|
|
2465
|
-
appendToFieldArray:
|
|
2466
|
-
updateFieldArrayItem:
|
|
2467
|
-
removeFromFieldArray:
|
|
2468
|
-
insertIntoFieldArray:
|
|
2469
|
-
getFieldArray:
|
|
2470
|
-
isFieldArray:
|
|
2507
|
+
appendToFieldArray: J,
|
|
2508
|
+
updateFieldArrayItem: te,
|
|
2509
|
+
removeFromFieldArray: oe,
|
|
2510
|
+
insertIntoFieldArray: ae,
|
|
2511
|
+
getFieldArray: O,
|
|
2512
|
+
isFieldArray: _,
|
|
2471
2513
|
// Operações remotas
|
|
2472
|
-
applyRemoteFilter:
|
|
2473
|
-
refreshData:
|
|
2474
|
-
setPageSize:
|
|
2475
|
-
getPageSize:
|
|
2514
|
+
applyRemoteFilter: re,
|
|
2515
|
+
refreshData: ue,
|
|
2516
|
+
setPageSize: F,
|
|
2517
|
+
getPageSize: k,
|
|
2476
2518
|
// Debug
|
|
2477
|
-
getDebugInfo:
|
|
2519
|
+
getDebugInfo: Pe
|
|
2478
2520
|
};
|
|
2479
2521
|
}
|
|
2480
|
-
function
|
|
2522
|
+
function St(n) {
|
|
2481
2523
|
const {
|
|
2482
2524
|
dataSource: e,
|
|
2483
2525
|
currentRecord: t,
|
|
@@ -2486,25 +2528,26 @@ function Et(n) {
|
|
|
2486
2528
|
grandTotalRecords: s,
|
|
2487
2529
|
isLoading: o,
|
|
2488
2530
|
error: c,
|
|
2489
|
-
canNext:
|
|
2490
|
-
canPrior:
|
|
2491
|
-
isEmpty:
|
|
2492
|
-
isFirst:
|
|
2493
|
-
isLast:
|
|
2494
|
-
isBrowsing:
|
|
2495
|
-
first:
|
|
2496
|
-
last:
|
|
2497
|
-
next:
|
|
2498
|
-
prior:
|
|
2499
|
-
goToRecord:
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2531
|
+
canNext: u,
|
|
2532
|
+
canPrior: p,
|
|
2533
|
+
isEmpty: C,
|
|
2534
|
+
isFirst: W,
|
|
2535
|
+
isLast: M,
|
|
2536
|
+
isBrowsing: P,
|
|
2537
|
+
first: L,
|
|
2538
|
+
last: N,
|
|
2539
|
+
next: d,
|
|
2540
|
+
prior: f,
|
|
2541
|
+
goToRecord: b,
|
|
2542
|
+
loadById: V,
|
|
2543
|
+
getFieldValue: K,
|
|
2544
|
+
getFieldArray: m,
|
|
2545
|
+
isFieldArray: h,
|
|
2546
|
+
applyRemoteFilter: Y,
|
|
2547
|
+
refreshData: Z,
|
|
2548
|
+
getPageSize: E,
|
|
2549
|
+
getDebugInfo: j
|
|
2550
|
+
} = Ce(n);
|
|
2508
2551
|
return {
|
|
2509
2552
|
dataSource: e,
|
|
2510
2553
|
currentRecord: t,
|
|
@@ -2513,30 +2556,31 @@ function Et(n) {
|
|
|
2513
2556
|
grandTotalRecords: s,
|
|
2514
2557
|
isLoading: o,
|
|
2515
2558
|
error: c,
|
|
2516
|
-
canNext:
|
|
2517
|
-
canPrior:
|
|
2518
|
-
isEmpty:
|
|
2519
|
-
isFirst:
|
|
2520
|
-
isLast:
|
|
2521
|
-
isBrowsing:
|
|
2522
|
-
first:
|
|
2523
|
-
last:
|
|
2524
|
-
next:
|
|
2525
|
-
prior:
|
|
2526
|
-
goToRecord:
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2559
|
+
canNext: u,
|
|
2560
|
+
canPrior: p,
|
|
2561
|
+
isEmpty: C,
|
|
2562
|
+
isFirst: W,
|
|
2563
|
+
isLast: M,
|
|
2564
|
+
isBrowsing: P,
|
|
2565
|
+
first: L,
|
|
2566
|
+
last: N,
|
|
2567
|
+
next: d,
|
|
2568
|
+
prior: f,
|
|
2569
|
+
goToRecord: b,
|
|
2570
|
+
loadById: V,
|
|
2571
|
+
getFieldValue: K,
|
|
2572
|
+
getFieldArray: m,
|
|
2573
|
+
isFieldArray: h,
|
|
2574
|
+
applyRemoteFilter: Y,
|
|
2575
|
+
refreshData: Z,
|
|
2576
|
+
getPageSize: E,
|
|
2577
|
+
getDebugInfo: j
|
|
2534
2578
|
};
|
|
2535
2579
|
}
|
|
2536
|
-
function
|
|
2537
|
-
return
|
|
2580
|
+
function Ft(n) {
|
|
2581
|
+
return Ce(n);
|
|
2538
2582
|
}
|
|
2539
|
-
class
|
|
2583
|
+
class At {
|
|
2540
2584
|
/**
|
|
2541
2585
|
* Gera chave de query baseada no DataSource e filtros
|
|
2542
2586
|
*/
|
|
@@ -2560,7 +2604,7 @@ class Ft {
|
|
|
2560
2604
|
);
|
|
2561
2605
|
}
|
|
2562
2606
|
}
|
|
2563
|
-
const
|
|
2607
|
+
const xt = {
|
|
2564
2608
|
/** Configuração para dados que mudam raramente */
|
|
2565
2609
|
STATIC_DATA: {
|
|
2566
2610
|
staleTime: 30 * 60 * 1e3,
|
|
@@ -2590,31 +2634,31 @@ const At = {
|
|
|
2590
2634
|
// 1 minuto
|
|
2591
2635
|
retry: 5
|
|
2592
2636
|
}
|
|
2593
|
-
},
|
|
2594
|
-
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: o, validator: c } = n,
|
|
2637
|
+
}, Ct = (n) => {
|
|
2638
|
+
const { initialData: e, name: t, label: r, initialDataSource: i, onLoadComplete: s, store: o, validator: c } = n, u = () => o && o.existsValue(t) ? o.getValue(t) : i || new ye(t, {
|
|
2595
2639
|
records: e,
|
|
2596
2640
|
grandTotalRecords: e.length,
|
|
2597
2641
|
currentPage: 0,
|
|
2598
2642
|
totalPages: 0,
|
|
2599
2643
|
pageSize: 0,
|
|
2600
2644
|
validator: c
|
|
2601
|
-
}, r), [
|
|
2602
|
-
|
|
2645
|
+
}, r), [p, C] = T(
|
|
2646
|
+
u()
|
|
2603
2647
|
);
|
|
2604
|
-
return
|
|
2605
|
-
o && o.setValue(t,
|
|
2606
|
-
}, [t]), { dataSource:
|
|
2607
|
-
},
|
|
2648
|
+
return q(() => {
|
|
2649
|
+
o && o.setValue(t, p), s && s(p);
|
|
2650
|
+
}, [t]), { dataSource: p };
|
|
2651
|
+
}, bt = (n) => {
|
|
2608
2652
|
const e = (r) => {
|
|
2609
2653
|
r.addListener(n.listener);
|
|
2610
2654
|
}, t = (r) => {
|
|
2611
2655
|
r.removeListener(n.listener);
|
|
2612
2656
|
};
|
|
2613
|
-
|
|
2657
|
+
q(() => (n.dataSource && (t(n.dataSource), e(n.dataSource)), () => {
|
|
2614
2658
|
n.dataSource && t(n.dataSource);
|
|
2615
2659
|
}), [n.dataSource?.uuid || n.dataSource?.getName()]);
|
|
2616
|
-
},
|
|
2617
|
-
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] =
|
|
2660
|
+
}, Dt = (n) => {
|
|
2661
|
+
const { initialData: e, name: t, initialDataSource: r, onLoadComplete: i, validator: s } = n, [o, c] = T(
|
|
2618
2662
|
r ?? new Ge(t, {
|
|
2619
2663
|
records: e,
|
|
2620
2664
|
grandTotalRecords: e.length,
|
|
@@ -2624,9 +2668,9 @@ const At = {
|
|
|
2624
2668
|
validator: s
|
|
2625
2669
|
})
|
|
2626
2670
|
);
|
|
2627
|
-
return
|
|
2628
|
-
c((
|
|
2629
|
-
const
|
|
2671
|
+
return q(() => {
|
|
2672
|
+
c((u) => {
|
|
2673
|
+
const p = {
|
|
2630
2674
|
records: e,
|
|
2631
2675
|
grandTotalRecords: e.length,
|
|
2632
2676
|
totalPages: 0,
|
|
@@ -2634,11 +2678,11 @@ const At = {
|
|
|
2634
2678
|
pageSize: 0,
|
|
2635
2679
|
validator: s
|
|
2636
2680
|
};
|
|
2637
|
-
return
|
|
2681
|
+
return u.isActive() ? u.setData(p) : u.open(p), u;
|
|
2638
2682
|
}), i && i(o);
|
|
2639
2683
|
}, [e, t]), { dataSource: o };
|
|
2640
2684
|
};
|
|
2641
|
-
class
|
|
2685
|
+
class be {
|
|
2642
2686
|
tokenManager;
|
|
2643
2687
|
constructor(e) {
|
|
2644
2688
|
this.tokenManager = e;
|
|
@@ -2653,7 +2697,7 @@ class Ve {
|
|
|
2653
2697
|
}
|
|
2654
2698
|
async get(e, t, r, i) {
|
|
2655
2699
|
try {
|
|
2656
|
-
const s = this.prepareHeaders(t, r), o = await
|
|
2700
|
+
const s = this.prepareHeaders(t, r), o = await X.get(e, { headers: s, ...i });
|
|
2657
2701
|
return ie.convertJsonToObject(o.data);
|
|
2658
2702
|
} catch (s) {
|
|
2659
2703
|
return Promise.reject(s);
|
|
@@ -2661,7 +2705,7 @@ class Ve {
|
|
|
2661
2705
|
}
|
|
2662
2706
|
async post(e, t, r, i, s) {
|
|
2663
2707
|
try {
|
|
2664
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2708
|
+
const o = this.prepareHeaders(r, i), c = await X.post(
|
|
2665
2709
|
e,
|
|
2666
2710
|
ie.convertObjectToJson(t),
|
|
2667
2711
|
{
|
|
@@ -2677,7 +2721,7 @@ class Ve {
|
|
|
2677
2721
|
async postNoConvertId(e, t, r, i, s) {
|
|
2678
2722
|
try {
|
|
2679
2723
|
const o = this.prepareHeaders(r, i);
|
|
2680
|
-
return (await
|
|
2724
|
+
return (await X.post(
|
|
2681
2725
|
e,
|
|
2682
2726
|
t,
|
|
2683
2727
|
{
|
|
@@ -2691,7 +2735,7 @@ class Ve {
|
|
|
2691
2735
|
}
|
|
2692
2736
|
async put(e, t, r, i, s) {
|
|
2693
2737
|
try {
|
|
2694
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2738
|
+
const o = this.prepareHeaders(r, i), c = await X.put(e, ie.convertObjectToJson(t), {
|
|
2695
2739
|
headers: o,
|
|
2696
2740
|
...s
|
|
2697
2741
|
});
|
|
@@ -2703,7 +2747,7 @@ class Ve {
|
|
|
2703
2747
|
async putNoConvertId(e, t, r, i, s) {
|
|
2704
2748
|
try {
|
|
2705
2749
|
const o = this.prepareHeaders(r, i);
|
|
2706
|
-
return (await
|
|
2750
|
+
return (await X.put(e, t, {
|
|
2707
2751
|
headers: o,
|
|
2708
2752
|
...s
|
|
2709
2753
|
})).data;
|
|
@@ -2714,7 +2758,7 @@ class Ve {
|
|
|
2714
2758
|
async binaryPut(e, t, r = {}, i, s) {
|
|
2715
2759
|
try {
|
|
2716
2760
|
const o = this.prepareHeaders(r, i);
|
|
2717
|
-
return s = s || {}, (await
|
|
2761
|
+
return s = s || {}, (await X.put(e, t, {
|
|
2718
2762
|
headers: o,
|
|
2719
2763
|
...s
|
|
2720
2764
|
})).data;
|
|
@@ -2724,7 +2768,7 @@ class Ve {
|
|
|
2724
2768
|
}
|
|
2725
2769
|
async delete(e, t, r, i) {
|
|
2726
2770
|
try {
|
|
2727
|
-
const s = this.prepareHeaders(t, r), o = await
|
|
2771
|
+
const s = this.prepareHeaders(t, r), o = await X.delete(e, { headers: s, ...i });
|
|
2728
2772
|
return ie.convertJsonToObject(o.data);
|
|
2729
2773
|
} catch (s) {
|
|
2730
2774
|
return Promise.reject(s);
|
|
@@ -2732,7 +2776,7 @@ class Ve {
|
|
|
2732
2776
|
}
|
|
2733
2777
|
async patch(e, t, r, i, s) {
|
|
2734
2778
|
try {
|
|
2735
|
-
const o = this.prepareHeaders(r, i), c = await
|
|
2779
|
+
const o = this.prepareHeaders(r, i), c = await X.patch(e, ie.convertObjectToJson(t), {
|
|
2736
2780
|
headers: o,
|
|
2737
2781
|
...s
|
|
2738
2782
|
});
|
|
@@ -2744,7 +2788,7 @@ class Ve {
|
|
|
2744
2788
|
async patchNoConvertId(e, t, r, i, s) {
|
|
2745
2789
|
try {
|
|
2746
2790
|
const o = this.prepareHeaders(r, i);
|
|
2747
|
-
return (await
|
|
2791
|
+
return (await X.patch(e, t, {
|
|
2748
2792
|
headers: o,
|
|
2749
2793
|
...s
|
|
2750
2794
|
})).data;
|
|
@@ -2759,7 +2803,7 @@ class Ve {
|
|
|
2759
2803
|
async getBlob(e, t, r) {
|
|
2760
2804
|
try {
|
|
2761
2805
|
const i = this.prepareHeaders(t, r);
|
|
2762
|
-
return (await
|
|
2806
|
+
return (await X.get(e, {
|
|
2763
2807
|
headers: i,
|
|
2764
2808
|
responseType: "blob"
|
|
2765
2809
|
})).data;
|
|
@@ -2774,7 +2818,7 @@ class Ve {
|
|
|
2774
2818
|
async postBlob(e, t, r, i) {
|
|
2775
2819
|
try {
|
|
2776
2820
|
const s = this.prepareHeaders(r, i);
|
|
2777
|
-
return (await
|
|
2821
|
+
return (await X.post(e, t, {
|
|
2778
2822
|
headers: s,
|
|
2779
2823
|
responseType: "blob"
|
|
2780
2824
|
})).data;
|
|
@@ -2793,15 +2837,15 @@ class Ve {
|
|
|
2793
2837
|
const c = this.tokenManager.getToken();
|
|
2794
2838
|
c && (s.Authorization = `Bearer ${c.access_token}`);
|
|
2795
2839
|
}
|
|
2796
|
-
return (await
|
|
2840
|
+
return (await X.post(e, t, { headers: s })).data;
|
|
2797
2841
|
} catch (s) {
|
|
2798
2842
|
return Promise.reject(s);
|
|
2799
2843
|
}
|
|
2800
2844
|
}
|
|
2801
2845
|
}
|
|
2802
|
-
ne.decorate(ne.inject(
|
|
2803
|
-
ne.decorate(ne.injectable(),
|
|
2804
|
-
class
|
|
2846
|
+
ne.decorate(ne.inject(We.TokenManager), be, 0);
|
|
2847
|
+
ne.decorate(ne.injectable(), be);
|
|
2848
|
+
class Ke {
|
|
2805
2849
|
client;
|
|
2806
2850
|
constructor(e) {
|
|
2807
2851
|
this.client = e;
|
|
@@ -2901,8 +2945,8 @@ class Qe {
|
|
|
2901
2945
|
return this.client.delete(`${this.getEndpoint()}/${e}`, t, !1);
|
|
2902
2946
|
}
|
|
2903
2947
|
}
|
|
2904
|
-
ne.decorate(ne.injectable(),
|
|
2905
|
-
class
|
|
2948
|
+
ne.decorate(ne.injectable(), Ke);
|
|
2949
|
+
class le {
|
|
2906
2950
|
content;
|
|
2907
2951
|
pageable;
|
|
2908
2952
|
totalElements;
|
|
@@ -2914,8 +2958,8 @@ class ge {
|
|
|
2914
2958
|
first;
|
|
2915
2959
|
numberOfElements;
|
|
2916
2960
|
empty;
|
|
2917
|
-
constructor(e, t, r, i, s, o, c,
|
|
2918
|
-
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort = o || { sorted: !1, unsorted: !0, empty: !0 }, this.last = c !== void 0 ? c : i === r - 1, this.first =
|
|
2961
|
+
constructor(e, t, r, i, s, o, c, u, p, C) {
|
|
2962
|
+
this.content = e, this.totalElements = t, this.totalPages = r, this.number = i, this.size = s, this.sort = o || { sorted: !1, unsorted: !0, empty: !0 }, this.last = c !== void 0 ? c : i === r - 1, this.first = u !== void 0 ? u : i === 0, this.numberOfElements = p !== void 0 ? p : e.length, this.empty = C !== void 0 ? C : e.length === 0, this.pageable = {
|
|
2919
2963
|
sort: this.sort,
|
|
2920
2964
|
offset: i * s,
|
|
2921
2965
|
pageSize: s,
|
|
@@ -2925,19 +2969,19 @@ class ge {
|
|
|
2925
2969
|
};
|
|
2926
2970
|
}
|
|
2927
2971
|
static createFromValues(e, t, r, i, s) {
|
|
2928
|
-
return new
|
|
2972
|
+
return new le(e, t, r, i, s);
|
|
2929
2973
|
}
|
|
2930
2974
|
}
|
|
2931
|
-
function
|
|
2975
|
+
function Ye(n) {
|
|
2932
2976
|
return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
|
|
2933
2977
|
}
|
|
2934
|
-
function
|
|
2978
|
+
function Xe(n) {
|
|
2935
2979
|
return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
|
|
2936
2980
|
}
|
|
2937
|
-
function
|
|
2981
|
+
function Ze(n) {
|
|
2938
2982
|
return n.pageable ? n.pageable.pageNumber : n.page.number;
|
|
2939
2983
|
}
|
|
2940
|
-
function
|
|
2984
|
+
function Vt(n) {
|
|
2941
2985
|
const {
|
|
2942
2986
|
name: e,
|
|
2943
2987
|
label: t,
|
|
@@ -2946,28 +2990,28 @@ function Dt(n) {
|
|
|
2946
2990
|
sort: s,
|
|
2947
2991
|
transformData: o,
|
|
2948
2992
|
onLoadComplete: c,
|
|
2949
|
-
onDestroy:
|
|
2950
|
-
filterData:
|
|
2951
|
-
findAll:
|
|
2952
|
-
findAllWithSort:
|
|
2953
|
-
findAllWithFilter:
|
|
2954
|
-
findAllWithFilterAndSort:
|
|
2955
|
-
initialDataSource:
|
|
2956
|
-
pageSize:
|
|
2957
|
-
currentPage:
|
|
2958
|
-
loadOnStart:
|
|
2959
|
-
store:
|
|
2993
|
+
onDestroy: u,
|
|
2994
|
+
filterData: p,
|
|
2995
|
+
findAll: C,
|
|
2996
|
+
findAllWithSort: W,
|
|
2997
|
+
findAllWithFilter: M,
|
|
2998
|
+
findAllWithFilterAndSort: P,
|
|
2999
|
+
initialDataSource: L,
|
|
3000
|
+
pageSize: N = 50,
|
|
3001
|
+
currentPage: d = 0,
|
|
3002
|
+
loadOnStart: f = !0,
|
|
3003
|
+
store: b,
|
|
2960
3004
|
id: V,
|
|
2961
|
-
validator:
|
|
2962
|
-
} = n,
|
|
3005
|
+
validator: K
|
|
3006
|
+
} = n, m = ce(!1), h = () => !!(b && b.existsValue(e) || L), Y = () => b && b.existsValue(e) ? b.getValue(e) : L || new Ae(r, e, {
|
|
2963
3007
|
records: [],
|
|
2964
3008
|
grandTotalRecords: 0,
|
|
2965
|
-
currentPage:
|
|
3009
|
+
currentPage: d,
|
|
2966
3010
|
totalPages: 0,
|
|
2967
|
-
pageSize:
|
|
2968
|
-
validator:
|
|
2969
|
-
}, t), Z = () =>
|
|
2970
|
-
dataSource:
|
|
3011
|
+
pageSize: N,
|
|
3012
|
+
validator: K
|
|
3013
|
+
}, t), Z = () => b && b.existsValue(e) ? b.getValue(e).getCurrentPage() : L ? L.getCurrentPage() : 0, [E, j] = T({
|
|
3014
|
+
dataSource: Y(),
|
|
2971
3015
|
isLoading: !1,
|
|
2972
3016
|
isError: !1,
|
|
2973
3017
|
error: "",
|
|
@@ -2977,154 +3021,154 @@ function Dt(n) {
|
|
|
2977
3021
|
sort: s,
|
|
2978
3022
|
id: V,
|
|
2979
3023
|
currentPage: Z(),
|
|
2980
|
-
pageSize:
|
|
3024
|
+
pageSize: N,
|
|
2981
3025
|
loadDataCount: h() ? 1 : 0
|
|
2982
|
-
}), ee = async (
|
|
2983
|
-
let
|
|
2984
|
-
if (
|
|
2985
|
-
const
|
|
2986
|
-
|
|
3026
|
+
}), ee = async (y, w, x, $, v, J, te, oe, ae) => {
|
|
3027
|
+
let O;
|
|
3028
|
+
if (J) {
|
|
3029
|
+
const _ = await r.findOne(J);
|
|
3030
|
+
_ ? O = le.createFromValues([_], 1, 0, 0, 0) : O = le.createFromValues([], 0, 0, 0, 0);
|
|
2987
3031
|
} else
|
|
2988
|
-
|
|
2989
|
-
|
|
3032
|
+
P && $ && v && v.length > 0 ? O = await P($, w, x, v) : M && $ ? O = await M($, w, x) : W && v && v.length > 0 ? O = await W(w, x, v) : C ? O = await C(w, x) : $ && v && v.length > 0 ? O = await r.findAllWithFilterAndSort($, w, x, v) : $ ? O = await r.findAllWithFilter($, w, x) : v && v.length > 0 ? O = await r.findAllWithSort(w, x, v) : O = await r.findAll(w, x);
|
|
3033
|
+
p && (O = p(O)), o && (O = o(O)), j((_) => {
|
|
2990
3034
|
const re = {
|
|
2991
|
-
records:
|
|
2992
|
-
grandTotalRecords:
|
|
2993
|
-
totalPages:
|
|
2994
|
-
currentPage:
|
|
3035
|
+
records: O.content,
|
|
3036
|
+
grandTotalRecords: Ye(O),
|
|
3037
|
+
totalPages: Xe(O),
|
|
3038
|
+
currentPage: Ze(O),
|
|
2995
3039
|
pageSize: x,
|
|
2996
|
-
filter:
|
|
2997
|
-
sort:
|
|
3040
|
+
filter: $,
|
|
3041
|
+
sort: v,
|
|
2998
3042
|
originFilter: te,
|
|
2999
3043
|
originGlobalFilter: ae,
|
|
3000
3044
|
originSort: oe,
|
|
3001
|
-
validator:
|
|
3045
|
+
validator: K
|
|
3002
3046
|
};
|
|
3003
|
-
return
|
|
3004
|
-
...
|
|
3005
|
-
currentPage:
|
|
3047
|
+
return _.dataSource.isActive() ? _.dataSource.setData(re) : _.dataSource.open(re), {
|
|
3048
|
+
..._,
|
|
3049
|
+
currentPage: w,
|
|
3006
3050
|
pageSize: x,
|
|
3007
|
-
filter:
|
|
3008
|
-
sort:
|
|
3009
|
-
id:
|
|
3051
|
+
filter: $,
|
|
3052
|
+
sort: v,
|
|
3053
|
+
id: J,
|
|
3010
3054
|
isLoading: !1,
|
|
3011
3055
|
isError: !1,
|
|
3012
3056
|
error: "",
|
|
3013
|
-
loadDataCount:
|
|
3057
|
+
loadDataCount: _.loadDataCount + 1
|
|
3014
3058
|
};
|
|
3015
|
-
}),
|
|
3059
|
+
}), b && b.setValue(e, E.dataSource);
|
|
3016
3060
|
};
|
|
3017
|
-
|
|
3018
|
-
c &&
|
|
3019
|
-
}, [
|
|
3020
|
-
const D = l((
|
|
3021
|
-
if (
|
|
3022
|
-
const
|
|
3061
|
+
q(() => {
|
|
3062
|
+
c && E.loadDataCount > 0 && c(E.dataSource);
|
|
3063
|
+
}, [E.loadDataCount]);
|
|
3064
|
+
const D = l((y) => {
|
|
3065
|
+
if (y.type === a.refreshData) {
|
|
3066
|
+
const w = y.options;
|
|
3023
3067
|
try {
|
|
3024
|
-
|
|
3068
|
+
j((x) => ({
|
|
3025
3069
|
...x,
|
|
3026
3070
|
isLoading: !0,
|
|
3027
|
-
filter:
|
|
3028
|
-
sort:
|
|
3029
|
-
currentPage:
|
|
3030
|
-
id:
|
|
3071
|
+
filter: w.filter,
|
|
3072
|
+
sort: w.sort,
|
|
3073
|
+
currentPage: w.currentPage,
|
|
3074
|
+
id: w.id
|
|
3031
3075
|
})), ee(
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3076
|
+
E.name,
|
|
3077
|
+
w.currentPage,
|
|
3078
|
+
w.pageSize,
|
|
3079
|
+
w.filter,
|
|
3080
|
+
w.sort,
|
|
3081
|
+
w.id,
|
|
3082
|
+
w.originFilter,
|
|
3083
|
+
w.originSort,
|
|
3084
|
+
w.originGlobalFilter
|
|
3041
3085
|
).catch((x) => {
|
|
3042
|
-
const
|
|
3043
|
-
|
|
3044
|
-
...
|
|
3086
|
+
const $ = G(x);
|
|
3087
|
+
j((v) => ({
|
|
3088
|
+
...v,
|
|
3045
3089
|
isError: !0,
|
|
3046
3090
|
isLoading: !1,
|
|
3047
|
-
error:
|
|
3048
|
-
})), n.onError && n.onError(
|
|
3091
|
+
error: $
|
|
3092
|
+
})), n.onError && n.onError($, x);
|
|
3049
3093
|
});
|
|
3050
3094
|
} catch (x) {
|
|
3051
|
-
const
|
|
3052
|
-
|
|
3053
|
-
...
|
|
3095
|
+
const $ = G(x);
|
|
3096
|
+
j((v) => ({
|
|
3097
|
+
...v,
|
|
3054
3098
|
isError: !0,
|
|
3055
3099
|
isLoading: !1,
|
|
3056
|
-
error:
|
|
3057
|
-
})), n.onError && n.onError(
|
|
3100
|
+
error: $
|
|
3101
|
+
})), n.onError && n.onError($, x);
|
|
3058
3102
|
}
|
|
3059
3103
|
}
|
|
3060
|
-
}, [ee,
|
|
3061
|
-
|
|
3062
|
-
}, [D]), A = l((
|
|
3063
|
-
|
|
3104
|
+
}, [ee, E.name, n.onError]), S = l((y) => {
|
|
3105
|
+
m.current || (y.addListener(D), m.current = !0);
|
|
3106
|
+
}, [D]), A = l((y) => {
|
|
3107
|
+
m.current && (y.removeListener(D), m.current = !1);
|
|
3064
3108
|
}, [D]);
|
|
3065
|
-
|
|
3109
|
+
q(() => {
|
|
3066
3110
|
try {
|
|
3067
|
-
return E
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
).catch((
|
|
3075
|
-
const
|
|
3076
|
-
|
|
3111
|
+
return S(E.dataSource), f && E.loadDataCount === 0 ? (j((y) => ({ ...y, isLoading: !0 })), ee(
|
|
3112
|
+
E.name,
|
|
3113
|
+
d,
|
|
3114
|
+
N,
|
|
3115
|
+
E.filter,
|
|
3116
|
+
E.sort,
|
|
3117
|
+
E.id
|
|
3118
|
+
).catch((y) => {
|
|
3119
|
+
const w = G(y);
|
|
3120
|
+
j((x) => ({
|
|
3077
3121
|
...x,
|
|
3078
3122
|
isError: !0,
|
|
3079
3123
|
isLoading: !1,
|
|
3080
|
-
error:
|
|
3081
|
-
})), n.onError && n.onError(
|
|
3082
|
-
})) : c && c(
|
|
3083
|
-
|
|
3124
|
+
error: w
|
|
3125
|
+
})), n.onError && n.onError(w, y);
|
|
3126
|
+
})) : c && c(E.dataSource), () => {
|
|
3127
|
+
u && (A(E.dataSource), u(E.dataSource));
|
|
3084
3128
|
};
|
|
3085
|
-
} catch (
|
|
3086
|
-
const
|
|
3087
|
-
|
|
3129
|
+
} catch (y) {
|
|
3130
|
+
const w = G(y);
|
|
3131
|
+
j((x) => ({
|
|
3088
3132
|
...x,
|
|
3089
3133
|
isError: !0,
|
|
3090
3134
|
isLoading: !1,
|
|
3091
|
-
error:
|
|
3092
|
-
})), n.onError && n.onError(
|
|
3135
|
+
error: w
|
|
3136
|
+
})), n.onError && n.onError(w, y);
|
|
3093
3137
|
}
|
|
3094
3138
|
}, [
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3139
|
+
E.name,
|
|
3140
|
+
E.sort,
|
|
3141
|
+
E.filter,
|
|
3142
|
+
E.id,
|
|
3143
|
+
E.currentPage,
|
|
3144
|
+
E.pageSize
|
|
3101
3145
|
]);
|
|
3102
|
-
const
|
|
3103
|
-
|
|
3104
|
-
...
|
|
3146
|
+
const B = () => {
|
|
3147
|
+
j((y) => ({
|
|
3148
|
+
...y,
|
|
3105
3149
|
isError: !1,
|
|
3106
3150
|
isLoading: !1,
|
|
3107
3151
|
error: ""
|
|
3108
3152
|
}));
|
|
3109
3153
|
};
|
|
3110
3154
|
return {
|
|
3111
|
-
isLoading:
|
|
3112
|
-
isError:
|
|
3113
|
-
error:
|
|
3114
|
-
dataSource:
|
|
3115
|
-
clearError:
|
|
3155
|
+
isLoading: E.isLoading,
|
|
3156
|
+
isError: E.isError,
|
|
3157
|
+
error: E.error,
|
|
3158
|
+
dataSource: E.dataSource,
|
|
3159
|
+
clearError: B
|
|
3116
3160
|
};
|
|
3117
3161
|
}
|
|
3118
|
-
function
|
|
3162
|
+
function et(n) {
|
|
3119
3163
|
return n.totalElements || n.totalElements === 0 ? n.totalElements : n.page.totalElements;
|
|
3120
3164
|
}
|
|
3121
|
-
function
|
|
3165
|
+
function tt(n) {
|
|
3122
3166
|
return n.totalPages || n.totalPages === 0 ? n.totalPages : n.page.totalPages;
|
|
3123
3167
|
}
|
|
3124
|
-
function
|
|
3168
|
+
function rt(n) {
|
|
3125
3169
|
return n.pageable ? n.pageable.pageNumber : n.page.number;
|
|
3126
3170
|
}
|
|
3127
|
-
function
|
|
3171
|
+
function Tt(n) {
|
|
3128
3172
|
const {
|
|
3129
3173
|
name: e,
|
|
3130
3174
|
service: t,
|
|
@@ -3133,140 +3177,140 @@ function Vt(n) {
|
|
|
3133
3177
|
transformData: s,
|
|
3134
3178
|
onLoadComplete: o,
|
|
3135
3179
|
onDestroy: c,
|
|
3136
|
-
filterData:
|
|
3137
|
-
findAll:
|
|
3138
|
-
findAllWithSort:
|
|
3139
|
-
findAllWithFilter:
|
|
3140
|
-
findAllWithFilterAndSort:
|
|
3141
|
-
initialDataSource:
|
|
3142
|
-
pageSize:
|
|
3143
|
-
currentPage:
|
|
3144
|
-
loadOnStart:
|
|
3145
|
-
store:
|
|
3146
|
-
validator:
|
|
3147
|
-
} = n, V = () => !!(
|
|
3180
|
+
filterData: u,
|
|
3181
|
+
findAll: p,
|
|
3182
|
+
findAllWithSort: C,
|
|
3183
|
+
findAllWithFilter: W,
|
|
3184
|
+
findAllWithFilterAndSort: M,
|
|
3185
|
+
initialDataSource: P,
|
|
3186
|
+
pageSize: L = 50,
|
|
3187
|
+
currentPage: N = 0,
|
|
3188
|
+
loadOnStart: d = !0,
|
|
3189
|
+
store: f,
|
|
3190
|
+
validator: b
|
|
3191
|
+
} = n, V = () => !!(f && f.existsValue(e) || P), K = () => f && f.existsValue(e) ? f.getValue(e) : P || new Je(t, e, {
|
|
3148
3192
|
records: [],
|
|
3149
3193
|
grandTotalRecords: 0,
|
|
3150
|
-
currentPage:
|
|
3194
|
+
currentPage: N,
|
|
3151
3195
|
totalPages: 0,
|
|
3152
|
-
pageSize:
|
|
3153
|
-
validator:
|
|
3154
|
-
}), [
|
|
3155
|
-
dataSource:
|
|
3196
|
+
pageSize: L,
|
|
3197
|
+
validator: b
|
|
3198
|
+
}), [m, h] = T({
|
|
3199
|
+
dataSource: K(),
|
|
3156
3200
|
isLoading: !1,
|
|
3157
3201
|
isError: !1,
|
|
3158
3202
|
error: "",
|
|
3159
3203
|
name: e,
|
|
3160
3204
|
filter: r,
|
|
3161
3205
|
sort: i,
|
|
3162
|
-
currentPage:
|
|
3163
|
-
pageSize:
|
|
3206
|
+
currentPage: N,
|
|
3207
|
+
pageSize: L,
|
|
3164
3208
|
loadDataCount: V() ? 1 : 0
|
|
3165
|
-
}),
|
|
3166
|
-
let
|
|
3167
|
-
|
|
3209
|
+
}), Y = async (D, S, A, B, y, w, x, $) => {
|
|
3210
|
+
let v;
|
|
3211
|
+
M && B && y && y.length > 0 ? v = await M(B, S, A, y) : W && B ? v = await W(B, S, A) : C && y && y.length > 0 ? v = await C(S, A, y) : p ? v = await p(S, A) : B && y && y.length > 0 ? v = await t.findAllWithFilterAndSort(B, S, A, y) : B ? v = await t.findAllWithFilter(B, S, A) : y && y.length > 0 ? v = await t.findAllWithSort(S, A, y) : v = await t.findAll(S, A), u && (v = u(v)), s && (v = s(v)), h((J) => {
|
|
3168
3212
|
const te = {
|
|
3169
|
-
records:
|
|
3170
|
-
grandTotalRecords:
|
|
3171
|
-
totalPages:
|
|
3172
|
-
currentPage:
|
|
3213
|
+
records: v.content,
|
|
3214
|
+
grandTotalRecords: et(v),
|
|
3215
|
+
totalPages: tt(v),
|
|
3216
|
+
currentPage: rt(v),
|
|
3173
3217
|
pageSize: A,
|
|
3174
|
-
filter:
|
|
3175
|
-
sort:
|
|
3176
|
-
originFilter:
|
|
3177
|
-
originGlobalFilter:
|
|
3218
|
+
filter: B,
|
|
3219
|
+
sort: y,
|
|
3220
|
+
originFilter: w,
|
|
3221
|
+
originGlobalFilter: $,
|
|
3178
3222
|
originSort: x,
|
|
3179
|
-
validator:
|
|
3223
|
+
validator: b
|
|
3180
3224
|
};
|
|
3181
|
-
return
|
|
3182
|
-
...
|
|
3183
|
-
currentPage:
|
|
3225
|
+
return J.dataSource.isActive() ? J.dataSource.setData(te) : J.dataSource.open(te), {
|
|
3226
|
+
...J,
|
|
3227
|
+
currentPage: S,
|
|
3184
3228
|
pageSize: A,
|
|
3185
|
-
filter:
|
|
3186
|
-
sort:
|
|
3229
|
+
filter: B,
|
|
3230
|
+
sort: y,
|
|
3187
3231
|
isLoading: !1,
|
|
3188
3232
|
isError: !1,
|
|
3189
3233
|
error: "",
|
|
3190
|
-
loadDataCount:
|
|
3234
|
+
loadDataCount: J.loadDataCount + 1
|
|
3191
3235
|
};
|
|
3192
|
-
}),
|
|
3236
|
+
}), f && f.setValue(e, m.dataSource), o && o(m.dataSource);
|
|
3193
3237
|
}, Z = (D) => {
|
|
3194
|
-
if (D.type ===
|
|
3195
|
-
const
|
|
3238
|
+
if (D.type === a.refreshData) {
|
|
3239
|
+
const S = D.options;
|
|
3196
3240
|
try {
|
|
3197
3241
|
h((A) => ({
|
|
3198
3242
|
...A,
|
|
3199
3243
|
isLoading: !0,
|
|
3200
|
-
filter:
|
|
3201
|
-
sort:
|
|
3202
|
-
currentPage:
|
|
3203
|
-
})),
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3244
|
+
filter: S.filter,
|
|
3245
|
+
sort: S.sort,
|
|
3246
|
+
currentPage: S.currentPage
|
|
3247
|
+
})), Y(
|
|
3248
|
+
m.name,
|
|
3249
|
+
S.currentPage,
|
|
3250
|
+
S.pageSize,
|
|
3251
|
+
S.filter,
|
|
3252
|
+
S.sort,
|
|
3253
|
+
S.originFilter,
|
|
3254
|
+
S.originSort,
|
|
3255
|
+
S.originGlobalFilter
|
|
3212
3256
|
).catch((A) => {
|
|
3213
|
-
const
|
|
3214
|
-
h((
|
|
3215
|
-
...
|
|
3257
|
+
const B = G(A);
|
|
3258
|
+
h((y) => ({
|
|
3259
|
+
...y,
|
|
3216
3260
|
isError: !0,
|
|
3217
3261
|
isLoading: !1,
|
|
3218
|
-
error:
|
|
3219
|
-
})), n.onError && n.onError(
|
|
3262
|
+
error: B
|
|
3263
|
+
})), n.onError && n.onError(B, A);
|
|
3220
3264
|
});
|
|
3221
3265
|
} catch (A) {
|
|
3222
|
-
const
|
|
3223
|
-
h((
|
|
3224
|
-
...
|
|
3266
|
+
const B = G(A);
|
|
3267
|
+
h((y) => ({
|
|
3268
|
+
...y,
|
|
3225
3269
|
isError: !0,
|
|
3226
3270
|
isLoading: !1,
|
|
3227
|
-
error:
|
|
3228
|
-
})), n.onError && n.onError(
|
|
3271
|
+
error: B
|
|
3272
|
+
})), n.onError && n.onError(B, A);
|
|
3229
3273
|
}
|
|
3230
3274
|
}
|
|
3231
|
-
},
|
|
3275
|
+
}, E = (D) => {
|
|
3232
3276
|
D.addListener(Z);
|
|
3233
|
-
},
|
|
3277
|
+
}, j = (D) => {
|
|
3234
3278
|
D.removeListener(Z);
|
|
3235
3279
|
};
|
|
3236
|
-
|
|
3280
|
+
q(() => {
|
|
3237
3281
|
try {
|
|
3238
|
-
return
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3282
|
+
return E(m.dataSource), d && m.loadDataCount === 0 && (h((D) => ({ ...D, isLoading: !0 })), Y(
|
|
3283
|
+
m.name,
|
|
3284
|
+
N,
|
|
3285
|
+
L,
|
|
3286
|
+
m.filter,
|
|
3287
|
+
m.sort
|
|
3244
3288
|
).catch((D) => {
|
|
3245
|
-
const
|
|
3289
|
+
const S = G(D);
|
|
3246
3290
|
h((A) => ({
|
|
3247
3291
|
...A,
|
|
3248
3292
|
isError: !0,
|
|
3249
3293
|
isLoading: !1,
|
|
3250
|
-
error:
|
|
3251
|
-
})), n.onError && n.onError(
|
|
3294
|
+
error: S
|
|
3295
|
+
})), n.onError && n.onError(S, D);
|
|
3252
3296
|
})), () => {
|
|
3253
|
-
c && (
|
|
3297
|
+
c && (j(m.dataSource), c(m.dataSource));
|
|
3254
3298
|
};
|
|
3255
3299
|
} catch (D) {
|
|
3256
|
-
const
|
|
3300
|
+
const S = G(D);
|
|
3257
3301
|
h((A) => ({
|
|
3258
3302
|
...A,
|
|
3259
3303
|
isError: !0,
|
|
3260
3304
|
isLoading: !1,
|
|
3261
|
-
error:
|
|
3262
|
-
})), n.onError && n.onError(
|
|
3305
|
+
error: S
|
|
3306
|
+
})), n.onError && n.onError(S, D);
|
|
3263
3307
|
}
|
|
3264
3308
|
}, [
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3309
|
+
m.name,
|
|
3310
|
+
m.sort,
|
|
3311
|
+
m.filter,
|
|
3312
|
+
m.currentPage,
|
|
3313
|
+
m.pageSize
|
|
3270
3314
|
]);
|
|
3271
3315
|
const ee = () => {
|
|
3272
3316
|
h((D) => ({
|
|
@@ -3277,46 +3321,46 @@ function Vt(n) {
|
|
|
3277
3321
|
}));
|
|
3278
3322
|
};
|
|
3279
3323
|
return {
|
|
3280
|
-
isLoading:
|
|
3281
|
-
isError:
|
|
3282
|
-
error:
|
|
3283
|
-
dataSource:
|
|
3324
|
+
isLoading: m.isLoading,
|
|
3325
|
+
isError: m.isError,
|
|
3326
|
+
error: m.error,
|
|
3327
|
+
dataSource: m.dataSource,
|
|
3284
3328
|
clearError: ee
|
|
3285
3329
|
};
|
|
3286
3330
|
}
|
|
3287
|
-
function Tt(n) {
|
|
3288
|
-
return ze((e) => e.get(n));
|
|
3289
|
-
}
|
|
3290
3331
|
function Ot(n) {
|
|
3291
|
-
|
|
3332
|
+
return Me((e) => e.get(n));
|
|
3333
|
+
}
|
|
3334
|
+
function Pt(n) {
|
|
3335
|
+
q(() => {
|
|
3292
3336
|
n();
|
|
3293
3337
|
}, []);
|
|
3294
3338
|
}
|
|
3295
|
-
function
|
|
3296
|
-
|
|
3339
|
+
function Lt(n, e) {
|
|
3340
|
+
q(() => {
|
|
3297
3341
|
n();
|
|
3298
3342
|
}, e);
|
|
3299
3343
|
}
|
|
3300
|
-
function
|
|
3301
|
-
|
|
3344
|
+
function Bt(n) {
|
|
3345
|
+
q(() => () => {
|
|
3302
3346
|
n();
|
|
3303
3347
|
}, []);
|
|
3304
3348
|
}
|
|
3305
|
-
function
|
|
3306
|
-
const [, n] =
|
|
3349
|
+
function $t() {
|
|
3350
|
+
const [, n] = T(0);
|
|
3307
3351
|
return l(() => {
|
|
3308
3352
|
n((t) => t + 1);
|
|
3309
3353
|
}, []);
|
|
3310
3354
|
}
|
|
3311
|
-
const
|
|
3312
|
-
function
|
|
3313
|
-
const [, n] =
|
|
3355
|
+
const it = (n) => (n + 1) % 1e6;
|
|
3356
|
+
function st() {
|
|
3357
|
+
const [, n] = ze(it, 0);
|
|
3314
3358
|
return n;
|
|
3315
3359
|
}
|
|
3316
|
-
function
|
|
3317
|
-
return
|
|
3360
|
+
function Nt() {
|
|
3361
|
+
return st();
|
|
3318
3362
|
}
|
|
3319
|
-
const
|
|
3363
|
+
const nt = je((n, e) => ({
|
|
3320
3364
|
values: /* @__PURE__ */ new Map(),
|
|
3321
3365
|
setValue: (t, r) => n((i) => {
|
|
3322
3366
|
const s = new Map(i.values);
|
|
@@ -3330,24 +3374,24 @@ const st = Me((n, e) => ({
|
|
|
3330
3374
|
}),
|
|
3331
3375
|
clearAllValues: () => n((t) => ({ values: /* @__PURE__ */ new Map() })),
|
|
3332
3376
|
reset: () => n((t) => ({ values: /* @__PURE__ */ new Map() }))
|
|
3333
|
-
})),
|
|
3334
|
-
const e =
|
|
3335
|
-
return { setValue: (
|
|
3336
|
-
e.setValue(`${n}.${
|
|
3337
|
-
}, getValue: (
|
|
3338
|
-
e.clearValue(`${n}.${
|
|
3339
|
-
}, existsValue: (
|
|
3340
|
-
for (const [
|
|
3341
|
-
|
|
3377
|
+
})), ot = ke(nt), Ht = (n = "default") => {
|
|
3378
|
+
const e = ot();
|
|
3379
|
+
return { setValue: (p, C) => {
|
|
3380
|
+
e.setValue(`${n}.${p}`, C);
|
|
3381
|
+
}, getValue: (p) => e.getValue(`${n}.${p}`), clearValue: (p) => {
|
|
3382
|
+
e.clearValue(`${n}.${p}`);
|
|
3383
|
+
}, existsValue: (p) => e.existsValue(`${n}.${p}`), clearAllValues: () => {
|
|
3384
|
+
for (const [p, C] of e.values.entries())
|
|
3385
|
+
p.startsWith(`${n}.`) && e.clearValue(p);
|
|
3342
3386
|
}, reset: () => {
|
|
3343
3387
|
e.clearAllValues();
|
|
3344
3388
|
}, values: e.values };
|
|
3345
3389
|
};
|
|
3346
|
-
function
|
|
3347
|
-
const r =
|
|
3348
|
-
|
|
3390
|
+
function Wt(n, e, t = window) {
|
|
3391
|
+
const r = ce(e);
|
|
3392
|
+
q(() => {
|
|
3349
3393
|
r.current = e;
|
|
3350
|
-
}, [e]),
|
|
3394
|
+
}, [e]), q(
|
|
3351
3395
|
() => {
|
|
3352
3396
|
if (t && t.addEventListener && r.current) {
|
|
3353
3397
|
const s = (o) => r.current(o);
|
|
@@ -3361,46 +3405,46 @@ function Ht(n, e, t = window) {
|
|
|
3361
3405
|
);
|
|
3362
3406
|
}
|
|
3363
3407
|
export {
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3408
|
+
jt as ADVANCED,
|
|
3409
|
+
kt as ARCHBASE_IOC_API_TYPE,
|
|
3410
|
+
xt as ARCHBASE_QUERY_DEFAULTS,
|
|
3411
|
+
be as ArchbaseAxiosRemoteApiClient,
|
|
3412
|
+
ye as ArchbaseDataSource,
|
|
3413
|
+
U as ArchbaseDataSourceV2,
|
|
3370
3414
|
Ge as ArchbaseLocalFilterDataSource,
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3415
|
+
At as ArchbaseQueryUtils,
|
|
3416
|
+
Ke as ArchbaseRemoteApiService,
|
|
3417
|
+
Ae as ArchbaseRemoteDataSource,
|
|
3418
|
+
Qe as ArchbaseRemoteDataSourceV2,
|
|
3419
|
+
Je as ArchbaseRemoteFilterDataSource,
|
|
3420
|
+
a as DataSourceEventNames,
|
|
3421
|
+
le as DefaultPage,
|
|
3422
|
+
Ut as FILTER_TYPE,
|
|
3423
|
+
_e as LocalFilter,
|
|
3424
|
+
vt as MigrationValidation,
|
|
3425
|
+
_t as NORMAL,
|
|
3382
3426
|
Gt as QUICK,
|
|
3383
3427
|
qe as RemoteFilter,
|
|
3384
|
-
|
|
3428
|
+
It as USAGE_EXAMPLE,
|
|
3385
3429
|
qt as useArchbaseBool,
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3430
|
+
Ct as useArchbaseDataSource,
|
|
3431
|
+
bt as useArchbaseDataSourceListener,
|
|
3432
|
+
xe as useArchbaseDataSourceV2,
|
|
3433
|
+
Et as useArchbaseDataSourceV2Editor,
|
|
3434
|
+
wt as useArchbaseDataSourceV2ReadOnly,
|
|
3435
|
+
Pt as useArchbaseDidMount,
|
|
3436
|
+
Lt as useArchbaseDidUpdate,
|
|
3437
|
+
Wt as useArchbaseEventListener,
|
|
3438
|
+
$t as useArchbaseForceRerender,
|
|
3439
|
+
Nt as useArchbaseForceUpdate,
|
|
3440
|
+
Dt as useArchbaseLocalFilterDataSource,
|
|
3441
|
+
Vt as useArchbaseRemoteDataSource,
|
|
3442
|
+
Ce as useArchbaseRemoteDataSourceV2,
|
|
3443
|
+
Ft as useArchbaseRemoteDataSourceV2Editor,
|
|
3444
|
+
St as useArchbaseRemoteDataSourceV2ReadOnly,
|
|
3445
|
+
Tt as useArchbaseRemoteFilterDataSource,
|
|
3446
|
+
Ot as useArchbaseRemoteServiceApi,
|
|
3447
|
+
Ht as useArchbaseStore,
|
|
3448
|
+
yt as useArchbaseV1V2Compatibility,
|
|
3449
|
+
Bt as useArchbaseWillUnmount
|
|
3406
3450
|
};
|