@sankhyalabs/sankhyablocks 8.8.0-rc.5 → 8.8.0-rc.7
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/{SnkMultiSelectionListDataSource-45893a0c.js → SnkMultiSelectionListDataSource-49120c1a.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-2454608a.js → dataunit-fetcher-d2b1e486.js} +51 -24
- package/dist/cjs/snk-actions-button.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +3 -2
- package/dist/cjs/{snk-guides-viewer-018c1c8e.js → snk-guides-viewer-724cdac7.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-grid/snk-grid.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +6 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +3 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +13 -14
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/dataunit-fetcher.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +28 -9
- package/dist/components/dataunit-fetcher.js +51 -24
- package/dist/components/snk-grid2.js +1 -0
- package/dist/esm/{SnkMultiSelectionListDataSource-a0b69ac4.js → SnkMultiSelectionListDataSource-52cd2213.js} +1 -1
- package/dist/esm/{dataunit-fetcher-493182bc.js → dataunit-fetcher-e7cb71d2.js} +51 -24
- package/dist/esm/snk-actions-button.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +3 -2
- package/dist/esm/{snk-guides-viewer-7c120bc6.js → snk-guides-viewer-fbe0c5a6.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-b9b7bfce.entry.js → p-13e22fee.entry.js} +1 -1
- package/dist/sankhyablocks/p-1c32a70d.entry.js +1 -0
- package/dist/sankhyablocks/{p-21d01a8c.entry.js → p-48ec4931.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7650d823.js → p-61755a99.js} +1 -1
- package/dist/sankhyablocks/{p-8f7e0bbd.entry.js → p-64e2d600.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e13c3fbc.entry.js → p-76aa485c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-f34b9087.entry.js → p-a9de84fc.entry.js} +1 -1
- package/dist/sankhyablocks/{p-53091bcd.js → p-aeb2298c.js} +1 -1
- package/dist/sankhyablocks/p-b4a0b2e3.js +60 -0
- package/dist/sankhyablocks/{p-e33b308f.entry.js → p-bc6b332c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-9256574e.entry.js → p-f2aba462.entry.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-bdfcc2e2.js +0 -59
- package/dist/sankhyablocks/p-db45a464.entry.js +0 -1
@@ -192,6 +192,9 @@ class ArrayRepository {
|
|
192
192
|
for (const item of this._list) {
|
193
193
|
const processedItem = itemProcessor(item);
|
194
194
|
if (processedItem == undefined) {
|
195
|
+
continue;
|
196
|
+
}
|
197
|
+
if (processedItem.value == undefined) {
|
195
198
|
hasEmpty = true;
|
196
199
|
continue;
|
197
200
|
}
|
@@ -287,26 +290,25 @@ class PreloadManager {
|
|
287
290
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
288
291
|
return Promise.resolve(undefined);
|
289
292
|
}
|
293
|
+
let filterFunction;
|
294
|
+
const request = dataUnit.getLastLoadRequest();
|
295
|
+
if (request != undefined) {
|
296
|
+
const columnFilters = PreloadManager.getColumnFilters(request.filters);
|
297
|
+
filterFunction = PreloadManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
298
|
+
}
|
290
299
|
return new Promise((accept, reject) => {
|
291
300
|
PreloadManager.getRepository(dataUnit).distict(record => {
|
301
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
302
|
+
return undefined;
|
303
|
+
}
|
292
304
|
const fieldValue = record[fieldName];
|
293
305
|
if (fieldValue == undefined) {
|
294
|
-
return
|
306
|
+
return { key: null, value: null };
|
295
307
|
}
|
296
308
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
297
309
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
298
310
|
})
|
299
|
-
.then(result =>
|
300
|
-
if (result != undefined && result.size > 0) {
|
301
|
-
const field = dataUnit.getField(fieldName);
|
302
|
-
const sortedMap = new Map(Array.from(result.entries())
|
303
|
-
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
304
|
-
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
305
|
-
accept(sortedMap);
|
306
|
-
return;
|
307
|
-
}
|
308
|
-
accept(result);
|
309
|
-
})
|
311
|
+
.then(result => accept(result))
|
310
312
|
.catch(reason => reject(reason));
|
311
313
|
});
|
312
314
|
}
|
@@ -320,7 +322,7 @@ class PreloadManager {
|
|
320
322
|
return PreloadManager.loadFromCache(dataUnit, request);
|
321
323
|
}
|
322
324
|
}
|
323
|
-
//Como não vamos aproveitar o cache, ele precisa ser
|
325
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
324
326
|
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
325
327
|
}
|
326
328
|
return loadFromServer(dataUnit, request);
|
@@ -390,7 +392,7 @@ class PreloadManager {
|
|
390
392
|
.then(loadResult => {
|
391
393
|
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
392
394
|
const { count, result: records } = loadResult;
|
393
|
-
const firstRecord = count == 0 ?
|
395
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
394
396
|
const lastRecord = offset + Math.min(records.length, limit);
|
395
397
|
const currentPage = offset / limit;
|
396
398
|
const paginationInfo = {
|
@@ -536,17 +538,36 @@ class DatasetStrategy {
|
|
536
538
|
return Promise.resolve({ records: [], loadingInfo });
|
537
539
|
}
|
538
540
|
try {
|
541
|
+
const localSorting = [];
|
542
|
+
const serverSorting = [];
|
543
|
+
if (request.sort != undefined) {
|
544
|
+
for (const sort of request.sort) {
|
545
|
+
const descriptor = dataUnit.getField(sort.field);
|
546
|
+
const local = descriptor != undefined
|
547
|
+
&& descriptor.properties != undefined
|
548
|
+
&& descriptor.properties.calculated === "true";
|
549
|
+
if (local) {
|
550
|
+
localSorting.push(sort);
|
551
|
+
}
|
552
|
+
else {
|
553
|
+
serverSorting.push(sort);
|
554
|
+
}
|
555
|
+
}
|
556
|
+
}
|
539
557
|
const fields = this.getFieldsList(dataUnit);
|
540
558
|
const serviceName = "DatasetSP.loadRecords";
|
541
|
-
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo);
|
542
|
-
const {
|
559
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
560
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
561
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
543
562
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
544
563
|
const loadingInProgress = pagerId != undefined;
|
545
564
|
const count = loadingInfo.count + records.length;
|
565
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
546
566
|
return Promise.resolve({
|
547
567
|
records,
|
548
568
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
549
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count
|
569
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
570
|
+
needReload })
|
550
571
|
});
|
551
572
|
}
|
552
573
|
catch (error) {
|
@@ -556,9 +577,10 @@ class DatasetStrategy {
|
|
556
577
|
}
|
557
578
|
getFieldsList(dataUnit) {
|
558
579
|
let fields = ["__record__id__", "__record__label__"];
|
559
|
-
dataUnit.metadata.fields.forEach(descriptor => {
|
560
|
-
if (descriptor.standAlone)
|
580
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
581
|
+
if (descriptor.standAlone) {
|
561
582
|
return;
|
583
|
+
}
|
562
584
|
fields = fields.concat(this.getFieldNames(descriptor));
|
563
585
|
});
|
564
586
|
return fields;
|
@@ -570,7 +592,7 @@ class DatasetStrategy {
|
|
570
592
|
}
|
571
593
|
return [descriptor.name, descriptionField];
|
572
594
|
}
|
573
|
-
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo) {
|
595
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
574
596
|
const dataSetID = dataUnit.dataUnitId;
|
575
597
|
const dataUnitName = dataUnit.name;
|
576
598
|
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
@@ -591,13 +613,13 @@ class DatasetStrategy {
|
|
591
613
|
tryJoinedFields: true,
|
592
614
|
parallelLoader: true,
|
593
615
|
crudListener: "br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",
|
594
|
-
txProperties: this.getTxProperties(dataUnitName, request),
|
616
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
595
617
|
useDefaultRowsLimit: false
|
596
618
|
}
|
597
619
|
};
|
598
620
|
return JSON.stringify(requestBody);
|
599
621
|
}
|
600
|
-
getTxProperties(dataUnitName, request) {
|
622
|
+
getTxProperties(dataUnitName, request, sorting) {
|
601
623
|
const txProperties = {
|
602
624
|
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
603
625
|
};
|
@@ -605,7 +627,6 @@ class DatasetStrategy {
|
|
605
627
|
if (serverSideFilters.length !== 0) {
|
606
628
|
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
607
629
|
}
|
608
|
-
const sorting = request.sort;
|
609
630
|
if (sorting != undefined && sorting.length !== 0) {
|
610
631
|
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
611
632
|
}
|
@@ -712,7 +733,7 @@ class DataUnitDataLoader {
|
|
712
733
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
713
734
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
714
735
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
715
|
-
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
736
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
716
737
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
717
738
|
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
718
739
|
.catch(reason => console.error(reason));
|
@@ -730,6 +751,11 @@ class DataUnitDataLoader {
|
|
730
751
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
731
752
|
return;
|
732
753
|
}
|
754
|
+
if (loadingInfo.needReload) {
|
755
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
756
|
+
dataUnit.gotoPage(0);
|
757
|
+
return;
|
758
|
+
}
|
733
759
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
734
760
|
}
|
735
761
|
static registryLoading(dataUnit, loadingInfo) {
|
@@ -795,6 +821,7 @@ class DataUnitFetcher {
|
|
795
821
|
defaultValue
|
796
822
|
label
|
797
823
|
visible
|
824
|
+
standAlone
|
798
825
|
readOnly
|
799
826
|
required
|
800
827
|
dataType
|
@@ -116,6 +116,7 @@ const SnkGrid = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
116
116
|
if (this._gridConfig && this._dataUnit) {
|
117
117
|
this._dataUnit.defaultSorting = this._gridConfig
|
118
118
|
.columns
|
119
|
+
.filter(col => col.ascending != undefined)
|
119
120
|
.sort((colA, colB) => colA.orderIndex - colB.orderIndex)
|
120
121
|
.map(({ name: field, ascending }) => {
|
121
122
|
const { dataType } = this._dataUnit.getField(field);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { UserInterface, DateUtils } from '@sankhyalabs/core';
|
2
|
-
import { P as PreloadManager } from './dataunit-fetcher-
|
2
|
+
import { P as PreloadManager } from './dataunit-fetcher-e7cb71d2.js';
|
3
3
|
|
4
4
|
class SnkMultiSelectionListDataSource {
|
5
5
|
setDataUnit(dataUnit) {
|
@@ -31,6 +31,9 @@ class ArrayRepository {
|
|
31
31
|
for (const item of this._list) {
|
32
32
|
const processedItem = itemProcessor(item);
|
33
33
|
if (processedItem == undefined) {
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
if (processedItem.value == undefined) {
|
34
37
|
hasEmpty = true;
|
35
38
|
continue;
|
36
39
|
}
|
@@ -126,26 +129,25 @@ class PreloadManager {
|
|
126
129
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
127
130
|
return Promise.resolve(undefined);
|
128
131
|
}
|
132
|
+
let filterFunction;
|
133
|
+
const request = dataUnit.getLastLoadRequest();
|
134
|
+
if (request != undefined) {
|
135
|
+
const columnFilters = PreloadManager.getColumnFilters(request.filters);
|
136
|
+
filterFunction = PreloadManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
137
|
+
}
|
129
138
|
return new Promise((accept, reject) => {
|
130
139
|
PreloadManager.getRepository(dataUnit).distict(record => {
|
140
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
141
|
+
return undefined;
|
142
|
+
}
|
131
143
|
const fieldValue = record[fieldName];
|
132
144
|
if (fieldValue == undefined) {
|
133
|
-
return
|
145
|
+
return { key: null, value: null };
|
134
146
|
}
|
135
147
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
136
148
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
137
149
|
})
|
138
|
-
.then(result =>
|
139
|
-
if (result != undefined && result.size > 0) {
|
140
|
-
const field = dataUnit.getField(fieldName);
|
141
|
-
const sortedMap = new Map(Array.from(result.entries())
|
142
|
-
.sort((itemA, itemB) => FieldComparator.compareValues(field, itemA[1], itemB[1]))
|
143
|
-
.map(([key, value]) => key === "" ? ["(Vazio)", value] : [key, value]));
|
144
|
-
accept(sortedMap);
|
145
|
-
return;
|
146
|
-
}
|
147
|
-
accept(result);
|
148
|
-
})
|
150
|
+
.then(result => accept(result))
|
149
151
|
.catch(reason => reject(reason));
|
150
152
|
});
|
151
153
|
}
|
@@ -159,7 +161,7 @@ class PreloadManager {
|
|
159
161
|
return PreloadManager.loadFromCache(dataUnit, request);
|
160
162
|
}
|
161
163
|
}
|
162
|
-
//Como não vamos aproveitar o cache, ele precisa ser
|
164
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
163
165
|
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
164
166
|
}
|
165
167
|
return loadFromServer(dataUnit, request);
|
@@ -229,7 +231,7 @@ class PreloadManager {
|
|
229
231
|
.then(loadResult => {
|
230
232
|
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
231
233
|
const { count, result: records } = loadResult;
|
232
|
-
const firstRecord = count == 0 ?
|
234
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
233
235
|
const lastRecord = offset + Math.min(records.length, limit);
|
234
236
|
const currentPage = offset / limit;
|
235
237
|
const paginationInfo = {
|
@@ -375,17 +377,36 @@ class DatasetStrategy {
|
|
375
377
|
return Promise.resolve({ records: [], loadingInfo });
|
376
378
|
}
|
377
379
|
try {
|
380
|
+
const localSorting = [];
|
381
|
+
const serverSorting = [];
|
382
|
+
if (request.sort != undefined) {
|
383
|
+
for (const sort of request.sort) {
|
384
|
+
const descriptor = dataUnit.getField(sort.field);
|
385
|
+
const local = descriptor != undefined
|
386
|
+
&& descriptor.properties != undefined
|
387
|
+
&& descriptor.properties.calculated === "true";
|
388
|
+
if (local) {
|
389
|
+
localSorting.push(sort);
|
390
|
+
}
|
391
|
+
else {
|
392
|
+
serverSorting.push(sort);
|
393
|
+
}
|
394
|
+
}
|
395
|
+
}
|
378
396
|
const fields = this.getFieldsList(dataUnit);
|
379
397
|
const serviceName = "DatasetSP.loadRecords";
|
380
|
-
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo);
|
381
|
-
const {
|
398
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
399
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
400
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
382
401
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
383
402
|
const loadingInProgress = pagerId != undefined;
|
384
403
|
const count = loadingInfo.count + records.length;
|
404
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
385
405
|
return Promise.resolve({
|
386
406
|
records,
|
387
407
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
388
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count
|
408
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
409
|
+
needReload })
|
389
410
|
});
|
390
411
|
}
|
391
412
|
catch (error) {
|
@@ -395,9 +416,10 @@ class DatasetStrategy {
|
|
395
416
|
}
|
396
417
|
getFieldsList(dataUnit) {
|
397
418
|
let fields = ["__record__id__", "__record__label__"];
|
398
|
-
dataUnit.metadata.fields.forEach(descriptor => {
|
399
|
-
if (descriptor.standAlone)
|
419
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
420
|
+
if (descriptor.standAlone) {
|
400
421
|
return;
|
422
|
+
}
|
401
423
|
fields = fields.concat(this.getFieldNames(descriptor));
|
402
424
|
});
|
403
425
|
return fields;
|
@@ -409,7 +431,7 @@ class DatasetStrategy {
|
|
409
431
|
}
|
410
432
|
return [descriptor.name, descriptionField];
|
411
433
|
}
|
412
|
-
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo) {
|
434
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
413
435
|
const dataSetID = dataUnit.dataUnitId;
|
414
436
|
const dataUnitName = dataUnit.name;
|
415
437
|
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
@@ -430,13 +452,13 @@ class DatasetStrategy {
|
|
430
452
|
tryJoinedFields: true,
|
431
453
|
parallelLoader: true,
|
432
454
|
crudListener: "br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",
|
433
|
-
txProperties: this.getTxProperties(dataUnitName, request),
|
455
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
434
456
|
useDefaultRowsLimit: false
|
435
457
|
}
|
436
458
|
};
|
437
459
|
return JSON.stringify(requestBody);
|
438
460
|
}
|
439
|
-
getTxProperties(dataUnitName, request) {
|
461
|
+
getTxProperties(dataUnitName, request, sorting) {
|
440
462
|
const txProperties = {
|
441
463
|
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
442
464
|
};
|
@@ -444,7 +466,6 @@ class DatasetStrategy {
|
|
444
466
|
if (serverSideFilters.length !== 0) {
|
445
467
|
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
446
468
|
}
|
447
|
-
const sorting = request.sort;
|
448
469
|
if (sorting != undefined && sorting.length !== 0) {
|
449
470
|
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
450
471
|
}
|
@@ -551,7 +572,7 @@ class DataUnitDataLoader {
|
|
551
572
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
552
573
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
553
574
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
554
|
-
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
575
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
555
576
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
556
577
|
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
557
578
|
.catch(reason => console.error(reason));
|
@@ -569,6 +590,11 @@ class DataUnitDataLoader {
|
|
569
590
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
570
591
|
return;
|
571
592
|
}
|
593
|
+
if (loadingInfo.needReload) {
|
594
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
595
|
+
dataUnit.gotoPage(0);
|
596
|
+
return;
|
597
|
+
}
|
572
598
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
573
599
|
}
|
574
600
|
static registryLoading(dataUnit, loadingInfo) {
|
@@ -634,6 +660,7 @@ class DataUnitFetcher {
|
|
634
660
|
defaultValue
|
635
661
|
label
|
636
662
|
visible
|
663
|
+
standAlone
|
637
664
|
readOnly
|
638
665
|
required
|
639
666
|
dataType
|
@@ -7,7 +7,7 @@ import './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.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-e7cb71d2.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.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-9840d004.js';
|
5
5
|
import { d as dist, D as DataFetcher, U as UrlUtils } from './DataFetcher-07935045.js';
|
6
6
|
import { A as AutorizationType, a as AuthFetcher } from './auth-fetcher-1afab780.js';
|
7
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
7
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-e7cb71d2.js';
|
8
8
|
import { P as PesquisaFetcher } from './pesquisa-fetcher-7c46996d.js';
|
9
9
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
10
10
|
import './form-config-fetcher-5b886892.js';
|
@@ -3,7 +3,7 @@ import { ApplicationContext, DataType, Action } from '@sankhyalabs/core';
|
|
3
3
|
import { D as DataFetcher } from './DataFetcher-07935045.js';
|
4
4
|
import { S as SaveErrorsEnum } from './ISave-4412b20c.js';
|
5
5
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
6
|
-
import { D as DataUnitFetcher } from './dataunit-fetcher-
|
6
|
+
import { D as DataUnitFetcher } from './dataunit-fetcher-e7cb71d2.js';
|
7
7
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
8
8
|
import './_commonjsHelpers-9943807e.js';
|
9
9
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
@@ -7,7 +7,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
7
7
|
import './ISave-4412b20c.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-e7cb71d2.js';
|
11
11
|
import './filter-item-type.enum-5028ed3f.js';
|
12
12
|
import './form-config-fetcher-5b886892.js';
|
13
13
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
@@ -8,12 +8,12 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import './dataunit-fetcher-
|
11
|
+
import './dataunit-fetcher-e7cb71d2.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarElement } from './taskbar-elements-0a6b8b95.js';
|
15
15
|
import { c as VIEW_MODE } from './constants-3644f1b6.js';
|
16
|
-
import { S as SnkGuidesViewer } from './snk-guides-viewer-
|
16
|
+
import { S as SnkGuidesViewer } from './snk-guides-viewer-fbe0c5a6.js';
|
17
17
|
import { S as SnkMessageBuilder } from './SnkMessageBuilder-7ac66e9c.js';
|
18
18
|
import './ConfigStorage-9840d004.js';
|
19
19
|
import './_commonjsHelpers-9943807e.js';
|
@@ -6,14 +6,14 @@ import { C as ConfigStorage } from './ConfigStorage-9840d004.js';
|
|
6
6
|
import { P as PresentationMode } from './index-1564817d.js';
|
7
7
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
8
8
|
import { s as store } from './index-bdf75557.js';
|
9
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
9
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-52cd2213.js';
|
10
10
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
11
11
|
import './form-config-fetcher-5b886892.js';
|
12
12
|
import './DataFetcher-07935045.js';
|
13
13
|
import './_commonjsHelpers-9943807e.js';
|
14
14
|
import './PrintUtils-3e4ff0f5.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
|
-
import './dataunit-fetcher-
|
16
|
+
import './dataunit-fetcher-e7cb71d2.js';
|
17
17
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
18
18
|
import './ResourceIDUtils-a114189a.js';
|
19
19
|
|
@@ -108,6 +108,7 @@ const SnkGrid = class {
|
|
108
108
|
if (this._gridConfig && this._dataUnit) {
|
109
109
|
this._dataUnit.defaultSorting = this._gridConfig
|
110
110
|
.columns
|
111
|
+
.filter(col => col.ascending != undefined)
|
111
112
|
.sort((colA, colB) => colA.orderIndex - colB.orderIndex)
|
112
113
|
.map(({ name: field, ascending }) => {
|
113
114
|
const { dataType } = this._dataUnit.getField(field);
|
@@ -11,7 +11,7 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
11
11
|
import './ISave-4412b20c.js';
|
12
12
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
13
13
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
14
|
-
import './dataunit-fetcher-
|
14
|
+
import './dataunit-fetcher-e7cb71d2.js';
|
15
15
|
import './filter-item-type.enum-5028ed3f.js';
|
16
16
|
import './form-config-fetcher-5b886892.js';
|
17
17
|
import { SelectionMode } from '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { S as snk_guides_viewer } from './snk-guides-viewer-
|
1
|
+
export { S as snk_guides_viewer } from './snk-guides-viewer-fbe0c5a6.js';
|
2
2
|
import './index-a7d3d3f1.js';
|
3
3
|
import '@sankhyalabs/core';
|
4
4
|
import './SnkFormConfigManager-a7c4ac16.js';
|
@@ -18,6 +18,6 @@ import './constants-3644f1b6.js';
|
|
18
18
|
import './pesquisa-fetcher-7c46996d.js';
|
19
19
|
import './ISave-4412b20c.js';
|
20
20
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
21
|
-
import './dataunit-fetcher-
|
21
|
+
import './dataunit-fetcher-e7cb71d2.js';
|
22
22
|
import './ResourceIDUtils-a114189a.js';
|
23
23
|
import '@sankhyalabs/core/dist/dataunit/DataUnit';
|
@@ -8,11 +8,11 @@ import { P as PresentationMode } from './index-1564817d.js';
|
|
8
8
|
import './ISave-4412b20c.js';
|
9
9
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
10
10
|
import '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
11
|
-
import { I as InMemoryLoader } from './dataunit-fetcher-
|
11
|
+
import { I as InMemoryLoader } from './dataunit-fetcher-e7cb71d2.js';
|
12
12
|
import './filter-item-type.enum-5028ed3f.js';
|
13
13
|
import './form-config-fetcher-5b886892.js';
|
14
14
|
import { T as TaskbarProcessor } from './taskbar-processor-94402e6e.js';
|
15
|
-
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-
|
15
|
+
import { S as SnkMultiSelectionListDataSource } from './SnkMultiSelectionListDataSource-52cd2213.js';
|
16
16
|
import './index-bdf75557.js';
|
17
17
|
import './_commonjsHelpers-9943807e.js';
|
18
18
|
import './PrintUtils-3e4ff0f5.js';
|
@@ -1 +1 @@
|
|
1
|
-
import{r as t,h as s,H as i,g as e}from"./p-d2d301a6.js";import{ApplicationContext as n,StringUtils as o,ErrorException as a,WarningException as c,ObjectUtils as r,DateUtils as l,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as d}from"./p-4f7b9c50.js";import{P as p}from"./p-eaad0aa8.js";import"./p-efb2e247.js";import"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-bdfcc2e2.js";import"./p-584d7212.js";import"./p-0f2b03e5.js";import{R as m}from"./p-688dcb4c.js";import"./p-112455b1.js";import"./p-8d884fab.js";class v{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.javaCall)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecJava})}))}async callExecJava(t){const s={requestBody:{javaCall:t}};await d.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(s))}}class b{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.runScript)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecScript})}))}async callExecScript(t){const s={runScript:t};await d.get().callServiceBroker("ActionButtonsSP.executeScript",s)}}class w{constructor(){this._application=n.getContextValue("__SNK__APPLICATION__")}async execute(t,s){const i=t.resourceID;if(!i)return;let e=await this.buildLaunchObject(t,s);return this._application.openApp(i,e),null}buildLaunchObject(t,s){return new Promise((i=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},c=[];e.forEach((i=>{const e=i.localField;let r=s.getFieldValue(e);if(!r){let i=s.getField(e).label;throw i=o.isEmpty(s.getField(e).label)?e:i,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:i}))}r=o.isEmpty(r.toString())?void 0:r.toString(),n[i.targetField]=r,c.push({fieldName:i.targetField,value:r})})),n.ACTION_PARAMETERS=c,n.call_time=Date.now(),i(n)}i(null)}))}}class k{execute(t){var s,i,e;const n=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.name,o=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}async callExecProcedure(t){const s={requestBody:{stpCall:t}};await d.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(s))}}var f,_;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(f||(f={}));class y{constructor(t){this.actionType=t,this._application=n.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case f.LAUNCH_SCREEN:return new w;case f.JAVASCRIPT:return new b;case f.JAVA:return new v;case f.PROCEDURE:return new k;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(_||(_={}));const S="__MASTER_ROW__";class P{constructor(t,s,i){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=s,this._selectedRows=(null===(e=null==s?void 0:s.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==s?void 0:s.getSelectionInfo().records,this._application=n.getContextValue("__SNK__APPLICATION__"),this._appResourceId=i}apply(t,s){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:i,callback:e})=>{this.resolvePromptParams(t,i,s).then((()=>{this.actionExecute(i,e)}))}))}async execute(t){var s;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(s=t.actionConfig.params)||void 0===s?void 0:s.promptParam){const s=t.actionConfig.params.promptParam;let i=!1;for(let t=0;t<s.length;t++)if(!i&&"true"===s[t].saveLast){i=!0;break}i&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=r.copy(t),e.applyParameters=t=>{this.apply(t,i)},e.openPopup()}else t.type!=f.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:s})=>{this.actionExecute(t,s)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((s=>{let i=t.actionConfig.params.promptParam;return s&&s.param.forEach((t=>{i=i.map((s=>s.name!==t.paramName?s:Object.assign(Object.assign({},s),"B"===s.paramType?{value:"S"===t.$}:{value:t.$})))})),i}))}actionExecute(t,s){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,s),this.recordsReloader(t.refreshType)}resolvePromptParams(t,s,i){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,s),i&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let s,i,e=t.paramType,n=!1,o=t.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",s={"sk-precision":Number(t.precision)};break;case p.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case p.ENTITY:s={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(i=t.entityPK),o=t.value?Number(t.value):null;break;case p.OPTIONS:e="O";let a=t.options.split(";").map((function(t,s){let i,e;if(t.indexOf("=")>-1){let s=t.split("=");i=s[0],e=s[1]}else i=s+1,e=t;return{data:i,value:e}}));s={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:i,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:s,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,s){s.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));o.isEmpty(t.value)||s.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let s;switch(t){case"D":s="F";break;case"DT":case"DH":s="D";break;case"B":case"ENTITY":case"SO":s="S";break;default:s=t}return s}getParamValue(t){let s=t.value;return s?("DT"==t.paramType?s=l.formatDate(s):"DH"==t.paramType&&(s=l.formatDateTime(s)),s):s}async loadLastValues(t){const s=await this.buildResourceId(t.actionID);return new Promise(((t,i)=>{if(this._lastValuesCache[s])t(this._lastValuesCache[s]);else{const e={config:{chave:s,tipo:"T"}};d.get().callServiceBroker("SystemUtilsSP.getConf",e).then((i=>{var e,n;let o;(null===(n=null===(e=i.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=i.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[s]=o,t(o)})).catch((t=>{i(t)}))}}))}async saveLastValues(t,s){if(this._application){let i={params:{param:[]}};s.forEach((t=>{"true"==t.saveLast&&i.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=i.params,this._application.saveConfig(e,i)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,s){this.addRows(t),s(t)}addRows(t){const s={row:[]},i=this._selectedRows;for(const t in i){const e=i[t],n={};e.hasOwnProperty(S)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[S],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));s.row.push(n)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case _.NONE:break;case _.PARENT:case _.MASTER:case _.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,s,i,e;if(null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===s?void 0:s.isAllRecords())return{filters:{filters:null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class A{async clientConfirm(t,s){return new Promise((i=>{const e=n.getContextValue("__SNK__APPLICATION__");let o="";t.content.event.hasOwnProperty("stpCall")?(s.requestBody=t.content.event.stpCall,o=f.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(s.requestBody=t.content.event.runScript,o=f.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(s.requestBody=t.content.event.javaCall,o=f.JAVA);let a={type:"S",sequence:t.content.event.sequence};s.requestBody.params?Array.isArray(s.requestBody.params.param)||(s.requestBody.params.param=[s.requestBody.params.param]):s.requestBody.params={param:[]},s.requestBody.params.param.push(a);const c=t.content.event.title.$,r=t.content.event.message.$;let l;switch(o){case f.JAVASCRIPT:l={runScript:s.requestBody};break;case f.PROCEDURE:l={requestBody:{stpCall:s.requestBody}};break;case f.JAVA:l={requestBody:{javaCall:s.requestBody}}}if("S"==t.content.event.showNoOption){a.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=c,t.message=r,t.accept=async()=>{a.$="S",await s.reCall(l),i()},t.cancel=async()=>{a.$="N",await s.reCall(l),i()},t.openPopup()}else e.confirm(c,r,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(a.paramName="__CONFIRMACAO__",a.$="S",await s.reCall(l),i())}))}))}}const N=class{constructor(s){t(this,s),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const s=this._actions.find((s=>s.actionID==t.detail.id)),i=new y(s.type).executor;new P(i,this._dataUnit,this._resourceID).execute(Object.assign({},s)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return d.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var s;(null===(s=t.actions)||void 0===s?void 0:s.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const s=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();s&&this._dropdownParent&&(this._dropdownParent.style.top=s.y+s.height+5+"px",this._dropdownParent.style.left=s.x+"px")}closeDropdown(t){const s=null==t?void 0:t.target;s&&(s.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new A;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return s(i,null,this._actions&&this._actions.length>0&&s("div",{class:`ez-padding-left--medium snk-actions-button \n ${this.canShowDropdown()?" snk-actions-button--overlap":""}\n `},s("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),s("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&s("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&s("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};N.style=".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";export{N as snk_actions_button}
|
1
|
+
import{r as t,h as s,H as i,g as e}from"./p-d2d301a6.js";import{ApplicationContext as n,StringUtils as o,ErrorException as a,WarningException as c,ObjectUtils as r,DateUtils as l,ArrayUtils as h,ElementIDUtils as u}from"@sankhyalabs/core";import{D as d}from"./p-4f7b9c50.js";import{P as p}from"./p-eaad0aa8.js";import"./p-efb2e247.js";import"./p-5534e08c.js";import"./p-9e7d65a4.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-b4a0b2e3.js";import"./p-584d7212.js";import"./p-0f2b03e5.js";import{R as m}from"./p-688dcb4c.js";import"./p-112455b1.js";import"./p-8d884fab.js";class v{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.javaCall)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecJava})}))}async callExecJava(t){const s={requestBody:{javaCall:t}};await d.get().callServiceBroker("ActionButtonsSP.executeJava",JSON.stringify(s))}}class b{execute(t){var s;const i={actionID:t.actionID,refreshType:null===(s=t.actionConfig.runScript)||void 0===s?void 0:s.refreshType};return new Promise((t=>{t({execSource:i,callback:this.callExecScript})}))}async callExecScript(t){const s={runScript:t};await d.get().callServiceBroker("ActionButtonsSP.executeScript",s)}}class w{constructor(){this._application=n.getContextValue("__SNK__APPLICATION__")}async execute(t,s){const i=t.resourceID;if(!i)return;let e=await this.buildLaunchObject(t,s);return this._application.openApp(i,e),null}buildLaunchObject(t,s){return new Promise((i=>{let e=t.actionConfig.params.param;if(e&&e.length>0){let n={},c=[];e.forEach((i=>{const e=i.localField;let r=s.getFieldValue(e);if(!r){let i=s.getField(e).label;throw i=o.isEmpty(s.getField(e).label)?e:i,new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.launchScreen.emptyField",{description:t.description,localFieldLabel:i}))}r=o.isEmpty(r.toString())?void 0:r.toString(),n[i.targetField]=r,c.push({fieldName:i.targetField,value:r})})),n.ACTION_PARAMETERS=c,n.call_time=Date.now(),i(n)}i(null)}))}}class k{execute(t){var s,i,e;const n=null===(s=t.actionConfig.dbCall)||void 0===s?void 0:s.name,o=null===(i=t.actionConfig.dbCall)||void 0===i?void 0:i.rootEntity,a={actionID:t.actionID,refreshType:null===(e=t.actionConfig.dbCall)||void 0===e?void 0:e.refreshType,procName:n,rootEntity:o};return new Promise((t=>{t({execSource:a,callback:this.callExecProcedure})}))}async callExecProcedure(t){const s={requestBody:{stpCall:t}};await d.get().callServiceBroker("ActionButtonsSP.executeSTP",JSON.stringify(s))}}var f,_;!function(t){t.LAUNCH_SCREEN="LC",t.JAVASCRIPT="SC",t.JAVA="RJ",t.PROCEDURE="SP",t.EMBEDDED="EB"}(f||(f={}));class y{constructor(t){this.actionType=t,this._application=n.getContextValue("__SNK__APPLICATION__")}get executor(){switch(this.actionType){case f.LAUNCH_SCREEN:return new w;case f.JAVASCRIPT:return new b;case f.JAVA:return new v;case f.PROCEDURE:return new k;default:throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.nonExistentType",{actionType:this.actionType}))}}}!function(t){t.NONE="NONE",t.PARENT="PARENT",t.MASTER="MASTER",t.ALL="ALL"}(_||(_={}));const S="__MASTER_ROW__";class P{constructor(t,s,i){var e;this._lastValuesCache={},this._actionsExecuteInterface=t,this._dataUnit=s,this._selectedRows=(null===(e=null==s?void 0:s.getSelectionInfo())||void 0===e?void 0:e.isAllRecords())?[]:null==s?void 0:s.getSelectionInfo().records,this._application=n.getContextValue("__SNK__APPLICATION__"),this._appResourceId=i}apply(t,s){this._application.closePopUp(),this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:i,callback:e})=>{this.resolvePromptParams(t,i,s).then((()=>{this.actionExecute(i,e)}))}))}async execute(t){var s;if(!t.actionConfig)throw new c(this._application.messagesBuilder.getMessage("snkActionsButton.title.warning",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.incorrectAction",{description:t.description}));if(null===(s=t.actionConfig.params)||void 0===s?void 0:s.promptParam){const s=t.actionConfig.params.promptParam;let i=!1;for(let t=0;t<s.length;t++)if(!i&&"true"===s[t].saveLast){i=!0;break}i&&(t.actionConfig.params.promptParam=await this.loadSavedValuesIntoParams(t));const e=document.createElement("snk-actions-form");window.document.body.appendChild(e),e.action=r.copy(t),e.applyParameters=t=>{this.apply(t,i)},e.openPopup()}else t.type!=f.LAUNCH_SCREEN?this._actionsExecuteInterface.execute(t,this._dataUnit).then((({execSource:t,callback:s})=>{this.actionExecute(t,s)})):this._actionsExecuteInterface.execute(t,this._dataUnit)}loadSavedValuesIntoParams(t){return this.loadLastValues(t).then((s=>{let i=t.actionConfig.params.promptParam;return s&&s.param.forEach((t=>{i=i.map((s=>s.name!==t.paramName?s:Object.assign(Object.assign({},s),"B"===s.paramType?{value:"S"===t.$}:{value:t.$})))})),i}))}actionExecute(t,s){t.virtualPage=this.buildVirtualPage(),this.prepareAndExecute(t,s),this.recordsReloader(t.refreshType)}resolvePromptParams(t,s,i){return new Promise((e=>{let n=[];t.actionConfig.params.promptParam.forEach((t=>{n.push(this.buildPromptParam(t))})),this.putParamsOnExecSource(n,s),i&&this.saveLastValues(t,n),e()}))}buildPromptParam(t){let s,i,e=t.paramType,n=!1,o=t.value;switch(e){case p.DATE:e="D";break;case p.DATETIME:e="H";break;case p.DECIMAL:e="F",s={"sk-precision":Number(t.precision)};break;case p.BOOLEAN:e="S",n=!0,o=t.value?"S":"N";break;case p.ENTITY:s={"sk-entity-name":t.entityName,"sk-allow-show-hierarchical-mode":t.hierarchyEntity,"sk-data-type":"S"},t.hierarchyEntity&&t.entityPK&&(i=t.entityPK),o=t.value?Number(t.value):null;break;case p.OPTIONS:e="O";let a=t.options.split(";").map((function(t,s){let i,e;if(t.indexOf("=")>-1){let s=t.split("=");i=s[0],e=s[1]}else i=s+1,e=t;return{data:i,value:e}}));s={"sk-options":a}}return{description:t.label,required:"true"==t.required,fieldName:t.name,fieldNameOri:t.name,entityPK:i,paramType:t.paramType,type:e,isCheckbox:n,saveLast:t.saveLast,fieldProp:s,value:o,isGeneratedName:t.isGeneratedName}}putParamsOnExecSource(t,s){s.params={param:[]},t.forEach((t=>{if(t.isGeneratedName&&t.value)throw new a(this._application.messagesBuilder.getMessage("snkActionsButton.title.error",void 0),this._application.messagesBuilder.getMessage("snkActionsButton.action.emptyParamName",void 0));o.isEmpty(t.value)||s.params.param.push({type:this.getParamDataType(t.paramType),paramName:t.fieldName,$:this.getParamValue(t)})}))}getParamDataType(t){let s;switch(t){case"D":s="F";break;case"DT":case"DH":s="D";break;case"B":case"ENTITY":case"SO":s="S";break;default:s=t}return s}getParamValue(t){let s=t.value;return s?("DT"==t.paramType?s=l.formatDate(s):"DH"==t.paramType&&(s=l.formatDateTime(s)),s):s}async loadLastValues(t){const s=await this.buildResourceId(t.actionID);return new Promise(((t,i)=>{if(this._lastValuesCache[s])t(this._lastValuesCache[s]);else{const e={config:{chave:s,tipo:"T"}};d.get().callServiceBroker("SystemUtilsSP.getConf",e).then((i=>{var e,n;let o;(null===(n=null===(e=i.config)||void 0===e?void 0:e.data)||void 0===n?void 0:n.params)&&(o=i.config.data.params,Array.isArray(o.param)||(o.param=[o.param])),this._lastValuesCache[s]=o,t(o)})).catch((t=>{i(t)}))}}))}async saveLastValues(t,s){if(this._application){let i={params:{param:[]}};s.forEach((t=>{"true"==t.saveLast&&i.params.param.push({paramName:t.fieldName,$:t.value})}));const e=await this.buildResourceId(t.actionID);this._lastValuesCache[e]=i.params,this._application.saveConfig(e,i)}}async buildResourceId(t){return this._appResourceId+".actionconfig."+t}prepareAndExecute(t,s){this.addRows(t),s(t)}addRows(t){const s={row:[]},i=this._selectedRows;for(const t in i){const e=i[t],n={};e.hasOwnProperty(S)&&(n.master="S",n.entityName=e.__ENTITY_NAME__,delete e[S],delete e.__ENTITY_NAME__);for(const t in e)"NUFIN"===t&&(n.field||(n.field=[]),n.field.push({fieldName:t,$:e[t]}));s.row.push(n)}s.row.length>0&&(t.rows=s)}recordsReloader(t){switch(t){case _.NONE:break;case _.PARENT:case _.MASTER:case _.ALL:this._dataUnit.loadData();break;default:this._dataUnit.reloadCurrentRecord()}}buildVirtualPage(){var t,s,i,e;if(null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.getSelectionInfo())||void 0===s?void 0:s.isAllRecords())return{filters:{filters:null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},orders:{orders:null===(e=this._dataUnit)||void 0===e?void 0:e.getSort()}}}}class A{async clientConfirm(t,s){return new Promise((i=>{const e=n.getContextValue("__SNK__APPLICATION__");let o="";t.content.event.hasOwnProperty("stpCall")?(s.requestBody=t.content.event.stpCall,o=f.PROCEDURE):t.content.event.hasOwnProperty("runScript")?(s.requestBody=t.content.event.runScript,o=f.JAVASCRIPT):t.content.event.hasOwnProperty("javaCall")&&(s.requestBody=t.content.event.javaCall,o=f.JAVA);let a={type:"S",sequence:t.content.event.sequence};s.requestBody.params?Array.isArray(s.requestBody.params.param)||(s.requestBody.params.param=[s.requestBody.params.param]):s.requestBody.params={param:[]},s.requestBody.params.param.push(a);const c=t.content.event.title.$,r=t.content.event.message.$;let l;switch(o){case f.JAVASCRIPT:l={runScript:s.requestBody};break;case f.PROCEDURE:l={requestBody:{stpCall:s.requestBody}};break;case f.JAVA:l={requestBody:{javaCall:s.requestBody}}}if("S"==t.content.event.showNoOption){a.paramName="__ESCOLHA_SIMNAO__";const t=document.createElement("snk-client-confirm");window.document.body.appendChild(t),t.titleMessage=c,t.message=r,t.accept=async()=>{a.$="S",await s.reCall(l),i()},t.cancel=async()=>{a.$="N",await s.reCall(l),i()},t.openPopup()}else e.confirm(c,r,null,"warn",{labelCancel:"Cancelar",labelConfirm:"Sim"}).then((async t=>{t&&(a.paramName="__CONFIRMACAO__",a.$="S",await s.reCall(l),i())}))}))}}const N=class{constructor(s){t(this,s),this.CLIENT_EVENT_CONFIRM_NAME="br.com.sankhya.actionbutton.clientconfirm",this.handleClick=t=>{const s=this._actions.find((s=>s.actionID==t.detail.id)),i=new y(s.type).executor;new P(i,this._dataUnit,this._resourceID).execute(Object.assign({},s)),this._showDropdown=!1},this._items=[],this._showDropdown=!1,this._actions=[],this._isOrderActions=!1}async getActions(){let t={param:{entityName:this._entityName,resourceID:this._resourceID}};return d.get().callServiceBroker("ActionButtonsSP.getActions",t).then((t=>{var s;(null===(s=t.actions)||void 0===s?void 0:s.action)&&(this._actions=this._isOrderActions?h.sortAlphabetically(t.actions.action,"description"):t.actions.action)}))}controlDropdown(){this._showDropdown=!this._showDropdown}canShowDropdown(){var t;return this._showDropdown&&(null===(t=this._items)||void 0===t?void 0:t.length)>0}positionDropdown(){var t;const s=null===(t=this._ezButton)||void 0===t?void 0:t.getBoundingClientRect();s&&this._dropdownParent&&(this._dropdownParent.style.top=s.y+s.height+5+"px",this._dropdownParent.style.left=s.x+"px")}closeDropdown(t){const s=null==t?void 0:t.target;s&&(s.closest(".snk-actions-button")||(this._showDropdown=!1))}setEvents(){document.removeEventListener("click",this.closeDropdown.bind(this)),document.addEventListener("click",this.closeDropdown.bind(this)),document.removeEventListener("scroll",this.positionDropdown.bind(this)),document.addEventListener("scroll",this.positionDropdown.bind(this))}async componentWillLoad(){this._application=n.getContextValue("__SNK__APPLICATION__"),this._isOrderActions=await this._application.getBooleanParam("global.ordenar.acoes.personalizadas");const t=this._element.parentElement;this._dataUnit=null==t?void 0:t.dataUnit,this._resourceID=null==t?void 0:t.resourceID,this._entityName=this._dataUnit.name.split("/")[2],null==this._resourceID&&(this._resourceID=await m.getResourceID()),this.setEvents(),this.getActions().then((()=>{this.loadItems()}))}async componentDidLoad(){if(this._element&&(u.addIDInfo(this._element),this.positionDropdown(),!await this._application.hasClientEvent(this.CLIENT_EVENT_CONFIRM_NAME))){const t=new A;this._application.addClientEvent(this.CLIENT_EVENT_CONFIRM_NAME,t.clientConfirm)}}componentDidUpdate(){this.positionDropdown()}loadItems(){this._actions&&0!=this._actions.length&&this._actions.forEach((t=>{this._items.push({id:t.actionID,label:t.description})}))}getElementID(t){return{[u.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:u.getInternalIDInfo(t)}}render(){return s(i,null,this._actions&&this._actions.length>0&&s("div",{class:`ez-padding-left--medium snk-actions-button \n ${this.canShowDropdown()?" snk-actions-button--overlap":""}\n `},s("ez-button",Object.assign({ref:t=>this._ezButton=t,iconName:"acao",size:"small",mode:"icon",title:this._application.messagesBuilder.getMessage("snkActionsButton.title.actions",void 0),onClick:()=>this.controlDropdown()},this.getElementID("button"))),s("div",Object.assign({ref:t=>this._dropdownParent=t,class:(this.canShowDropdown()?"snk-actions-button__dropdown--show":"snk-actions-button__dropdown")+"\n "},this.getElementID("dropdown")),this.canShowDropdown()&&s("ez-dropdown",Object.assign({items:this._items,onEzClick:t=>this.handleClick(t)},this.getElementID("dropdown"))))),this.canShowDropdown()&&s("div",Object.assign({class:"ez-scrim ez-scrim--light"},this.getElementID("ezScrim"))))}get _element(){return e(this)}};N.style=".sc-snk-actions-button-h{--snk-actions-button--z-index:var(--most-visible, 3);display:flex;width:fit-content;height:fit-content}.snk-actions-button.sc-snk-actions-button{display:flex;width:fit-content;height:fit-content}.snk-actions-button__dropdown--show.sc-snk-actions-button{display:flex;flex-direction:column;position:fixed}.snk-actions-button__dropdown.sc-snk-actions-button>ez-dropdown.sc-snk-actions-button{position:relative}.snk-actions-button--overlap.sc-snk-actions-button{z-index:var(--snk-actions-button--z-index)}.snk-actions-button__dropdown.sc-snk-actions-button{display:none}";export{N as snk_actions_button}
|
@@ -0,0 +1 @@
|
|
1
|
+
import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{SortMode as r,ElementIDUtils as d,ApplicationContext as a,DataType as o}from"@sankhyalabs/core";import{UserInterface as n}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{T as h}from"./p-c9841939.js";import{C as l}from"./p-b19c272c.js";import{P as c}from"./p-5534e08c.js";import{T as u}from"./p-c2beb95c.js";import{s as v}from"./p-6dc031de.js";import{S as g}from"./p-aeb2298c.js";import{SelectionMode as m}from"@sankhyalabs/core/dist/dataunit/DataUnit";import"./p-0f2b03e5.js";import"./p-4f7b9c50.js";import"./p-112455b1.js";import"./p-8d884fab.js";import"./p-584d7212.js";import"./p-b4a0b2e3.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"./p-688dcb4c.js";const f=class{constructor(s){i(this,s),this.actionClick=t(this,"actionClick",7),this.gridDoubleClick=t(this,"gridDoubleClick",7),this._topTaskbarProcessor=new u({"snkGridTopTaskbar.regular":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.regular.secondary":["FORM_MODE","CONFIGURATOR","INSERT"],"snkGridTopTaskbar.finish_edition":["CANCEL","SAVE"],"snkGridTopTaskbar.finish_edition.secondary":[]}),this._headerTaskbarProcessor=new u({"snkGridHeaderTaskbar.unselected":["REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.selected":["UPDATE","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","ATTACH","REFRESH","DATA_EXPORTER","ACTIONS_BUTTON"],"snkGridHeaderTaskbar.detail.unselected":["REFRESH"],"snkGridHeaderTaskbar.detail.selected":["UPDATE","ATTACH","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","REFRESH"]}),this._dataUnit=void 0,this._dataState=void 0,this._gridConfig=void 0,this._popUpGridConfig=!1,this.columnFilterDataSource=new g,this.configName=void 0,this.resourceID=void 0,this.selectionToastConfig=void 0,this.actionsList=void 0,this.isDetail=void 0,this.taskbarManager=void 0,this.statusResolver=void 0,this.multipleSelection=void 0,this.presentationMode=c.PRIMARY,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.recordsValidator=void 0,this.canEdit=!0,this.taskbarCustomContainerId=void 0,this.gridHeaderCustomSlotId="GRID_HEADER_CUSTOM_ELEMENTS",this.topTaskbarCustomSlotId="GRID_TASKBAR_CUSTOM_ELEMENTS"}async showConfig(){null!=this._grid&&this.openGridConfig()}async hideConfig(){null!=this._grid&&this.closeGridConfig()}async setConfig(i){this.setGridConfig(i)}async reloadFilterBar(){var i;null===(i=this._snkFilterBar)||void 0===i||i.reload()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._popUpGridConfig=!0}))}closeGridConfig(){this._popUpGridConfig=!1}setGridConfig(i){this._gridConfig=i,this.assertDefaultSorting()}assertDefaultSorting(){this._gridConfig&&this._dataUnit&&(this._dataUnit.defaultSorting=this._gridConfig.columns.filter((i=>null!=i.ascending)).sort(((i,t)=>i.orderIndex-t.orderIndex)).map((({name:i,ascending:t})=>{const{dataType:s}=this._dataUnit.getField(i);return{field:i,dataType:s,mode:t?r.ASC:r.DESC}})))}loadConfig(){l.loadGridConfig(this.configName,this.resourceID).then((i=>{this.setGridConfig(i)})).catch((i=>{console.warn(i)}))}gridConfigChangeHandler(i){l.saveGridConfig(i.detail,this.configName,this.resourceID),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig(),this.dataExporterProviderStore()})),i.stopPropagation()}buildColumnsMetadata(i){const t=[];return null==i||i.forEach((i=>{var s,e;if(i.hidden&&"RECDESP"!==i.name)return;const r=null===(s=this._dataUnit)||void 0===s?void 0:s.getField(i.name);if(t.push({label:i.label,id:i.name,width:i.width,type:null==r?void 0:r.dataType,userInterface:null==r?void 0:r.userInterface}),null!=(null===(e=null==r?void 0:r.properties)||void 0===e?void 0:e.DESCRIPTIONFIELD)){const i=r.properties.mergedFrom;t.push({label:r.properties.DESCRIPTIONENTITY,id:`${i?i+".":""}${r.properties.ENTITYNAME}.${r.properties.DESCRIPTIONFIELD}`,width:200,type:o.TEXT,userInterface:n.LONGTEXT})}})),t||[]}getPaginationInfo(){var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo()}getExporterOffset(i){if(null==i)return;const t=i.firstRecord;return t>0?t-1:t}async dataExporterProviderStore(){var i;const t=await(null===(i=this._snkDataUnit)||void 0===i?void 0:i.getSelectedRecordsIDsInfo()),s={getFilters:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getAppliedFilters()},getColumnsMetadata:async()=>{var i;const t=await(null===(i=this._grid)||void 0===i?void 0:i.getColumnsState());return this.buildColumnsMetadata(t)},getOrders:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.getSort()},getResourceURI:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.name},getSelectedNumber:()=>{var i,t;return null===(t=null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)||void 0===t?void 0:t.length},getTotalRecords:()=>{var i,t,s;const{total:e}=(null===(i=this._dataUnit)||void 0===i?void 0:i.getPaginationInfo())||{};return null!=e?e:null===(s=null===(t=this._dataUnit)||void 0===t?void 0:t.records)||void 0===s?void 0:s.length},getSelectedIDs:()=>t||[],getOffset:()=>this.getExporterOffset(this.getPaginationInfo()),getLimit:()=>{var i;return null===(i=this._dataUnit)||void 0===i?void 0:i.pageSize},getRecordID:()=>{var i,t,s;return null===(s=null===(t=null===(i=this._dataUnit)||void 0===i?void 0:i.records)||void 0===t?void 0:t[0])||void 0===s?void 0:s.__record__id__}};v.set("exporterProviders",Object.assign(Object.assign({},v.get("exporterProviders")),{[this.configName]:s}))}addElementID(){d.addIDInfo(this._element,null,{dataUnit:this._dataUnit})}finshLoading(){this.assertDefaultSorting(),this.addElementID(),null!=this.columnFilterDataSource&&(this.columnFilterDataSource.setApplication(this._application),this.columnFilterDataSource.setDataUnit(this._dataUnit))}componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataUnit?this.finshLoading():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.finshLoading()})),this.messagesBuilder||(this.messagesBuilder=this._snkDataUnit.messagesBuilder),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail})),this._snkDataUnit.addEventListener("cancelEdition",(()=>{var i;(null===(i=this._dataState)||void 0===i?void 0:i.recordsIsEmpty)&&this._dataUnit.clearSelection()}));break}i=i.parentElement}this.loadConfig()}getHeaderDisabledButtons(){var i;const t=[];return(null===(i=this._dataState)||void 0===i?void 0:i.selectionInfo)&&(this._dataState.selectionInfo.length>1&&t.push(h.CLONE,"ATTACH"),this._dataState.selectionInfo.isAllRecords()&&t.push("REMOVE")),t}getInvisibleButtons(){let i=[];return this._dataUnit&&0!==this._dataUnit.records.length||i.push("DATA_EXPORTER"),this._dataState&&this._dataState.selectionInfo.mode===m.ALL_RECORDS&&i.push("ACTIONS_BUTTON"),i}componentWillRender(){var i;const t=this.getInvisibleButtons();let s;s=this._dataState&&(null===(i=this._dataState.selectionInfo)||void 0===i?void 0:i.length)?this.isDetail?"snkGridHeaderTaskbar.detail.selected":"snkGridHeaderTaskbar.selected":this.isDetail?"snkGridHeaderTaskbar.detail.unselected":"snkGridHeaderTaskbar.unselected",this._headerTaskbarProcessor.process(s,this.taskbarManager,this._dataState,this.getHeaderDisabledButtons(),t),this._topTaskbarProcessor.process(this.getTopTaskBarId(this.presentationMode===c.SECONDARY?".secondary":""),this.taskbarManager,this._dataState,void 0,t),this.dataExporterProviderStore()}getTopTaskBarId(i){var t;return(null===(t=this._dataState)||void 0===t?void 0:t.isDirty)?`snkGridTopTaskbar.finish_edition${i}`:`snkGridTopTaskbar.regular${i}`}getPrimaryButton(){return this.presentationMode===c.PRIMARY?"INSERT":""}render(){var i,t;if(this._dataUnit)return s("div",{class:"snk-grid__container ez-flex ez-flex--column ez-flex-item--auto ez-padding--large"},s("div",{class:"snk-grid__header ez-margin-bottom--medium"},s("snk-filter-bar",{ref:i=>this._snkFilterBar=i,dataUnit:this._dataUnit,"data-element-id":"gridFilter",class:"snk-grid__filter-bar ez-align--top",configName:this.configName,messagesBuilder:this.messagesBuilder,resourceID:this.resourceID}),(null===(t=null===(i=this._snkFilterBar)||void 0===i?void 0:i.filterConfig)||void 0===t?void 0:t.length)>0&&s("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-grid__header-divider"}),s("snk-taskbar",{class:"ez-padding-left--medium","data-element-id":"grid_top",key:"topTaskbar",configName:this.configName,dataUnit:this._dataUnit,messagesBuilder:this.messagesBuilder,buttons:this._topTaskbarProcessor.buttons,disabledButtons:this._topTaskbarProcessor.disabledButtons,customButtons:this._topTaskbarProcessor.customButtons,primaryButton:this.getPrimaryButton(),resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.topTaskbarCustomSlotId},s("slot",{name:this.topTaskbarCustomSlotId}))),s("ez-grid",{ref:i=>this._grid=i,class:(this.presentationMode===c.SECONDARY?"snk-grid-container__without-shadow ":"")+"snk-grid__table","data-element-id":"embedded",dataUnit:this._dataUnit,key:"grid-"+this._snkDataUnit.entityName,config:this._gridConfig,onConfigChange:i=>{this.gridConfigChangeHandler(i)},onEzDoubleClick:()=>this.gridDoubleClick.emit(),statusResolver:this.statusResolver,multipleSelection:this.multipleSelection,columnfilterDataSource:this.columnFilterDataSource,selectionToastConfig:this.selectionToastConfig,useEnterLikeTab:this.useEnterLikeTab,recordsValidator:this.recordsValidator,canEdit:this.canEdit},s("snk-taskbar",{dataUnit:this._dataUnit,configName:this.configName,messagesBuilder:this.messagesBuilder,"data-element-id":"grid_left",buttons:this._headerTaskbarProcessor.buttons,disabledButtons:this._headerTaskbarProcessor.disabledButtons,customButtons:this._headerTaskbarProcessor.customButtons,slot:"leftButtons",actionsList:this.actionsList,resourceID:this.resourceID,customContainerId:this.taskbarCustomContainerId,customSlotId:this.gridHeaderCustomSlotId},s("slot",{name:this.gridHeaderCustomSlotId}))),s("div",{class:"ez-col ez-col--sd-12"},s("slot",{name:"SnkGridFooter"})),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._popUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this._gridConfig,"data-element-id":this._element.getAttribute(d.DATA_ELEMENT_ID_ATTRIBUTE_NAME),application:this._application,selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this.resourceID})))}get _element(){return e(this)}};f.style=".snk-grid__container.sc-snk-grid{display:flex;height:100%;width:100%}.snk-grid__header.sc-snk-grid{display:flex;flex-wrap:nowrap;width:100%}.snk-grid__filter-bar.sc-snk-grid{width:100%}.snk-grid__header-divider.sc-snk-grid{margin-bottom:var(--space--medium)}.snk-grid__table.sc-snk-grid{min-height:300px}.snk-grid-container__without-shadow.sc-snk-grid{--ezgrid__container--shadow:unset}";export{f as snk_grid}
|