react-graph-grid 0.1.4 → 0.1.5
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/README.md +4 -0
- package/dist/index.esm.js +21 -0
- package/dist/index.js +56 -0
- package/dist/index10.esm.js +3844 -0
- package/dist/index10.js +3848 -0
- package/dist/index11.esm.js +4121 -0
- package/dist/index11.js +4125 -0
- package/dist/index12.esm.js +5238 -0
- package/dist/index12.js +5242 -0
- package/dist/index13.esm.js +5466 -0
- package/dist/index13.js +5470 -0
- package/dist/index14.esm.js +22 -0
- package/dist/index14.js +26 -0
- package/dist/index15.esm.js +402 -0
- package/dist/index15.js +403 -0
- package/dist/index16.esm.js +507 -0
- package/dist/index16.js +507 -0
- package/dist/index17.esm.js +256 -0
- package/dist/index17.js +257 -0
- package/dist/index18.esm.js +261 -0
- package/dist/index18.js +263 -0
- package/dist/index19.esm.js +623 -0
- package/dist/index19.js +624 -0
- package/dist/index2.esm.js +6 -0
- package/dist/index2.js +2 -0
- package/dist/index20.esm.js +219 -0
- package/dist/index20.js +220 -0
- package/dist/index21.esm.js +298 -0
- package/dist/index21.js +299 -0
- package/dist/index22.esm.js +662 -0
- package/dist/index22.js +663 -0
- package/dist/index23.esm.js +340 -0
- package/dist/index23.js +341 -0
- package/dist/index24.esm.js +269 -0
- package/dist/index24.js +270 -0
- package/dist/index25.esm.js +600 -0
- package/dist/index25.js +601 -0
- package/dist/index26.esm.js +245 -0
- package/dist/index26.js +246 -0
- package/dist/index27.esm.js +136 -0
- package/dist/index27.js +137 -0
- package/dist/index28.esm.js +70 -0
- package/dist/index28.js +70 -0
- package/dist/index29.esm.js +748 -0
- package/dist/index29.js +748 -0
- package/dist/index30.esm.js +363 -0
- package/dist/index30.js +363 -0
- package/dist/index4.esm.js +27 -0
- package/dist/index4.js +27 -0
- package/dist/index5.esm.js +35 -0
- package/dist/index5.js +39 -0
- package/dist/index6.esm.js +200 -0
- package/dist/index6.js +204 -0
- package/dist/index7.esm.js +9 -0
- package/dist/index7.js +13 -0
- package/dist/index8.esm.js +65 -0
- package/dist/index8.js +68 -0
- package/dist/index9.esm.js +102 -0
- package/dist/index9.js +103 -0
- package/{src/css/default.css → dist/react-graph-grid.css} +2 -1
- package/package.json +6 -3
- package/eslint.config.js +0 -29
- package/index.html +0 -13
- package/index.js +0 -19
- package/npm.aps +0 -0
- package/src/Base.jsx +0 -81
- package/src/Card.jsx +0 -333
- package/src/Dropdown.jsx +0 -339
- package/src/FieldEdit.jsx +0 -376
- package/src/Graph.jsx +0 -482
- package/src/Grid.jsx +0 -887
- package/src/GridCD.jsx +0 -180
- package/src/GridDB.jsx +0 -897
- package/src/GridFE.jsx +0 -753
- package/src/GridFL.jsx +0 -468
- package/src/GridGR.jsx +0 -311
- package/src/GridPK.jsx +0 -414
- package/src/Modal.jsx +0 -511
- package/src/Overlay.jsx +0 -140
- package/src/Tests/DebugApp.jsx +0 -334
- package/src/Tests/TestData.jsx +0 -251
- package/src/Themes/DefaultGridTheme.jsx +0 -36
- package/src/Themes/Images.jsx +0 -438
- package/src/Themes/Translate.jsx +0 -76
- package/src/css/default_.css +0 -945
- package/src/main.jsx +0 -10
- package/vite.config.js +0 -14
- /package/{public → dist}/IM.svg +0 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
import { require_jsx_runtime } from "./index7.esm.js";
|
|
2
|
+
import { BaseComponent, NodeStatus } from "./index8.esm.js";
|
|
3
|
+
import { Images } from "./index16.esm.js";
|
|
4
|
+
import { Dropdown } from "./index17.esm.js";
|
|
5
|
+
import { WaveType } from "./index18.esm.js";
|
|
6
|
+
import { GridPKClass } from "./index21.esm.js";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
9
|
+
function GridDB(props) {
|
|
10
|
+
let grid = null;
|
|
11
|
+
const [gridState, setState] = useState({
|
|
12
|
+
grid,
|
|
13
|
+
ind: 0
|
|
14
|
+
});
|
|
15
|
+
grid = gridState.grid;
|
|
16
|
+
let needGetRows = false;
|
|
17
|
+
if (!grid || grid.uid !== props.uid && props.uid != null) {
|
|
18
|
+
grid = null;
|
|
19
|
+
if (props.findGrid) grid = props.findGrid(props);
|
|
20
|
+
grid = grid || new GridDBClass(props);
|
|
21
|
+
needGetRows = !props.noAutoRefresh && !props.parentGrids;
|
|
22
|
+
}
|
|
23
|
+
if (props.init) props.init(grid);
|
|
24
|
+
grid.refreshState = function() {
|
|
25
|
+
setState({
|
|
26
|
+
grid,
|
|
27
|
+
ind: grid.stateind++
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
grid._waitingRows = needGetRows && (grid.rows.length <= 0 || grid.columns.length <= 0);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
grid.setupEvents(grid);
|
|
33
|
+
if (grid._waitingRows) grid.getRows({
|
|
34
|
+
filters: grid.collectFilters(),
|
|
35
|
+
grid
|
|
36
|
+
}).then((rows) => {
|
|
37
|
+
grid.rows = rows;
|
|
38
|
+
grid.afterGetRows();
|
|
39
|
+
grid.refreshState();
|
|
40
|
+
}).finally(() => {
|
|
41
|
+
grid._waitingRows = false;
|
|
42
|
+
grid.refreshState();
|
|
43
|
+
});
|
|
44
|
+
else if (grid.columns.length <= 0 && grid.getColumns) grid.prepareColumns().then(() => grid.refreshState());
|
|
45
|
+
return () => {
|
|
46
|
+
grid.clearEvents();
|
|
47
|
+
};
|
|
48
|
+
}, [grid]);
|
|
49
|
+
return grid.render();
|
|
50
|
+
}
|
|
51
|
+
var GridDBClass = class GridDBClass extends GridPKClass {
|
|
52
|
+
constructor(props) {
|
|
53
|
+
super(props);
|
|
54
|
+
const grid = this;
|
|
55
|
+
grid.pageNumber = 1;
|
|
56
|
+
grid.pageSize = props.pageSize === 0 ? 0 : props.pageSize || 10;
|
|
57
|
+
grid.pageSizes = [
|
|
58
|
+
5,
|
|
59
|
+
10,
|
|
60
|
+
15,
|
|
61
|
+
20,
|
|
62
|
+
30,
|
|
63
|
+
40,
|
|
64
|
+
50,
|
|
65
|
+
100
|
|
66
|
+
];
|
|
67
|
+
grid.buttons = props.buttons || [];
|
|
68
|
+
grid.sortDisabled = props.sortDisabled;
|
|
69
|
+
grid.opt.toolbarClass = props.toolbarClass;
|
|
70
|
+
grid.opt.toolbarButtonsClass = props.toolbarButtonsClass;
|
|
71
|
+
grid.opt.pagerClass = props.pagerClass;
|
|
72
|
+
grid.opt.pagerButtonsClass = props.pagerButtonsClass;
|
|
73
|
+
grid.opt.inputClass = props.inputClass;
|
|
74
|
+
grid.sortColumns = [];
|
|
75
|
+
grid._sortSeq = 1;
|
|
76
|
+
grid.multi = props.multi;
|
|
77
|
+
}
|
|
78
|
+
static gridSettings = {};
|
|
79
|
+
visitByWave(e) {
|
|
80
|
+
const grid = this;
|
|
81
|
+
const rpr = new Promise(function(resolve) {
|
|
82
|
+
resolve(e);
|
|
83
|
+
});
|
|
84
|
+
if (grid.skipOnWaveVisit(e)) return rpr;
|
|
85
|
+
if (e.waveType === WaveType.value) {
|
|
86
|
+
if (grid.status === NodeStatus.filter) {
|
|
87
|
+
if (!grid._selecting) grid.selectedRowIndex = -1;
|
|
88
|
+
grid.value = grid.text = "";
|
|
89
|
+
grid._selectedOptions = [];
|
|
90
|
+
return rpr;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
grid.pageNumber = 1;
|
|
94
|
+
return super.visitByWave(e);
|
|
95
|
+
}
|
|
96
|
+
keyAdd() {
|
|
97
|
+
const grid = this;
|
|
98
|
+
return `${super.keyAdd()}_${grid.pageSize}_${grid.pageNumber}_`;
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
const grid = this;
|
|
102
|
+
grid.setupPagerButtons();
|
|
103
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
104
|
+
grid.renderToolbar(),
|
|
105
|
+
grid.renderPager(),
|
|
106
|
+
super.render(),
|
|
107
|
+
grid.renderPager(true),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dropdown, {
|
|
109
|
+
init: (dd) => {
|
|
110
|
+
grid.menuDropdown = dd;
|
|
111
|
+
dd._grid = grid;
|
|
112
|
+
},
|
|
113
|
+
closeWhenMiss: true,
|
|
114
|
+
getItems: (e) => {
|
|
115
|
+
return e.self._grid.getGridSettings(e);
|
|
116
|
+
},
|
|
117
|
+
onItemClick: (e) => {
|
|
118
|
+
e.self._grid.onSettingsItemClick(e.itemId);
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
] });
|
|
122
|
+
}
|
|
123
|
+
isDisabled() {
|
|
124
|
+
return this._isDisabled === true;
|
|
125
|
+
}
|
|
126
|
+
setDisabled(value) {
|
|
127
|
+
const grid = this;
|
|
128
|
+
grid._isDisabled = value;
|
|
129
|
+
}
|
|
130
|
+
isEditing() {
|
|
131
|
+
return this._isEditing === true;
|
|
132
|
+
}
|
|
133
|
+
setEditing(value) {
|
|
134
|
+
const grid = this;
|
|
135
|
+
grid._isEditing = value;
|
|
136
|
+
}
|
|
137
|
+
renderToolbar() {
|
|
138
|
+
const grid = this;
|
|
139
|
+
grid.buttons = grid.buttons || [];
|
|
140
|
+
return grid.buttons.length <= 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
141
|
+
className: grid.opt.toolbarClass || "toolbar-default",
|
|
142
|
+
children: grid.buttons.map((button, ind) => {
|
|
143
|
+
return button.render ? button.render() : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
144
|
+
className: `${button.class || grid.opt.toolbarButtonsClass || BaseComponent.theme.toolbarButtonsClass || "grid-toolbar-button"}`,
|
|
145
|
+
style: {
|
|
146
|
+
width: button.w ? button.w : button.img ? "" : "auto",
|
|
147
|
+
display: button.getVisible && !button.getVisible() ? "none" : "",
|
|
148
|
+
padding: button.padding ? button.padding : "",
|
|
149
|
+
margin: "5px 2px"
|
|
150
|
+
},
|
|
151
|
+
title: grid.translate(button.title, "grid-toolbar-button"),
|
|
152
|
+
disabled: button.getDisabled && button.getDisabled({ grid }) || button.disabled ? "disabled" : "",
|
|
153
|
+
onClick: button.click ? (e) => {
|
|
154
|
+
e.grid = grid;
|
|
155
|
+
button.click(e);
|
|
156
|
+
} : grid.onButtonClick ? (e) => {
|
|
157
|
+
grid.onButtonClick(e);
|
|
158
|
+
} : null,
|
|
159
|
+
children: [button.img ? button.img() : "", GridDBClass.gridSettings.buttonSize > 0 || !button.img ? grid.translate(button.label, "grid-toolbar-button") || grid.translate(button.title, "grid-toolbar-button") : ""]
|
|
160
|
+
}, `toolbarButton_${grid.id}_${button.id}_${ind}_`);
|
|
161
|
+
})
|
|
162
|
+
}, `gridToolbarDiv_${grid.id}_`);
|
|
163
|
+
}
|
|
164
|
+
renderAppliedFilters() {
|
|
165
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
166
|
+
}
|
|
167
|
+
renderPager(bottom) {
|
|
168
|
+
const grid = this;
|
|
169
|
+
return grid.pagerButtons.length <= 0 || bottom && !grid.allowBottomPager ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
170
|
+
className: grid.opt.pagerClass || BaseComponent.theme.pagerClass || "grid-pager-default",
|
|
171
|
+
style: {
|
|
172
|
+
display: "flex",
|
|
173
|
+
alignItems: "center"
|
|
174
|
+
},
|
|
175
|
+
children: grid.pagerButtons.map((button, ind) => {
|
|
176
|
+
return button.render ? button.render(button, bottom) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
177
|
+
"grid-pager-item": `${grid.id}_${button.id}_`,
|
|
178
|
+
className: `${button.class || BaseComponent.theme.pagerButtonsClass || "grid-pager-button"}`,
|
|
179
|
+
title: grid.translate(button.title, "grid-pager-button"),
|
|
180
|
+
disabled: grid.isEditing() || grid.isDisabled() || button.getDisabled && button.getDisabled({ grid }) || button.disabled ? "disabled" : "",
|
|
181
|
+
onClick: button.click ? button.click : null,
|
|
182
|
+
style: {
|
|
183
|
+
margin: "5px 2px",
|
|
184
|
+
minHeight: "2em",
|
|
185
|
+
display: "flex"
|
|
186
|
+
},
|
|
187
|
+
children: [button.img ? button.img() : "", button.label ? grid.translate(button.label, "grid-pager-button") : ""]
|
|
188
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_${ind}_`);
|
|
189
|
+
})
|
|
190
|
+
}, `pagerDiv_${bottom ? "bottom" : "top"}_${grid.id}_`);
|
|
191
|
+
}
|
|
192
|
+
gotoFirstPage() {
|
|
193
|
+
const grid = this;
|
|
194
|
+
grid.pageNumber = 1;
|
|
195
|
+
grid.selectedRowIndex = 0;
|
|
196
|
+
grid.refresh();
|
|
197
|
+
}
|
|
198
|
+
gotoPrevPage() {
|
|
199
|
+
const grid = this;
|
|
200
|
+
grid.pageNumber = grid.pageNumber > 1 ? grid.pageNumber - 1 : 1;
|
|
201
|
+
grid.selectedRowIndex = 0;
|
|
202
|
+
grid.refresh();
|
|
203
|
+
}
|
|
204
|
+
gotoNextPage() {
|
|
205
|
+
const grid = this;
|
|
206
|
+
grid.calculatePagesCount();
|
|
207
|
+
grid.pageNumber = grid.pageNumber < grid.pagesCount ? grid.pageNumber + 1 : grid.pageNumber;
|
|
208
|
+
grid.selectedRowIndex = 0;
|
|
209
|
+
grid.refresh();
|
|
210
|
+
}
|
|
211
|
+
gotoLastPage() {
|
|
212
|
+
const grid = this;
|
|
213
|
+
grid.calculatePagesCount();
|
|
214
|
+
grid.pageNumber = grid.pageNumber < grid.pagesCount ? grid.pagesCount : grid.pageNumber;
|
|
215
|
+
grid.selectedRowIndex = 0;
|
|
216
|
+
grid.refresh();
|
|
217
|
+
}
|
|
218
|
+
setupPagerButtons() {
|
|
219
|
+
const grid = this;
|
|
220
|
+
if (grid.pagerButtons && grid.pagerButtons.length > 0) return;
|
|
221
|
+
grid.pagerButtons = [];
|
|
222
|
+
grid.pagerButtonsDict = {};
|
|
223
|
+
const refresh = {
|
|
224
|
+
id: 0,
|
|
225
|
+
name: "refresh",
|
|
226
|
+
title: "Refresh",
|
|
227
|
+
label: Images.images.refresh ? "" : "Refresh",
|
|
228
|
+
click: function(e) {
|
|
229
|
+
grid.refresh();
|
|
230
|
+
},
|
|
231
|
+
img: Images.images.refresh,
|
|
232
|
+
class: grid.pagerButtonsClass,
|
|
233
|
+
getDisabled: function() {
|
|
234
|
+
return grid._waitingRows;
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
grid.pagerButtons.push(refresh);
|
|
238
|
+
grid.pagerButtonsDict[refresh.id] = grid.pagerButtonsDict[refresh.name] = refresh;
|
|
239
|
+
if (grid.showGridSettings) {
|
|
240
|
+
const settings = {
|
|
241
|
+
id: 1,
|
|
242
|
+
name: "settings",
|
|
243
|
+
title: "Settings",
|
|
244
|
+
label: Images.images.settings ? "" : "Settings",
|
|
245
|
+
click: function(e) {
|
|
246
|
+
grid.showGridSettings(e);
|
|
247
|
+
},
|
|
248
|
+
img: Images.images.settings,
|
|
249
|
+
class: grid.pagerButtonsClass,
|
|
250
|
+
getDisabled: function() {
|
|
251
|
+
return grid._waitingRows;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
grid.pagerButtons.push(settings);
|
|
255
|
+
grid.pagerButtonsDict[settings.id] = grid.pagerButtonsDict[settings.name] = settings;
|
|
256
|
+
}
|
|
257
|
+
if (grid.multi) {
|
|
258
|
+
const pocket = {
|
|
259
|
+
id: 2,
|
|
260
|
+
name: "pocket",
|
|
261
|
+
title: "Pocket",
|
|
262
|
+
label: Images.images.pocket ? "" : "Pocket",
|
|
263
|
+
click: function(e) {
|
|
264
|
+
grid.switchGridPocket(e);
|
|
265
|
+
},
|
|
266
|
+
img: grid.pocketOpened ? Images.images.pocketOpened : Images.images.pocket,
|
|
267
|
+
class: grid.pagerButtonsClass,
|
|
268
|
+
getDisabled: function() {
|
|
269
|
+
return grid._waitingRows;
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
grid.pagerButtons.push(pocket);
|
|
273
|
+
grid.pagerButtonsDict[pocket.id] = grid.pagerButtonsDict[pocket.name] = pocket;
|
|
274
|
+
}
|
|
275
|
+
if (grid.pageSize > 0) {
|
|
276
|
+
const first = {
|
|
277
|
+
id: 3,
|
|
278
|
+
name: "first",
|
|
279
|
+
title: "First",
|
|
280
|
+
label: Images.images.first ? "" : "First",
|
|
281
|
+
click: function(e) {
|
|
282
|
+
grid.gotoFirstPage();
|
|
283
|
+
},
|
|
284
|
+
getDisabled: function() {
|
|
285
|
+
return grid._waitingRows || !grid.rows || grid.rows.length <= 0 || grid.pageNumber === 1;
|
|
286
|
+
},
|
|
287
|
+
img: Images.images.first,
|
|
288
|
+
class: grid.pagerButtonsClass
|
|
289
|
+
};
|
|
290
|
+
grid.pagerButtons.push(first);
|
|
291
|
+
grid.pagerButtonsDict[first.id] = grid.pagerButtonsDict[first.name] = first;
|
|
292
|
+
const prev = {
|
|
293
|
+
id: 4,
|
|
294
|
+
name: "prev",
|
|
295
|
+
title: "Prev",
|
|
296
|
+
label: Images.images.prev ? "" : "Prev",
|
|
297
|
+
click: function(e) {
|
|
298
|
+
grid.gotoPrevPage();
|
|
299
|
+
},
|
|
300
|
+
getDisabled: function() {
|
|
301
|
+
return grid._waitingRows || !grid.rows || grid.rows.length <= 0 || grid.pageNumber === 1;
|
|
302
|
+
},
|
|
303
|
+
img: Images.images.prev,
|
|
304
|
+
class: grid.pagerButtonsClass
|
|
305
|
+
};
|
|
306
|
+
grid.pagerButtons.push(prev);
|
|
307
|
+
grid.pagerButtonsDict[prev.id] = grid.pagerButtonsDict[prev.name] = prev;
|
|
308
|
+
const curr = {
|
|
309
|
+
id: 5,
|
|
310
|
+
name: "curr",
|
|
311
|
+
title: "Current Page",
|
|
312
|
+
label: "Current Page",
|
|
313
|
+
click: function(e) {},
|
|
314
|
+
getDisabled: function() {
|
|
315
|
+
return grid._waitingRows || !grid.rows || grid.rows.length <= 1;
|
|
316
|
+
},
|
|
317
|
+
render: function(button, bottom) {
|
|
318
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
319
|
+
title: grid.translate(button.title, "grid-pager-button"),
|
|
320
|
+
value: grid.pageNumber,
|
|
321
|
+
"grid-pager-item": `${grid.id}_${button.id}_`,
|
|
322
|
+
className: `${button.class ? button.class : grid.opt.inputClass || BaseComponent.theme.inputClass || "grid-pager-current"}`,
|
|
323
|
+
style: {
|
|
324
|
+
width: "3em",
|
|
325
|
+
height: "2em",
|
|
326
|
+
display: "inline-block",
|
|
327
|
+
margin: "0 2px"
|
|
328
|
+
},
|
|
329
|
+
disabled: grid._waitingRows || grid.isEditing() || grid.isDisabled() ? "disabled" : "",
|
|
330
|
+
onChange: function(e) {
|
|
331
|
+
const newPage = +e.target.value;
|
|
332
|
+
if (grid.pageNumber !== newPage && newPage >= 1 && newPage <= grid.pagesCount) {
|
|
333
|
+
grid.pageNumber = newPage;
|
|
334
|
+
grid.selectedRowIndex = 0;
|
|
335
|
+
grid.refresh();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_`);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
grid.pagerButtons.push(curr);
|
|
342
|
+
grid.pagerButtonsDict[curr.id] = grid.pagerButtonsDict[curr.name] = curr;
|
|
343
|
+
const pages = {
|
|
344
|
+
id: 6,
|
|
345
|
+
name: "pages",
|
|
346
|
+
title: "Total Pages",
|
|
347
|
+
label: "Total Pages",
|
|
348
|
+
render: function(button, bottom) {
|
|
349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
350
|
+
className: "grid-pager-of",
|
|
351
|
+
title: grid.translate(button.title, "grid-pager-button"),
|
|
352
|
+
children: ` ${grid.translate("of", "pager-button")} ${grid.pagesCount >= 0 ? grid.pagesCount : "0"}`
|
|
353
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_`);
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
grid.pagerButtons.push(pages);
|
|
357
|
+
grid.pagerButtonsDict[pages.id] = grid.pagerButtonsDict[pages.name] = pages;
|
|
358
|
+
const next = {
|
|
359
|
+
id: 7,
|
|
360
|
+
name: "next",
|
|
361
|
+
title: "Next",
|
|
362
|
+
label: Images.images.next ? "" : "Next",
|
|
363
|
+
click: function(e) {
|
|
364
|
+
grid.gotoNextPage();
|
|
365
|
+
},
|
|
366
|
+
getDisabled: function() {
|
|
367
|
+
return grid._waitingRows || !grid.rows || grid.rows.length <= 0 || grid.pageNumber === grid.pagesCount;
|
|
368
|
+
},
|
|
369
|
+
img: Images.images.next,
|
|
370
|
+
class: grid.pagerButtonsClass
|
|
371
|
+
};
|
|
372
|
+
grid.pagerButtons.push(next);
|
|
373
|
+
grid.pagerButtonsDict[next.id] = grid.pagerButtonsDict[next.name] = next;
|
|
374
|
+
const last = {
|
|
375
|
+
id: 8,
|
|
376
|
+
name: "last",
|
|
377
|
+
title: "Last",
|
|
378
|
+
label: Images.images.last ? "" : "Last",
|
|
379
|
+
click: function(e) {
|
|
380
|
+
grid.gotoLastPage();
|
|
381
|
+
},
|
|
382
|
+
getDisabled: function() {
|
|
383
|
+
return grid._waitingRows || !grid.rows || grid.rows.length <= 0 || grid.pageNumber === grid.pagesCount;
|
|
384
|
+
},
|
|
385
|
+
img: Images.images.last,
|
|
386
|
+
class: grid.pagerButtonsClass
|
|
387
|
+
};
|
|
388
|
+
grid.pagerButtons.push(last);
|
|
389
|
+
grid.pagerButtonsDict[last.id] = grid.pagerButtonsDict[last.name] = last;
|
|
390
|
+
const pgsize = {
|
|
391
|
+
id: 9,
|
|
392
|
+
name: "pgsize",
|
|
393
|
+
title: "Page Size",
|
|
394
|
+
label: "Page Size",
|
|
395
|
+
render: function(button, bottom) {
|
|
396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
|
|
397
|
+
title: grid.translate(button.title, "grid-pager-button"),
|
|
398
|
+
"grid-pager-item": `${grid.id}_${button.id}_`,
|
|
399
|
+
className: `grid-pager-size ${button.class ? button.class : grid.opt.inputClass || BaseComponent.theme.inputClass || ""}`,
|
|
400
|
+
style: {
|
|
401
|
+
width: "4.5em",
|
|
402
|
+
height: "2em",
|
|
403
|
+
display: "inline-block",
|
|
404
|
+
margin: "0 2px"
|
|
405
|
+
},
|
|
406
|
+
value: grid.pageSize,
|
|
407
|
+
disabled: grid._waitingRows || grid.isEditing() || grid.isDisabled() ? "disabled" : "",
|
|
408
|
+
onChange: function(e) {
|
|
409
|
+
grid.setPageSize(+e.target.value);
|
|
410
|
+
},
|
|
411
|
+
children: grid.pageSizes.map((size, ind) => {
|
|
412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
|
|
413
|
+
value: +size,
|
|
414
|
+
children: size
|
|
415
|
+
}, `pageSize_${grid.id}_${ind}_`);
|
|
416
|
+
})
|
|
417
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_`);
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
grid.pagerButtons.push(pgsize);
|
|
421
|
+
grid.pagerButtonsDict[pgsize.id] = grid.pagerButtonsDict[pgsize.name] = pgsize;
|
|
422
|
+
}
|
|
423
|
+
const rows = {
|
|
424
|
+
id: 10,
|
|
425
|
+
name: "rows",
|
|
426
|
+
title: "Total Rows",
|
|
427
|
+
label: "Total Rows",
|
|
428
|
+
render: function(button, bottom) {
|
|
429
|
+
const total = `${grid.translate("total rows", "pager-button")} ${grid.totalRows >= 0 ? grid.totalRows : "0"}`;
|
|
430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
431
|
+
className: "grid-pager-total",
|
|
432
|
+
title: total,
|
|
433
|
+
style: { margin: "5px 2px" },
|
|
434
|
+
children: total
|
|
435
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_`);
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
grid.pagerButtons.push(rows);
|
|
439
|
+
grid.pagerButtonsDict[rows.id] = grid.pagerButtonsDict[rows.name] = rows;
|
|
440
|
+
if (!grid.sortDisabled) {
|
|
441
|
+
const sort = {
|
|
442
|
+
id: 11,
|
|
443
|
+
name: "sort",
|
|
444
|
+
title: "Sort",
|
|
445
|
+
label: "Sort",
|
|
446
|
+
render: function(button, bottom) {
|
|
447
|
+
return grid._sortString != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
448
|
+
className: "grid-pager-total",
|
|
449
|
+
title: grid._sortString,
|
|
450
|
+
style: { margin: "5px 2px" },
|
|
451
|
+
children: `${grid._sortString}`
|
|
452
|
+
}, `pager_${bottom ? "bottom" : "top"}_${grid.id}_${button.id}_`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {});
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
grid.pagerButtons.push(sort);
|
|
456
|
+
grid.pagerButtonsDict[sort.id] = grid.pagerButtonsDict[sort.name] = sort;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
setPageSize(newSize) {
|
|
460
|
+
const grid = this;
|
|
461
|
+
if (grid.pageSize === newSize || grid.pageSizes.indexOf(newSize) < 0) return;
|
|
462
|
+
grid.pageSize = newSize;
|
|
463
|
+
grid.pageNumber = 1;
|
|
464
|
+
grid.selectedRowIndex = 0;
|
|
465
|
+
grid.checkPocketState();
|
|
466
|
+
grid.refresh();
|
|
467
|
+
}
|
|
468
|
+
getHeaderGridTemplateColumns(col) {
|
|
469
|
+
return col.sortInd == null ? "auto 12px" : "auto 22px";
|
|
470
|
+
}
|
|
471
|
+
renderHeaderCell(col, context) {
|
|
472
|
+
const grid = this;
|
|
473
|
+
if (grid.sortDisabled) return super.renderHeaderCell(col, context);
|
|
474
|
+
const title = grid.translate(col.title || col.name) || "";
|
|
475
|
+
const sortDir = !col.sortable ? "" : col.asc ? "⯅" : col.desc ? "⯆" : "";
|
|
476
|
+
const decodedString = new DOMParser().parseFromString(`<!doctype html><body>${sortDir}`, "text/html").body.textContent;
|
|
477
|
+
const notDisabled = !grid._waitingRows && !grid.isEditing() && !grid.isDisabled();
|
|
478
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
479
|
+
className: `grid-header-title ${col.sortable ? "grid-header-title-sortable" : ""}`,
|
|
480
|
+
style: {
|
|
481
|
+
cursor: col.sortable && notDisabled ? "pointer" : "",
|
|
482
|
+
gridColumn: !sortDir ? "span 2" : "",
|
|
483
|
+
opacity: notDisabled ? "1" : "0.6",
|
|
484
|
+
whiteSpace: "nowrap",
|
|
485
|
+
overflowX: "hidden",
|
|
486
|
+
width: sortDir ? "calc(100% - 10px)" : "",
|
|
487
|
+
textAlign: "left"
|
|
488
|
+
},
|
|
489
|
+
onClick: (e) => {
|
|
490
|
+
if (!grid._waitingRows) grid.changeColumnSortOrder(col, e);
|
|
491
|
+
},
|
|
492
|
+
disabled: grid._waitingRows || col.disabled ? "disabled" : "",
|
|
493
|
+
children: title
|
|
494
|
+
}), sortDir ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
495
|
+
className: "grid-header-sort-sign",
|
|
496
|
+
style: { opacity: notDisabled ? "1" : "0.6" },
|
|
497
|
+
children: decodedString + (col.sortInd > 0 ? ` ${col.sortInd} ` : "")
|
|
498
|
+
}) : ""] });
|
|
499
|
+
}
|
|
500
|
+
getGridSettingsList() {
|
|
501
|
+
const grid = this;
|
|
502
|
+
const res = [{
|
|
503
|
+
id: 0,
|
|
504
|
+
text: grid.translate("Reset columns order", "grid-menu")
|
|
505
|
+
}, {
|
|
506
|
+
id: 1,
|
|
507
|
+
text: grid.translate("Reset columns widths", "grid-menu")
|
|
508
|
+
}];
|
|
509
|
+
if (!grid.sortDisabled) res.push({
|
|
510
|
+
id: 2,
|
|
511
|
+
text: grid.translate("Reset columns sort", "grid-menu")
|
|
512
|
+
});
|
|
513
|
+
return res;
|
|
514
|
+
}
|
|
515
|
+
getGridSettings(e) {
|
|
516
|
+
const grid = this;
|
|
517
|
+
return new Promise(function(resolve, reject) {
|
|
518
|
+
resolve(grid.getGridSettingsList());
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
showGridSettings(e) {
|
|
522
|
+
const grid = this;
|
|
523
|
+
if (!grid.menuDropdown) return;
|
|
524
|
+
const elem = document.getElementById(e.target.id);
|
|
525
|
+
grid.menuDropdown.opt.parentRect = elem ? elem.getBoundingClientRect() : e.target.getBoundingClientRect();
|
|
526
|
+
grid.menuDropdown.popup(e);
|
|
527
|
+
}
|
|
528
|
+
checkPocketState() {
|
|
529
|
+
super.checkPocketState();
|
|
530
|
+
const grid = this;
|
|
531
|
+
if (!grid.multi) return;
|
|
532
|
+
grid.setPocketImage();
|
|
533
|
+
}
|
|
534
|
+
setPocketImage() {
|
|
535
|
+
const grid = this;
|
|
536
|
+
if (!grid.multi || !grid.pagerButtonsDict) return;
|
|
537
|
+
const pocket = grid.pagerButtonsDict["pocket"];
|
|
538
|
+
if (!pocket) return;
|
|
539
|
+
pocket.img = grid.pocketOpened ? Images.images.pocketOpened : Images.images.pocket;
|
|
540
|
+
}
|
|
541
|
+
switchGridPocket(e) {
|
|
542
|
+
const grid = this;
|
|
543
|
+
if (!grid.multi) return;
|
|
544
|
+
grid.pocketOpened = !grid.pocketOpened;
|
|
545
|
+
grid.setPocketImage();
|
|
546
|
+
grid.refreshState();
|
|
547
|
+
if (grid.graph) grid.graph.triggerWave({
|
|
548
|
+
nodes: [grid],
|
|
549
|
+
withStartNodes: false
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
loadPocketRows() {
|
|
553
|
+
const grid = this;
|
|
554
|
+
super.loadPocketRows();
|
|
555
|
+
grid._sortColumns = [];
|
|
556
|
+
for (let col of grid.columns) if (col.sortInd != null && col.sortInd !== null || col.asc || col.desc) grid._sortColumns.push(col);
|
|
557
|
+
if (grid._sortColumns.length > 0) grid._sortColumns.sort((a, b) => {
|
|
558
|
+
return a.sortInd > b.sortInd ? 1 : -1;
|
|
559
|
+
});
|
|
560
|
+
else grid._sortColumns.push({
|
|
561
|
+
name: grid.getKeyColumn(),
|
|
562
|
+
asc: true
|
|
563
|
+
});
|
|
564
|
+
grid._selectedRows.sort((a, b) => {
|
|
565
|
+
let lastCol;
|
|
566
|
+
for (let col of grid._sortColumns) {
|
|
567
|
+
if (a[col.name] === b[col.name]) continue;
|
|
568
|
+
lastCol = col;
|
|
569
|
+
break;
|
|
570
|
+
}
|
|
571
|
+
if (!lastCol) return 0;
|
|
572
|
+
return a[lastCol.name] > b[lastCol.name] ? lastCol.asc ? 1 : -1 : lastCol.asc ? -1 : 1;
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
onSettingsItemClick(itemId) {
|
|
576
|
+
const grid = this;
|
|
577
|
+
switch (String(itemId)) {
|
|
578
|
+
case "0":
|
|
579
|
+
grid.resetColumnsOrderToDefault();
|
|
580
|
+
break;
|
|
581
|
+
case "1":
|
|
582
|
+
grid.resetColumnsWidthsToDefault();
|
|
583
|
+
break;
|
|
584
|
+
case "2":
|
|
585
|
+
grid.resetColumnsSort();
|
|
586
|
+
break;
|
|
587
|
+
default:
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
resetColumnsSort() {
|
|
591
|
+
const grid = this;
|
|
592
|
+
grid._sortString = "";
|
|
593
|
+
let needRefresh = false;
|
|
594
|
+
for (let col of grid.columns) {
|
|
595
|
+
needRefresh = needRefresh || col.asc != false || col.desc != false;
|
|
596
|
+
delete col.asc;
|
|
597
|
+
delete col.desc;
|
|
598
|
+
delete col.sortInd;
|
|
599
|
+
}
|
|
600
|
+
if (needRefresh) grid.refresh();
|
|
601
|
+
else grid.refreshState();
|
|
602
|
+
}
|
|
603
|
+
changeColumnSortOrder(column, e) {
|
|
604
|
+
const grid = this;
|
|
605
|
+
if (column === grid._skipClickColumn) {
|
|
606
|
+
delete grid._skipClickColumn;
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
if (!column.sortable || grid.isEditing() || grid.isDisabled()) return;
|
|
610
|
+
let nextInd = 1;
|
|
611
|
+
if (e.shiftKey) {
|
|
612
|
+
for (let col of grid.columns) if (col.sortInd != null && col.sortInd !== null) nextInd++;
|
|
613
|
+
else if (col.asc || col.desc) col.sortInd = nextInd++;
|
|
614
|
+
}
|
|
615
|
+
if (column.asc) {
|
|
616
|
+
delete column.asc;
|
|
617
|
+
column.desc = true;
|
|
618
|
+
if (!e.shiftKey) delete column.sortInd;
|
|
619
|
+
} else if (column.desc) {
|
|
620
|
+
const prevInd = column.sortInd;
|
|
621
|
+
delete column.desc;
|
|
622
|
+
delete column.sortInd;
|
|
623
|
+
if (e.shiftKey) {
|
|
624
|
+
for (let col of grid.columns) if (col.sortInd > prevInd) col.sortInd--;
|
|
625
|
+
}
|
|
626
|
+
} else {
|
|
627
|
+
column.asc = true;
|
|
628
|
+
if (e.shiftKey) column.sortInd = nextInd;
|
|
629
|
+
else delete column.sortInd;
|
|
630
|
+
}
|
|
631
|
+
if (!e.shiftKey) for (let col of grid.columns) {
|
|
632
|
+
if (col === column) continue;
|
|
633
|
+
delete col.asc;
|
|
634
|
+
delete col.desc;
|
|
635
|
+
delete col.sortInd;
|
|
636
|
+
}
|
|
637
|
+
delete grid._sortString;
|
|
638
|
+
grid.selectedRowIndex = 0;
|
|
639
|
+
grid.afterSortColumn(column);
|
|
640
|
+
grid.refresh();
|
|
641
|
+
}
|
|
642
|
+
afterSortColumn(column) {
|
|
643
|
+
const grid = this;
|
|
644
|
+
grid.getSortedString();
|
|
645
|
+
delete grid._selectedRows;
|
|
646
|
+
}
|
|
647
|
+
getSortedString() {
|
|
648
|
+
const grid = this;
|
|
649
|
+
grid._sortString = "";
|
|
650
|
+
if (grid.sortDisabled) return "";
|
|
651
|
+
const sortedColumns = [];
|
|
652
|
+
for (let col of grid.columns) if (col.asc || col.desc) sortedColumns.push(col);
|
|
653
|
+
sortedColumns.sort((a, b) => {
|
|
654
|
+
return a.sortInd > b.sortInd ? 1 : -1;
|
|
655
|
+
});
|
|
656
|
+
const arr = [];
|
|
657
|
+
for (let col of sortedColumns) arr.push((col.title || col.name) + (col.desc ? " (" + grid.translate("desc") + ")" : ""));
|
|
658
|
+
grid._sortString = arr.join(", ");
|
|
659
|
+
grid._sortString = grid._sortString ? grid.translate("sort", "pager-button") + ": " + grid._sortString : "";
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
export { GridDB, GridDBClass };
|