@sankhyalabs/ezui 1.1.161 → 1.2.0-beta.1
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/{ApplicationUtils-4a223c7a.js → ApplicationUtils-483c0a9e.js} +26 -7
- package/dist/cjs/CSSVarsUtils-09b431cc.js +55 -0
- package/dist/cjs/DialogType-a1e288e6.js +8 -0
- package/dist/cjs/ez-actions-button.cjs.entry.js +101 -0
- package/dist/cjs/ez-combo-box.cjs.entry.js +8 -4
- package/dist/cjs/ez-date-input.cjs.entry.js +6 -6
- package/dist/cjs/ez-date-time-input.cjs.entry.js +7 -7
- package/dist/cjs/ez-dialog.cjs.entry.js +33 -14
- package/dist/cjs/ez-filter-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-form.cjs.entry.js +101 -86
- package/dist/cjs/ez-grid-config.cjs.entry.js +3 -2
- package/dist/cjs/ez-grid.cjs.entry.js +97155 -92841
- package/dist/cjs/ez-number-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-popover.cjs.entry.js +6 -0
- package/dist/cjs/ez-radio-button.cjs.entry.js +49 -0
- package/dist/cjs/ez-search.cjs.entry.js +1 -1
- package/dist/cjs/ez-time-input.cjs.entry.js +1 -1
- package/dist/cjs/ez-upload.cjs.entry.js +2 -1
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +3 -2
- package/dist/collection/components/ez-actions-button/ez-actions-button.css +49 -0
- package/dist/collection/components/ez-actions-button/ez-actions-button.js +177 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.css +31 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +4 -1
- package/dist/collection/components/ez-date-input/ez-date-input.js +5 -3
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +6 -6
- package/dist/collection/components/ez-dialog/DialogType.js +6 -0
- package/dist/collection/components/ez-dialog/ez-dialog.css +9 -1
- package/dist/collection/components/ez-dialog/ez-dialog.js +53 -26
- package/dist/collection/components/ez-form/DataBinder.js +46 -18
- package/dist/collection/components/ez-form/ez-form.js +75 -68
- package/dist/collection/components/ez-form/fieldbuilder/tpl/TextInput.tpl.js +2 -2
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +24 -165
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +71 -44
- package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +4 -4
- package/dist/collection/components/ez-grid/ez-grid.js +36 -321
- package/dist/collection/components/ez-grid/subcomponents/ez-grid-config/ez-grid-config.js +2 -1
- package/dist/collection/components/ez-popover/ez-popover.js +6 -0
- package/dist/collection/components/ez-radio-button/ez-radio-button.css +204 -0
- package/dist/collection/components/ez-radio-button/ez-radio-button.js +160 -0
- package/dist/collection/utils/ApplicationUtils.js +25 -7
- package/dist/collection/utils/CSSVarsUtils.js +34 -0
- package/dist/collection/utils/index.js +1 -0
- package/dist/custom-elements/index.d.ts +12 -6
- package/dist/custom-elements/index.js +97132 -92676
- package/dist/esm/{ApplicationUtils-35350d20.js → ApplicationUtils-5f87ae60.js} +26 -7
- package/dist/esm/CSSVarsUtils-499b75c2.js +53 -0
- package/dist/esm/DialogType-72afa679.js +8 -0
- package/dist/esm/ez-actions-button.entry.js +97 -0
- package/dist/esm/ez-combo-box.entry.js +8 -4
- package/dist/esm/ez-date-input.entry.js +6 -6
- package/dist/esm/ez-date-time-input.entry.js +7 -7
- package/dist/esm/ez-dialog.entry.js +33 -14
- package/dist/esm/ez-filter-input.entry.js +1 -1
- package/dist/esm/ez-form.entry.js +101 -86
- package/dist/esm/ez-grid-config.entry.js +3 -2
- package/dist/esm/ez-grid.entry.js +96694 -92380
- package/dist/esm/ez-number-input.entry.js +1 -1
- package/dist/esm/ez-popover.entry.js +6 -0
- package/dist/esm/ez-radio-button.entry.js +45 -0
- package/dist/esm/ez-search.entry.js +1 -1
- package/dist/esm/ez-time-input.entry.js +1 -1
- package/dist/esm/ez-upload.entry.js +2 -1
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-0b099e95.entry.js +1 -0
- package/dist/ezui/{p-ff7b4b13.entry.js → p-240a76f1.entry.js} +1 -1
- package/dist/ezui/p-3263a002.js +1 -0
- package/dist/ezui/p-787fbdfe.js +1 -0
- package/dist/ezui/p-78fc16d7.entry.js +1 -0
- package/dist/ezui/{p-4c3d136c.entry.js → p-7d29e829.entry.js} +1 -1
- package/dist/ezui/p-898b9906.js +1 -0
- package/dist/ezui/p-8aaca58b.entry.js +1 -0
- package/dist/ezui/p-99440dbc.entry.js +1 -0
- package/dist/ezui/p-a7064bc1.entry.js +1 -0
- package/dist/ezui/{p-53bbba8e.entry.js → p-ad071710.entry.js} +1 -1
- package/dist/ezui/p-b0195dae.entry.js +1 -0
- package/dist/ezui/p-ba2bfa01.entry.js +1 -0
- package/dist/ezui/p-bedef638.entry.js +1 -0
- package/dist/ezui/p-d1bc45bd.entry.js +1 -0
- package/dist/ezui/{p-003d53b1.entry.js → p-d75c3aae.entry.js} +1 -1
- package/dist/ezui/p-e5c572c1.entry.js +304 -0
- package/dist/ezui/p-f4819fa3.entry.js +1 -0
- package/dist/types/components/ez-actions-button/ez-actions-button.d.ts +37 -0
- package/dist/types/components/ez-dialog/DialogType.d.ts +5 -0
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +22 -3
- package/dist/types/components/ez-form/DataBinder.d.ts +6 -1
- package/dist/types/components/ez-form/ez-form.d.ts +27 -3
- package/dist/types/components/ez-form/fieldbuilder/tpl/TextInput.tpl.d.ts +2 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +0 -85
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +2 -23
- package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +14 -11
- package/dist/types/components/ez-grid/ez-grid.d.ts +8 -66
- package/dist/types/components/ez-radio-button/ez-radio-button.d.ts +36 -0
- package/dist/types/components.d.ts +129 -76
- package/dist/types/utils/ApplicationUtils.d.ts +4 -1
- package/dist/types/utils/CSSVarsUtils.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +5 -5
- package/react/components.d.ts +2 -1
- package/react/components.js +2 -1
- package/react/components.js.map +1 -1
- package/dist/cjs/CSSVarsUtils-1034b7b6.js +0 -21
- package/dist/cjs/test-du.cjs.entry.js +0 -103
- package/dist/collection/components/test-du/test-du.css +0 -3
- package/dist/collection/components/test-du/test-du.js +0 -104
- package/dist/collection/utils/interfaces/PageableComponent.js +0 -1
- package/dist/esm/CSSVarsUtils-eb4c5af6.js +0 -19
- package/dist/esm/test-du.entry.js +0 -99
- package/dist/ezui/p-0cd386db.js +0 -1
- package/dist/ezui/p-403de0a4.entry.js +0 -1
- package/dist/ezui/p-4c3cd534.entry.js +0 -1
- package/dist/ezui/p-6668c3b0.entry.js +0 -1
- package/dist/ezui/p-7fd6deec.entry.js +0 -1
- package/dist/ezui/p-8be1a4d6.entry.js +0 -1
- package/dist/ezui/p-8d73594f.entry.js +0 -369
- package/dist/ezui/p-933a7475.js +0 -1
- package/dist/ezui/p-988ff301.entry.js +0 -1
- package/dist/ezui/p-cf56d3e8.entry.js +0 -1
- package/dist/ezui/p-da156da3.entry.js +0 -1
- package/dist/ezui/p-ec7b7e26.entry.js +0 -1
- package/dist/types/components/test-du/test-du.d.ts +0 -9
- package/dist/types/utils/interfaces/PageableComponent.d.ts +0 -12
|
@@ -3,8 +3,7 @@ import { Grid } from "ag-grid-community";
|
|
|
3
3
|
import gridTerms from "./i18n/pt-BR.js";
|
|
4
4
|
import getHeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
|
|
5
5
|
import DataSource from "./DataSource";
|
|
6
|
-
import { ApplicationContext, DataType } from "@sankhyalabs/core";
|
|
7
|
-
import { SortMode, UserInterface } from "@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";
|
|
6
|
+
import { ApplicationContext, DataType, SortMode, UserInterface } from "@sankhyalabs/core";
|
|
8
7
|
import { NumberUtils, StringUtils } from "@sankhyalabs/core";
|
|
9
8
|
export default class AgGridController {
|
|
10
9
|
constructor(enterprise) {
|
|
@@ -14,8 +13,6 @@ export default class AgGridController {
|
|
|
14
13
|
this.BLOCK_LOAD_DEBOUNCE = 400;
|
|
15
14
|
this._menuItems = [];
|
|
16
15
|
this._idAttribName = "__record__id__";
|
|
17
|
-
this._isFirstRecordOfPage = true;
|
|
18
|
-
this._isLastRecordOfPage = false;
|
|
19
16
|
this._enterprise = enterprise;
|
|
20
17
|
}
|
|
21
18
|
getSort() {
|
|
@@ -38,23 +35,21 @@ export default class AgGridController {
|
|
|
38
35
|
LicenseManager.setLicenseKey(ApplicationContext.getContextValue("__EZUI__GRID_LICENSE__"));
|
|
39
36
|
this._columnStateChangeCallback = options.onColumnStateChange;
|
|
40
37
|
this._selectionChangeCallback = options.onSelectionChange;
|
|
41
|
-
this._paginationChangeCallback = options.onPaginationChange;
|
|
42
38
|
this._doubleClickCallBack = options.onDoubleClick;
|
|
43
39
|
this._multipleSelection = options.allowMultipleSelection;
|
|
44
|
-
this._pageSize = options.pageSize;
|
|
45
|
-
this._serverURL = options.serverURL;
|
|
46
40
|
this._dataUnit = options.dataUnit;
|
|
47
41
|
if (this._dataUnit) {
|
|
48
42
|
this._dataUnit.sortingProvider = this;
|
|
49
43
|
}
|
|
50
|
-
this._dataSource = new DataSource(this._dataUnit, this
|
|
44
|
+
this._dataSource = new DataSource(this._dataUnit, this, options);
|
|
51
45
|
this._gridOptions = {
|
|
52
46
|
localeText: gridTerms,
|
|
53
47
|
rowModelType: "serverSide",
|
|
54
|
-
|
|
48
|
+
serverSideSortOnServer: true,
|
|
55
49
|
rowSelection: this._multipleSelection ? "multiple" : "single",
|
|
56
50
|
serverSideDatasource: this._dataSource,
|
|
57
51
|
sortingOrder: ['desc', 'asc', null],
|
|
52
|
+
columnDefs: this._colDefs,
|
|
58
53
|
blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
|
|
59
54
|
getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
|
|
60
55
|
getMainMenuItems: (params) => {
|
|
@@ -66,15 +61,9 @@ export default class AgGridController {
|
|
|
66
61
|
}));
|
|
67
62
|
return items;
|
|
68
63
|
},
|
|
69
|
-
//FIXME: Existe um bug no PartialStore.prototype.destroyAllBlocks do ag-grid, pois
|
|
70
|
-
//apesar de destruir os blocos, mantém a variável "blockHeights" com o tamanho antigo
|
|
71
|
-
//dos blocos, então, quando removemos uma linha, a altura do bloco não é recalculada.
|
|
72
|
-
//Descobri que setando manualmente a altura das linhas, apesar do bloco ficar com
|
|
73
|
-
//tamanho errado, isso afeta menos o componente.
|
|
74
64
|
getRowHeight: this.getRowHeight.bind(this)
|
|
75
65
|
};
|
|
76
66
|
this.setOptionsEvents(this._gridOptions);
|
|
77
|
-
this.setOptionsPagination(this._gridOptions);
|
|
78
67
|
this.setOptionsSupress(this._gridOptions);
|
|
79
68
|
if (this._enterprise) {
|
|
80
69
|
this._grid = new EnterpriseGrid(container, this._gridOptions);
|
|
@@ -82,7 +71,6 @@ export default class AgGridController {
|
|
|
82
71
|
else {
|
|
83
72
|
this._grid = new Grid(container, this._gridOptions);
|
|
84
73
|
}
|
|
85
|
-
this._lastPageStatus = this.getPaginationStatus();
|
|
86
74
|
//Atualiza estado da seleção inicial
|
|
87
75
|
this.onSelectionChange();
|
|
88
76
|
this._gridOptions.api.setHeaderHeight(this.getRowHeight());
|
|
@@ -98,24 +86,11 @@ export default class AgGridController {
|
|
|
98
86
|
opt.onColumnMoved = e => this.onCallStateChange("columnMoved", e);
|
|
99
87
|
opt.onColumnVisible = e => this.onCallStateChange("visibleChange", e);
|
|
100
88
|
opt.onSelectionChanged = () => this.onSelectionChange();
|
|
101
|
-
opt.onPaginationChanged = () => this.onPaginationChange();
|
|
102
89
|
opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
|
|
103
90
|
opt.onDragStopped = evt => this.onCallStateChange("columnMovedEnd", evt);
|
|
104
91
|
}
|
|
105
|
-
syncSelection() {
|
|
106
|
-
if (this._dataUnit) {
|
|
107
|
-
this.selectRows(this._dataUnit.getSelection());
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
setOptionsPagination(opt) {
|
|
111
|
-
opt.pagination = (this._pageSize > -1);
|
|
112
|
-
opt.paginationPageSize = this._pageSize;
|
|
113
|
-
opt.cacheBlockSize = this._pageSize;
|
|
114
|
-
opt.maxBlocksInCache = 1;
|
|
115
|
-
}
|
|
116
92
|
setOptionsSupress(opt) {
|
|
117
93
|
opt.suppressDragLeaveHidesColumns = true;
|
|
118
|
-
opt.suppressPaginationPanel = true;
|
|
119
94
|
opt.suppressMenuHide = true;
|
|
120
95
|
}
|
|
121
96
|
setData(data) {
|
|
@@ -128,15 +103,11 @@ export default class AgGridController {
|
|
|
128
103
|
if (this._grid === undefined) {
|
|
129
104
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
130
105
|
}
|
|
131
|
-
this._dataSource.setLocalRefresh(true);
|
|
132
|
-
this._gridOptions.api.refreshServerSideStore({ purge: true });
|
|
133
106
|
}
|
|
134
107
|
updateRows() {
|
|
135
108
|
if (this._grid === undefined) {
|
|
136
109
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
137
110
|
}
|
|
138
|
-
this._dataSource.setLocalRefresh(true);
|
|
139
|
-
this._gridOptions.api.refreshServerSideStore({ purge: true });
|
|
140
111
|
}
|
|
141
112
|
selectRows(rowIds) {
|
|
142
113
|
if (this._grid === undefined) {
|
|
@@ -155,7 +126,7 @@ export default class AgGridController {
|
|
|
155
126
|
if (this._grid === undefined) {
|
|
156
127
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
157
128
|
}
|
|
158
|
-
this._gridOptions.api.
|
|
129
|
+
this._gridOptions.api.refreshServerSide({ purge: true });
|
|
159
130
|
}
|
|
160
131
|
changeValues(changes, rowIds) {
|
|
161
132
|
if (this._grid === undefined) {
|
|
@@ -188,15 +159,12 @@ export default class AgGridController {
|
|
|
188
159
|
if (this._grid === undefined) {
|
|
189
160
|
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
190
161
|
}
|
|
191
|
-
this._gridOptions.api.
|
|
162
|
+
this._gridOptions.api.refreshServerSide({ purge: false });
|
|
192
163
|
}
|
|
193
164
|
setColumnsDef(cols, showCheckSelection) {
|
|
194
|
-
|
|
195
|
-
throw new Error("Erro interno: Grid ainda não inicializado.");
|
|
196
|
-
}
|
|
197
|
-
const colDefs = [];
|
|
165
|
+
const newColDefs = [];
|
|
198
166
|
if (showCheckSelection) {
|
|
199
|
-
|
|
167
|
+
newColDefs.push({
|
|
200
168
|
colId: this.CHECK_BOX_COL_ID,
|
|
201
169
|
headerName: "",
|
|
202
170
|
checkboxSelection: true,
|
|
@@ -209,9 +177,12 @@ export default class AgGridController {
|
|
|
209
177
|
});
|
|
210
178
|
}
|
|
211
179
|
cols.forEach(c => {
|
|
212
|
-
|
|
180
|
+
newColDefs.push(this.buildColDef(c));
|
|
213
181
|
});
|
|
214
|
-
this.
|
|
182
|
+
this._colDefs = newColDefs;
|
|
183
|
+
if (this._gridOptions) {
|
|
184
|
+
this._gridOptions.api.setColumnDefs(this._colDefs);
|
|
185
|
+
}
|
|
215
186
|
}
|
|
216
187
|
getColumnsDef() {
|
|
217
188
|
if (this._grid === undefined) {
|
|
@@ -281,96 +252,21 @@ export default class AgGridController {
|
|
|
281
252
|
addColumnMenuItem(item) {
|
|
282
253
|
this._menuItems.push(item);
|
|
283
254
|
}
|
|
284
|
-
nextPage() {
|
|
285
|
-
this._lastPageStatus = this.getPaginationStatus();
|
|
286
|
-
this._gridOptions.api.paginationGoToNextPage();
|
|
287
|
-
}
|
|
288
|
-
previousPage() {
|
|
289
|
-
this._lastPageStatus = this.getPaginationStatus();
|
|
290
|
-
this._gridOptions.api.paginationGoToPreviousPage();
|
|
291
|
-
}
|
|
292
|
-
goToPage(page) {
|
|
293
|
-
this._gridOptions.api.paginationGoToPage(page);
|
|
294
|
-
}
|
|
295
255
|
quickFilter(term) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
isFirstOfPage() {
|
|
307
|
-
return this._isFirstRecordOfPage;
|
|
308
|
-
}
|
|
309
|
-
previousRecord() {
|
|
310
|
-
const pagination = this.getPaginationStatus();
|
|
311
|
-
if (this._isFirstRecordOfPage && pagination.hasPrevious) {
|
|
312
|
-
this.previousPage();
|
|
313
|
-
}
|
|
314
|
-
else {
|
|
315
|
-
if (this._dataUnit) {
|
|
316
|
-
this._dataUnit.previousRecord();
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
const node = this._gridOptions.api.getSelectedNodes()[0];
|
|
320
|
-
this.setSelectedIndex(node.rowIndex - 1);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
nextRecord() {
|
|
325
|
-
const pagination = this.getPaginationStatus();
|
|
326
|
-
if (this._isLastRecordOfPage && pagination.hasNext) {
|
|
327
|
-
this.nextPage();
|
|
328
|
-
}
|
|
329
|
-
else {
|
|
330
|
-
if (this._dataUnit) {
|
|
331
|
-
this._dataUnit.nextRecord();
|
|
332
|
-
}
|
|
333
|
-
else {
|
|
334
|
-
const node = this._gridOptions.api.getSelectedNodes()[0];
|
|
335
|
-
this.setSelectedIndex(node.rowIndex + 1);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
selectFirstRow() {
|
|
340
|
-
this._dataUnit.selectFirst();
|
|
341
|
-
}
|
|
342
|
-
hasPreviousRecord() {
|
|
343
|
-
const pagination = this.getPaginationStatus();
|
|
344
|
-
if (this._isFirstRecordOfPage) {
|
|
345
|
-
return pagination.hasPrevious;
|
|
346
|
-
}
|
|
347
|
-
else {
|
|
348
|
-
if (this._dataUnit) {
|
|
349
|
-
return this._dataUnit.hasPrevious();
|
|
350
|
-
}
|
|
351
|
-
else {
|
|
352
|
-
return pagination.hasPrevious || this._gridOptions.api.getSelectedRows()[0].rowIndex > 0;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
hasNextRecord() {
|
|
357
|
-
const pagination = this.getPaginationStatus();
|
|
358
|
-
if (this._isLastRecordOfPage) {
|
|
359
|
-
return pagination.hasNext;
|
|
256
|
+
if (term) {
|
|
257
|
+
const quickFilter = {
|
|
258
|
+
term,
|
|
259
|
+
fields: this._gridOptions.columnApi
|
|
260
|
+
.getColumns()
|
|
261
|
+
.filter(col => col.isVisible() && ![this.CHECK_BOX_COL_ID, this.RECORD_ARCHIVE_COL_ID].includes(col.getColId()))
|
|
262
|
+
.map(col => col.getColId())
|
|
263
|
+
};
|
|
264
|
+
this._dataSource.quickFilter = quickFilter;
|
|
360
265
|
}
|
|
361
266
|
else {
|
|
362
|
-
|
|
363
|
-
return this._dataUnit.hasNext() || this.getPaginationStatus().hasNext;
|
|
364
|
-
}
|
|
365
|
-
else {
|
|
366
|
-
const api = this._gridOptions.api;
|
|
367
|
-
return pagination.hasNext || api.getSelectedRows()[0].rowIndex < api.getDisplayedRowCount();
|
|
368
|
-
}
|
|
267
|
+
this._dataSource.quickFilter = undefined;
|
|
369
268
|
}
|
|
370
269
|
}
|
|
371
|
-
selectLastRow() {
|
|
372
|
-
this._dataUnit.selectLast();
|
|
373
|
-
}
|
|
374
270
|
setSelectedIndex(index) {
|
|
375
271
|
var _a;
|
|
376
272
|
(_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
|
|
@@ -464,49 +360,12 @@ export default class AgGridController {
|
|
|
464
360
|
return false;
|
|
465
361
|
}
|
|
466
362
|
onSelectionChange() {
|
|
467
|
-
const selectedNodes = this._gridOptions.api.getSelectedNodes();
|
|
468
|
-
if (selectedNodes.length > 0) {
|
|
469
|
-
this._isFirstRecordOfPage = selectedNodes[0].rowIndex === this._gridOptions.api.getFirstDisplayedRow();
|
|
470
|
-
this._isLastRecordOfPage = selectedNodes[0].rowIndex === this._gridOptions.api.getLastDisplayedRow();
|
|
471
|
-
}
|
|
472
363
|
if (this._selectionChangeCallback) {
|
|
473
364
|
this._selectionChangeCallback({
|
|
474
|
-
selection: this._gridOptions.api.getSelectedRows()
|
|
475
|
-
isFirstOfPage: this._isFirstRecordOfPage,
|
|
476
|
-
isLastOfPage: this._isLastRecordOfPage
|
|
365
|
+
selection: this._gridOptions.api.getSelectedRows()
|
|
477
366
|
});
|
|
478
367
|
}
|
|
479
368
|
}
|
|
480
|
-
onPaginationChange() {
|
|
481
|
-
var _a, _b;
|
|
482
|
-
const currentPageStatus = this.getPaginationStatus();
|
|
483
|
-
if (((_a = this._lastPageStatus) === null || _a === void 0 ? void 0 : _a.currentPage) != (currentPageStatus === null || currentPageStatus === void 0 ? void 0 : currentPageStatus.currentPage)) {
|
|
484
|
-
((_b = this._lastPageStatus) === null || _b === void 0 ? void 0 : _b.currentPage) < (currentPageStatus === null || currentPageStatus === void 0 ? void 0 : currentPageStatus.currentPage) ? this.selectFirstRow() : this.selectLastRow();
|
|
485
|
-
}
|
|
486
|
-
this.syncSelection();
|
|
487
|
-
if (this._paginationChangeCallback) {
|
|
488
|
-
if (this._gridOptions.api) {
|
|
489
|
-
this._paginationChangeCallback(currentPageStatus);
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
getPaginationStatus() {
|
|
494
|
-
const api = this._gridOptions.api;
|
|
495
|
-
const currentPage = api.paginationGetCurrentPage();
|
|
496
|
-
const isLastPage = api.paginationGetTotalPages() === (currentPage + 1);
|
|
497
|
-
const pageSize = api.paginationGetPageSize();
|
|
498
|
-
const totalRows = api.paginationGetRowCount();
|
|
499
|
-
const pageStart = currentPage * pageSize + 1;
|
|
500
|
-
const pageEnd = Math.min(totalRows, (currentPage + 1) * pageSize);
|
|
501
|
-
return {
|
|
502
|
-
hasPrevious: currentPage > 0,
|
|
503
|
-
hasNext: !isLastPage,
|
|
504
|
-
currentPage: currentPage + 1,
|
|
505
|
-
pageStart,
|
|
506
|
-
pageEnd,
|
|
507
|
-
totalRows
|
|
508
|
-
};
|
|
509
|
-
}
|
|
510
369
|
onRowDoubleClick(evt) {
|
|
511
370
|
if (this._doubleClickCallBack) {
|
|
512
371
|
this._doubleClickCallBack(evt.data);
|
|
@@ -1,56 +1,83 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Action, ObjectUtils } from "@sankhyalabs/core";
|
|
2
2
|
export default class DataSource {
|
|
3
|
-
constructor(dataUnit,
|
|
3
|
+
constructor(dataUnit, controller, options) {
|
|
4
|
+
this.RECORD_ARCHIVE = "__RECORD_ARCHIVE__";
|
|
5
|
+
this.duObserver = (action) => {
|
|
6
|
+
switch (action.type) {
|
|
7
|
+
case Action.METADATA_LOADED:
|
|
8
|
+
this._controller.setColumnsDef(this.buildColumnDefs(), true);
|
|
9
|
+
break;
|
|
10
|
+
case Action.LOADING_DATA:
|
|
11
|
+
this._waitingForLoad = true;
|
|
12
|
+
this._controller.refresh();
|
|
13
|
+
break;
|
|
14
|
+
case Action.DATA_LOADED:
|
|
15
|
+
this._waitingForLoad = false;
|
|
16
|
+
this.callbackGetRows(this._lastLoadingParams);
|
|
17
|
+
if (this._options) {
|
|
18
|
+
this._options.onPaginationChange(this._dataUnit.getPaginationInfo());
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
case Action.RECORDS_REMOVED:
|
|
22
|
+
case Action.DATA_SAVED:
|
|
23
|
+
case Action.EDITION_CANCELED:
|
|
24
|
+
case Action.DATA_CHANGED:
|
|
25
|
+
this._controller.refresh();
|
|
26
|
+
break;
|
|
27
|
+
case Action.SELECTION_CHANGED:
|
|
28
|
+
case Action.NEXT_SELECTED:
|
|
29
|
+
case Action.PREVIOUS_SELECTED:
|
|
30
|
+
this._controller.selectRows(this._dataUnit.getSelection());
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
4
34
|
this._dataUnit = dataUnit;
|
|
5
|
-
this.
|
|
35
|
+
this._controller = controller;
|
|
36
|
+
this._controller.setColumnsDef(this.buildColumnDefs(), true);
|
|
37
|
+
this._options = options;
|
|
38
|
+
this._dataUnit.subscribe(this.duObserver);
|
|
6
39
|
}
|
|
7
40
|
getRows(params) {
|
|
8
|
-
if (this.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.then(data => {
|
|
12
|
-
this._mockedServer = new Server(data.rowData);
|
|
13
|
-
params.success(this._mockedServer.getData(params.request));
|
|
14
|
-
})
|
|
15
|
-
.catch(() => params.fail());
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
params.success(this._mockedServer.getData(params.request));
|
|
19
|
-
}
|
|
41
|
+
if (this.needReload(params)) {
|
|
42
|
+
this._lastLoadingParams = params;
|
|
43
|
+
this._dataUnit.loadData(this.quickFilter);
|
|
20
44
|
}
|
|
21
45
|
else {
|
|
22
|
-
this.
|
|
23
|
-
|
|
24
|
-
.
|
|
46
|
+
this._lastLoadingParams = params;
|
|
47
|
+
if (!this._waitingForLoad) {
|
|
48
|
+
this.callbackGetRows(params);
|
|
49
|
+
}
|
|
25
50
|
}
|
|
26
51
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
resolve(this._lastPageResponse);
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
fetch(this._serverURL)
|
|
43
|
-
.then(response => {
|
|
44
|
-
response.json().then(rowData => resolve({ rowData }));
|
|
45
|
-
})
|
|
46
|
-
.catch(() => reject());
|
|
47
|
-
}
|
|
48
|
-
});
|
|
52
|
+
needReload(currentLoading) {
|
|
53
|
+
if (this._lastLoadingParams) {
|
|
54
|
+
return ObjectUtils.objectToString(currentLoading.request) != ObjectUtils.objectToString(this._lastLoadingParams.request);
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
callbackGetRows(params) {
|
|
59
|
+
if (params) {
|
|
60
|
+
params.success({ rowData: this._dataUnit.records });
|
|
61
|
+
}
|
|
49
62
|
}
|
|
50
|
-
|
|
51
|
-
this.
|
|
63
|
+
destroy() {
|
|
64
|
+
this._dataUnit.unsubscribe(this.duObserver);
|
|
52
65
|
}
|
|
53
|
-
|
|
54
|
-
|
|
66
|
+
buildColumnDefs() {
|
|
67
|
+
const columnDefs = [];
|
|
68
|
+
if (this._dataUnit.metadata) {
|
|
69
|
+
this._dataUnit.metadata.fields.forEach(f => {
|
|
70
|
+
var _a;
|
|
71
|
+
if (f.visible !== false && f.name !== this.RECORD_ARCHIVE) {
|
|
72
|
+
const props = new Map();
|
|
73
|
+
const properties = this._dataUnit.getField(f.name).properties;
|
|
74
|
+
for (const value in properties) {
|
|
75
|
+
props.set(value, properties[value]);
|
|
76
|
+
}
|
|
77
|
+
columnDefs.push({ label: f.label, name: f.name, userInterface: f.userInterface, options: (_a = this._dataUnit.getField(f.name).properties) === null || _a === void 0 ? void 0 : _a.options, props });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return columnDefs;
|
|
55
82
|
}
|
|
56
83
|
}
|
package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js
CHANGED
|
@@ -2,10 +2,10 @@ const HeaderColumnTemplate = `<div class="ag-cell-label-container" role="present
|
|
|
2
2
|
<span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button" aria-hidden="true"></span>
|
|
3
3
|
<div ref="eLabel" class="ag-header-cell-label" role="presentation" unselectable="on">
|
|
4
4
|
<span ref="eText" class="ag-header-cell-text" unselectable="on"></span>
|
|
5
|
-
<span ref="eFilter" class="ag-header-icon ag-header-label-icon ag-filter-icon" aria-hidden="true"></span>
|
|
6
|
-
<span ref="eSortAsc" class="ag-header-icon ag-header-label-icon ag-sort-ascending-icon" aria-hidden="true"></span>
|
|
7
|
-
<span ref="eSortDesc" class="ag-header-icon ag-header-label-icon ag-sort-descending-icon" aria-hidden="true"></span>
|
|
8
|
-
<span ref="eSortNone" class="ag-header-icon ag-header-label-icon ag-sort-none-icon" aria-hidden="true"></span>
|
|
5
|
+
<span ref="eFilter" class="ag-header-icon ag-header-label-icon ag-filter-icon ag-hidden" aria-hidden="true"></span>
|
|
6
|
+
<span ref="eSortAsc" class="ag-header-icon ag-header-label-icon ag-sort-ascending-icon ag-hidden" aria-hidden="true"></span>
|
|
7
|
+
<span ref="eSortDesc" class="ag-header-icon ag-header-label-icon ag-sort-descending-icon ag-hidden" aria-hidden="true"></span>
|
|
8
|
+
<span ref="eSortNone" class="ag-header-icon ag-header-label-icon ag-sort-none-icon ag-hidden" aria-hidden="true"></span>
|
|
9
9
|
</div>
|
|
10
10
|
</div>`;
|
|
11
11
|
|