@sankhyalabs/ezui 4.16.1 → 4.18.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/ez-grid.cjs.entry.js +166 -29
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +83 -13
- package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.js +81 -0
- package/dist/collection/components/ez-grid/ez-grid.js +10 -4
- package/dist/custom-elements/index.js +166 -29
- package/dist/esm/ez-grid.entry.js +166 -29
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/{p-00f4bff5.entry.js → p-9334e296.entry.js} +1 -1
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +4 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +6 -0
- package/dist/types/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.d.ts +30 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +1 -1
- package/dist/types/components.d.ts +3 -3
- package/package.json +1 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/template/HeaderColumnTemplate.js +0 -16
|
@@ -118901,21 +118901,6 @@ const gridTerms = {
|
|
|
118901
118901
|
ctrlV: "Ctrl+V"
|
|
118902
118902
|
};
|
|
118903
118903
|
|
|
118904
|
-
const HeaderColumnTemplate = `<div class="ag-cell-label-container" role="presentation" title="{{HEADER_TITLE}}">
|
|
118905
|
-
<span ref="eMenu" class="ag-header-icon ag-header-cell-menu-button" aria-hidden="true"></span>
|
|
118906
|
-
<div ref="eLabel" class="ag-header-cell-label" role="presentation" unselectable="on">
|
|
118907
|
-
<span ref="eText" class="ag-header-cell-text" unselectable="on"></span>
|
|
118908
|
-
<span ref="eFilter" class="ag-header-icon ag-header-label-icon ag-filter-icon ag-hidden" aria-hidden="true"></span>
|
|
118909
|
-
<span ref="eSortAsc" class="ag-header-icon ag-header-label-icon ag-sort-ascending-icon ag-hidden" aria-hidden="true"></span>
|
|
118910
|
-
<span ref="eSortDesc" class="ag-header-icon ag-header-label-icon ag-sort-descending-icon ag-hidden" aria-hidden="true"></span>
|
|
118911
|
-
<span ref="eSortNone" class="ag-header-icon ag-header-label-icon ag-sort-none-icon ag-hidden" aria-hidden="true"></span>
|
|
118912
|
-
</div>
|
|
118913
|
-
</div>`;
|
|
118914
|
-
|
|
118915
|
-
function getHeaderColumnTemplate(headerTooltip = "") {
|
|
118916
|
-
return HeaderColumnTemplate.replaceAll("{{HEADER_TITLE}}", headerTooltip)
|
|
118917
|
-
}
|
|
118918
|
-
|
|
118919
118904
|
class DataSource {
|
|
118920
118905
|
constructor(dataUnit, controller, options) {
|
|
118921
118906
|
this.RECORD_ARCHIVE = "__RECORD_ARCHIVE__";
|
|
@@ -119101,6 +119086,88 @@ class SelectionHeader {
|
|
|
119101
119086
|
}
|
|
119102
119087
|
}
|
|
119103
119088
|
|
|
119089
|
+
class EzGridCustomHeader {
|
|
119090
|
+
init(agParams) {
|
|
119091
|
+
var _a;
|
|
119092
|
+
this.params = agParams;
|
|
119093
|
+
this.element = document.createElement('div');
|
|
119094
|
+
this.element.classList.add('ag-cell-label-container');
|
|
119095
|
+
this.element.setAttribute('title', (_a = this.params.tooltip) !== null && _a !== void 0 ? _a : '');
|
|
119096
|
+
this.element.innerHTML = `
|
|
119097
|
+
<div class='ez-flex ez-flex--justify-between'>
|
|
119098
|
+
<i id='ez-grid-filter-icon' class='ez-icon-filter' style='color:#008561'></i>
|
|
119099
|
+
<i id='ez-grid-menu-icon' class='ez-icon-dots-vertical'></i>
|
|
119100
|
+
</div>
|
|
119101
|
+
<div id='ez-header-container' class='ez-flex ez-flex--justify-between ag-header-cell-text'>
|
|
119102
|
+
<span class='ag-header-cell-text'>${this.params.displayName}</span>
|
|
119103
|
+
<i id='ez-grid-sort-icon-down' class='ez-icon-arrow_downward' style='display: none;margin-left: 4px;font-size: var(--text--medium, 14px);align-self: center;'></i>
|
|
119104
|
+
<i id='ez-grid-sort-icon-up' class='ez-icon-arrow_downward' style='display: none; transform: rotate(180deg);margin-left: 4px;font-size: var(--text--medium, 14px);align-self: center;'></i>
|
|
119105
|
+
</div>
|
|
119106
|
+
`;
|
|
119107
|
+
this.configMenuClick();
|
|
119108
|
+
this.configSortClick();
|
|
119109
|
+
this.configSortListener();
|
|
119110
|
+
this.configFilterButton();
|
|
119111
|
+
}
|
|
119112
|
+
refresh(agParams) {
|
|
119113
|
+
this.params = agParams;
|
|
119114
|
+
this.configFilterButton();
|
|
119115
|
+
this.configSortIcon();
|
|
119116
|
+
}
|
|
119117
|
+
configFilterButton() {
|
|
119118
|
+
this.filterButton = this.element.querySelector('#ez-grid-filter-icon');
|
|
119119
|
+
this.filterButton.style.display = this.params.hasFilter() ? 'flex' : 'none';
|
|
119120
|
+
this.onFilterButtonClickListener = this.params.showColumnFilter.bind(this);
|
|
119121
|
+
this.filterButton.addEventListener('click', this.onFilterButtonClickListener);
|
|
119122
|
+
}
|
|
119123
|
+
configSortIcon() {
|
|
119124
|
+
this.sortDownIcon.style.display = this.params.column.isSortDescending() ? 'flex' : 'none';
|
|
119125
|
+
this.sortUpIcon.style.display = this.params.column.isSortAscending() ? 'flex' : 'none';
|
|
119126
|
+
}
|
|
119127
|
+
configSortListener() {
|
|
119128
|
+
if (this.params.enableSorting) {
|
|
119129
|
+
this.sortUpIcon = this.element.querySelector('#ez-grid-sort-icon-up');
|
|
119130
|
+
this.sortDownIcon = this.element.querySelector('#ez-grid-sort-icon-down');
|
|
119131
|
+
this.onSortChangedListener = this.configSortIcon.bind(this);
|
|
119132
|
+
this.params.column.addEventListener('sortChanged', this.onSortChangedListener);
|
|
119133
|
+
this.configSortIcon();
|
|
119134
|
+
}
|
|
119135
|
+
}
|
|
119136
|
+
onSortClick(event) {
|
|
119137
|
+
this.params.progressSort(event.shiftKey);
|
|
119138
|
+
}
|
|
119139
|
+
configSortClick() {
|
|
119140
|
+
if (this.params.column.getColDef().sortable) {
|
|
119141
|
+
this.headerContainer = this.element.querySelector('#ez-header-container');
|
|
119142
|
+
this.onSortClickListener = this.onSortClick.bind(this);
|
|
119143
|
+
this.headerContainer.addEventListener('click', this.onSortClickListener);
|
|
119144
|
+
}
|
|
119145
|
+
}
|
|
119146
|
+
onMenuClick() {
|
|
119147
|
+
this.params.showColumnMenu(this.menuButton);
|
|
119148
|
+
}
|
|
119149
|
+
configMenuClick() {
|
|
119150
|
+
this.menuButton = this.element.querySelector('#ez-grid-menu-icon');
|
|
119151
|
+
this.onMenuClickListener = this.onMenuClick.bind(this);
|
|
119152
|
+
this.menuButton.addEventListener('click', this.onMenuClickListener);
|
|
119153
|
+
}
|
|
119154
|
+
getGui() {
|
|
119155
|
+
return this.element;
|
|
119156
|
+
}
|
|
119157
|
+
destroy() {
|
|
119158
|
+
if (this.onMenuClickListener) {
|
|
119159
|
+
this.menuButton.removeEventListener('click', this.onMenuClickListener);
|
|
119160
|
+
}
|
|
119161
|
+
if (this.onSortClickListener) {
|
|
119162
|
+
this.headerContainer.removeEventListener('click', this.onSortClickListener);
|
|
119163
|
+
}
|
|
119164
|
+
if (this.onFilterButtonClickListener) {
|
|
119165
|
+
this.filterButton.removeEventListener('click', this.onFilterButtonClickListener);
|
|
119166
|
+
}
|
|
119167
|
+
this.params.column.removeEventListener('sortChanged', this.onSortChangedListener);
|
|
119168
|
+
}
|
|
119169
|
+
}
|
|
119170
|
+
|
|
119104
119171
|
class AgGridController {
|
|
119105
119172
|
constructor(enterprise) {
|
|
119106
119173
|
this.DEFAULT_ROW_HEIGHT = 30;
|
|
@@ -119155,22 +119222,15 @@ class AgGridController {
|
|
|
119155
119222
|
blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
|
|
119156
119223
|
navigateToNextCell: this.navigateToNextCell.bind(this),
|
|
119157
119224
|
getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
|
|
119158
|
-
getMainMenuItems: (params) =>
|
|
119159
|
-
const column = params.column;
|
|
119160
|
-
const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
|
|
119161
|
-
this._menuItems.forEach(m => items.push({
|
|
119162
|
-
name: m.label,
|
|
119163
|
-
action: () => m.action(column.getColId(), m.name)
|
|
119164
|
-
}));
|
|
119165
|
-
return items;
|
|
119166
|
-
},
|
|
119225
|
+
getMainMenuItems: (params) => this.buildMenuItemOptions(params),
|
|
119167
119226
|
getRowHeight: this.getRowHeight.bind(this),
|
|
119168
119227
|
defaultColDef: {
|
|
119169
119228
|
headerClass: "ez-grid__cell-header",
|
|
119170
119229
|
cellClass: "ez-grid__cell-body"
|
|
119171
119230
|
},
|
|
119172
119231
|
components: {
|
|
119173
|
-
'ezGridHeaderComponent': SelectionHeader
|
|
119232
|
+
'ezGridHeaderComponent': SelectionHeader,
|
|
119233
|
+
'ezGridCustomHeader': EzGridCustomHeader,
|
|
119174
119234
|
},
|
|
119175
119235
|
context: {
|
|
119176
119236
|
headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
|
|
@@ -119196,6 +119256,69 @@ class AgGridController {
|
|
|
119196
119256
|
this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
|
|
119197
119257
|
}
|
|
119198
119258
|
}
|
|
119259
|
+
buildMenuItemOptions(params) {
|
|
119260
|
+
const col = params.column;
|
|
119261
|
+
const items = [];
|
|
119262
|
+
if (col.getColDef().sortable) {
|
|
119263
|
+
items.push(this.buildMenuItemOptionSort(params, 'asc'));
|
|
119264
|
+
items.push(this.buildMenuItemOptionSort(params, 'desc'));
|
|
119265
|
+
}
|
|
119266
|
+
/*
|
|
119267
|
+
TODO: Adicionar quando filtro de colunar estiver finalizado.
|
|
119268
|
+
items.push(this.buildMenuItemFilterColumn(params));
|
|
119269
|
+
*/
|
|
119270
|
+
this._menuItems.forEach(m => items.push({
|
|
119271
|
+
icon: m.icon,
|
|
119272
|
+
name: m.label,
|
|
119273
|
+
action: () => m.action(params),
|
|
119274
|
+
}));
|
|
119275
|
+
items.push(this.buildMenuItemOptionPin(params));
|
|
119276
|
+
return items;
|
|
119277
|
+
}
|
|
119278
|
+
buildMenuItemOptionSort(params, sortOrder) {
|
|
119279
|
+
return {
|
|
119280
|
+
icon: `<div style="${sortOrder === "asc" ? 'transform: rotate(180deg); position: relative; top: -4px;' : ''}"><i class='ez-icon-arrow_downward'></i></div>`,
|
|
119281
|
+
name: sortOrder === "asc" ? "Ordenar Ascendente" : "Ordenar Descendente",
|
|
119282
|
+
action: () => this.sortDataByColumn(params, sortOrder)
|
|
119283
|
+
};
|
|
119284
|
+
}
|
|
119285
|
+
/*
|
|
119286
|
+
TODO: Voltar função quando for implementado o filtro de coluna
|
|
119287
|
+
private buildMenuItemFilterColumn( _params: GetMainMenuItemsParams): MenuItemDef{
|
|
119288
|
+
return {
|
|
119289
|
+
icon: `<i class='ez-icon-filter'></i>`,
|
|
119290
|
+
name: "Filtrar",
|
|
119291
|
+
action: () => window.alert("Abrir popover de filtro")
|
|
119292
|
+
}
|
|
119293
|
+
}*/
|
|
119294
|
+
buildMenuItemOptionPin(params) {
|
|
119295
|
+
const { column, columnApi } = params;
|
|
119296
|
+
const isPinned = params.column.isPinned();
|
|
119297
|
+
return {
|
|
119298
|
+
icon: `<i class='ez-icon-${isPinned ? 'un-pin' : 'push-pin'}'></i>`,
|
|
119299
|
+
name: isPinned ? "Desafixar coluna" : "Fixar coluna",
|
|
119300
|
+
action: () => {
|
|
119301
|
+
columnApi.applyColumnState({
|
|
119302
|
+
state: [{ colId: column.getColId(), pinned: column.isPinned() ? null : 'left' }],
|
|
119303
|
+
});
|
|
119304
|
+
}
|
|
119305
|
+
};
|
|
119306
|
+
}
|
|
119307
|
+
sortDataByColumn(params, order) {
|
|
119308
|
+
const col = params.column;
|
|
119309
|
+
const colApi = params.columnApi;
|
|
119310
|
+
if (col.getSort() === order) {
|
|
119311
|
+
colApi.applyColumnState({
|
|
119312
|
+
defaultState: { sort: null },
|
|
119313
|
+
});
|
|
119314
|
+
}
|
|
119315
|
+
else {
|
|
119316
|
+
colApi.applyColumnState({
|
|
119317
|
+
state: [{ colId: col.getColId(), sort: order }],
|
|
119318
|
+
defaultState: { sort: null },
|
|
119319
|
+
});
|
|
119320
|
+
}
|
|
119321
|
+
}
|
|
119199
119322
|
getRowHeight() {
|
|
119200
119323
|
return this.DEFAULT_ROW_HEIGHT;
|
|
119201
119324
|
}
|
|
@@ -119516,7 +119639,10 @@ class AgGridController {
|
|
|
119516
119639
|
return this._gridOptions.api.getSelectedRows();
|
|
119517
119640
|
}
|
|
119518
119641
|
addColumnMenuItem(item) {
|
|
119519
|
-
this._menuItems.
|
|
119642
|
+
const itemsNames = this._menuItems.map(i => i.name);
|
|
119643
|
+
if (!itemsNames.includes(item.name)) {
|
|
119644
|
+
this._menuItems.push(item);
|
|
119645
|
+
}
|
|
119520
119646
|
}
|
|
119521
119647
|
quickFilter(term) {
|
|
119522
119648
|
if (term) {
|
|
@@ -119537,6 +119663,14 @@ class AgGridController {
|
|
|
119537
119663
|
var _a;
|
|
119538
119664
|
(_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
|
|
119539
119665
|
}
|
|
119666
|
+
hasFilterColumn(_columnName) {
|
|
119667
|
+
return false; //TODO: substituir pelo state dos filtros de colunas
|
|
119668
|
+
}
|
|
119669
|
+
showColumnFilter() {
|
|
119670
|
+
/*
|
|
119671
|
+
TODO: Implementar chamada para apresentar filtro de coluna na grid
|
|
119672
|
+
*/
|
|
119673
|
+
}
|
|
119540
119674
|
buildColDef(source) {
|
|
119541
119675
|
var _a, _b, _c;
|
|
119542
119676
|
let tooltip = undefined;
|
|
@@ -119552,8 +119686,11 @@ class AgGridController {
|
|
|
119552
119686
|
field: source.name,
|
|
119553
119687
|
sortable: propSortable,
|
|
119554
119688
|
resizable: true,
|
|
119689
|
+
headerComponent: 'ezGridCustomHeader',
|
|
119555
119690
|
headerComponentParams: {
|
|
119556
|
-
|
|
119691
|
+
tooltip: tooltip,
|
|
119692
|
+
hasFilter: () => this.hasFilterColumn(source.name),
|
|
119693
|
+
showColumnFilter: () => this.showColumnFilter()
|
|
119557
119694
|
},
|
|
119558
119695
|
valueFormatter: params => {
|
|
119559
119696
|
return this.getFormatterByColumn(params, source);
|
|
@@ -119774,8 +119911,8 @@ const EzGrid = class {
|
|
|
119774
119911
|
/**
|
|
119775
119912
|
* Adiciona item de menu nas colunas.
|
|
119776
119913
|
*/
|
|
119777
|
-
async addColumnMenuItem(label, name, action) {
|
|
119778
|
-
this._gridController.addColumnMenuItem({ label, name, action });
|
|
119914
|
+
async addColumnMenuItem(label, name, action, icon) {
|
|
119915
|
+
this._gridController.addColumnMenuItem({ label, name, action, icon });
|
|
119779
119916
|
}
|
|
119780
119917
|
/**
|
|
119781
119918
|
* Aplica o estado das colunas.
|
|
@@ -2,10 +2,10 @@ import { Grid as EnterpriseGrid, LicenseManager } from "ag-grid-enterprise";
|
|
|
2
2
|
import { Grid } from "ag-grid-community";
|
|
3
3
|
import { ApplicationContext, DataType, SortMode, UserInterface, NumberUtils, StringUtils } from "@sankhyalabs/core";
|
|
4
4
|
import gridTerms from "./i18n/pt-BR.js";
|
|
5
|
-
import getHeaderColumnTemplate from "./template/HeaderColumnTemplate.js";
|
|
6
5
|
import DataSource from "./DataSource";
|
|
7
6
|
import { CellRendererStatus } from "./components/cellRendererStatus";
|
|
8
7
|
import SelectionHeader from "./components/selectionHeader";
|
|
8
|
+
import { EzGridCustomHeader } from './components/EzGridCustomHeader';
|
|
9
9
|
export default class AgGridController {
|
|
10
10
|
constructor(enterprise) {
|
|
11
11
|
this.DEFAULT_ROW_HEIGHT = 30;
|
|
@@ -60,22 +60,15 @@ export default class AgGridController {
|
|
|
60
60
|
blockLoadDebounceMillis: this.BLOCK_LOAD_DEBOUNCE,
|
|
61
61
|
navigateToNextCell: this.navigateToNextCell.bind(this),
|
|
62
62
|
getRowNodeId: this._dataUnit ? (params) => typeof params === "string" ? params : params[this._idAttribName] : undefined,
|
|
63
|
-
getMainMenuItems: (params) =>
|
|
64
|
-
const column = params.column;
|
|
65
|
-
const items = [column.isPinned() ? "clearPinned" : "pinLeft", "separator"];
|
|
66
|
-
this._menuItems.forEach(m => items.push({
|
|
67
|
-
name: m.label,
|
|
68
|
-
action: () => m.action(column.getColId(), m.name)
|
|
69
|
-
}));
|
|
70
|
-
return items;
|
|
71
|
-
},
|
|
63
|
+
getMainMenuItems: (params) => this.buildMenuItemOptions(params),
|
|
72
64
|
getRowHeight: this.getRowHeight.bind(this),
|
|
73
65
|
defaultColDef: {
|
|
74
66
|
headerClass: "ez-grid__cell-header",
|
|
75
67
|
cellClass: "ez-grid__cell-body"
|
|
76
68
|
},
|
|
77
69
|
components: {
|
|
78
|
-
'ezGridHeaderComponent': SelectionHeader
|
|
70
|
+
'ezGridHeaderComponent': SelectionHeader,
|
|
71
|
+
'ezGridCustomHeader': EzGridCustomHeader,
|
|
79
72
|
},
|
|
80
73
|
context: {
|
|
81
74
|
headerCheckStatusGetter: () => this.getSelectionHeaderStatus(),
|
|
@@ -101,6 +94,69 @@ export default class AgGridController {
|
|
|
101
94
|
this._gridOptions.api.setHeaderHeight(this.getHeaderRowHeight());
|
|
102
95
|
}
|
|
103
96
|
}
|
|
97
|
+
buildMenuItemOptions(params) {
|
|
98
|
+
const col = params.column;
|
|
99
|
+
const items = [];
|
|
100
|
+
if (col.getColDef().sortable) {
|
|
101
|
+
items.push(this.buildMenuItemOptionSort(params, 'asc'));
|
|
102
|
+
items.push(this.buildMenuItemOptionSort(params, 'desc'));
|
|
103
|
+
}
|
|
104
|
+
/*
|
|
105
|
+
TODO: Adicionar quando filtro de colunar estiver finalizado.
|
|
106
|
+
items.push(this.buildMenuItemFilterColumn(params));
|
|
107
|
+
*/
|
|
108
|
+
this._menuItems.forEach(m => items.push({
|
|
109
|
+
icon: m.icon,
|
|
110
|
+
name: m.label,
|
|
111
|
+
action: () => m.action(params),
|
|
112
|
+
}));
|
|
113
|
+
items.push(this.buildMenuItemOptionPin(params));
|
|
114
|
+
return items;
|
|
115
|
+
}
|
|
116
|
+
buildMenuItemOptionSort(params, sortOrder) {
|
|
117
|
+
return {
|
|
118
|
+
icon: `<div style="${sortOrder === "asc" ? 'transform: rotate(180deg); position: relative; top: -4px;' : ''}"><i class='ez-icon-arrow_downward'></i></div>`,
|
|
119
|
+
name: sortOrder === "asc" ? "Ordenar Ascendente" : "Ordenar Descendente",
|
|
120
|
+
action: () => this.sortDataByColumn(params, sortOrder)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
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
|
+
buildMenuItemOptionPin(params) {
|
|
133
|
+
const { column, columnApi } = params;
|
|
134
|
+
const isPinned = params.column.isPinned();
|
|
135
|
+
return {
|
|
136
|
+
icon: `<i class='ez-icon-${isPinned ? 'un-pin' : 'push-pin'}'></i>`,
|
|
137
|
+
name: isPinned ? "Desafixar coluna" : "Fixar coluna",
|
|
138
|
+
action: () => {
|
|
139
|
+
columnApi.applyColumnState({
|
|
140
|
+
state: [{ colId: column.getColId(), pinned: column.isPinned() ? null : 'left' }],
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
sortDataByColumn(params, order) {
|
|
146
|
+
const col = params.column;
|
|
147
|
+
const colApi = params.columnApi;
|
|
148
|
+
if (col.getSort() === order) {
|
|
149
|
+
colApi.applyColumnState({
|
|
150
|
+
defaultState: { sort: null },
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
colApi.applyColumnState({
|
|
155
|
+
state: [{ colId: col.getColId(), sort: order }],
|
|
156
|
+
defaultState: { sort: null },
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
104
160
|
getRowHeight() {
|
|
105
161
|
return this.DEFAULT_ROW_HEIGHT;
|
|
106
162
|
}
|
|
@@ -421,7 +477,10 @@ export default class AgGridController {
|
|
|
421
477
|
return this._gridOptions.api.getSelectedRows();
|
|
422
478
|
}
|
|
423
479
|
addColumnMenuItem(item) {
|
|
424
|
-
this._menuItems.
|
|
480
|
+
const itemsNames = this._menuItems.map(i => i.name);
|
|
481
|
+
if (!itemsNames.includes(item.name)) {
|
|
482
|
+
this._menuItems.push(item);
|
|
483
|
+
}
|
|
425
484
|
}
|
|
426
485
|
quickFilter(term) {
|
|
427
486
|
if (term) {
|
|
@@ -442,6 +501,14 @@ export default class AgGridController {
|
|
|
442
501
|
var _a;
|
|
443
502
|
(_a = this._gridOptions.api.getDisplayedRowAtIndex(index)) === null || _a === void 0 ? void 0 : _a.setSelected(true);
|
|
444
503
|
}
|
|
504
|
+
hasFilterColumn(_columnName) {
|
|
505
|
+
return false; //TODO: substituir pelo state dos filtros de colunas
|
|
506
|
+
}
|
|
507
|
+
showColumnFilter() {
|
|
508
|
+
/*
|
|
509
|
+
TODO: Implementar chamada para apresentar filtro de coluna na grid
|
|
510
|
+
*/
|
|
511
|
+
}
|
|
445
512
|
buildColDef(source) {
|
|
446
513
|
var _a, _b, _c;
|
|
447
514
|
let tooltip = undefined;
|
|
@@ -457,8 +524,11 @@ export default class AgGridController {
|
|
|
457
524
|
field: source.name,
|
|
458
525
|
sortable: propSortable,
|
|
459
526
|
resizable: true,
|
|
527
|
+
headerComponent: 'ezGridCustomHeader',
|
|
460
528
|
headerComponentParams: {
|
|
461
|
-
|
|
529
|
+
tooltip: tooltip,
|
|
530
|
+
hasFilter: () => this.hasFilterColumn(source.name),
|
|
531
|
+
showColumnFilter: () => this.showColumnFilter()
|
|
462
532
|
},
|
|
463
533
|
valueFormatter: params => {
|
|
464
534
|
return this.getFormatterByColumn(params, source);
|
package/dist/collection/components/ez-grid/controller/ag-grid/components/EzGridCustomHeader.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export class EzGridCustomHeader {
|
|
2
|
+
init(agParams) {
|
|
3
|
+
var _a;
|
|
4
|
+
this.params = agParams;
|
|
5
|
+
this.element = document.createElement('div');
|
|
6
|
+
this.element.classList.add('ag-cell-label-container');
|
|
7
|
+
this.element.setAttribute('title', (_a = this.params.tooltip) !== null && _a !== void 0 ? _a : '');
|
|
8
|
+
this.element.innerHTML = `
|
|
9
|
+
<div class='ez-flex ez-flex--justify-between'>
|
|
10
|
+
<i id='ez-grid-filter-icon' class='ez-icon-filter' style='color:#008561'></i>
|
|
11
|
+
<i id='ez-grid-menu-icon' class='ez-icon-dots-vertical'></i>
|
|
12
|
+
</div>
|
|
13
|
+
<div id='ez-header-container' class='ez-flex ez-flex--justify-between ag-header-cell-text'>
|
|
14
|
+
<span class='ag-header-cell-text'>${this.params.displayName}</span>
|
|
15
|
+
<i id='ez-grid-sort-icon-down' class='ez-icon-arrow_downward' style='display: none;margin-left: 4px;font-size: var(--text--medium, 14px);align-self: center;'></i>
|
|
16
|
+
<i id='ez-grid-sort-icon-up' class='ez-icon-arrow_downward' style='display: none; transform: rotate(180deg);margin-left: 4px;font-size: var(--text--medium, 14px);align-self: center;'></i>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
19
|
+
this.configMenuClick();
|
|
20
|
+
this.configSortClick();
|
|
21
|
+
this.configSortListener();
|
|
22
|
+
this.configFilterButton();
|
|
23
|
+
}
|
|
24
|
+
refresh(agParams) {
|
|
25
|
+
this.params = agParams;
|
|
26
|
+
this.configFilterButton();
|
|
27
|
+
this.configSortIcon();
|
|
28
|
+
}
|
|
29
|
+
configFilterButton() {
|
|
30
|
+
this.filterButton = this.element.querySelector('#ez-grid-filter-icon');
|
|
31
|
+
this.filterButton.style.display = this.params.hasFilter() ? 'flex' : 'none';
|
|
32
|
+
this.onFilterButtonClickListener = this.params.showColumnFilter.bind(this);
|
|
33
|
+
this.filterButton.addEventListener('click', this.onFilterButtonClickListener);
|
|
34
|
+
}
|
|
35
|
+
configSortIcon() {
|
|
36
|
+
this.sortDownIcon.style.display = this.params.column.isSortDescending() ? 'flex' : 'none';
|
|
37
|
+
this.sortUpIcon.style.display = this.params.column.isSortAscending() ? 'flex' : 'none';
|
|
38
|
+
}
|
|
39
|
+
configSortListener() {
|
|
40
|
+
if (this.params.enableSorting) {
|
|
41
|
+
this.sortUpIcon = this.element.querySelector('#ez-grid-sort-icon-up');
|
|
42
|
+
this.sortDownIcon = this.element.querySelector('#ez-grid-sort-icon-down');
|
|
43
|
+
this.onSortChangedListener = this.configSortIcon.bind(this);
|
|
44
|
+
this.params.column.addEventListener('sortChanged', this.onSortChangedListener);
|
|
45
|
+
this.configSortIcon();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
onSortClick(event) {
|
|
49
|
+
this.params.progressSort(event.shiftKey);
|
|
50
|
+
}
|
|
51
|
+
configSortClick() {
|
|
52
|
+
if (this.params.column.getColDef().sortable) {
|
|
53
|
+
this.headerContainer = this.element.querySelector('#ez-header-container');
|
|
54
|
+
this.onSortClickListener = this.onSortClick.bind(this);
|
|
55
|
+
this.headerContainer.addEventListener('click', this.onSortClickListener);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
onMenuClick() {
|
|
59
|
+
this.params.showColumnMenu(this.menuButton);
|
|
60
|
+
}
|
|
61
|
+
configMenuClick() {
|
|
62
|
+
this.menuButton = this.element.querySelector('#ez-grid-menu-icon');
|
|
63
|
+
this.onMenuClickListener = this.onMenuClick.bind(this);
|
|
64
|
+
this.menuButton.addEventListener('click', this.onMenuClickListener);
|
|
65
|
+
}
|
|
66
|
+
getGui() {
|
|
67
|
+
return this.element;
|
|
68
|
+
}
|
|
69
|
+
destroy() {
|
|
70
|
+
if (this.onMenuClickListener) {
|
|
71
|
+
this.menuButton.removeEventListener('click', this.onMenuClickListener);
|
|
72
|
+
}
|
|
73
|
+
if (this.onSortClickListener) {
|
|
74
|
+
this.headerContainer.removeEventListener('click', this.onSortClickListener);
|
|
75
|
+
}
|
|
76
|
+
if (this.onFilterButtonClickListener) {
|
|
77
|
+
this.filterButton.removeEventListener('click', this.onFilterButtonClickListener);
|
|
78
|
+
}
|
|
79
|
+
this.params.column.removeEventListener('sortChanged', this.onSortChangedListener);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -27,8 +27,8 @@ export class EzGrid {
|
|
|
27
27
|
/**
|
|
28
28
|
* Adiciona item de menu nas colunas.
|
|
29
29
|
*/
|
|
30
|
-
async addColumnMenuItem(label, name, action) {
|
|
31
|
-
this._gridController.addColumnMenuItem({ label, name, action });
|
|
30
|
+
async addColumnMenuItem(label, name, action, icon) {
|
|
31
|
+
this._gridController.addColumnMenuItem({ label, name, action, icon });
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Aplica o estado das colunas.
|
|
@@ -354,7 +354,7 @@ export class EzGrid {
|
|
|
354
354
|
"optional": false,
|
|
355
355
|
"docs": {
|
|
356
356
|
"tags": [],
|
|
357
|
-
"text": "Unidade de dados. Respons\u00E1vel pelo controle de edi\u00E7\u00E3o de registros e
|
|
357
|
+
"text": "Unidade de dados. Respons\u00E1vel pelo controle de edi\u00E7\u00E3o de registros e\ninforma\u00E7\u00F5es pertinentes aos campos."
|
|
358
358
|
}
|
|
359
359
|
},
|
|
360
360
|
"statusResolver": {
|
|
@@ -516,7 +516,7 @@ export class EzGrid {
|
|
|
516
516
|
},
|
|
517
517
|
"addColumnMenuItem": {
|
|
518
518
|
"complexType": {
|
|
519
|
-
"signature": "(label: string, name: string, action: Function) => Promise<void>",
|
|
519
|
+
"signature": "(label: string, name: string, action: Function, icon: HTMLElement | string) => Promise<void>",
|
|
520
520
|
"parameters": [{
|
|
521
521
|
"tags": [],
|
|
522
522
|
"text": ""
|
|
@@ -526,6 +526,9 @@ export class EzGrid {
|
|
|
526
526
|
}, {
|
|
527
527
|
"tags": [],
|
|
528
528
|
"text": ""
|
|
529
|
+
}, {
|
|
530
|
+
"tags": [],
|
|
531
|
+
"text": ""
|
|
529
532
|
}],
|
|
530
533
|
"references": {
|
|
531
534
|
"Promise": {
|
|
@@ -533,6 +536,9 @@ export class EzGrid {
|
|
|
533
536
|
},
|
|
534
537
|
"Function": {
|
|
535
538
|
"location": "global"
|
|
539
|
+
},
|
|
540
|
+
"HTMLElement": {
|
|
541
|
+
"location": "global"
|
|
536
542
|
}
|
|
537
543
|
},
|
|
538
544
|
"return": "Promise<void>"
|