@sankhyalabs/ezui 4.18.2 → 4.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants-3a1d64fb.js +7 -0
- package/dist/cjs/ez-check.cjs.entry.js +1 -1
- package/dist/cjs/ez-combo-box.cjs.entry.js +2 -2
- package/dist/cjs/ez-filter-input_2.cjs.entry.js +137 -0
- package/dist/cjs/ez-form-view.cjs.entry.js +1 -1
- package/dist/cjs/ez-grid.cjs.entry.js +373 -282
- package/dist/cjs/ez-list.cjs.entry.js +85 -72
- package/dist/cjs/ez-multi-selection-list.cjs.entry.js +181 -0
- package/dist/cjs/{ez-filter-input_4.cjs.entry.js → ez-scroller_3.cjs.entry.js} +0 -116
- package/dist/cjs/ezui.cjs.js +1 -1
- package/dist/cjs/filter-column.cjs.entry.js +108 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +3 -0
- package/dist/collection/components/ez-check/ez-check.css +1 -0
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +1 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +186 -119
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridUtils.js +8 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.js +8 -1
- package/dist/collection/components/ez-grid/ez-grid.css +14 -4
- package/dist/collection/components/ez-grid/ez-grid.js +49 -20
- package/dist/collection/components/ez-grid/subcomponents/filter-column.css +34 -0
- package/dist/collection/components/ez-grid/subcomponents/filter-column.js +297 -0
- package/dist/collection/components/ez-list/ez-list.css +0 -1
- package/dist/collection/components/ez-list/ez-list.js +88 -77
- package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.css +36 -0
- package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +318 -0
- package/dist/collection/components/ez-multi-selection-list/interfaces/IMultiSelectionListDataSource.js +1 -0
- package/dist/collection/components/ez-multi-selection-list/interfaces/IMultiSelectionOption.js +1 -0
- package/dist/collection/components/ez-multi-selection-list/subcomponents/multi-selection-box-message.css +18 -0
- package/dist/collection/components/ez-multi-selection-list/subcomponents/multi-selection-box-message.js +41 -0
- package/dist/collection/utils/constants.js +1 -0
- package/dist/custom-elements/index.d.ts +18 -0
- package/dist/custom-elements/index.js +761 -362
- package/dist/esm/constants-6dab64f7.js +4 -0
- package/dist/esm/ez-check.entry.js +1 -1
- package/dist/esm/ez-combo-box.entry.js +2 -2
- package/dist/esm/ez-filter-input_2.entry.js +132 -0
- package/dist/esm/ez-form-view.entry.js +1 -1
- package/dist/esm/ez-grid.entry.js +373 -282
- package/dist/esm/ez-list.entry.js +85 -72
- package/dist/esm/ez-multi-selection-list.entry.js +177 -0
- package/dist/esm/{ez-filter-input_4.entry.js → ez-scroller_3.entry.js} +3 -118
- package/dist/esm/ezui.js +1 -1
- package/dist/esm/filter-column.entry.js +104 -0
- package/dist/esm/loader.js +1 -1
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-06b3c6cd.entry.js +1 -0
- package/dist/ezui/{p-967758ac.entry.js → p-0dc118f3.entry.js} +1 -1
- package/dist/ezui/p-27a01a26.js +1 -0
- package/dist/ezui/p-353be5eb.entry.js +1 -0
- package/dist/ezui/p-3e25ecbc.entry.js +1 -0
- package/dist/ezui/{p-b945133d.entry.js → p-4186ca4f.entry.js} +1 -1
- package/dist/ezui/{p-b2056805.entry.js → p-5c0ac5ba.entry.js} +1 -1
- package/dist/ezui/{p-9334e296.entry.js → p-b7dd1382.entry.js} +2 -2
- package/dist/ezui/p-c72a799e.entry.js +1 -0
- package/dist/ezui/p-e04e9dbd.entry.js +1 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +5 -1
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +14 -5
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridUtils.d.ts +1 -0
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +9 -7
- package/dist/types/components/ez-grid/ez-grid.d.ts +14 -4
- package/dist/types/components/ez-grid/subcomponents/filter-column.d.ts +45 -0
- package/dist/types/components/ez-list/ez-list.d.ts +5 -5
- package/dist/types/components/ez-multi-selection-list/ez-multi-selection-list.d.ts +64 -0
- package/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionListDataSource.d.ts +4 -0
- package/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionOption.d.ts +4 -0
- package/dist/types/components/ez-multi-selection-list/subcomponents/multi-selection-box-message.d.ts +4 -0
- package/dist/types/components.d.ts +117 -1
- package/dist/types/utils/constants.d.ts +1 -0
- package/package.json +1 -1
- package/react/components.d.ts +3 -0
- package/react/components.js +3 -0
- package/react/components.js.map +1 -1
- package/dist/cjs/constants-5a75e2f3.js +0 -5
- package/dist/esm/constants-ca136201.js +0 -3
- package/dist/ezui/p-3f4ae3a3.js +0 -1
- package/dist/ezui/p-4ebb1d15.entry.js +0 -1
- package/dist/ezui/p-afea6e50.entry.js +0 -1
|
@@ -1,25 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Grid } from
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import DataSource from "./DataSource";
|
|
6
|
-
import { CellRendererStatus } from "./components/cellRendererStatus";
|
|
7
|
-
import SelectionHeader from "./components/selectionHeader";
|
|
1
|
+
import { ApplicationContext, DataType, NumberUtils, SortMode, StringUtils, UserInterface } from '@sankhyalabs/core';
|
|
2
|
+
import { Grid, } from 'ag-grid-community';
|
|
3
|
+
import { Grid as EnterpriseGrid, LicenseManager } from 'ag-grid-enterprise';
|
|
4
|
+
import DataSource from './DataSource';
|
|
8
5
|
import { EzGridCustomHeader } from './components/EzGridCustomHeader';
|
|
6
|
+
import { CellRendererStatus } from './components/cellRendererStatus';
|
|
7
|
+
import SelectionHeader from './components/selectionHeader';
|
|
8
|
+
import gridTerms from './i18n/pt-BR.js';
|
|
9
|
+
import { DISTINCT_FILTER_NAME_PREFIX } from '../../../../utils/constants';
|
|
10
|
+
import { calcFilterColumnLeftPosition } from './AgGridUtils';
|
|
9
11
|
export default class AgGridController {
|
|
12
|
+
configFilterColumn(filterColumn) {
|
|
13
|
+
this._filterColumn = filterColumn;
|
|
14
|
+
this._filterColumn.addEventListener('applyFilterColumnOptions', this.handleFilteredColumnsChanged.bind(this));
|
|
15
|
+
}
|
|
16
|
+
handleFilteredColumnsChanged(event) {
|
|
17
|
+
const applied = event.detail;
|
|
18
|
+
this._filteredColumns.set(applied.field, applied.values);
|
|
19
|
+
this._gridOptions.api.refreshHeader();
|
|
20
|
+
this._dataUnit.loadData();
|
|
21
|
+
}
|
|
22
|
+
showFilterColumn(configs) {
|
|
23
|
+
var _a;
|
|
24
|
+
(_a = this._filterColumn) === null || _a === void 0 ? void 0 : _a.show(configs);
|
|
25
|
+
}
|
|
10
26
|
constructor(enterprise) {
|
|
11
27
|
this.DEFAULT_ROW_HEIGHT = 30;
|
|
12
28
|
this.DEFAULT_HEADER_ROW_HEIGHT = 32;
|
|
13
|
-
this.CHECK_BOX_COL_ID =
|
|
14
|
-
this.STATUS_COL_ID =
|
|
15
|
-
this.RECORD_ARCHIVE_COL_ID =
|
|
29
|
+
this.CHECK_BOX_COL_ID = 'checkBoxColumn';
|
|
30
|
+
this.STATUS_COL_ID = 'statusColumn';
|
|
31
|
+
this.RECORD_ARCHIVE_COL_ID = '__RECORD_ARCHIVE__';
|
|
16
32
|
this.BLOCK_LOAD_DEBOUNCE = 400;
|
|
17
33
|
this.DEFAULT_FONT_SIZE = 14;
|
|
18
34
|
this.DEFAULT_ICON_SIZE = 12;
|
|
19
35
|
this.DEFAULT_MAX_SIZE = 200;
|
|
20
36
|
this._menuItems = [];
|
|
21
|
-
this._idAttribName =
|
|
37
|
+
this._idAttribName = '__record__id__';
|
|
22
38
|
this._gridConfig = [];
|
|
39
|
+
this._filteredColumns = new Map();
|
|
40
|
+
this._filterColumnleftPosition = '0px';
|
|
23
41
|
this._enterprise = enterprise;
|
|
24
42
|
}
|
|
25
43
|
getGridConfig() {
|
|
@@ -27,23 +45,59 @@ export default class AgGridController {
|
|
|
27
45
|
}
|
|
28
46
|
getSort() {
|
|
29
47
|
const sortedColumns = [];
|
|
30
|
-
this._gridOptions.columnApi
|
|
48
|
+
this._gridOptions.columnApi
|
|
49
|
+
.getColumnState()
|
|
31
50
|
.sort((colA, colB) => colA.sortIndex - colB.sortIndex)
|
|
32
51
|
.forEach(({ colId, sort }) => {
|
|
33
52
|
if (sort) {
|
|
34
53
|
const field = this._dataUnit.getField(colId);
|
|
35
|
-
const mode = sort ===
|
|
54
|
+
const mode = sort === 'asc' ? SortMode.ASC : SortMode.DESC;
|
|
36
55
|
const sortField = field ? { field: field.name, dataType: field.dataType, mode } : { field: colId, dataType: DataType.TEXT, mode };
|
|
37
56
|
sortedColumns.push(sortField);
|
|
38
57
|
}
|
|
39
58
|
});
|
|
40
59
|
return sortedColumns;
|
|
41
60
|
}
|
|
42
|
-
|
|
61
|
+
getFilter() {
|
|
62
|
+
if (!this._filteredColumns || this._filteredColumns.size === 0) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
return Array.from(this._filteredColumns.entries())
|
|
66
|
+
.map(([column, items]) => {
|
|
67
|
+
var _a;
|
|
68
|
+
const checkedOptions = items.filter(option => option.check);
|
|
69
|
+
if (checkedOptions.length > 0) {
|
|
70
|
+
const fieldDescriptor = this._dataUnit.getField(column);
|
|
71
|
+
const dataType = (_a = fieldDescriptor === null || fieldDescriptor === void 0 ? void 0 : fieldDescriptor.dataType) !== null && _a !== void 0 ? _a : DataType.TEXT;
|
|
72
|
+
let placeholders = '';
|
|
73
|
+
const params = [];
|
|
74
|
+
checkedOptions.forEach(option => {
|
|
75
|
+
if (placeholders.length > 0) {
|
|
76
|
+
placeholders = placeholders + ',';
|
|
77
|
+
}
|
|
78
|
+
const paramName = `PARAM_${column}_${params.length + 1}`;
|
|
79
|
+
placeholders = `${placeholders}:${paramName}`; //FIXME: trocar por ? quando o backend estiver funcionando
|
|
80
|
+
params.push({
|
|
81
|
+
dataType: dataType === DataType.OBJECT ? DataType.TEXT : dataType,
|
|
82
|
+
name: paramName,
|
|
83
|
+
value: option.value,
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const columnExpression = dataType === DataType.DATE ? `onlydate(this.${column})` : `this.${column}`;
|
|
87
|
+
return {
|
|
88
|
+
name: `${DISTINCT_FILTER_NAME_PREFIX}${column}`,
|
|
89
|
+
expression: `${columnExpression} in (${placeholders})`,
|
|
90
|
+
params,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return undefined;
|
|
94
|
+
})
|
|
95
|
+
.filter(item => item != undefined);
|
|
96
|
+
}
|
|
43
97
|
initDatagrid(container, options) {
|
|
44
98
|
var _a;
|
|
45
99
|
if (this._grid === undefined) {
|
|
46
|
-
LicenseManager.setLicenseKey(ApplicationContext.getContextValue(
|
|
100
|
+
LicenseManager.setLicenseKey(ApplicationContext.getContextValue('__EZUI__GRID_LICENSE__'));
|
|
47
101
|
this._columnStateChangeCallback = options.onColumnStateChange;
|
|
48
102
|
this._selectionChangeCallback = options.onSelectionChange;
|
|
49
103
|
this._doubleClickCallBack = options.onDoubleClick;
|
|
@@ -52,28 +106,30 @@ export default class AgGridController {
|
|
|
52
106
|
this._statusResolver = options.statusResolver;
|
|
53
107
|
if (this._dataUnit) {
|
|
54
108
|
this._dataUnit.sortingProvider = this;
|
|
109
|
+
this._dataUnit.addFilterProvider(this);
|
|
55
110
|
}
|
|
56
111
|
this._gridOptions = {
|
|
57
112
|
localeText: gridTerms,
|
|
58
|
-
rowSelection: this._multipleSelection ?
|
|
113
|
+
rowSelection: this._multipleSelection ? 'multiple' : 'single',
|
|
59
114
|
sortingOrder: ['desc', 'asc', null],
|
|
60
115
|
blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
|
|
61
116
|
navigateToNextCell: this.navigateToNextCell.bind(this),
|
|
62
|
-
getRowNodeId: this._dataUnit ?
|
|
117
|
+
getRowNodeId: this._dataUnit ? params => (typeof params === 'string' ? params : params[this._idAttribName]) : undefined,
|
|
63
118
|
getMainMenuItems: (params) => this.buildMenuItemOptions(params),
|
|
119
|
+
postProcessPopup: (params) => this.setFilterColumnLeftPosition(params),
|
|
64
120
|
getRowHeight: this.getRowHeight.bind(this),
|
|
65
121
|
defaultColDef: {
|
|
66
|
-
headerClass:
|
|
67
|
-
cellClass:
|
|
122
|
+
headerClass: 'ez-grid__cell-header',
|
|
123
|
+
cellClass: 'ez-grid__cell-body',
|
|
68
124
|
},
|
|
69
125
|
components: {
|
|
70
|
-
|
|
71
|
-
|
|
126
|
+
ezGridHeaderComponent: SelectionHeader,
|
|
127
|
+
ezGridCustomHeader: EzGridCustomHeader,
|
|
72
128
|
},
|
|
73
129
|
context: {
|
|
74
130
|
headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
|
|
75
|
-
headerCheckStatusSetter: (selectAll) => this.updateSelectionForAll(selectAll)
|
|
76
|
-
}
|
|
131
|
+
headerCheckStatusSetter: (selectAll) => this.updateSelectionForAll(selectAll),
|
|
132
|
+
},
|
|
77
133
|
};
|
|
78
134
|
this.defineRowModelType(this._gridOptions, options);
|
|
79
135
|
this.setOptionsEvents(this._gridOptions);
|
|
@@ -94,17 +150,22 @@ export default class AgGridController {
|
|
|
94
150
|
this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
|
|
95
151
|
}
|
|
96
152
|
}
|
|
153
|
+
setFilterColumnLeftPosition(params) {
|
|
154
|
+
if (params.type === 'columnMenu') {
|
|
155
|
+
const ePopup = params.ePopup;
|
|
156
|
+
const leftString = ePopup.style.left.replace('px', '');
|
|
157
|
+
this._filterColumnleftPosition = `${calcFilterColumnLeftPosition(parseInt(leftString))}px`;
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
97
161
|
buildMenuItemOptions(params) {
|
|
98
162
|
const col = params.column;
|
|
99
163
|
const items = [];
|
|
100
164
|
if (col.getColDef().sortable) {
|
|
101
165
|
items.push(this.buildMenuItemOptionSort(params, 'asc'));
|
|
102
166
|
items.push(this.buildMenuItemOptionSort(params, 'desc'));
|
|
167
|
+
items.push(this.buildMenuItemFilterColumn(params));
|
|
103
168
|
}
|
|
104
|
-
/*
|
|
105
|
-
TODO: Adicionar quando filtro de colunar estiver finalizado.
|
|
106
|
-
items.push(this.buildMenuItemFilterColumn(params));
|
|
107
|
-
*/
|
|
108
169
|
this._menuItems.forEach(m => items.push({
|
|
109
170
|
icon: m.icon,
|
|
110
171
|
name: m.label,
|
|
@@ -115,31 +176,31 @@ export default class AgGridController {
|
|
|
115
176
|
}
|
|
116
177
|
buildMenuItemOptionSort(params, sortOrder) {
|
|
117
178
|
return {
|
|
118
|
-
icon: `<
|
|
119
|
-
name: sortOrder ===
|
|
120
|
-
action: () => this.sortDataByColumn(params, sortOrder)
|
|
179
|
+
icon: `<i class='ez-icon-arrow_downward'></i>`,
|
|
180
|
+
name: sortOrder === 'asc' ? 'Ordenar Ascendente' : 'Ordenar Descendente',
|
|
181
|
+
action: () => this.sortDataByColumn(params, sortOrder),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
buildMenuItemFilterColumn(params) {
|
|
185
|
+
const columnName = params.column.getId();
|
|
186
|
+
const columnLabel = params.column.getColDef().headerName;
|
|
187
|
+
return {
|
|
188
|
+
icon: `<i class='ez-icon-filter'></i>`,
|
|
189
|
+
name: 'Filtrar',
|
|
190
|
+
action: () => this.showFilterColumn({ columnName, columnLabel, leftPosition: this._filterColumnleftPosition, filteredOptions: this._filteredColumns.get(columnName) }),
|
|
121
191
|
};
|
|
122
192
|
}
|
|
123
|
-
/*
|
|
124
|
-
TODO: Voltar função quando for implementado o filtro de coluna
|
|
125
|
-
private buildMenuItemFilterColumn( _params: GetMainMenuItemsParams): MenuItemDef{
|
|
126
|
-
return {
|
|
127
|
-
icon: `<i class='ez-icon-filter'></i>`,
|
|
128
|
-
name: "Filtrar",
|
|
129
|
-
action: () => window.alert("Abrir popover de filtro")
|
|
130
|
-
}
|
|
131
|
-
}*/
|
|
132
193
|
buildMenuItemOptionPin(params) {
|
|
133
194
|
const { column, columnApi } = params;
|
|
134
195
|
const isPinned = params.column.isPinned();
|
|
135
196
|
return {
|
|
136
197
|
icon: `<i class='ez-icon-${isPinned ? 'un-pin' : 'push-pin'}'></i>`,
|
|
137
|
-
name: isPinned ?
|
|
198
|
+
name: isPinned ? 'Desafixar coluna' : 'Fixar coluna',
|
|
138
199
|
action: () => {
|
|
139
200
|
columnApi.applyColumnState({
|
|
140
201
|
state: [{ colId: column.getColId(), pinned: column.isPinned() ? null : 'left' }],
|
|
141
202
|
});
|
|
142
|
-
}
|
|
203
|
+
},
|
|
143
204
|
};
|
|
144
205
|
}
|
|
145
206
|
sortDataByColumn(params, order) {
|
|
@@ -191,9 +252,9 @@ export default class AgGridController {
|
|
|
191
252
|
(_h = this._dataUnit) === null || _h === void 0 ? void 0 : _h.nextRecord();
|
|
192
253
|
}
|
|
193
254
|
return params.nextCellPosition;
|
|
194
|
-
case
|
|
195
|
-
case
|
|
196
|
-
if (((_j = params.nextCellPosition) === null || _j === void 0 ? void 0 : _j.column.colDef.headerName) !==
|
|
255
|
+
case 'ArrowLeft':
|
|
256
|
+
case 'ArrowRight':
|
|
257
|
+
if (((_j = params.nextCellPosition) === null || _j === void 0 ? void 0 : _j.column.colDef.headerName) !== '') {
|
|
197
258
|
return params.nextCellPosition;
|
|
198
259
|
}
|
|
199
260
|
else {
|
|
@@ -204,21 +265,21 @@ export default class AgGridController {
|
|
|
204
265
|
}
|
|
205
266
|
defineRowModelType(opt, sourceOptions) {
|
|
206
267
|
if (this._dataUnit != undefined) {
|
|
207
|
-
opt.rowModelType =
|
|
268
|
+
opt.rowModelType = 'serverSide';
|
|
208
269
|
opt.serverSideDatasource = new DataSource(this._dataUnit, this, sourceOptions);
|
|
209
270
|
opt.serverSideSortOnServer = true;
|
|
210
271
|
opt.columnDefs = this._colDefs;
|
|
211
272
|
}
|
|
212
273
|
}
|
|
213
274
|
setOptionsEvents(opt) {
|
|
214
|
-
opt.onSortChanged = e => this.onCallStateChange(
|
|
215
|
-
opt.onColumnResized = e => this.onCallStateChange(
|
|
216
|
-
opt.onColumnPinned = e => this.onCallStateChange(
|
|
217
|
-
opt.onColumnMoved = e => this.onCallStateChange(
|
|
218
|
-
opt.onColumnVisible = e => this.onCallStateChange(
|
|
275
|
+
opt.onSortChanged = e => this.onCallStateChange('sort', e);
|
|
276
|
+
opt.onColumnResized = e => this.onCallStateChange('columnResize', e);
|
|
277
|
+
opt.onColumnPinned = e => this.onCallStateChange('columnPinned', e);
|
|
278
|
+
opt.onColumnMoved = e => this.onCallStateChange('columnMoved', e);
|
|
279
|
+
opt.onColumnVisible = e => this.onCallStateChange('visibleChange', e);
|
|
219
280
|
opt.onSelectionChanged = e => this.onSelectionChange(e);
|
|
220
281
|
opt.onRowDoubleClicked = evt => this.onRowDoubleClick(evt);
|
|
221
|
-
opt.onDragStopped = evt => this.onCallStateChange(
|
|
282
|
+
opt.onDragStopped = evt => this.onCallStateChange('columnMovedEnd', evt);
|
|
222
283
|
}
|
|
223
284
|
setOptionsSupress(opt) {
|
|
224
285
|
opt.suppressDragLeaveHidesColumns = true;
|
|
@@ -252,18 +313,18 @@ export default class AgGridController {
|
|
|
252
313
|
}
|
|
253
314
|
setData(data) {
|
|
254
315
|
if (this._grid === undefined) {
|
|
255
|
-
throw new Error(
|
|
316
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
256
317
|
}
|
|
257
318
|
this._gridOptions.api.setRowData(data);
|
|
258
319
|
}
|
|
259
320
|
addRows() {
|
|
260
321
|
if (this._grid === undefined) {
|
|
261
|
-
throw new Error(
|
|
322
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
262
323
|
}
|
|
263
324
|
}
|
|
264
325
|
updateRows() {
|
|
265
326
|
if (this._grid === undefined) {
|
|
266
|
-
throw new Error(
|
|
327
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
267
328
|
}
|
|
268
329
|
}
|
|
269
330
|
selectAll(quietly = false) {
|
|
@@ -286,7 +347,7 @@ export default class AgGridController {
|
|
|
286
347
|
try {
|
|
287
348
|
this._gridOptions.context.selectionChangeQuietly = quietly;
|
|
288
349
|
if (this._grid === undefined) {
|
|
289
|
-
throw new Error(
|
|
350
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
290
351
|
}
|
|
291
352
|
let lastSelected;
|
|
292
353
|
this._gridOptions.api.forEachNode(node => {
|
|
@@ -318,13 +379,13 @@ export default class AgGridController {
|
|
|
318
379
|
}
|
|
319
380
|
removeRows() {
|
|
320
381
|
if (this._grid === undefined) {
|
|
321
|
-
throw new Error(
|
|
382
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
322
383
|
}
|
|
323
384
|
this._gridOptions.api.refreshServerSide({ purge: true });
|
|
324
385
|
}
|
|
325
386
|
changeValues(changes, rowIds) {
|
|
326
387
|
if (this._grid === undefined) {
|
|
327
|
-
throw new Error(
|
|
388
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
328
389
|
}
|
|
329
390
|
if (changes) {
|
|
330
391
|
let rowNodes;
|
|
@@ -351,7 +412,7 @@ export default class AgGridController {
|
|
|
351
412
|
}
|
|
352
413
|
refresh() {
|
|
353
414
|
if (this._grid === undefined) {
|
|
354
|
-
throw new Error(
|
|
415
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
355
416
|
}
|
|
356
417
|
this._gridOptions.api.refreshServerSide({ purge: false });
|
|
357
418
|
}
|
|
@@ -369,17 +430,19 @@ export default class AgGridController {
|
|
|
369
430
|
}
|
|
370
431
|
setFocusOnRow(rowIndex) {
|
|
371
432
|
let displayedColumns = this._gridOptions.columnApi.getAllDisplayedColumns();
|
|
372
|
-
let firstCell = displayedColumns.find(
|
|
433
|
+
let firstCell = displayedColumns.find(column => column.getColDef().headerName !== '');
|
|
373
434
|
this._gridOptions.api.ensureColumnVisible(firstCell);
|
|
374
435
|
this._gridOptions.api.ensureIndexVisible(rowIndex);
|
|
375
436
|
this._gridOptions.api.setFocusedCell(rowIndex, firstCell);
|
|
376
437
|
}
|
|
377
438
|
setColumnsDef(cols) {
|
|
378
|
-
const newColDefs = [
|
|
439
|
+
const newColDefs = [
|
|
440
|
+
Object.assign({ colId: this.CHECK_BOX_COL_ID, headerName: '', checkboxSelection: true, width: 29, suppressMovable: true, suppressAutoSize: true, suppressMenu: true, lockPosition: true, pinned: true }, (this._multipleSelection && { headerComponent: 'ezGridHeaderComponent', headerClass: 'ag-column-select-header' })),
|
|
441
|
+
];
|
|
379
442
|
if (this._statusResolver != undefined) {
|
|
380
443
|
newColDefs.push({
|
|
381
444
|
colId: this.STATUS_COL_ID,
|
|
382
|
-
headerName:
|
|
445
|
+
headerName: '',
|
|
383
446
|
checkboxSelection: false,
|
|
384
447
|
headerCheckboxSelection: false,
|
|
385
448
|
width: 29,
|
|
@@ -390,11 +453,11 @@ export default class AgGridController {
|
|
|
390
453
|
pinned: true,
|
|
391
454
|
cellRenderer: CellRendererStatus,
|
|
392
455
|
cellRendererParams: {
|
|
393
|
-
statusResolver: this._statusResolver
|
|
456
|
+
statusResolver: this._statusResolver,
|
|
394
457
|
},
|
|
395
458
|
cellStyle: {
|
|
396
|
-
|
|
397
|
-
}
|
|
459
|
+
'text-align': 'center',
|
|
460
|
+
},
|
|
398
461
|
});
|
|
399
462
|
}
|
|
400
463
|
cols.forEach(c => {
|
|
@@ -407,25 +470,27 @@ export default class AgGridController {
|
|
|
407
470
|
}
|
|
408
471
|
getColumnsDef() {
|
|
409
472
|
if (this._grid === undefined) {
|
|
410
|
-
throw new Error(
|
|
473
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
411
474
|
}
|
|
412
475
|
const colDef = this._gridOptions.columnApi.getColumns();
|
|
413
|
-
return colDef
|
|
476
|
+
return colDef
|
|
477
|
+
.filter(c => ![this.CHECK_BOX_COL_ID, this.STATUS_COL_ID].includes(c.getColId()))
|
|
478
|
+
.map(c => {
|
|
414
479
|
const def = c.getColDef();
|
|
415
480
|
const colDef = { name: def.field, label: def.headerName };
|
|
416
|
-
this.conditionalSet(colDef,
|
|
417
|
-
this.conditionalSet(colDef,
|
|
418
|
-
this.conditionalSet(colDef,
|
|
419
|
-
this.conditionalSet(colDef,
|
|
420
|
-
this.conditionalSet(colDef,
|
|
421
|
-
this.conditionalSet(colDef,
|
|
422
|
-
this.conditionalSet(colDef,
|
|
481
|
+
this.conditionalSet(colDef, 'sortable', def.sortable);
|
|
482
|
+
this.conditionalSet(colDef, 'resizable', def.resizable);
|
|
483
|
+
this.conditionalSet(colDef, 'sort', def.sort);
|
|
484
|
+
this.conditionalSet(colDef, 'sortIndex', def.sortIndex);
|
|
485
|
+
this.conditionalSet(colDef, 'width', def.width);
|
|
486
|
+
this.conditionalSet(colDef, 'pinned', def.pinned !== null);
|
|
487
|
+
this.conditionalSet(colDef, 'hidden', def.hide);
|
|
423
488
|
return colDef;
|
|
424
489
|
});
|
|
425
490
|
}
|
|
426
491
|
setColumnsState(state) {
|
|
427
492
|
if (this._grid === undefined) {
|
|
428
|
-
throw new Error(
|
|
493
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
429
494
|
}
|
|
430
495
|
const colDef = this._gridOptions.columnApi.getColumns();
|
|
431
496
|
let columns = this.getColumnsDef();
|
|
@@ -454,24 +519,26 @@ export default class AgGridController {
|
|
|
454
519
|
}
|
|
455
520
|
getColumnsState() {
|
|
456
521
|
if (this._grid === undefined) {
|
|
457
|
-
throw new Error(
|
|
522
|
+
throw new Error('Erro interno: Grid ainda não inicializado.');
|
|
458
523
|
}
|
|
459
524
|
const colState = this._gridOptions.columnApi.getColumnState();
|
|
460
|
-
return colState
|
|
525
|
+
return colState
|
|
526
|
+
.map(s => {
|
|
461
527
|
const def = this._gridOptions.columnApi.getColumn(s.colId).getColDef();
|
|
462
528
|
const label = def.headerName;
|
|
463
|
-
const name = def.checkboxSelection ?
|
|
529
|
+
const name = def.checkboxSelection ? '__SELECTION__' : s.colId;
|
|
464
530
|
const colState = { label, name };
|
|
465
|
-
this.conditionalSet(colState,
|
|
466
|
-
this.conditionalSet(colState,
|
|
467
|
-
this.conditionalSet(colState,
|
|
468
|
-
this.conditionalSet(colState,
|
|
469
|
-
this.conditionalSet(colState,
|
|
531
|
+
this.conditionalSet(colState, 'sort', s.sort);
|
|
532
|
+
this.conditionalSet(colState, 'sortIndex', s.sortIndex);
|
|
533
|
+
this.conditionalSet(colState, 'width', s.width);
|
|
534
|
+
this.conditionalSet(colState, 'pinned', s.pinned !== null);
|
|
535
|
+
this.conditionalSet(colState, 'hidden', s.hide);
|
|
470
536
|
const props = new Map();
|
|
471
537
|
props.set('sortable', def.sortable);
|
|
472
|
-
this.conditionalSet(colState,
|
|
538
|
+
this.conditionalSet(colState, 'props', props);
|
|
473
539
|
return colState;
|
|
474
|
-
})
|
|
540
|
+
})
|
|
541
|
+
.filter(c => c.name !== '__SELECTION__' && c.name !== this.STATUS_COL_ID);
|
|
475
542
|
}
|
|
476
543
|
getSelection() {
|
|
477
544
|
return this._gridOptions.api.getSelectedRows();
|
|
@@ -489,7 +556,7 @@ export default class AgGridController {
|
|
|
489
556
|
fields: this._gridOptions.columnApi
|
|
490
557
|
.getColumns()
|
|
491
558
|
.filter(col => col.isVisible() && ![this.CHECK_BOX_COL_ID, this.STATUS_COL_ID, this.RECORD_ARCHIVE_COL_ID].includes(col.getColId()))
|
|
492
|
-
.map(col => col.getColId())
|
|
559
|
+
.map(col => col.getColId()),
|
|
493
560
|
};
|
|
494
561
|
this._dataSource.quickFilter = quickFilter;
|
|
495
562
|
}
|
|
@@ -501,23 +568,20 @@ export default class AgGridController {
|
|
|
501
568
|
var _a;
|
|
502
569
|
(_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
|
|
503
570
|
}
|
|
504
|
-
hasFilterColumn(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
/*
|
|
509
|
-
TODO: Implementar chamada para apresentar filtro de coluna na grid
|
|
510
|
-
*/
|
|
571
|
+
hasFilterColumn(columnName) {
|
|
572
|
+
var _a;
|
|
573
|
+
const filterOptions = (_a = this._filteredColumns.get(columnName)) !== null && _a !== void 0 ? _a : [];
|
|
574
|
+
return filterOptions.map(item => item.check).includes(true);
|
|
511
575
|
}
|
|
512
576
|
buildColDef(source) {
|
|
513
577
|
var _a, _b, _c;
|
|
514
578
|
let tooltip = undefined;
|
|
515
|
-
const propSortable = StringUtils.getBooleanValue((_a = source.props) === null || _a === void 0 ? void 0 : _a.get(
|
|
516
|
-
if ((_b = source.props) === null || _b === void 0 ? void 0 : _b.get(
|
|
517
|
-
tooltip = (_c = source.props) === null || _c === void 0 ? void 0 : _c.get(
|
|
579
|
+
const propSortable = StringUtils.getBooleanValue((_a = source.props) === null || _a === void 0 ? void 0 : _a.get('gridSortable'), true);
|
|
580
|
+
if ((_b = source.props) === null || _b === void 0 ? void 0 : _b.get('gridHeaderTooltip')) {
|
|
581
|
+
tooltip = (_c = source.props) === null || _c === void 0 ? void 0 : _c.get('gridHeaderTooltip');
|
|
518
582
|
}
|
|
519
583
|
else if (propSortable === false) {
|
|
520
|
-
tooltip =
|
|
584
|
+
tooltip = 'Coluna não pode ser ordenada';
|
|
521
585
|
}
|
|
522
586
|
return {
|
|
523
587
|
headerName: source.label,
|
|
@@ -527,18 +591,19 @@ export default class AgGridController {
|
|
|
527
591
|
headerComponent: 'ezGridCustomHeader',
|
|
528
592
|
headerComponentParams: {
|
|
529
593
|
tooltip: tooltip,
|
|
594
|
+
isSortable: propSortable,
|
|
530
595
|
hasFilter: () => this.hasFilterColumn(source.name),
|
|
531
|
-
showColumnFilter: () => this.
|
|
596
|
+
showColumnFilter: (leftPosition) => this.showFilterColumn({ columnName: source.name, columnLabel: source.label, leftPosition, filteredOptions: this._filteredColumns.get(source.name) }),
|
|
532
597
|
},
|
|
533
598
|
valueFormatter: params => {
|
|
534
599
|
return this.getFormatterByColumn(params, source);
|
|
535
600
|
},
|
|
536
|
-
cellStyle: this.getStyleByColumn(source)
|
|
601
|
+
cellStyle: this.getStyleByColumn(source),
|
|
537
602
|
};
|
|
538
603
|
}
|
|
539
604
|
getInitCellStyle() {
|
|
540
605
|
return {
|
|
541
|
-
|
|
606
|
+
'line-height': this.getRowHeight() - 1 + 'px',
|
|
542
607
|
};
|
|
543
608
|
}
|
|
544
609
|
getStyleByColumn(source) {
|
|
@@ -546,32 +611,34 @@ export default class AgGridController {
|
|
|
546
611
|
switch (source === null || source === void 0 ? void 0 : source.userInterface) {
|
|
547
612
|
case UserInterface.DECIMALNUMBER:
|
|
548
613
|
case UserInterface.INTEGERNUMBER:
|
|
549
|
-
cellStyle[
|
|
614
|
+
cellStyle['text-align'] = 'right';
|
|
550
615
|
break;
|
|
551
616
|
case UserInterface.DATE:
|
|
552
617
|
case UserInterface.DATETIME:
|
|
553
618
|
case UserInterface.TIME:
|
|
554
|
-
cellStyle[
|
|
619
|
+
cellStyle['text-align'] = 'center';
|
|
555
620
|
break;
|
|
556
621
|
default:
|
|
557
|
-
cellStyle[
|
|
622
|
+
cellStyle['text-align'] = 'left';
|
|
558
623
|
}
|
|
559
624
|
return cellStyle;
|
|
560
625
|
}
|
|
561
626
|
getFormatterByColumn(params, source) {
|
|
562
627
|
var _a;
|
|
563
|
-
if ((source === null || source === void 0 ? void 0 : source.userInterface) ===
|
|
628
|
+
if ((source === null || source === void 0 ? void 0 : source.userInterface) === 'OPTIONSELECTOR' && source.options) {
|
|
564
629
|
const prop = source === null || source === void 0 ? void 0 : source.options;
|
|
565
630
|
let options;
|
|
566
|
-
if (typeof prop ===
|
|
631
|
+
if (typeof prop === 'string') {
|
|
567
632
|
const parsed = JSON.parse(prop);
|
|
568
|
-
options = Object.keys(parsed).map(key => {
|
|
633
|
+
options = Object.keys(parsed).map(key => {
|
|
634
|
+
return { value: key, label: parsed[key] };
|
|
635
|
+
});
|
|
569
636
|
}
|
|
570
637
|
else {
|
|
571
638
|
options = prop;
|
|
572
639
|
}
|
|
573
640
|
let optionSelected;
|
|
574
|
-
options.forEach(
|
|
641
|
+
options.forEach(option => {
|
|
575
642
|
if (option.value == params.value) {
|
|
576
643
|
optionSelected = option;
|
|
577
644
|
}
|
|
@@ -579,16 +646,16 @@ export default class AgGridController {
|
|
|
579
646
|
return optionSelected === null || optionSelected === void 0 ? void 0 : optionSelected.label;
|
|
580
647
|
}
|
|
581
648
|
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SWITCH) {
|
|
582
|
-
if ((params === null || params === void 0 ? void 0 : params.value) ===
|
|
583
|
-
return
|
|
649
|
+
if ((params === null || params === void 0 ? void 0 : params.value) === 'S' || (params === null || params === void 0 ? void 0 : params.value) === true || (params === null || params === void 0 ? void 0 : params.value) === 'true') {
|
|
650
|
+
return 'Sim';
|
|
584
651
|
}
|
|
585
|
-
else if ((params === null || params === void 0 ? void 0 : params.value) ===
|
|
586
|
-
return
|
|
652
|
+
else if ((params === null || params === void 0 ? void 0 : params.value) === 'N' || (params === null || params === void 0 ? void 0 : params.value) === false || (params === null || params === void 0 ? void 0 : params.value) === 'false') {
|
|
653
|
+
return 'Não';
|
|
587
654
|
}
|
|
588
655
|
}
|
|
589
656
|
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.SEARCH) {
|
|
590
657
|
if (((_a = params === null || params === void 0 ? void 0 : params.value) === null || _a === void 0 ? void 0 : _a.value) != undefined) {
|
|
591
|
-
return params.value.value +
|
|
658
|
+
return params.value.value + ' - ' + params.value.label;
|
|
592
659
|
}
|
|
593
660
|
else {
|
|
594
661
|
return params === null || params === void 0 ? void 0 : params.value;
|
|
@@ -596,7 +663,7 @@ export default class AgGridController {
|
|
|
596
663
|
}
|
|
597
664
|
if ((source === null || source === void 0 ? void 0 : source.userInterface) === UserInterface.DECIMALNUMBER) {
|
|
598
665
|
if (params.value != undefined) {
|
|
599
|
-
const precision = Number(source.props.get(
|
|
666
|
+
const precision = Number(source.props.get('precision')) || 2;
|
|
600
667
|
return NumberUtils.format(params.value.toString(), precision, precision);
|
|
601
668
|
}
|
|
602
669
|
}
|
|
@@ -607,7 +674,7 @@ export default class AgGridController {
|
|
|
607
674
|
}
|
|
608
675
|
}
|
|
609
676
|
onCallStateChange(type, e) {
|
|
610
|
-
const finished = !(
|
|
677
|
+
const finished = !('finished' in e) || e['finished'];
|
|
611
678
|
if (finished && this._columnStateChangeCallback) {
|
|
612
679
|
let info = {};
|
|
613
680
|
let isUserChange = this.isUIEvent(e['source'], e['type']);
|
|
@@ -620,10 +687,10 @@ export default class AgGridController {
|
|
|
620
687
|
}
|
|
621
688
|
}
|
|
622
689
|
isElementResize(e) {
|
|
623
|
-
return e[
|
|
690
|
+
return e['target'] && e['target'].getAttribute('ref') === 'eResize';
|
|
624
691
|
}
|
|
625
692
|
isUIEvent(source, type) {
|
|
626
|
-
let optionsArr = [
|
|
693
|
+
let optionsArr = ['uiColumnMoved', 'uiColumnResized', 'uiColumnDragged', 'uiColumnExpanded', 'uiColumnSorted'];
|
|
627
694
|
if (type === 'dragStopped') {
|
|
628
695
|
return true;
|
|
629
696
|
}
|
|
@@ -641,14 +708,14 @@ export default class AgGridController {
|
|
|
641
708
|
const selectionInfo = this._dataUnit;
|
|
642
709
|
this._selectionChangeCallback({
|
|
643
710
|
selection: selectionInfo.records,
|
|
644
|
-
selectionHeaderStatus: this.getSelectionHeaderStatus()
|
|
711
|
+
selectionHeaderStatus: this.getSelectionHeaderStatus(),
|
|
645
712
|
});
|
|
646
713
|
}
|
|
647
714
|
else {
|
|
648
715
|
this._dataUnit.updatePageSelection(this._gridOptions.api.getSelectedRows().map((r) => r.__record__id__)).then(selectionInfo => {
|
|
649
716
|
this._selectionChangeCallback({
|
|
650
717
|
selection: selectionInfo.records,
|
|
651
|
-
selectionHeaderStatus: this.getSelectionHeaderStatus()
|
|
718
|
+
selectionHeaderStatus: this.getSelectionHeaderStatus(),
|
|
652
719
|
});
|
|
653
720
|
});
|
|
654
721
|
}
|
|
@@ -656,7 +723,7 @@ export default class AgGridController {
|
|
|
656
723
|
else {
|
|
657
724
|
this._selectionChangeCallback({
|
|
658
725
|
selection: this._gridOptions.api.getSelectedRows(),
|
|
659
|
-
selectionHeaderStatus: this.getSelectionHeaderStatus()
|
|
726
|
+
selectionHeaderStatus: this.getSelectionHeaderStatus(),
|
|
660
727
|
});
|
|
661
728
|
}
|
|
662
729
|
}, 0);
|
|
@@ -684,7 +751,7 @@ export default class AgGridController {
|
|
|
684
751
|
if ((field === null || field === void 0 ? void 0 : field.userInterface) === UserInterface.SEARCH) {
|
|
685
752
|
return this.DEFAULT_MAX_SIZE;
|
|
686
753
|
}
|
|
687
|
-
const labelSize = (((
|
|
754
|
+
const labelSize = (((_b = field === null || field === void 0 ? void 0 : field.label) === null || _b === void 0 ? void 0 : _b.length) || 0) * this.DEFAULT_FONT_SIZE + this.DEFAULT_ICON_SIZE;
|
|
688
755
|
return labelSize > this.DEFAULT_MAX_SIZE ? this.DEFAULT_MAX_SIZE : labelSize;
|
|
689
756
|
}
|
|
690
757
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function calcFilterColumnLeftPosition(leftReference) {
|
|
2
|
+
const FIX_MARGIN = 60;
|
|
3
|
+
const FILTER_COLUMN_WIDTH = 330;
|
|
4
|
+
const screenWidth = window.innerWidth;
|
|
5
|
+
const maxLeft = screenWidth - (FILTER_COLUMN_WIDTH + FIX_MARGIN);
|
|
6
|
+
const leftInt = leftReference - FIX_MARGIN;
|
|
7
|
+
return leftInt > maxLeft ? maxLeft : leftInt;
|
|
8
|
+
}
|