@sankhyalabs/sankhyablocks 8.15.0-dev.60 → 8.15.0-dev.62
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-7df9d3bb.js → ConfigStorage-9a53a42c.js} +12 -11
- package/dist/cjs/{form-config-fetcher-3c4daeb5.js → DataFetcher-515bda03.js} +0 -251
- package/dist/cjs/{IExporterProvider-1ed8e92a.js → IExporterProvider-d3a3ccd1.js} +55 -12
- package/dist/cjs/{SnkFormConfigManager-4259edbe.js → SnkFormConfigManager-dda10d75.js} +2 -2
- package/dist/cjs/{SnkMessageBuilder-66aa2557.js → SnkMessageBuilder-4a95fe86.js} +6 -12
- package/dist/cjs/{auth-fetcher-e6112be7.js → auth-fetcher-5acb0335.js} +1 -1
- package/dist/cjs/{pesquisa-fetcher-cb768be1.js → dataunit-fetcher-e2109392.js} +68 -173
- package/dist/cjs/form-config-fetcher-3f430aee.js +256 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pesquisa-fetcher-916a935c.js +166 -0
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +10 -8
- package/dist/cjs/snk-application.cjs.entry.js +49 -39
- package/dist/cjs/snk-attach.cjs.entry.js +19 -17
- package/dist/cjs/snk-crud.cjs.entry.js +43 -9
- package/dist/cjs/snk-data-exporter.cjs.entry.js +9 -7
- package/dist/cjs/snk-data-unit-dee38ccd.js +614 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +10 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +8 -6
- package/dist/cjs/snk-filter-bar.cjs.entry.js +3 -2
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -2
- package/dist/cjs/snk-form-config.cjs.entry.js +2 -1
- package/dist/cjs/snk-form-view.cjs.entry.js +36 -0
- package/dist/cjs/snk-form.cjs.entry.js +28 -7
- package/dist/cjs/snk-grid.cjs.entry.js +55 -10
- package/dist/cjs/{snk-guides-viewer-bec9c1a5.js → snk-guides-viewer-af4a6ae5.js} +19 -6
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +8 -6
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +96 -14
- package/dist/collection/collection-manifest.json +1 -1
- package/dist/collection/components/snk-application/snk-application.js +37 -17
- package/dist/collection/components/snk-crud/snk-crud.js +109 -6
- package/dist/collection/components/snk-crud/subcomponents/snk-form-view.js +79 -0
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +41 -4
- package/dist/collection/components/snk-data-exporter/interfaces/IExporterProvider.js +14 -8
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +5 -0
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +413 -165
- package/dist/collection/components/snk-data-unit/test/resources/metadataMock.js +24 -0
- package/dist/collection/components/snk-form/snk-form.js +50 -4
- package/dist/collection/components/snk-grid/snk-grid.js +96 -7
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +156 -8
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +35 -0
- package/dist/collection/lib/dataUnit/ValueFormatter.js +4 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.js +1 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +51 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.js +22 -0
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +2 -2
- package/dist/collection/lib/message/SnkMessageBuilder.js +25 -32
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -0
- package/dist/components/ConfigStorage.js +2 -1
- package/dist/components/DataFetcher.js +7024 -0
- package/dist/components/IExporterProvider.js +54 -12
- package/dist/components/SnkMessageBuilder.js +6 -12
- package/dist/components/dataunit-fetcher.js +58 -164
- package/dist/components/form-config-fetcher.js +3 -7023
- package/dist/components/pesquisa-fetcher.js +164 -0
- package/dist/components/snk-actions-button2.js +4 -2
- package/dist/components/snk-application2.js +26 -17
- package/dist/components/snk-attach2.js +4 -2
- package/dist/components/snk-crud.js +46 -9
- package/dist/components/snk-data-exporter2.js +4 -2
- package/dist/components/snk-data-unit2.js +356 -166
- package/dist/components/snk-detail-view2.js +21 -6
- package/dist/components/snk-form-config2.js +1 -1
- package/dist/components/snk-form-view2.js +39 -1
- package/dist/components/snk-form.js +26 -5
- package/dist/components/snk-grid2.js +58 -11
- package/dist/components/snk-simple-crud2.js +96 -10
- package/dist/esm/{ConfigStorage-928c3bf4.js → ConfigStorage-174101b9.js} +2 -1
- package/dist/esm/{form-config-fetcher-e3094014.js → DataFetcher-4b4b7beb.js} +1 -250
- package/dist/esm/{IExporterProvider-ceabfb7e.js → IExporterProvider-640e1f6b.js} +54 -12
- package/dist/esm/{SnkFormConfigManager-a87ade7a.js → SnkFormConfigManager-87bd8082.js} +2 -2
- package/dist/esm/{SnkMessageBuilder-0a4becdd.js → SnkMessageBuilder-3a767111.js} +6 -12
- package/dist/esm/{auth-fetcher-e1cb288f.js → auth-fetcher-9f86c346.js} +1 -1
- package/dist/esm/{pesquisa-fetcher-72125b13.js → dataunit-fetcher-87ecba4a.js} +57 -163
- package/dist/esm/form-config-fetcher-5d72aaf1.js +253 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pesquisa-fetcher-9cfab836.js +164 -0
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +5 -3
- package/dist/esm/snk-application.entry.js +30 -20
- package/dist/esm/snk-attach.entry.js +5 -3
- package/dist/esm/snk-crud.entry.js +43 -9
- package/dist/esm/snk-data-exporter.entry.js +6 -4
- package/dist/esm/snk-data-unit-1132e40b.js +612 -0
- package/dist/esm/snk-data-unit.entry.js +10 -2
- package/dist/esm/snk-detail-view.entry.js +8 -6
- package/dist/esm/snk-filter-bar.entry.js +3 -2
- package/dist/esm/snk-filter-modal-item.entry.js +3 -2
- package/dist/esm/snk-form-config.entry.js +2 -1
- package/dist/esm/snk-form-view.entry.js +36 -0
- package/dist/esm/snk-form.entry.js +28 -7
- package/dist/esm/snk-grid.entry.js +56 -11
- package/dist/esm/{snk-guides-viewer-303aafb4.js → snk-guides-viewer-359e39a7.js} +19 -6
- package/dist/esm/snk-guides-viewer.entry.js +8 -6
- package/dist/esm/snk-personalized-filter.entry.js +3 -2
- package/dist/esm/snk-simple-crud.entry.js +95 -13
- package/dist/sankhyablocks/p-010d475f.js +1 -0
- package/dist/sankhyablocks/p-08fee6e8.js +60 -0
- package/dist/sankhyablocks/p-0bcc6e83.js +1 -0
- package/dist/sankhyablocks/p-2a84e45b.entry.js +1 -0
- package/dist/sankhyablocks/{p-0e8702f0.js → p-2eb90860.js} +1 -1
- package/dist/sankhyablocks/p-33f695d6.entry.js +1 -0
- package/dist/sankhyablocks/p-3519a984.entry.js +1 -0
- package/dist/sankhyablocks/p-4ce73e88.js +1 -0
- package/dist/sankhyablocks/{p-e27496ed.js → p-566f5f50.js} +6 -6
- package/dist/sankhyablocks/p-59dccb7a.entry.js +1 -0
- package/dist/sankhyablocks/p-5c8a9e27.entry.js +1 -0
- package/dist/sankhyablocks/p-66a31d30.entry.js +11 -0
- package/dist/sankhyablocks/p-6b2be902.js +6 -0
- package/dist/sankhyablocks/p-7ecaaea2.entry.js +1 -0
- package/dist/sankhyablocks/p-83950924.entry.js +1 -0
- package/dist/sankhyablocks/p-873d2e6a.entry.js +1 -0
- package/dist/sankhyablocks/p-931343a1.entry.js +1 -0
- package/dist/sankhyablocks/p-a6dfa396.js +1 -0
- package/dist/sankhyablocks/p-aa854fa8.entry.js +1 -0
- package/dist/sankhyablocks/p-b11921ca.entry.js +1 -0
- package/dist/sankhyablocks/p-cb91634d.js +1 -0
- package/dist/sankhyablocks/p-cf9d2d1e.entry.js +1 -0
- package/dist/sankhyablocks/p-d29a252c.js +1 -0
- package/dist/sankhyablocks/p-d799aa7f.entry.js +1 -0
- package/dist/sankhyablocks/p-da6e3dcf.entry.js +1 -0
- package/dist/sankhyablocks/p-e0c27486.js +26 -0
- package/dist/sankhyablocks/p-f72e8835.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +6 -2
- package/dist/types/components/snk-crud/snk-crud.d.ts +14 -1
- package/dist/types/components/snk-crud/subcomponents/snk-form-view.d.ts +13 -1
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +6 -0
- package/dist/types/components/snk-data-exporter/interfaces/IExporterProvider.d.ts +3 -0
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +45 -1
- package/dist/types/components/snk-data-unit/test/resources/metadataMock.d.ts +3 -0
- package/dist/types/components/snk-form/snk-form.d.ts +6 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +19 -3
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +22 -0
- package/dist/types/components.d.ts +68 -4
- package/dist/types/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.d.ts +11 -0
- package/dist/types/lib/dataUnit/ValueFormatter.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IBuildRequestBodyLoadRowMetadata.d.ts +10 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/interfaces/IRowMetadata.d.ts +7 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.d.ts +6 -0
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/test/resources/metadataMock.d.ts +20 -0
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IExporterColumnMetadata.d.ts +2 -0
- package/dist/types/lib/http/data-fetcher/fetchers/pesquisa-fetcher.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/snk-data-unit-abd2113f.js +0 -427
- package/dist/esm/snk-data-unit-29eba11a.js +0 -425
- package/dist/sankhyablocks/p-029bfc09.js +0 -1
- package/dist/sankhyablocks/p-03dcc5ff.entry.js +0 -1
- package/dist/sankhyablocks/p-07825198.js +0 -1
- package/dist/sankhyablocks/p-13ea113d.entry.js +0 -1
- package/dist/sankhyablocks/p-1fa244c0.entry.js +0 -1
- package/dist/sankhyablocks/p-2d972c2e.entry.js +0 -1
- package/dist/sankhyablocks/p-314e2d1a.entry.js +0 -1
- package/dist/sankhyablocks/p-32556aa6.js +0 -1
- package/dist/sankhyablocks/p-3494a28e.entry.js +0 -1
- package/dist/sankhyablocks/p-35bd4df7.entry.js +0 -1
- package/dist/sankhyablocks/p-536eeb16.js +0 -26
- package/dist/sankhyablocks/p-563701f3.js +0 -1
- package/dist/sankhyablocks/p-61984566.entry.js +0 -1
- package/dist/sankhyablocks/p-64977b22.entry.js +0 -1
- package/dist/sankhyablocks/p-65b6dba3.entry.js +0 -1
- package/dist/sankhyablocks/p-6bc64fb0.entry.js +0 -1
- package/dist/sankhyablocks/p-aedf37fb.js +0 -65
- package/dist/sankhyablocks/p-b233f5aa.entry.js +0 -1
- package/dist/sankhyablocks/p-b86ea293.entry.js +0 -1
- package/dist/sankhyablocks/p-c73482cf.js +0 -1
- package/dist/sankhyablocks/p-cb3c7b4a.entry.js +0 -11
- package/dist/sankhyablocks/p-d911a023.entry.js +0 -1
- package/dist/sankhyablocks/p-fa84e72f.entry.js +0 -1
@@ -1,10 +1,12 @@
|
|
1
|
-
import { D as DataFetcher } from './
|
2
|
-
import
|
3
|
-
import { SortMode, ApplicationContext, UserInterface, DateUtils, DataType } from '@sankhyalabs/core';
|
1
|
+
import { D as DataFetcher } from './DataFetcher.js';
|
2
|
+
import './pesquisa-fetcher.js';
|
3
|
+
import { SortMode, ApplicationContext, UserInterface, DateUtils, ObjectUtils, NumberUtils, DataType } from '@sankhyalabs/core';
|
4
4
|
import './ISave.js';
|
5
5
|
import '@sankhyalabs/ezui/dist/collection/utils/constants';
|
6
6
|
import { UserInterface as UserInterface$1 } from '@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata';
|
7
|
+
import { P as PreloadManager } from './dataunit-fetcher.js';
|
7
8
|
import './filter-item-type.enum.js';
|
9
|
+
import './form-config-fetcher.js';
|
8
10
|
import InMemoryFilterColumnDataSource from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource';
|
9
11
|
import { h } from '@stencil/core/internal/client';
|
10
12
|
|
@@ -206,6 +208,41 @@ const openFieldSearch = async (moreOptions, field) => {
|
|
206
208
|
await moreOptions.showActions();
|
207
209
|
};
|
208
210
|
|
211
|
+
class RmPrecisionCustomValueFormatter {
|
212
|
+
setGrid(grid) {
|
213
|
+
if (this._grid) {
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
this._grid = grid;
|
217
|
+
this.refreshSelectedRows();
|
218
|
+
}
|
219
|
+
setDataState(dataState) {
|
220
|
+
if (ObjectUtils.objectToString(dataState) === ObjectUtils.objectToString(this._dataState)) {
|
221
|
+
return;
|
222
|
+
}
|
223
|
+
this._dataState = dataState;
|
224
|
+
this.refreshSelectedRows();
|
225
|
+
}
|
226
|
+
format(currentValue, column, recordId) {
|
227
|
+
var _a;
|
228
|
+
if (!currentValue) {
|
229
|
+
return currentValue;
|
230
|
+
}
|
231
|
+
const rowMetadata = (_a = this._dataState) === null || _a === void 0 ? void 0 : _a.metadataByRow.get(recordId);
|
232
|
+
const rmPrecision = rowMetadata === null || rowMetadata === void 0 ? void 0 : rowMetadata.getProp('rm_precision', column.name);
|
233
|
+
if (rmPrecision) {
|
234
|
+
return NumberUtils.format(currentValue, rmPrecision, rmPrecision);
|
235
|
+
}
|
236
|
+
else {
|
237
|
+
return currentValue;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
refreshSelectedRows() {
|
241
|
+
var _a;
|
242
|
+
(_a = this._grid) === null || _a === void 0 ? void 0 : _a.refreshSelectedRows();
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
209
246
|
class CommonsExporter {
|
210
247
|
constructor(dataUnit, grid) {
|
211
248
|
this.dataUnit = dataUnit;
|
@@ -213,26 +250,31 @@ class CommonsExporter {
|
|
213
250
|
}
|
214
251
|
async getColumnsMetadata() {
|
215
252
|
var _a;
|
216
|
-
|
217
|
-
return this.buildColumnsMetadata(columnsState);
|
253
|
+
this.columnsState = await ((_a = this.grid) === null || _a === void 0 ? void 0 : _a.getColumnsState());
|
254
|
+
return await this.buildColumnsMetadata(this.columnsState);
|
218
255
|
}
|
219
|
-
|
256
|
+
getColumnsState() {
|
257
|
+
return this.columnsState;
|
258
|
+
}
|
259
|
+
async buildColumnsMetadata(gridColumns) {
|
260
|
+
var _a, _b;
|
220
261
|
const columnsMetadata = [];
|
221
|
-
|
222
|
-
var _a, _b;
|
262
|
+
for (const column of gridColumns) {
|
223
263
|
/**
|
224
264
|
* TODO: Analisar e criar uma melhor forma de tratar essa validação do "RECDESP".
|
225
265
|
*/
|
226
266
|
if (column.hidden && column.name !== "RECDESP") {
|
227
|
-
|
267
|
+
continue;
|
228
268
|
}
|
229
269
|
const fieldData = (_a = this.dataUnit) === null || _a === void 0 ? void 0 : _a.getField(column.name);
|
270
|
+
const customFormatter = await this.grid.getCustomValueFormatter(column.name);
|
230
271
|
const columnData = {
|
231
272
|
label: column.label,
|
232
273
|
id: column.name,
|
233
274
|
width: (fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface) === UserInterface$1.SEARCH ? 30 : column.width,
|
234
275
|
type: fieldData === null || fieldData === void 0 ? void 0 : fieldData.dataType,
|
235
|
-
userInterface: fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface
|
276
|
+
userInterface: fieldData === null || fieldData === void 0 ? void 0 : fieldData.userInterface,
|
277
|
+
customFormatter
|
236
278
|
};
|
237
279
|
columnsMetadata.push(columnData);
|
238
280
|
if (((_b = fieldData === null || fieldData === void 0 ? void 0 : fieldData.properties) === null || _b === void 0 ? void 0 : _b.DESCRIPTIONFIELD) != undefined) {
|
@@ -248,9 +290,9 @@ class CommonsExporter {
|
|
248
290
|
};
|
249
291
|
columnsMetadata.push(descriptionColumn);
|
250
292
|
}
|
251
|
-
}
|
293
|
+
}
|
252
294
|
return columnsMetadata || [];
|
253
295
|
}
|
254
296
|
}
|
255
297
|
|
256
|
-
export { CommonsExporter as C, SnkMultiSelectionListDataSource as S, TaskbarProcessor as T, CrudUtils as a, buildFieldSearch as b, openFieldSearch as o };
|
298
|
+
export { CommonsExporter as C, RmPrecisionCustomValueFormatter as R, SnkMultiSelectionListDataSource as S, TaskbarProcessor as T, CrudUtils as a, buildFieldSearch as b, openFieldSearch as o };
|
@@ -29,6 +29,7 @@ const snkDataUnitMessages = {
|
|
29
29
|
forbiddenRemove: "Não é possível remover. Verifique as permissões de acesso.",
|
30
30
|
removeAllConfirmation: "Os <strong>{{size}} registros selecionados</strong> serão excluídos.<br/><br/><strong>Você realmente gostaria de continuar?</strong>",
|
31
31
|
removeAllInfo: "Os {{size}} registros foram removidos com sucesso!",
|
32
|
+
fieldNameRequired: "É necessário informar o nome da coluna."
|
32
33
|
};
|
33
34
|
|
34
35
|
const snkFilterBarMessages = {
|
@@ -552,7 +553,7 @@ class SnkMessageBuilder {
|
|
552
553
|
this.loadAppMessages().then((msgs) => {
|
553
554
|
this._appMessages = msgs;
|
554
555
|
}, error => {
|
555
|
-
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages
|
556
|
+
console.info('O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages', error);
|
556
557
|
});
|
557
558
|
}
|
558
559
|
/**
|
@@ -644,17 +645,10 @@ class SnkMessageBuilder {
|
|
644
645
|
return message;
|
645
646
|
}
|
646
647
|
}
|
647
|
-
loadAppMessages() {
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
.then(module => {
|
652
|
-
accept(module.default);
|
653
|
-
})
|
654
|
-
.catch(reason => {
|
655
|
-
reject(reason);
|
656
|
-
});
|
657
|
-
});
|
648
|
+
async loadAppMessages() {
|
649
|
+
const messagesUrl = await this._application.getApplicationPath();
|
650
|
+
const module = await import(/* webpackIgnore: true */ `${messagesUrl}/messages/appmessages.js`);
|
651
|
+
return module.default;
|
658
652
|
}
|
659
653
|
}
|
660
654
|
var OperationMap;
|
@@ -1,171 +1,11 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
1
|
+
import { ObjectUtils, DataUnit, DataType, DateUtils, StringUtils, ChangeOperation, ApplicationContext, UserInterface, DataUnitStorage } from '@sankhyalabs/core';
|
2
|
+
import { D as DataFetcher, d as dist } 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
5
|
import { ColumnFilterManager } from '@sankhyalabs/ezui/dist/collection/components/ez-grid/utils';
|
6
6
|
import SortingUtils from '@sankhyalabs/core/dist/utils/SortingUtils';
|
7
7
|
import { R as ResourceIDUtils } from './ResourceIDUtils.js';
|
8
8
|
|
9
|
-
class PesquisaFetcher {
|
10
|
-
constructor() {
|
11
|
-
this._defaultPageSize = 100;
|
12
|
-
this._templateByQuery = new Map();
|
13
|
-
this._searchListenersByDataUnit = new Map();
|
14
|
-
this.buldTemplates();
|
15
|
-
}
|
16
|
-
buldTemplates() {
|
17
|
-
this._templateByQuery.set("search", dist.gql `query($entityName: String! $argument: String $criteria: InputSearchCriteria $options: InputSearchOptions) {
|
18
|
-
$queryAlias$: search(entityName: $entityName argument: $argument criteria: $criteria options: $options){
|
19
|
-
value
|
20
|
-
label
|
21
|
-
}
|
22
|
-
}`);
|
23
|
-
}
|
24
|
-
loadSearchOptions(entityName, argument, criteria, options) {
|
25
|
-
var _a;
|
26
|
-
const cleanText = (argument === null || argument === void 0 ? void 0 : argument.toString().trim()) || undefined;
|
27
|
-
argument = isNaN(Number(cleanText)) && cleanText ? `%${cleanText}` : cleanText;
|
28
|
-
criteria === null || criteria === void 0 ? void 0 : criteria.params.forEach(param => {
|
29
|
-
if (param.dataType === DataType.OBJECT) {
|
30
|
-
param.value = JSON.stringify(param.value);
|
31
|
-
}
|
32
|
-
});
|
33
|
-
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, options);
|
34
|
-
const values = {
|
35
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
36
|
-
entityName,
|
37
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
38
|
-
options: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions) || options,
|
39
|
-
};
|
40
|
-
if (values.options) {
|
41
|
-
(_a = values.options) === null || _a === void 0 ? true : delete _a.dataUnitId;
|
42
|
-
}
|
43
|
-
return new Promise((resolve, reject) => {
|
44
|
-
DataFetcher.get()
|
45
|
-
.callGraphQL({
|
46
|
-
values,
|
47
|
-
query: this._templateByQuery.get("search"),
|
48
|
-
})
|
49
|
-
.then((result) => {
|
50
|
-
resolve(result);
|
51
|
-
})
|
52
|
-
.catch((error) => {
|
53
|
-
reject(error);
|
54
|
-
});
|
55
|
-
});
|
56
|
-
}
|
57
|
-
loadAdvancedSearch(entityName, argument, criteria, searchOptions) {
|
58
|
-
var _a, _b, _c, _d;
|
59
|
-
const listenerResult = this.applySearchListener(SearchListenerType.beforeSearch, entityName, argument, criteria, searchOptions);
|
60
|
-
const values = {
|
61
|
-
argument: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.argument) || argument,
|
62
|
-
criteria: (listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.criteria) || criteria,
|
63
|
-
searchOptions: Object.assign(Object.assign({}, searchOptions), listenerResult === null || listenerResult === void 0 ? void 0 : listenerResult.searchOptions),
|
64
|
-
};
|
65
|
-
const serviceName = "PesquisaSP.getSuggestion";
|
66
|
-
const externalCriteria = {
|
67
|
-
query: {
|
68
|
-
$: (_a = values.criteria) === null || _a === void 0 ? void 0 : _a.expression
|
69
|
-
}
|
70
|
-
};
|
71
|
-
if (((_c = (_b = values.criteria) === null || _b === void 0 ? void 0 : _b.params) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
72
|
-
externalCriteria.params = {
|
73
|
-
param: values.criteria.params.map(param => {
|
74
|
-
let value = param.value;
|
75
|
-
if (typeof value === "string") {
|
76
|
-
const match = /CTX\{([^}]+)\}/.exec(value);
|
77
|
-
if (match) {
|
78
|
-
value = ApplicationContext.getContextValue(`__SNK__APPLICATION__FILTER__CONTEXT(${match[1]})__`);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
let type = param.dataType;
|
82
|
-
if (type === DataType.OBJECT) {
|
83
|
-
value = value.value;
|
84
|
-
type = "S";
|
85
|
-
}
|
86
|
-
else {
|
87
|
-
type = convertParamType(param.dataType);
|
88
|
-
}
|
89
|
-
return { $: value, type };
|
90
|
-
})
|
91
|
-
};
|
92
|
-
}
|
93
|
-
const options = searchOptions != undefined
|
94
|
-
? Object.assign(Object.assign({}, values === null || values === void 0 ? void 0 : values.searchOptions), { "pkFieldName": searchOptions.codeFieldName, "label": searchOptions.descriptionFieldName, "fieldName": searchOptions.codeFieldName, "useDescriptionOptions": false, "enableRowsCounter": true }) : undefined;
|
95
|
-
const reqBody = {
|
96
|
-
"serviceName": serviceName,
|
97
|
-
"requestBody": {
|
98
|
-
"criteria": Object.assign({ "entityName": entityName, "compacted": false, "ignoreEntityCriteria": false, "limit": this._defaultPageSize, "query": { "$": values.argument }, "orderByDesc": false, "externalCriteria": externalCriteria, "localEntityName": (_d = values.searchOptions) === null || _d === void 0 ? void 0 : _d.rootEntity }, { options }),
|
99
|
-
"clientEventList": {
|
100
|
-
"clientEvent": []
|
101
|
-
}
|
102
|
-
}
|
103
|
-
};
|
104
|
-
return new Promise((resolve, reject) => {
|
105
|
-
DataFetcher.get()
|
106
|
-
.callServiceBroker("PesquisaSP.getSuggestion", JSON.stringify(reqBody))
|
107
|
-
.then(result => resolve(result))
|
108
|
-
.catch(error => reject(error));
|
109
|
-
});
|
110
|
-
}
|
111
|
-
addSearchListener(entityName, dataUnitID, listener) {
|
112
|
-
var _a;
|
113
|
-
const dataUnitSearchListeners = this._searchListenersByDataUnit.get(dataUnitID) || [];
|
114
|
-
const entityListener = dataUnitSearchListeners.find(currentListener => currentListener.entity === entityName);
|
115
|
-
if (!entityListener) {
|
116
|
-
this._searchListenersByDataUnit.set(dataUnitID, [...dataUnitSearchListeners, { entity: entityName, listener }]);
|
117
|
-
}
|
118
|
-
else {
|
119
|
-
for (const type of Object.keys(listener)) {
|
120
|
-
if (type in entityListener.listener) {
|
121
|
-
const listenerFunctionIsEquals = ((_a = entityListener.listener[type]) === null || _a === void 0 ? void 0 : _a.toString()) === listener[type].toString();
|
122
|
-
if (listenerFunctionIsEquals)
|
123
|
-
continue;
|
124
|
-
entityListener.listener[type] = listener[type];
|
125
|
-
}
|
126
|
-
}
|
127
|
-
}
|
128
|
-
return () => {
|
129
|
-
const newListeners = dataUnitSearchListeners.filter(currentListener => currentListener.entity !== entityName);
|
130
|
-
if (!newListeners.length) {
|
131
|
-
this._searchListenersByDataUnit.delete(dataUnitID);
|
132
|
-
return;
|
133
|
-
}
|
134
|
-
this._searchListenersByDataUnit.set(dataUnitID, newListeners);
|
135
|
-
};
|
136
|
-
}
|
137
|
-
applySearchListener(listenerType, entityName, argument, criteria, searchOptions) {
|
138
|
-
var _a;
|
139
|
-
const dataUnitId = searchOptions === null || searchOptions === void 0 ? void 0 : searchOptions.dataUnitId;
|
140
|
-
if (!dataUnitId)
|
141
|
-
return;
|
142
|
-
const entityListener = (_a = this._searchListenersByDataUnit.get(dataUnitId)) === null || _a === void 0 ? void 0 : _a.find(({ entity }) => entity === entityName);
|
143
|
-
if (!entityListener)
|
144
|
-
return;
|
145
|
-
const { listener } = entityListener;
|
146
|
-
if (!(listenerType in listener))
|
147
|
-
return;
|
148
|
-
return listener[listenerType]({ argument, criteria, searchOptions });
|
149
|
-
}
|
150
|
-
}
|
151
|
-
function convertParamType(dataType) {
|
152
|
-
//Alerta: Cuidado pra não contaminar o DataType com a implementação
|
153
|
-
//atual da pesquisa... em geral, somente inteiros,
|
154
|
-
//data (com ou sem hora) e string são realmente relevantes
|
155
|
-
switch (dataType) {
|
156
|
-
case DataType.NUMBER:
|
157
|
-
return "I";
|
158
|
-
case DataType.DATE:
|
159
|
-
return "D";
|
160
|
-
default:
|
161
|
-
return "S";
|
162
|
-
}
|
163
|
-
}
|
164
|
-
var SearchListenerType;
|
165
|
-
(function (SearchListenerType) {
|
166
|
-
SearchListenerType["beforeSearch"] = "beforeSearch";
|
167
|
-
})(SearchListenerType || (SearchListenerType = {}));
|
168
|
-
|
169
9
|
class ArrayRepository {
|
170
10
|
constructor(equalsFunction) {
|
171
11
|
this._list = [];
|
@@ -529,6 +369,11 @@ class InMemoryLoader {
|
|
529
369
|
}
|
530
370
|
InMemoryLoader.IN_MEMORY_DATA_UNIT_NAME = "InMemoryDataUnit";
|
531
371
|
|
372
|
+
function getRecordValue(record, fieldName) {
|
373
|
+
var _a, _b;
|
374
|
+
return ((_a = record[fieldName]) === null || _a === void 0 ? void 0 : _a.value) !== undefined ? (_b = record[fieldName]) === null || _b === void 0 ? void 0 : _b.value : record[fieldName];
|
375
|
+
}
|
376
|
+
|
532
377
|
class DatasetStrategy {
|
533
378
|
canSlice() {
|
534
379
|
return false;
|
@@ -583,6 +428,53 @@ class DatasetStrategy {
|
|
583
428
|
return Promise.reject(error);
|
584
429
|
}
|
585
430
|
}
|
431
|
+
async loadRowMetadata(snkDataUnit, fieldName, metadataName, updatedFields = {}) {
|
432
|
+
try {
|
433
|
+
const serviceName = "DatasetSP.loadRowMetadata";
|
434
|
+
const parsedRequestBody = await this.buildRequestBodyLoadRowMetadata({ snkDataUnit, fieldName, metadataName, serviceName, updatedFields });
|
435
|
+
const response = await DataFetcher.get().callServiceBroker(serviceName, parsedRequestBody);
|
436
|
+
return response;
|
437
|
+
}
|
438
|
+
catch (error) {
|
439
|
+
console.error(error);
|
440
|
+
return Promise.reject(error);
|
441
|
+
}
|
442
|
+
}
|
443
|
+
async buildRequestBodyLoadRowMetadata({ snkDataUnit, serviceName, fieldName, metadataName, updatedFields, }) {
|
444
|
+
const dataUnit = snkDataUnit.dataUnit;
|
445
|
+
const entityName = DataUnitFetcher.parseDataUnitName(dataUnit.name).entityName;
|
446
|
+
const recordIdInfo = await snkDataUnit.getSelectedRecordsIDsInfo();
|
447
|
+
const pk = recordIdInfo.reduce((accumulator, currentValue) => {
|
448
|
+
accumulator[currentValue.name] = currentValue.value;
|
449
|
+
return accumulator;
|
450
|
+
}, {});
|
451
|
+
const record = dataUnit.getSelectedRecord();
|
452
|
+
const fields = dataUnit.metadata.fields.filter(({ standAlone, name }) => !standAlone && !name.includes(".")).map(({ name }) => name);
|
453
|
+
const values = fields.reduce((accumulator, currentValue, currentIndex) => {
|
454
|
+
const recordValue = getRecordValue(record, currentValue);
|
455
|
+
const updatedFieldValue = getRecordValue(updatedFields, currentValue);
|
456
|
+
accumulator[currentIndex] = updatedFieldValue !== undefined ? updatedFieldValue : recordValue;
|
457
|
+
return accumulator;
|
458
|
+
}, {});
|
459
|
+
const requestBody = {
|
460
|
+
serviceName,
|
461
|
+
requestBody: {
|
462
|
+
dataSetID: dataUnit.dataUnitId,
|
463
|
+
entityName,
|
464
|
+
standAlone: false,
|
465
|
+
metadataName,
|
466
|
+
fieldName,
|
467
|
+
fields,
|
468
|
+
record: {
|
469
|
+
pk,
|
470
|
+
oldPk: pk,
|
471
|
+
values,
|
472
|
+
},
|
473
|
+
}
|
474
|
+
};
|
475
|
+
const parsedRequestBody = JSON.stringify(requestBody);
|
476
|
+
return parsedRequestBody;
|
477
|
+
}
|
586
478
|
getFieldsList(dataUnit) {
|
587
479
|
let fields = ["__record__id__", "__record__label__"];
|
588
480
|
dataUnit.metadata.fields.forEach((descriptor) => {
|
@@ -662,9 +554,11 @@ class DatasetStrategy {
|
|
662
554
|
}
|
663
555
|
processRecords(dataUnit, fields, responseRecords) {
|
664
556
|
return responseRecords.map((dataFrame) => {
|
557
|
+
const lastElement = dataFrame[dataFrame.length - 1];
|
665
558
|
const duRecord = {
|
666
559
|
__record__id__: dataFrame[0],
|
667
|
-
__record__label__: dataFrame[1]
|
560
|
+
__record__label__: dataFrame[1],
|
561
|
+
__record__metadata__: lastElement['_rmd'],
|
668
562
|
};
|
669
563
|
dataUnit.metadata.fields.forEach(fieldDescriptor => {
|
670
564
|
duRecord[fieldDescriptor.name] = this.buildFieldValue(fieldDescriptor, fields, dataFrame);
|
@@ -1149,4 +1043,4 @@ class DataUnitFetcher {
|
|
1149
1043
|
}
|
1150
1044
|
}
|
1151
1045
|
|
1152
|
-
export { DataUnitFetcher as D, InMemoryLoader as I,
|
1046
|
+
export { DataUnitFetcher as D, InMemoryLoader as I, PreloadManager as P, applyFilter as a, applySorting as b, buildPaginationInfo as c, DatasetStrategy as d, getRecordValue as g };
|