@sankhyalabs/sankhyablocks 8.8.0-rc.1 → 8.8.0-rc.11
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/{ConfigStorage-a97ca159.js → ConfigStorage-c15716fd.js} +5 -2
- package/dist/cjs/{DataFetcher-2a99283c.js → DataFetcher-713f0749.js} +32 -32
- package/dist/cjs/PreloadManager-e26d237f.js +224 -0
- package/dist/cjs/{SnkFormConfigManager-f641f502.js → SnkFormConfigManager-29101e20.js} +2 -2
- package/dist/cjs/{SnkMultiSelectionListDataSource-56db34ee.js → SnkMultiSelectionListDataSource-d74d2336.js} +10 -6
- package/dist/cjs/{auth-fetcher-78231356.js → auth-fetcher-555ff856.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-4f7d4ee7.js → dataunit-fetcher-66c0b7af.js} +48 -248
- package/dist/cjs/{form-config-fetcher-a322a522.js → form-config-fetcher-17775a75.js} +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-7ef61508.js → pesquisa-fetcher-34922b83.js} +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button.cjs.entry.js +93 -86
- package/dist/cjs/snk-application.cjs.entry.js +16 -6
- package/dist/cjs/snk-attach.cjs.entry.js +4 -2
- package/dist/cjs/snk-crud.cjs.entry.js +7 -5
- package/dist/cjs/snk-data-exporter.cjs.entry.js +1 -1
- package/dist/cjs/snk-detail-view.cjs.entry.js +24 -8
- package/dist/cjs/snk-filter-bar.cjs.entry.js +19 -4
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -2
- package/dist/cjs/snk-form.cjs.entry.js +4 -4
- package/dist/cjs/snk-grid-config.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +8 -7
- package/dist/cjs/{snk-guides-viewer-aab80f66.js → snk-guides-viewer-b173ce35.js} +78 -5
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -7
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-simple-crud.cjs.entry.js +8 -5
- package/dist/collection/components/snk-actions-button/actions/executor/java.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/javascript.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/actions/executor/procedure.executor.js +2 -2
- package/dist/collection/components/snk-actions-button/clientEvent/index.js +81 -76
- package/dist/collection/components/snk-application/snk-application.js +1 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +18 -1
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +80 -8
- package/dist/collection/components/snk-filter-bar/filter-item/dataunitfilter/data-unit-filter-builder.js +17 -2
- package/dist/collection/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.js +5 -5
- package/dist/collection/components/snk-grid/snk-grid.js +1 -0
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +33 -34
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +7 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/ArrayRepository.js +25 -4
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +25 -55
- 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 +29 -8
- package/dist/collection/lib/http/data-fetcher/fetchers/personalized-filter-fetcher.js +3 -0
- package/dist/collection/lib/workspace/workspace.js +7 -0
- package/dist/components/ConfigStorage.js +3 -0
- package/dist/components/DataFetcher.js +32 -32
- package/dist/components/SnkMultiSelectionListDataSource.js +5 -5
- package/dist/components/dataunit-fetcher.js +87 -68
- package/dist/components/snk-actions-button2.js +87 -82
- package/dist/components/snk-application2.js +8 -0
- package/dist/components/snk-detail-view2.js +88 -2
- package/dist/components/snk-filter-bar2.js +17 -2
- package/dist/components/snk-grid2.js +1 -0
- package/dist/esm/{ConfigStorage-26f89143.js → ConfigStorage-79c81f36.js} +5 -2
- package/dist/esm/{DataFetcher-90e91631.js → DataFetcher-79f78222.js} +32 -32
- package/dist/esm/PreloadManager-8826b96a.js +222 -0
- package/dist/esm/{SnkFormConfigManager-18948123.js → SnkFormConfigManager-7723f3ec.js} +2 -2
- package/dist/esm/{SnkMultiSelectionListDataSource-b9410c72.js → SnkMultiSelectionListDataSource-27572f47.js} +6 -6
- package/dist/esm/{auth-fetcher-a8c8ee7e.js → auth-fetcher-e260d0cd.js} +1 -1
- package/dist/esm/{dataunit-fetcher-1c2ccae2.js → dataunit-fetcher-831feb12.js} +41 -240
- package/dist/esm/{form-config-fetcher-7c3b6273.js → form-config-fetcher-e1603e66.js} +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-90d6853b.js → pesquisa-fetcher-8e922c9d.js} +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button.entry.js +93 -86
- package/dist/esm/snk-application.entry.js +16 -6
- package/dist/esm/snk-attach.entry.js +4 -2
- package/dist/esm/snk-crud.entry.js +7 -5
- package/dist/esm/snk-data-exporter.entry.js +1 -1
- package/dist/esm/snk-detail-view.entry.js +24 -8
- package/dist/esm/snk-filter-bar.entry.js +20 -5
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-form-config.entry.js +2 -2
- package/dist/esm/snk-form.entry.js +4 -4
- package/dist/esm/snk-grid-config.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +8 -7
- package/dist/esm/{snk-guides-viewer-62b0fa69.js → snk-guides-viewer-e62e0edc.js} +79 -6
- package/dist/esm/snk-guides-viewer.entry.js +9 -7
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-simple-crud.entry.js +8 -5
- package/dist/sankhyablocks/{p-ebfa6460.entry.js → p-06e76ed2.entry.js} +1 -1
- package/dist/sankhyablocks/p-29176742.js +56 -0
- package/dist/sankhyablocks/p-2e6f1666.js +1 -0
- package/dist/sankhyablocks/{p-d563e451.entry.js → p-3bf4df20.entry.js} +1 -1
- package/dist/sankhyablocks/p-3c4f0354.js +1 -0
- package/dist/sankhyablocks/p-3ccb321d.entry.js +1 -0
- package/dist/sankhyablocks/{p-240f5892.js → p-41d156dd.js} +1 -1
- package/dist/sankhyablocks/{p-d47bbee3.js → p-4651b43f.js} +1 -1
- package/dist/sankhyablocks/{p-8652f90b.entry.js → p-47e4b6c9.entry.js} +1 -1
- package/dist/sankhyablocks/{p-68fbd480.entry.js → p-4f5b995d.entry.js} +1 -1
- package/dist/sankhyablocks/p-5f6113c8.js +60 -0
- package/dist/sankhyablocks/p-72b32e25.entry.js +11 -0
- package/dist/sankhyablocks/{p-57550ddc.entry.js → p-747043a5.entry.js} +1 -1
- package/dist/sankhyablocks/p-77756526.js +1 -0
- package/dist/sankhyablocks/{p-e74e2153.entry.js → p-80692cbd.entry.js} +1 -1
- package/dist/sankhyablocks/p-848b2e3b.entry.js +1 -0
- package/dist/sankhyablocks/p-862e5bf6.entry.js +1 -0
- package/dist/sankhyablocks/p-95b05e58.entry.js +1 -0
- package/dist/sankhyablocks/p-a1cce4f5.entry.js +1 -0
- package/dist/sankhyablocks/{p-5d51bff4.js → p-c9399ce6.js} +1 -1
- package/dist/sankhyablocks/p-d0b36421.js +1 -0
- package/dist/sankhyablocks/p-d32fe25e.js +1 -0
- package/dist/sankhyablocks/p-eb1561bf.entry.js +1 -0
- package/dist/sankhyablocks/p-f1743d68.entry.js +1 -0
- package/dist/sankhyablocks/p-f2e798f1.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/clientEvent/index.d.ts +1 -1
- package/dist/types/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.d.ts +3 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +22 -11
- package/dist/types/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.d.ts +1 -0
- package/dist/types/lib/http/data-fetcher/DataFetcher.d.ts +5 -2
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +3 -6
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/ILoadingInfo.d.ts +2 -0
- package/dist/types/lib/workspace/workspace.d.ts +1 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-193971ad.js +0 -1
- package/dist/sankhyablocks/p-19cbe6e2.entry.js +0 -11
- package/dist/sankhyablocks/p-2c7c1323.entry.js +0 -1
- package/dist/sankhyablocks/p-3253e7f2.entry.js +0 -1
- package/dist/sankhyablocks/p-5dd52ec5.entry.js +0 -1
- package/dist/sankhyablocks/p-6541f0df.js +0 -1
- package/dist/sankhyablocks/p-910af03c.js +0 -56
- package/dist/sankhyablocks/p-992a9d0f.js +0 -1
- package/dist/sankhyablocks/p-acb1374c.entry.js +0 -1
- package/dist/sankhyablocks/p-b36053da.entry.js +0 -1
- package/dist/sankhyablocks/p-b481e5ad.js +0 -1
- package/dist/sankhyablocks/p-d264da22.entry.js +0 -1
- package/dist/sankhyablocks/p-d56b65e3.entry.js +0 -1
- package/dist/sankhyablocks/p-e473ca13.entry.js +0 -1
- package/dist/sankhyablocks/p-e86d4a53.js +0 -59
@@ -1,4 +1,5 @@
|
|
1
1
|
import { UserInterface, DateUtils } from '@sankhyalabs/core';
|
2
|
+
import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
2
3
|
import { a as PreloadManager } from './dataunit-fetcher.js';
|
3
4
|
|
4
5
|
class TaskbarProcessor {
|
@@ -65,11 +66,7 @@ class SnkMultiSelectionListDataSource {
|
|
65
66
|
if (fieldName == undefined) {
|
66
67
|
return Promise.resolve(undefined);
|
67
68
|
}
|
68
|
-
|
69
|
-
if (result == undefined) {
|
70
|
-
return Promise.resolve(undefined);
|
71
|
-
}
|
72
|
-
return Promise.resolve(Array.from(result.entries()).map(([label, value]) => ({ label: String(label), value, check: true })));
|
69
|
+
return Promise.resolve(await PreloadManager.getDistinct(this._dataUnit, fieldName));
|
73
70
|
}
|
74
71
|
fetchData(filterTerm, fieldName) {
|
75
72
|
return new Promise(resolve => {
|
@@ -84,6 +81,9 @@ class SnkMultiSelectionListDataSource {
|
|
84
81
|
});
|
85
82
|
});
|
86
83
|
}
|
84
|
+
sortItems(fieldName, items) {
|
85
|
+
return InMemoryFilterColumnDataSource.defaultSorterMultSelectionOption(this._dataUnit, fieldName, items);
|
86
|
+
}
|
87
87
|
}
|
88
88
|
|
89
89
|
export { SnkMultiSelectionListDataSource as S, TaskbarProcessor as T };
|
@@ -2,6 +2,7 @@ import { DataType, FieldComparator, SortMode, DataUnit, defaultDataLoader, DateU
|
|
2
2
|
import { d as dist, D as DataFetcher } from './DataFetcher.js';
|
3
3
|
import { DISTINCT_FILTER_NAME_PREFIX } from '@sankhyalabs/ezui/dist/collection/utils/constants';
|
4
4
|
import { DataUnitTransient } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
5
|
+
import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
5
6
|
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
6
7
|
|
7
8
|
class PesquisaFetcher {
|
@@ -187,9 +188,23 @@ class ArrayRepository {
|
|
187
188
|
return Promise.resolve({ result, count });
|
188
189
|
}
|
189
190
|
async distict(itemProcessor) {
|
190
|
-
const processedItems =
|
191
|
-
|
192
|
-
|
191
|
+
const processedItems = [];
|
192
|
+
let hasEmpty = false;
|
193
|
+
for (const item of this._list) {
|
194
|
+
const processedItem = itemProcessor(item);
|
195
|
+
if (processedItem == undefined) {
|
196
|
+
continue;
|
197
|
+
}
|
198
|
+
if (processedItem.value == undefined) {
|
199
|
+
hasEmpty = true;
|
200
|
+
continue;
|
201
|
+
}
|
202
|
+
processedItems.push(processedItem);
|
203
|
+
}
|
204
|
+
if (hasEmpty) {
|
205
|
+
processedItems.push({ key: "", value: null });
|
206
|
+
}
|
207
|
+
return Promise.resolve(new Map(processedItems.map(item => [item.key, item.value])));
|
193
208
|
}
|
194
209
|
async push(items) {
|
195
210
|
this._list.push(...items);
|
@@ -198,7 +213,14 @@ class ArrayRepository {
|
|
198
213
|
this._list = [];
|
199
214
|
}
|
200
215
|
async delete(items) {
|
201
|
-
this._list = this._list.filter(item =>
|
216
|
+
this._list = this._list.filter(item => {
|
217
|
+
for (const removed of items) {
|
218
|
+
if (this._equalsFunction(item, removed)) {
|
219
|
+
return false;
|
220
|
+
}
|
221
|
+
}
|
222
|
+
return true;
|
223
|
+
});
|
202
224
|
}
|
203
225
|
async update(items) {
|
204
226
|
this._list = this._list.map(existingItem => {
|
@@ -225,21 +247,12 @@ class ArrayRepository {
|
|
225
247
|
}
|
226
248
|
}
|
227
249
|
|
228
|
-
const COLUMN_FILTER_PATTERN = /FILTRO_COLUNA_(.+)/;
|
229
250
|
class PreloadManager {
|
230
251
|
static setLoadingStatus(dataUnit, loadingInProgress) {
|
231
252
|
this._loadingStatus.set(dataUnit.name, loadingInProgress);
|
232
253
|
}
|
233
|
-
static isCacheEnabled(
|
234
|
-
|
235
|
-
if (dataUnitResourceId !== this.applicationResourceID) {
|
236
|
-
return false;
|
237
|
-
}
|
238
|
-
return this.getRepository(dataUnit).isOperating();
|
239
|
-
}
|
240
|
-
static getResourceId(dataUnitName) {
|
241
|
-
const dataUnitNameInfo = DataUnitFetcher.parseDataUnitName(dataUnitName);
|
242
|
-
return dataUnitNameInfo == undefined ? undefined : dataUnitNameInfo.resourceID;
|
254
|
+
static isCacheEnabled(_dataUnit) {
|
255
|
+
return true;
|
243
256
|
}
|
244
257
|
static cacheRecords(dataUnit, records, resetDatabase, loadingInProgress) {
|
245
258
|
PreloadManager.setLoadingStatus(dataUnit, loadingInProgress);
|
@@ -267,18 +280,33 @@ class PreloadManager {
|
|
267
280
|
}
|
268
281
|
static async getDistinct(dataUnit, fieldName) {
|
269
282
|
if (!PreloadManager.isCacheEnabled(dataUnit)) {
|
270
|
-
return Promise.resolve(
|
283
|
+
return Promise.resolve(ColumnFilterManager.compileDistinct(fieldName, dataUnit));
|
284
|
+
}
|
285
|
+
let filterFunction;
|
286
|
+
const request = dataUnit.getLastLoadRequest();
|
287
|
+
if (request != undefined) {
|
288
|
+
const columnFilters = ColumnFilterManager.getColumnFilters(request.filters);
|
289
|
+
filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values()));
|
271
290
|
}
|
272
291
|
return new Promise((accept, reject) => {
|
273
292
|
PreloadManager.getRepository(dataUnit).distict(record => {
|
293
|
+
if (filterFunction != undefined && !filterFunction(record)) {
|
294
|
+
return undefined;
|
295
|
+
}
|
274
296
|
const fieldValue = record[fieldName];
|
275
297
|
if (fieldValue == undefined) {
|
276
|
-
return
|
298
|
+
return { key: null, value: null };
|
277
299
|
}
|
278
300
|
const value = fieldValue.value != undefined ? fieldValue.value : fieldValue;
|
279
301
|
return { key: dataUnit.getFormattedValue(fieldName, fieldValue), value };
|
280
302
|
})
|
281
|
-
.then(
|
303
|
+
.then(result => {
|
304
|
+
if (result == undefined) {
|
305
|
+
accept(undefined);
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
accept(Array.from(result.entries()).map(([label, value]) => ({ label, value, check: true })));
|
309
|
+
})
|
282
310
|
.catch(reason => reject(reason));
|
283
311
|
});
|
284
312
|
}
|
@@ -292,7 +320,7 @@ class PreloadManager {
|
|
292
320
|
return PreloadManager.loadFromCache(dataUnit, request);
|
293
321
|
}
|
294
322
|
}
|
295
|
-
//Como não vamos aproveitar o cache, ele precisa ser
|
323
|
+
//Como não vamos aproveitar o cache, ele precisa ser limpo.
|
296
324
|
PreloadManager.getRepository(dataUnit).clear().catch(() => { });
|
297
325
|
}
|
298
326
|
return loadFromServer(dataUnit, request);
|
@@ -330,39 +358,16 @@ class PreloadManager {
|
|
330
358
|
}
|
331
359
|
return PreloadManager._repositories.get(name);
|
332
360
|
}
|
333
|
-
static getFilterFunction(dataUnit, filters) {
|
334
|
-
if (filters != undefined && filters.length > 0) {
|
335
|
-
return record => {
|
336
|
-
for (const filter of filters) {
|
337
|
-
if (!PreloadManager.recordMatchesFilter(dataUnit, record, filter)) {
|
338
|
-
return false;
|
339
|
-
}
|
340
|
-
}
|
341
|
-
return true;
|
342
|
-
};
|
343
|
-
}
|
344
|
-
return undefined;
|
345
|
-
}
|
346
|
-
static recordMatchesFilter(dataUnit, record, columnFilter) {
|
347
|
-
const fieldValue = record[columnFilter.columnName];
|
348
|
-
for (let param of columnFilter.params) {
|
349
|
-
const paramValue = dataUnit.valueFromString(columnFilter.columnName, param.value);
|
350
|
-
if (FieldComparator.compareValues(dataUnit.getField(columnFilter.columnName), fieldValue, paramValue) === 0) {
|
351
|
-
return true;
|
352
|
-
}
|
353
|
-
}
|
354
|
-
return false;
|
355
|
-
}
|
356
361
|
static async loadFromCache(dataUnit, request) {
|
357
362
|
return new Promise((accept, reject) => {
|
358
|
-
const columnFilters =
|
363
|
+
const columnFilters = ColumnFilterManager.getColumnFilters(request.filters);
|
359
364
|
const { limit, offset, sort } = request;
|
360
365
|
PreloadManager.getRepository(dataUnit)
|
361
|
-
.load(
|
366
|
+
.load(ColumnFilterManager.getFilterFunction(dataUnit, Array.from(columnFilters.values())), PreloadManager.getSortingFunction(dataUnit, sort), offset, limit)
|
362
367
|
.then(loadResult => {
|
363
368
|
const stillLoading = PreloadManager._loadingStatus.get(dataUnit.name);
|
364
369
|
const { count, result: records } = loadResult;
|
365
|
-
const firstRecord = count == 0 ?
|
370
|
+
const firstRecord = count == 0 ? 0 : offset + 1;
|
366
371
|
const lastRecord = offset + Math.min(records.length, limit);
|
367
372
|
const currentPage = offset / limit;
|
368
373
|
const paginationInfo = {
|
@@ -375,19 +380,6 @@ class PreloadManager {
|
|
375
380
|
.catch(reason => reject(reason));
|
376
381
|
});
|
377
382
|
}
|
378
|
-
static getColumnFilters(filters) {
|
379
|
-
const columnFilters = new Map();
|
380
|
-
if (filters == undefined || filters.length == 0) {
|
381
|
-
return columnFilters;
|
382
|
-
}
|
383
|
-
filters.forEach(filter => {
|
384
|
-
const match = COLUMN_FILTER_PATTERN.exec(filter.name);
|
385
|
-
if (match) {
|
386
|
-
columnFilters.set(filter.name, Object.assign({ columnName: match[1] }, filter));
|
387
|
-
}
|
388
|
-
});
|
389
|
-
return columnFilters;
|
390
|
-
}
|
391
383
|
}
|
392
384
|
PreloadManager._repositories = new Map();
|
393
385
|
PreloadManager._loadingStatus = new Map();
|
@@ -508,17 +500,36 @@ class DatasetStrategy {
|
|
508
500
|
return Promise.resolve({ records: [], loadingInfo });
|
509
501
|
}
|
510
502
|
try {
|
503
|
+
const localSorting = [];
|
504
|
+
const serverSorting = [];
|
505
|
+
if (request.sort != undefined) {
|
506
|
+
for (const sort of request.sort) {
|
507
|
+
const descriptor = dataUnit.getField(sort.field);
|
508
|
+
const local = descriptor != undefined
|
509
|
+
&& descriptor.properties != undefined
|
510
|
+
&& descriptor.properties.calculated === "true";
|
511
|
+
if (local) {
|
512
|
+
localSorting.push(sort);
|
513
|
+
}
|
514
|
+
else {
|
515
|
+
serverSorting.push(sort);
|
516
|
+
}
|
517
|
+
}
|
518
|
+
}
|
511
519
|
const fields = this.getFieldsList(dataUnit);
|
512
520
|
const serviceName = "DatasetSP.loadRecords";
|
513
|
-
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo);
|
514
|
-
const {
|
521
|
+
const requestBody = this.buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, serverSorting);
|
522
|
+
const params = loadingInfo.quiet ? { urlParams: { quietMode: "true" } } : undefined;
|
523
|
+
const { result: responseRecords, pagerID: pagerId } = await DataFetcher.get().callServiceBroker(serviceName, requestBody, params);
|
515
524
|
const records = this.processRecords(dataUnit, fields, responseRecords);
|
516
525
|
const loadingInProgress = pagerId != undefined;
|
517
526
|
const count = loadingInfo.count + records.length;
|
527
|
+
const needReload = !loadingInProgress && localSorting.length > 0;
|
518
528
|
return Promise.resolve({
|
519
529
|
records,
|
520
530
|
loadingInfo: Object.assign(Object.assign({}, loadingInfo), { pagerId,
|
521
|
-
loadingInProgress, total: loadingInProgress ? undefined : count, count
|
531
|
+
loadingInProgress, total: loadingInProgress ? undefined : count, count,
|
532
|
+
needReload })
|
522
533
|
});
|
523
534
|
}
|
524
535
|
catch (error) {
|
@@ -528,7 +539,10 @@ class DatasetStrategy {
|
|
528
539
|
}
|
529
540
|
getFieldsList(dataUnit) {
|
530
541
|
let fields = ["__record__id__", "__record__label__"];
|
531
|
-
dataUnit.metadata.fields.forEach(descriptor => {
|
542
|
+
dataUnit.metadata.fields.forEach((descriptor) => {
|
543
|
+
if (descriptor.standAlone) {
|
544
|
+
return;
|
545
|
+
}
|
532
546
|
fields = fields.concat(this.getFieldNames(descriptor));
|
533
547
|
});
|
534
548
|
return fields;
|
@@ -540,7 +554,7 @@ class DatasetStrategy {
|
|
540
554
|
}
|
541
555
|
return [descriptor.name, descriptionField];
|
542
556
|
}
|
543
|
-
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo) {
|
557
|
+
buildRequestBody(serviceName, fields, dataUnit, request, loadingInfo, sorting) {
|
544
558
|
const dataSetID = dataUnit.dataUnitId;
|
545
559
|
const dataUnitName = dataUnit.name;
|
546
560
|
const entityName = DataUnitFetcher.parseDataUnitName(dataUnitName).entityName;
|
@@ -561,13 +575,13 @@ class DatasetStrategy {
|
|
561
575
|
tryJoinedFields: true,
|
562
576
|
parallelLoader: true,
|
563
577
|
crudListener: "br.com.sankhya.modelcore.dataset.DataUnitDatasetAdapter",
|
564
|
-
txProperties: this.getTxProperties(dataUnitName, request),
|
578
|
+
txProperties: this.getTxProperties(dataUnitName, request, sorting),
|
565
579
|
useDefaultRowsLimit: false
|
566
580
|
}
|
567
581
|
};
|
568
582
|
return JSON.stringify(requestBody);
|
569
583
|
}
|
570
|
-
getTxProperties(dataUnitName, request) {
|
584
|
+
getTxProperties(dataUnitName, request, sorting) {
|
571
585
|
const txProperties = {
|
572
586
|
"__DATA_UNIT_ADAPTER__[dataUnitName]": dataUnitName
|
573
587
|
};
|
@@ -575,7 +589,6 @@ class DatasetStrategy {
|
|
575
589
|
if (serverSideFilters.length !== 0) {
|
576
590
|
txProperties["__DATA_UNIT_ADAPTER__[criteria]"] = JSON.stringify(serverSideFilters);
|
577
591
|
}
|
578
|
-
const sorting = request.sort;
|
579
592
|
if (sorting != undefined && sorting.length !== 0) {
|
580
593
|
txProperties["__DATA_UNIT_ADAPTER__[sorting]"] = JSON.stringify(sorting);
|
581
594
|
}
|
@@ -682,7 +695,7 @@ class DataUnitDataLoader {
|
|
682
695
|
PreloadManager.cacheRecords(dataUnit, records, recreateCache, responseLoadingInfo.loadingInProgress);
|
683
696
|
if (PreloadManager.isCacheEnabled(dataUnit) && responseLoadingInfo.loadingInProgress) {
|
684
697
|
const newRequest = Object.assign(Object.assign({}, request), { offset: responseLoadingInfo.count });
|
685
|
-
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1 });
|
698
|
+
const newLoadingInfo = Object.assign(Object.assign({}, responseLoadingInfo), { pageNumber: (responseLoadingInfo.pageNumber || 0) + 1, quiet: true });
|
686
699
|
this.callLoader(dataUnit, newRequest, newLoadingInfo, dataLoader)
|
687
700
|
.then(result => DataUnitDataLoader.afterLoadingPage(dataUnit, result.loadingInfo))
|
688
701
|
.catch(reason => console.error(reason));
|
@@ -700,6 +713,11 @@ class DataUnitDataLoader {
|
|
700
713
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { count }));
|
701
714
|
return;
|
702
715
|
}
|
716
|
+
if (loadingInfo.needReload) {
|
717
|
+
//Ir para a primeira página, faz com que o loadData seja chamado novamente
|
718
|
+
dataUnit.gotoPage(0);
|
719
|
+
return;
|
720
|
+
}
|
703
721
|
dataUnit.updatePagination(Object.assign(Object.assign({}, dataUnitPagination), { total: count, count }));
|
704
722
|
}
|
705
723
|
static registryLoading(dataUnit, loadingInfo) {
|
@@ -724,7 +742,7 @@ class DataUnitDataLoader {
|
|
724
742
|
offset = 0;
|
725
743
|
}
|
726
744
|
const { total, count, loadingInProgress } = loadingInfo;
|
727
|
-
const firstRecord = count === 0 ? 0 : offset + 1;
|
745
|
+
const firstRecord = (count === 0 || pageSize === 0) ? 0 : offset + 1;
|
728
746
|
const lastRecord = offset + Math.min(pageSize, limit);
|
729
747
|
return {
|
730
748
|
total,
|
@@ -765,6 +783,7 @@ class DataUnitFetcher {
|
|
765
783
|
defaultValue
|
766
784
|
label
|
767
785
|
visible
|
786
|
+
standAlone
|
768
787
|
readOnly
|
769
788
|
required
|
770
789
|
dataType
|
@@ -22,13 +22,13 @@ class JavaExecutor {
|
|
22
22
|
resolve({ execSource, callback: this.callExecJava });
|
23
23
|
});
|
24
24
|
}
|
25
|
-
callExecJava(execSource) {
|
25
|
+
async callExecJava(execSource) {
|
26
26
|
const request = {
|
27
27
|
requestBody: {
|
28
28
|
javaCall: execSource
|
29
29
|
}
|
30
30
|
};
|
31
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
31
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_JAVA, JSON.stringify(request));
|
32
32
|
}
|
33
33
|
}
|
34
34
|
|
@@ -44,11 +44,11 @@ class JavascriptExecutor {
|
|
44
44
|
resolve({ execSource, callback: this.callExecScript });
|
45
45
|
});
|
46
46
|
}
|
47
|
-
callExecScript(execSource) {
|
47
|
+
async callExecScript(execSource) {
|
48
48
|
const request = {
|
49
49
|
runScript: execSource
|
50
50
|
};
|
51
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
51
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_SCRIPT, request);
|
52
52
|
}
|
53
53
|
}
|
54
54
|
|
@@ -110,13 +110,13 @@ class ProcedureExecutor {
|
|
110
110
|
resolve({ execSource, callback: this.callExecProcedure });
|
111
111
|
});
|
112
112
|
}
|
113
|
-
callExecProcedure(execSource) {
|
113
|
+
async callExecProcedure(execSource) {
|
114
114
|
const request = {
|
115
115
|
requestBody: {
|
116
116
|
stpCall: execSource
|
117
117
|
}
|
118
118
|
};
|
119
|
-
DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
119
|
+
await DataFetcher.get().callServiceBroker(SERVICE_ACTION_EXECUTE_STP, JSON.stringify(request));
|
120
120
|
}
|
121
121
|
}
|
122
122
|
|
@@ -506,86 +506,91 @@ class Actions {
|
|
506
506
|
const CONFIRMACAO = "__CONFIRMACAO__";
|
507
507
|
const ESCOLHA_SIM_NAO = "__ESCOLHA_SIMNAO__";
|
508
508
|
class ClientEventConfirm {
|
509
|
-
clientConfirm(clientEvent, recaller) {
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
if (!recaller.requestBody.params) {
|
529
|
-
recaller.requestBody.params = {
|
530
|
-
param: []
|
509
|
+
async clientConfirm(clientEvent, recaller) {
|
510
|
+
return new Promise((resolve) => {
|
511
|
+
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
512
|
+
let actionType = "";
|
513
|
+
if (clientEvent.content.event.hasOwnProperty('stpCall')) {
|
514
|
+
recaller.requestBody = clientEvent.content.event.stpCall;
|
515
|
+
actionType = ActionsType.PROCEDURE;
|
516
|
+
}
|
517
|
+
else if (clientEvent.content.event.hasOwnProperty('runScript')) {
|
518
|
+
recaller.requestBody = clientEvent.content.event.runScript;
|
519
|
+
actionType = ActionsType.JAVASCRIPT;
|
520
|
+
}
|
521
|
+
else if (clientEvent.content.event.hasOwnProperty('javaCall')) {
|
522
|
+
recaller.requestBody = clientEvent.content.event.javaCall;
|
523
|
+
actionType = ActionsType.JAVA;
|
524
|
+
}
|
525
|
+
let param = {
|
526
|
+
type: 'S',
|
527
|
+
sequence: clientEvent.content.event.sequence
|
531
528
|
};
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
529
|
+
if (!recaller.requestBody.params) {
|
530
|
+
recaller.requestBody.params = {
|
531
|
+
param: []
|
532
|
+
};
|
536
533
|
}
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
requestBody:
|
549
|
-
|
550
|
-
|
534
|
+
else {
|
535
|
+
if (!Array.isArray(recaller.requestBody.params.param)) {
|
536
|
+
recaller.requestBody.params.param = [recaller.requestBody.params.param];
|
537
|
+
}
|
538
|
+
}
|
539
|
+
recaller.requestBody.params.param.push(param);
|
540
|
+
const title = clientEvent.content.event.title.$;
|
541
|
+
const message = clientEvent.content.event.message.$;
|
542
|
+
let requestBody;
|
543
|
+
switch (actionType) {
|
544
|
+
case ActionsType.JAVASCRIPT:
|
545
|
+
requestBody = { runScript: recaller.requestBody };
|
546
|
+
break;
|
547
|
+
case ActionsType.PROCEDURE:
|
548
|
+
requestBody = {
|
549
|
+
requestBody: {
|
550
|
+
stpCall: recaller.requestBody
|
551
|
+
}
|
552
|
+
};
|
553
|
+
break;
|
554
|
+
case ActionsType.JAVA:
|
555
|
+
requestBody = {
|
556
|
+
requestBody: {
|
557
|
+
javaCall: recaller.requestBody
|
558
|
+
}
|
559
|
+
};
|
560
|
+
break;
|
561
|
+
}
|
562
|
+
if (clientEvent.content.event.showNoOption == 'S') {
|
563
|
+
param.paramName = ESCOLHA_SIM_NAO;
|
564
|
+
const form = document.createElement("snk-client-confirm");
|
565
|
+
window.document.body.appendChild(form);
|
566
|
+
form.titleMessage = title;
|
567
|
+
form.message = message;
|
568
|
+
form.accept = async () => {
|
569
|
+
param.$ = 'S';
|
570
|
+
await recaller.reCall(requestBody);
|
571
|
+
resolve();
|
551
572
|
};
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
javaCall: recaller.requestBody
|
557
|
-
}
|
573
|
+
form.cancel = async () => {
|
574
|
+
param.$ = 'N';
|
575
|
+
await recaller.reCall(requestBody);
|
576
|
+
resolve();
|
558
577
|
};
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
form.openPopup();
|
576
|
-
}
|
577
|
-
else {
|
578
|
-
application.confirm(title, message, null, 'warn', {
|
579
|
-
labelCancel: "Cancelar",
|
580
|
-
labelConfirm: "Sim"
|
581
|
-
}).then((confirmResult) => {
|
582
|
-
if (confirmResult) {
|
583
|
-
param.paramName = CONFIRMACAO;
|
584
|
-
param.$ = 'S';
|
585
|
-
recaller.reCall(requestBody);
|
586
|
-
}
|
587
|
-
});
|
588
|
-
}
|
578
|
+
form.openPopup();
|
579
|
+
}
|
580
|
+
else {
|
581
|
+
application.confirm(title, message, null, 'warn', {
|
582
|
+
labelCancel: "Cancelar",
|
583
|
+
labelConfirm: "Sim"
|
584
|
+
}).then(async (confirmResult) => {
|
585
|
+
if (confirmResult) {
|
586
|
+
param.paramName = CONFIRMACAO;
|
587
|
+
param.$ = 'S';
|
588
|
+
await recaller.reCall(requestBody);
|
589
|
+
resolve();
|
590
|
+
}
|
591
|
+
});
|
592
|
+
}
|
593
|
+
});
|
589
594
|
}
|
590
595
|
}
|
591
596
|
|
@@ -170,6 +170,13 @@ class Workspace {
|
|
170
170
|
var _a;
|
171
171
|
(_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.setScreenToUseOldLayout();
|
172
172
|
}
|
173
|
+
static applicationClick() {
|
174
|
+
var _a, _b;
|
175
|
+
if (!((_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.applicationClick)) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
(_b = window["workspace"]) === null || _b === void 0 ? void 0 : _b.applicationClick();
|
179
|
+
}
|
173
180
|
}
|
174
181
|
Workspace.resourceID = (_a = window["workspace"]) === null || _a === void 0 ? void 0 : _a.resourceID;
|
175
182
|
|
@@ -1047,6 +1054,7 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
|
|
1047
1054
|
}, 100);
|
1048
1055
|
ErrorTracking.init();
|
1049
1056
|
ConfigStorage.preload(this.applicationResourceID, this.configName);
|
1057
|
+
document.addEventListener("click", () => Workspace.applicationClick());
|
1050
1058
|
}
|
1051
1059
|
connectedCallback() {
|
1052
1060
|
ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
|