@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-kb-67792.3 → 0.0.0-bugfix-dev-KB-71601.0
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/cjs/{IExporterProvider-10b7fed5.js → IExporterProvider-a6e2acaa.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-d4873076.js → dataunit-fetcher-4c0d1485.js} +25 -11
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +39 -22
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-f0221097.js → snk-data-unit-054841d2.js} +3 -2
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-filter-bar.cjs.entry.js +14 -15
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-aafc3073.js → snk-guides-viewer-58907f8d.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +2 -2
- package/dist/collection/components/snk-attach/snk-attach.js +24 -15
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +8 -2
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +2 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +14 -15
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +17 -3
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +9 -9
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
- package/dist/components/dataunit-fetcher.js +25 -11
- package/dist/components/snk-attach2.js +38 -21
- package/dist/components/snk-data-unit2.js +2 -1
- package/dist/components/snk-filter-bar2.js +14 -15
- package/dist/esm/{IExporterProvider-d597f27d.js → IExporterProvider-66c83d70.js} +1 -1
- package/dist/esm/{dataunit-fetcher-3d2ec959.js → dataunit-fetcher-1c1cdd90.js} +25 -11
- package/dist/esm/snk-actions-button_4.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +39 -22
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-1ef94aef.js → snk-data-unit-a0a8b82a.js} +3 -2
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-filter-bar.entry.js +14 -15
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-62124f3d.js → snk-guides-viewer-5fe10c89.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +2 -2
- package/dist/sankhyablocks/{p-70001ac1.js → p-1b64a684.js} +1 -1
- package/dist/sankhyablocks/{p-0c68f40f.entry.js → p-42bd6a34.entry.js} +1 -1
- package/dist/sankhyablocks/p-449df4bf.entry.js +1 -0
- package/dist/sankhyablocks/p-5b26cc7c.entry.js +1 -0
- package/dist/sankhyablocks/{p-d65d98ed.entry.js → p-67525bf6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-74c665d5.entry.js → p-7a0d7901.entry.js} +1 -1
- package/dist/sankhyablocks/{p-421bec84.entry.js → p-812e5d2e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-51999ab5.entry.js → p-8c8ad7b9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-8c1ff936.entry.js → p-959fdc87.entry.js} +1 -1
- package/dist/sankhyablocks/{p-162b9a59.entry.js → p-9c5e0d8a.entry.js} +1 -1
- package/dist/sankhyablocks/p-a4c04730.js +60 -0
- package/dist/sankhyablocks/{p-094eebf6.entry.js → p-b6f1135c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-76a65660.js → p-c0b3a683.js} +1 -1
- package/dist/sankhyablocks/{p-c273d6ee.js → p-e6ab759c.js} +1 -1
- package/dist/sankhyablocks/{p-08c28ddd.entry.js → p-fb5798b4.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +1 -1
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +6 -1
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
- package/package.json +1 -1
- package/dist/sankhyablocks/p-091ce761.js +0 -60
- package/dist/sankhyablocks/p-42f7b05d.entry.js +0 -1
- package/dist/sankhyablocks/p-6c364d25.entry.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChangeOperation, DataType, DataUnit, DateUtils, StringUtils, } from '@sankhyalabs/core';
|
|
2
|
-
import { applyFilter, applySorting, buildPaginationInfo } from './dataUnitInMemoryUtils';
|
|
2
|
+
import { applyFilter, applySorting, buildPaginationInfo, } from './dataUnitInMemoryUtils';
|
|
3
3
|
export default class InMemoryLoader {
|
|
4
4
|
constructor(metadata, records, config) {
|
|
5
5
|
this.metadata = metadata;
|
|
@@ -82,9 +82,23 @@ export default class InMemoryLoader {
|
|
|
82
82
|
return StringUtils.generateUUID();
|
|
83
83
|
}
|
|
84
84
|
inMemoryLoader(dataUnit, request, recordsIn) {
|
|
85
|
-
let records =
|
|
85
|
+
let records = recordsIn ? [...recordsIn] : [];
|
|
86
|
+
records = applyFilter(records, dataUnit, request.filters);
|
|
86
87
|
records = applySorting(records, dataUnit, request.sort);
|
|
87
|
-
|
|
88
|
+
const { offset, limit } = request;
|
|
89
|
+
let pageRecords = records ? [...records] : [];
|
|
90
|
+
if (records && offset >= 0 && limit >= 0) {
|
|
91
|
+
pageRecords = records.slice(offset, offset + limit);
|
|
92
|
+
}
|
|
93
|
+
const paginationInfoBuilderParams = {
|
|
94
|
+
recordsLength: records.length,
|
|
95
|
+
offset,
|
|
96
|
+
recordsPerPage: limit
|
|
97
|
+
};
|
|
98
|
+
return Promise.resolve({
|
|
99
|
+
records: pageRecords,
|
|
100
|
+
paginationInfo: buildPaginationInfo(paginationInfoBuilderParams)
|
|
101
|
+
});
|
|
88
102
|
}
|
|
89
103
|
metadaLoader() {
|
|
90
104
|
return Promise.resolve(this._metadata);
|
|
@@ -21,17 +21,17 @@ export function applySorting(records, dataUnit, sorting) {
|
|
|
21
21
|
}
|
|
22
22
|
return records.sort(sortingFunction);
|
|
23
23
|
}
|
|
24
|
-
export function buildPaginationInfo(
|
|
25
|
-
if (
|
|
26
|
-
return
|
|
24
|
+
export function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
|
25
|
+
if (!recordsLength) {
|
|
26
|
+
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
const lastRecord = Math.min(
|
|
28
|
+
const lastRecordIndex = offset + recordsPerPage;
|
|
29
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
|
30
30
|
return {
|
|
31
|
-
currentPage:
|
|
32
|
-
firstRecord: offset,
|
|
31
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
|
32
|
+
firstRecord: offset + 1,
|
|
33
33
|
lastRecord: lastRecord,
|
|
34
|
-
total:
|
|
35
|
-
hasMore:
|
|
34
|
+
total: recordsLength,
|
|
35
|
+
hasMore: lastRecord < recordsLength,
|
|
36
36
|
};
|
|
37
37
|
}
|
package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js
CHANGED
|
@@ -6,21 +6,23 @@ const SERVICE = {
|
|
|
6
6
|
download: "AnexoSistemaSP.baixar",
|
|
7
7
|
};
|
|
8
8
|
export class AnexoSistemaFetcher {
|
|
9
|
-
constructor(entityName,
|
|
9
|
+
constructor(entityName, dataUnitName) {
|
|
10
10
|
var _a;
|
|
11
11
|
this.entityName = entityName;
|
|
12
|
-
this.registerKey = registerKey;
|
|
13
12
|
this.dataUnitName = dataUnitName;
|
|
14
13
|
this.validateFields = (fields) => {
|
|
15
14
|
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
|
16
15
|
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
|
17
16
|
if (!fields.LINK && !fields.NOMEARQUIVO)
|
|
18
17
|
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
|
19
|
-
if (!this.
|
|
18
|
+
if (!this._registerKey)
|
|
20
19
|
throw new Error('Register key can not be null');
|
|
21
20
|
};
|
|
22
21
|
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
|
23
22
|
}
|
|
23
|
+
set registerKey(registerKey) {
|
|
24
|
+
this._registerKey = registerKey;
|
|
25
|
+
}
|
|
24
26
|
async save(change) {
|
|
25
27
|
var _a, _b;
|
|
26
28
|
let { updatingFields: fields } = change;
|
|
@@ -39,7 +41,7 @@ export class AnexoSistemaFetcher {
|
|
|
39
41
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
40
42
|
link: fields.LINK,
|
|
41
43
|
nameEntity: this.entityName,
|
|
42
|
-
pkEntity: this.
|
|
44
|
+
pkEntity: this._registerKey,
|
|
43
45
|
typeAcess: fields.TIPOACESSO,
|
|
44
46
|
typeApres: fields.TIPOAPRES,
|
|
45
47
|
}
|
|
@@ -79,7 +81,7 @@ export class AnexoSistemaFetcher {
|
|
|
79
81
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
80
82
|
link: fields.LINK,
|
|
81
83
|
nameEntity: this.entityName,
|
|
82
|
-
pkEntity: this.
|
|
84
|
+
pkEntity: this._registerKey,
|
|
83
85
|
typeAcess: fields.TIPOACESSO,
|
|
84
86
|
typeApres: fields.TIPOAPRES,
|
|
85
87
|
}
|
|
@@ -245,18 +245,18 @@ function applySorting(records, dataUnit, sorting) {
|
|
|
245
245
|
}
|
|
246
246
|
return records.sort(sortingFunction);
|
|
247
247
|
}
|
|
248
|
-
function buildPaginationInfo(
|
|
249
|
-
if (
|
|
250
|
-
return
|
|
248
|
+
function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
|
249
|
+
if (!recordsLength) {
|
|
250
|
+
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
const lastRecord = Math.min(
|
|
252
|
+
const lastRecordIndex = offset + recordsPerPage;
|
|
253
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
|
254
254
|
return {
|
|
255
|
-
currentPage:
|
|
256
|
-
firstRecord: offset,
|
|
255
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
|
256
|
+
firstRecord: offset + 1,
|
|
257
257
|
lastRecord: lastRecord,
|
|
258
|
-
total:
|
|
259
|
-
hasMore:
|
|
258
|
+
total: recordsLength,
|
|
259
|
+
hasMore: lastRecord < recordsLength,
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -342,9 +342,23 @@ class InMemoryLoader {
|
|
|
342
342
|
return StringUtils.generateUUID();
|
|
343
343
|
}
|
|
344
344
|
inMemoryLoader(dataUnit, request, recordsIn) {
|
|
345
|
-
let records =
|
|
345
|
+
let records = recordsIn ? [...recordsIn] : [];
|
|
346
|
+
records = applyFilter(records, dataUnit, request.filters);
|
|
346
347
|
records = applySorting(records, dataUnit, request.sort);
|
|
347
|
-
|
|
348
|
+
const { offset, limit } = request;
|
|
349
|
+
let pageRecords = records ? [...records] : [];
|
|
350
|
+
if (records && offset >= 0 && limit >= 0) {
|
|
351
|
+
pageRecords = records.slice(offset, offset + limit);
|
|
352
|
+
}
|
|
353
|
+
const paginationInfoBuilderParams = {
|
|
354
|
+
recordsLength: records.length,
|
|
355
|
+
offset,
|
|
356
|
+
recordsPerPage: limit
|
|
357
|
+
};
|
|
358
|
+
return Promise.resolve({
|
|
359
|
+
records: pageRecords,
|
|
360
|
+
paginationInfo: buildPaginationInfo(paginationInfoBuilderParams)
|
|
361
|
+
});
|
|
348
362
|
}
|
|
349
363
|
metadaLoader() {
|
|
350
364
|
return Promise.resolve(this._metadata);
|
|
@@ -119,21 +119,23 @@ const SERVICE = {
|
|
|
119
119
|
download: "AnexoSistemaSP.baixar",
|
|
120
120
|
};
|
|
121
121
|
class AnexoSistemaFetcher {
|
|
122
|
-
constructor(entityName,
|
|
122
|
+
constructor(entityName, dataUnitName) {
|
|
123
123
|
var _a;
|
|
124
124
|
this.entityName = entityName;
|
|
125
|
-
this.registerKey = registerKey;
|
|
126
125
|
this.dataUnitName = dataUnitName;
|
|
127
126
|
this.validateFields = (fields) => {
|
|
128
127
|
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
|
129
128
|
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
|
130
129
|
if (!fields.LINK && !fields.NOMEARQUIVO)
|
|
131
130
|
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
|
132
|
-
if (!this.
|
|
131
|
+
if (!this._registerKey)
|
|
133
132
|
throw new Error('Register key can not be null');
|
|
134
133
|
};
|
|
135
134
|
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
|
136
135
|
}
|
|
136
|
+
set registerKey(registerKey) {
|
|
137
|
+
this._registerKey = registerKey;
|
|
138
|
+
}
|
|
137
139
|
async save(change) {
|
|
138
140
|
var _a, _b;
|
|
139
141
|
let { updatingFields: fields } = change;
|
|
@@ -152,7 +154,7 @@ class AnexoSistemaFetcher {
|
|
|
152
154
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
153
155
|
link: fields.LINK,
|
|
154
156
|
nameEntity: this.entityName,
|
|
155
|
-
pkEntity: this.
|
|
157
|
+
pkEntity: this._registerKey,
|
|
156
158
|
typeAcess: fields.TIPOACESSO,
|
|
157
159
|
typeApres: fields.TIPOAPRES,
|
|
158
160
|
}
|
|
@@ -192,7 +194,7 @@ class AnexoSistemaFetcher {
|
|
|
192
194
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
193
195
|
link: fields.LINK,
|
|
194
196
|
nameEntity: this.entityName,
|
|
195
|
-
pkEntity: this.
|
|
197
|
+
pkEntity: this._registerKey,
|
|
196
198
|
typeAcess: fields.TIPOACESSO,
|
|
197
199
|
typeApres: fields.TIPOAPRES,
|
|
198
200
|
}
|
|
@@ -466,7 +468,13 @@ class AttachFetcherDataUnitFactory {
|
|
|
466
468
|
}
|
|
467
469
|
let records = applyFilter(this._records, dataUnit, request.filters);
|
|
468
470
|
records = applySorting(records, dataUnit, request.sort);
|
|
469
|
-
|
|
471
|
+
//TODO: não está sendo tratada a paginação nesse caso, é preciso replicar a lógica como no inMemoryLoader
|
|
472
|
+
const paginationInfoBuilderParams = {
|
|
473
|
+
recordsLength: records.length,
|
|
474
|
+
offset: request.offset,
|
|
475
|
+
recordsPerPage: request.limit
|
|
476
|
+
};
|
|
477
|
+
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(paginationInfoBuilderParams) });
|
|
470
478
|
}
|
|
471
479
|
saveLoader(changes, fetcher) {
|
|
472
480
|
return new Promise((resolve) => {
|
|
@@ -663,11 +671,20 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
663
671
|
this.loadAttachmentDataUnit();
|
|
664
672
|
}
|
|
665
673
|
if (oldRegisterKey !== newRegisterKey) {
|
|
674
|
+
if (this._currentFetcher instanceof AnexoSistemaFetcher) {
|
|
675
|
+
this._currentFetcher.registerKey = newRegisterKey;
|
|
676
|
+
}
|
|
666
677
|
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData());
|
|
667
678
|
}
|
|
668
679
|
}
|
|
680
|
+
getAnexoSistemaFetcherInstance() {
|
|
681
|
+
var _a;
|
|
682
|
+
const anexoSistemaFetcher = new AnexoSistemaFetcher(this.entityName, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
|
683
|
+
anexoSistemaFetcher.registerKey = this.registerKey;
|
|
684
|
+
return anexoSistemaFetcher;
|
|
685
|
+
}
|
|
669
686
|
async initAttach() {
|
|
670
|
-
var _a, _b, _c, _d, _e
|
|
687
|
+
var _a, _b, _c, _d, _e;
|
|
671
688
|
if (!this.fetcherType && !this.registerKey)
|
|
672
689
|
return;
|
|
673
690
|
if (!this.fetcherType) {
|
|
@@ -675,18 +692,18 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
675
692
|
}
|
|
676
693
|
this.returnToGridMode();
|
|
677
694
|
if (this.fetcherType === "AnexoSistema") {
|
|
678
|
-
this._currentFetcher =
|
|
679
|
-
(
|
|
680
|
-
await ((
|
|
695
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
696
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
|
697
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
|
681
698
|
return;
|
|
682
699
|
}
|
|
683
700
|
if (this.fetcherType === "Attach") {
|
|
684
|
-
const hasMoreOneItem = ((
|
|
701
|
+
const hasMoreOneItem = ((_c = this.registerKey) === null || _c === void 0 ? void 0 : _c.split("_").length) > 1;
|
|
685
702
|
if (hasMoreOneItem)
|
|
686
703
|
return;
|
|
687
704
|
}
|
|
688
|
-
await ((
|
|
689
|
-
await ((
|
|
705
|
+
await ((_d = this._currentDataUnit) === null || _d === void 0 ? void 0 : _d.loadMetadata());
|
|
706
|
+
await ((_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadData(undefined, undefined, true, this.registerKey));
|
|
690
707
|
}
|
|
691
708
|
/**
|
|
692
709
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
@@ -745,11 +762,11 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
745
762
|
}
|
|
746
763
|
}
|
|
747
764
|
async loadAnexoSistema() {
|
|
748
|
-
var _a, _b
|
|
765
|
+
var _a, _b;
|
|
749
766
|
this._currentDataUnit = new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
|
750
|
-
this._currentFetcher =
|
|
767
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
751
768
|
if (!this._currentDataUnit.metadata) {
|
|
752
|
-
await ((
|
|
769
|
+
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
|
|
753
770
|
this.crudConfig = Object.assign({}, anexoSistemaCrudConfig);
|
|
754
771
|
}
|
|
755
772
|
this.initDataUnitLoaders();
|
|
@@ -759,7 +776,7 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
759
776
|
this._currentDataUnit.addInterceptor({
|
|
760
777
|
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
|
761
778
|
});
|
|
762
|
-
await ((
|
|
779
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
|
763
780
|
this.disableEditFieldsNotInForm();
|
|
764
781
|
}
|
|
765
782
|
async loadAttach() {
|
|
@@ -785,16 +802,16 @@ const SnkAttach = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
785
802
|
}
|
|
786
803
|
}
|
|
787
804
|
initDataUnitLoaders() {
|
|
788
|
-
var _a, _b
|
|
805
|
+
var _a, _b;
|
|
789
806
|
if (this.fetcherType === "AnexoSistema") {
|
|
790
|
-
this._currentFetcher =
|
|
807
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
791
808
|
this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
|
|
792
|
-
(
|
|
809
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
|
793
810
|
}
|
|
794
811
|
if (this.fetcherType === "Attach") {
|
|
795
812
|
this._currentFetcher = new AttachFetcher();
|
|
796
813
|
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
|
797
|
-
(
|
|
814
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
|
798
815
|
this.returnToGridMode();
|
|
799
816
|
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
|
800
817
|
});
|
|
@@ -596,7 +596,8 @@ const SnkDataUnit = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
|
596
596
|
if (forceMetadataLoad || !this.dataUnit.metadata)
|
|
597
597
|
await this.dataUnit.loadMetadata();
|
|
598
598
|
if ((_a = this.dataUnit.records) === null || _a === void 0 ? void 0 : _a.length) {
|
|
599
|
-
this.getMetadataByRow(this.dataUnit);
|
|
599
|
+
const { records } = this.getMetadataByRow(this.dataUnit);
|
|
600
|
+
this.dataUnit.records = records;
|
|
600
601
|
}
|
|
601
602
|
this.dataState = this.buildDataState();
|
|
602
603
|
let resolver;
|
|
@@ -267,13 +267,13 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
267
267
|
this._pendingVariables = false;
|
|
268
268
|
this._customfiltersToBeUpdated = [];
|
|
269
269
|
this._calculateSortIndex = (item) => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
270
|
+
if (!item.visible)
|
|
271
|
+
return 0;
|
|
272
|
+
if (item.hardFixed)
|
|
273
|
+
return 1000000; //campos Hard Fixed não variam a ordem
|
|
274
|
+
let index = item.fixed ? 100000 : 0;
|
|
275
|
+
index += this.hasValidValue(item) ? 10000 : 0;
|
|
276
|
+
index += this._updateSequence.lastIndexOf(item.id) + 1;
|
|
277
277
|
return index;
|
|
278
278
|
};
|
|
279
279
|
this._filtersComparator = (a, b) => {
|
|
@@ -294,13 +294,12 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
294
294
|
this.showPersonalizedFilter = false;
|
|
295
295
|
this.personalizedFilterId = undefined;
|
|
296
296
|
}
|
|
297
|
-
|
|
298
|
-
if (item.value
|
|
299
|
-
return
|
|
300
|
-
if (
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return index;
|
|
297
|
+
hasValidValue(item) {
|
|
298
|
+
if (item.value === undefined || item.value === null)
|
|
299
|
+
return false;
|
|
300
|
+
if (!Array.isArray(item.value))
|
|
301
|
+
return true;
|
|
302
|
+
return item.value.some(filterItem => filterItem.check === true);
|
|
304
303
|
}
|
|
305
304
|
observeFilterConfig(newValue, oldValue) {
|
|
306
305
|
if (ObjectUtils.equals(newValue, oldValue))
|
|
@@ -527,7 +526,7 @@ const SnkFilterBar = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement
|
|
|
527
526
|
getFilterItems() {
|
|
528
527
|
const pinnedItems = [];
|
|
529
528
|
const unpinnedItems = [];
|
|
530
|
-
this.filterConfig
|
|
529
|
+
this.filterConfig.sort((a, b) => this._filtersComparator(a, b))
|
|
531
530
|
.filter(this.filterActiveFilter)
|
|
532
531
|
.forEach((item, index) => {
|
|
533
532
|
item = ObjectUtils.copy(item);
|
|
@@ -5,7 +5,7 @@ import './index-3aa4977a.js';
|
|
|
5
5
|
import './ISave-d8c8bc59.js';
|
|
6
6
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
7
7
|
import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
8
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
|
8
|
+
import { P as PreloadManager } from './dataunit-fetcher-1c1cdd90.js';
|
|
9
9
|
import './filter-item-type.enum-d45e026f.js';
|
|
10
10
|
import './form-config-fetcher-e0382e5a.js';
|
|
11
11
|
import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
|
@@ -245,18 +245,18 @@ function applySorting(records, dataUnit, sorting) {
|
|
|
245
245
|
}
|
|
246
246
|
return records.sort(sortingFunction);
|
|
247
247
|
}
|
|
248
|
-
function buildPaginationInfo(
|
|
249
|
-
if (
|
|
250
|
-
return
|
|
248
|
+
function buildPaginationInfo({ recordsLength = 0, offset = 0, recordsPerPage = 0 }) {
|
|
249
|
+
if (!recordsLength) {
|
|
250
|
+
return { currentPage: 0, firstRecord: 0, lastRecord: 0, total: 0, hasMore: false };
|
|
251
251
|
}
|
|
252
|
-
const
|
|
253
|
-
const lastRecord = Math.min(
|
|
252
|
+
const lastRecordIndex = offset + recordsPerPage;
|
|
253
|
+
const lastRecord = lastRecordIndex ? Math.min(lastRecordIndex, recordsLength) : recordsLength;
|
|
254
254
|
return {
|
|
255
|
-
currentPage:
|
|
256
|
-
firstRecord: offset,
|
|
255
|
+
currentPage: recordsPerPage === 0 ? 0 : Math.ceil(offset / recordsPerPage),
|
|
256
|
+
firstRecord: offset + 1,
|
|
257
257
|
lastRecord: lastRecord,
|
|
258
|
-
total:
|
|
259
|
-
hasMore:
|
|
258
|
+
total: recordsLength,
|
|
259
|
+
hasMore: lastRecord < recordsLength,
|
|
260
260
|
};
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -342,9 +342,23 @@ class InMemoryLoader {
|
|
|
342
342
|
return StringUtils.generateUUID();
|
|
343
343
|
}
|
|
344
344
|
inMemoryLoader(dataUnit, request, recordsIn) {
|
|
345
|
-
let records =
|
|
345
|
+
let records = recordsIn ? [...recordsIn] : [];
|
|
346
|
+
records = applyFilter(records, dataUnit, request.filters);
|
|
346
347
|
records = applySorting(records, dataUnit, request.sort);
|
|
347
|
-
|
|
348
|
+
const { offset, limit } = request;
|
|
349
|
+
let pageRecords = records ? [...records] : [];
|
|
350
|
+
if (records && offset >= 0 && limit >= 0) {
|
|
351
|
+
pageRecords = records.slice(offset, offset + limit);
|
|
352
|
+
}
|
|
353
|
+
const paginationInfoBuilderParams = {
|
|
354
|
+
recordsLength: records.length,
|
|
355
|
+
offset,
|
|
356
|
+
recordsPerPage: limit
|
|
357
|
+
};
|
|
358
|
+
return Promise.resolve({
|
|
359
|
+
records: pageRecords,
|
|
360
|
+
paginationInfo: buildPaginationInfo(paginationInfoBuilderParams)
|
|
361
|
+
});
|
|
348
362
|
}
|
|
349
363
|
metadaLoader() {
|
|
350
364
|
return Promise.resolve(this._metadata);
|
|
@@ -7,7 +7,7 @@ import './index-3aa4977a.js';
|
|
|
7
7
|
import './ISave-d8c8bc59.js';
|
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
10
|
-
import './dataunit-fetcher-
|
|
10
|
+
import './dataunit-fetcher-1c1cdd90.js';
|
|
11
11
|
import './filter-item-type.enum-d45e026f.js';
|
|
12
12
|
import './form-config-fetcher-e0382e5a.js';
|
|
13
13
|
import { R as ResourceIDUtils } from './ResourceIDUtils-a114189a.js';
|
|
@@ -4,7 +4,7 @@ import { ApplicationUtils } from '@sankhyalabs/ezui/dist/collection/utils';
|
|
|
4
4
|
import { C as ConfigStorage } from './ConfigStorage-e476378d.js';
|
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-773a3e4b.js';
|
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-a411f73c.js';
|
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-1c1cdd90.js';
|
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-a87445a0.js';
|
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-ae87b754.js';
|
|
10
10
|
import './form-config-fetcher-e0382e5a.js';
|
|
@@ -4,7 +4,7 @@ import { D as DataFetcher } from './DataFetcher-773a3e4b.js';
|
|
|
4
4
|
import './pesquisa-fetcher-a87445a0.js';
|
|
5
5
|
import './index-3aa4977a.js';
|
|
6
6
|
import { S as SaveErrorsEnum } from './ISave-d8c8bc59.js';
|
|
7
|
-
import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-
|
|
7
|
+
import { P as PreloadManager, b as applyFilter, c as applySorting, d as buildPaginationInfo, D as DataUnitFetcher, I as InMemoryLoader } from './dataunit-fetcher-1c1cdd90.js';
|
|
8
8
|
import './filter-item-type.enum-d45e026f.js';
|
|
9
9
|
import './form-config-fetcher-e0382e5a.js';
|
|
10
10
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
|
@@ -113,21 +113,23 @@ const SERVICE = {
|
|
|
113
113
|
download: "AnexoSistemaSP.baixar",
|
|
114
114
|
};
|
|
115
115
|
class AnexoSistemaFetcher {
|
|
116
|
-
constructor(entityName,
|
|
116
|
+
constructor(entityName, dataUnitName) {
|
|
117
117
|
var _a;
|
|
118
118
|
this.entityName = entityName;
|
|
119
|
-
this.registerKey = registerKey;
|
|
120
119
|
this.dataUnitName = dataUnitName;
|
|
121
120
|
this.validateFields = (fields) => {
|
|
122
121
|
if (!!fields.LINK && !!fields.NOMEARQUIVO)
|
|
123
122
|
throw new Error(SaveErrorsEnum.LINK_AND_FILE_AT_THE_SAME_TIME);
|
|
124
123
|
if (!fields.LINK && !fields.NOMEARQUIVO)
|
|
125
124
|
throw new Error(SaveErrorsEnum.ANY_LINK_OR_FILE_FILLED);
|
|
126
|
-
if (!this.
|
|
125
|
+
if (!this._registerKey)
|
|
127
126
|
throw new Error('Register key can not be null');
|
|
128
127
|
};
|
|
129
128
|
this.resourceID = (window["resourceID"] || ((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID));
|
|
130
129
|
}
|
|
130
|
+
set registerKey(registerKey) {
|
|
131
|
+
this._registerKey = registerKey;
|
|
132
|
+
}
|
|
131
133
|
async save(change) {
|
|
132
134
|
var _a, _b;
|
|
133
135
|
let { updatingFields: fields } = change;
|
|
@@ -146,7 +148,7 @@ class AnexoSistemaFetcher {
|
|
|
146
148
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
147
149
|
link: fields.LINK,
|
|
148
150
|
nameEntity: this.entityName,
|
|
149
|
-
pkEntity: this.
|
|
151
|
+
pkEntity: this._registerKey,
|
|
150
152
|
typeAcess: fields.TIPOACESSO,
|
|
151
153
|
typeApres: fields.TIPOAPRES,
|
|
152
154
|
}
|
|
@@ -186,7 +188,7 @@ class AnexoSistemaFetcher {
|
|
|
186
188
|
nameAttach: fileInfo === null || fileInfo === void 0 ? void 0 : fileInfo.name,
|
|
187
189
|
link: fields.LINK,
|
|
188
190
|
nameEntity: this.entityName,
|
|
189
|
-
pkEntity: this.
|
|
191
|
+
pkEntity: this._registerKey,
|
|
190
192
|
typeAcess: fields.TIPOACESSO,
|
|
191
193
|
typeApres: fields.TIPOAPRES,
|
|
192
194
|
}
|
|
@@ -460,7 +462,13 @@ class AttachFetcherDataUnitFactory {
|
|
|
460
462
|
}
|
|
461
463
|
let records = applyFilter(this._records, dataUnit, request.filters);
|
|
462
464
|
records = applySorting(records, dataUnit, request.sort);
|
|
463
|
-
|
|
465
|
+
//TODO: não está sendo tratada a paginação nesse caso, é preciso replicar a lógica como no inMemoryLoader
|
|
466
|
+
const paginationInfoBuilderParams = {
|
|
467
|
+
recordsLength: records.length,
|
|
468
|
+
offset: request.offset,
|
|
469
|
+
recordsPerPage: request.limit
|
|
470
|
+
};
|
|
471
|
+
return Promise.resolve({ records, paginationInfo: buildPaginationInfo(paginationInfoBuilderParams) });
|
|
464
472
|
}
|
|
465
473
|
saveLoader(changes, fetcher) {
|
|
466
474
|
return new Promise((resolve) => {
|
|
@@ -656,11 +664,20 @@ const SnkAttach = class {
|
|
|
656
664
|
this.loadAttachmentDataUnit();
|
|
657
665
|
}
|
|
658
666
|
if (oldRegisterKey !== newRegisterKey) {
|
|
667
|
+
if (this._currentFetcher instanceof AnexoSistemaFetcher) {
|
|
668
|
+
this._currentFetcher.registerKey = newRegisterKey;
|
|
669
|
+
}
|
|
659
670
|
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadData());
|
|
660
671
|
}
|
|
661
672
|
}
|
|
673
|
+
getAnexoSistemaFetcherInstance() {
|
|
674
|
+
var _a;
|
|
675
|
+
const anexoSistemaFetcher = new AnexoSistemaFetcher(this.entityName, (_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.name);
|
|
676
|
+
anexoSistemaFetcher.registerKey = this.registerKey;
|
|
677
|
+
return anexoSistemaFetcher;
|
|
678
|
+
}
|
|
662
679
|
async initAttach() {
|
|
663
|
-
var _a, _b, _c, _d, _e
|
|
680
|
+
var _a, _b, _c, _d, _e;
|
|
664
681
|
if (!this.fetcherType && !this.registerKey)
|
|
665
682
|
return;
|
|
666
683
|
if (!this.fetcherType) {
|
|
@@ -668,18 +685,18 @@ const SnkAttach = class {
|
|
|
668
685
|
}
|
|
669
686
|
this.returnToGridMode();
|
|
670
687
|
if (this.fetcherType === "AnexoSistema") {
|
|
671
|
-
this._currentFetcher =
|
|
672
|
-
(
|
|
673
|
-
await ((
|
|
688
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
689
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
|
690
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
|
674
691
|
return;
|
|
675
692
|
}
|
|
676
693
|
if (this.fetcherType === "Attach") {
|
|
677
|
-
const hasMoreOneItem = ((
|
|
694
|
+
const hasMoreOneItem = ((_c = this.registerKey) === null || _c === void 0 ? void 0 : _c.split("_").length) > 1;
|
|
678
695
|
if (hasMoreOneItem)
|
|
679
696
|
return;
|
|
680
697
|
}
|
|
681
|
-
await ((
|
|
682
|
-
await ((
|
|
698
|
+
await ((_d = this._currentDataUnit) === null || _d === void 0 ? void 0 : _d.loadMetadata());
|
|
699
|
+
await ((_e = this._currentDataUnit) === null || _e === void 0 ? void 0 : _e.loadData(undefined, undefined, true, this.registerKey));
|
|
683
700
|
}
|
|
684
701
|
/**
|
|
685
702
|
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
|
@@ -738,11 +755,11 @@ const SnkAttach = class {
|
|
|
738
755
|
}
|
|
739
756
|
}
|
|
740
757
|
async loadAnexoSistema() {
|
|
741
|
-
var _a, _b
|
|
758
|
+
var _a, _b;
|
|
742
759
|
this._currentDataUnit = new DataUnitFetcher().getDataUnit(RESOURCE_ID, DATA_UNIT_NAME);
|
|
743
|
-
this._currentFetcher =
|
|
760
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
744
761
|
if (!this._currentDataUnit.metadata) {
|
|
745
|
-
await ((
|
|
762
|
+
await ((_a = this._currentDataUnit) === null || _a === void 0 ? void 0 : _a.loadMetadata());
|
|
746
763
|
this.crudConfig = Object.assign({}, anexoSistemaCrudConfig);
|
|
747
764
|
}
|
|
748
765
|
this.initDataUnitLoaders();
|
|
@@ -752,7 +769,7 @@ const SnkAttach = class {
|
|
|
752
769
|
this._currentDataUnit.addInterceptor({
|
|
753
770
|
interceptAction: (action) => this._currentDataUnitBuilder.getInterceptions(this._currentDataUnit, action, this._crudElement)
|
|
754
771
|
});
|
|
755
|
-
await ((
|
|
772
|
+
await ((_b = this._currentDataUnit) === null || _b === void 0 ? void 0 : _b.loadData());
|
|
756
773
|
this.disableEditFieldsNotInForm();
|
|
757
774
|
}
|
|
758
775
|
async loadAttach() {
|
|
@@ -778,16 +795,16 @@ const SnkAttach = class {
|
|
|
778
795
|
}
|
|
779
796
|
}
|
|
780
797
|
initDataUnitLoaders() {
|
|
781
|
-
var _a, _b
|
|
798
|
+
var _a, _b;
|
|
782
799
|
if (this.fetcherType === "AnexoSistema") {
|
|
783
|
-
this._currentFetcher =
|
|
800
|
+
this._currentFetcher = this.getAnexoSistemaFetcherInstance();
|
|
784
801
|
this._currentDataUnitBuilder = new AnexoSistemaDataUnitFactory(this.entityName, this.getMessage.bind(this));
|
|
785
|
-
(
|
|
802
|
+
(_a = this._currentDataUnitBuilder) === null || _a === void 0 ? void 0 : _a.initLoaders(this._currentDataUnit, this._currentFetcher, this.returnToGridMode.bind(this));
|
|
786
803
|
}
|
|
787
804
|
if (this.fetcherType === "Attach") {
|
|
788
805
|
this._currentFetcher = new AttachFetcher();
|
|
789
806
|
this._currentDataUnitBuilder = new AttachFetcherDataUnitFactory(this.getMessage.bind(this));
|
|
790
|
-
(
|
|
807
|
+
(_b = this._currentDataUnitBuilder) === null || _b === void 0 ? void 0 : _b.initLoaders(this._currentDataUnit, this._currentFetcher, async () => {
|
|
791
808
|
this.returnToGridMode();
|
|
792
809
|
await this._currentDataUnit.loadData(undefined, undefined, true, this.registerKey);
|
|
793
810
|
});
|
|
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-3aa4977a.js';
|
|
|
7
7
|
import './ISave-d8c8bc59.js';
|
|
8
8
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
10
|
-
import './dataunit-fetcher-
|
|
10
|
+
import './dataunit-fetcher-1c1cdd90.js';
|
|
11
11
|
import './filter-item-type.enum-d45e026f.js';
|
|
12
12
|
import './form-config-fetcher-e0382e5a.js';
|
|
13
13
|
import { d as VIEW_MODE } from './constants-8457af36.js';
|
|
@@ -4,12 +4,12 @@ import { ApplicationUtils, DialogType } from '@sankhyalabs/ezui/dist/collection/
|
|
|
4
4
|
import { D as DataExporterOption, a as DataExporterType, b as DataExporterFormat } from './index-3aa4977a.js';
|
|
5
5
|
import { R as REPORT_LAUNCHER_RESOURCE_ID } from './constants-8457af36.js';
|
|
6
6
|
import { D as DataFetcher } from './DataFetcher-773a3e4b.js';
|
|
7
|
-
import { S as SnkDataUnit } from './snk-data-unit-
|
|
7
|
+
import { S as SnkDataUnit } from './snk-data-unit-a0a8b82a.js';
|
|
8
8
|
import './pesquisa-fetcher-a87445a0.js';
|
|
9
9
|
import './ISave-d8c8bc59.js';
|
|
10
10
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
|
11
11
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
|
12
|
-
import './dataunit-fetcher-
|
|
12
|
+
import './dataunit-fetcher-1c1cdd90.js';
|
|
13
13
|
import './filter-item-type.enum-d45e026f.js';
|
|
14
14
|
import './form-config-fetcher-e0382e5a.js';
|
|
15
15
|
import './PrintUtils-3e4ff0f5.js';
|