@zeedhi/teknisa-components-vuetify 1.117.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.package.json +49 -0
- package/dist/teknisa-vuetify.css +1 -0
- package/dist/teknisa-vuetify.js +3882 -0
- package/environments.json +16 -0
- package/package.json +18 -17
- package/src/components/index.ts +38 -0
- package/src/components/public.ts +41 -0
- package/src/components/tek-breadcrumb-header/TekBreadcrumbHeader.ts +34 -0
- package/src/components/tek-breadcrumb-header/TekBreadcrumbHeader.vue +75 -0
- package/src/components/tek-grid/TekGrid.ts +318 -0
- package/src/components/tek-grid/TekGrid.vue +235 -0
- package/src/components/tek-grid/column-filter/TekGridColumnFilter.ts +244 -0
- package/src/components/tek-grid/column-filter/TekGridColumnFilter.vue +93 -0
- package/src/components/tek-grid/column-header/TekGridHeaderRow.ts +147 -0
- package/src/components/tek-grid/column-header/TekGridHeaderRow.vue +78 -0
- package/src/components/tek-grid/columns-button/TekGridColumnsButton.ts +96 -0
- package/src/components/tek-grid/columns-button/TekGridColumnsButton.vue +273 -0
- package/src/components/tek-grid/columns-button/TekGridColumnsOptionsController.ts +470 -0
- package/src/components/tek-grid/columns-button/TekGridColumnsOptionsModal.ts +513 -0
- package/src/components/tek-grid/filter-button/TekGridFilterButton.ts +47 -0
- package/src/components/tek-grid/filter-button/TekGridFilterButton.vue +28 -0
- package/src/components/tek-grid/indentation/TekGridIndentation.ts +21 -0
- package/src/components/tek-grid/indentation/TekGridIndentation.vue +33 -0
- package/src/components/tek-grid/layout-options/TekGridLayoutOptions.ts +119 -0
- package/src/components/tek-grid/layout-options/TekGridLayoutOptions.vue +172 -0
- package/src/components/tek-grid/row/TekGridFooterRow.ts +62 -0
- package/src/components/tek-grid/row/TekGridFooterRow.vue +64 -0
- package/src/components/tek-grid/row/TekGridGroupRow.ts +65 -0
- package/src/components/tek-grid/row/TekGridGroupRow.vue +65 -0
- package/src/components/tek-user-info/TekUserInfo.ts +51 -0
- package/src/components/tek-user-info/TekUserInfo.vue +53 -0
- package/src/components/tek-user-info/TekUserInfoList.ts +39 -0
- package/src/components/tek-user-info/TekUserInfoList.vue +12 -0
- package/src/composables/useTableLayout.ts +290 -0
- package/src/index.ts +29 -0
- package/src/shims-vue.d.ts +6 -0
- package/src/styles/index.scss +0 -0
- package/src/utils/isArrayOperation.ts +5 -0
- package/types/components/index.d.ts +5 -3
- package/types/components/public.d.ts +5 -18
- package/types/components/tek-breadcrumb-header/TekBreadcrumbHeader.d.ts +1137 -12
- package/types/components/tek-breadcrumb-header/TekBreadcrumbHeader.ts.d.ts +1138 -0
- package/types/components/tek-grid/TekGrid.d.ts +7208 -86
- package/types/components/tek-grid/TekGrid.ts.d.ts +7211 -0
- package/types/components/tek-grid/column-filter/TekGridColumnFilter.d.ts +130 -0
- package/types/components/tek-grid/column-filter/TekGridColumnFilter.ts.d.ts +130 -0
- package/types/components/tek-grid/column-header/TekGridHeaderRow.d.ts +225 -0
- package/types/components/tek-grid/column-header/TekGridHeaderRow.ts.d.ts +225 -0
- package/types/components/tek-grid/columns-button/TekGridColumnsButton.d.ts +2432 -0
- package/types/components/tek-grid/columns-button/TekGridColumnsButton.ts.d.ts +2432 -0
- package/types/components/tek-grid/{TekGridColumnsOptionsController.d.ts → columns-button/TekGridColumnsOptionsController.d.ts} +7 -8
- package/types/components/tek-grid/{TekGridColumnsOptionsModal.d.ts → columns-button/TekGridColumnsOptionsModal.d.ts} +2 -3
- package/types/components/tek-grid/filter-button/TekGridFilterButton.d.ts +2920 -0
- package/types/components/tek-grid/filter-button/TekGridFilterButton.ts.d.ts +2920 -0
- package/types/components/tek-grid/indentation/TekGridIndentation.d.ts +32 -0
- package/types/components/tek-grid/indentation/TekGridIndentation.ts.d.ts +32 -0
- package/types/components/tek-grid/layout-options/TekGridLayoutOptions.d.ts +1893 -0
- package/types/components/tek-grid/layout-options/TekGridLayoutOptions.ts.d.ts +1893 -0
- package/types/components/tek-grid/row/TekGridFooterRow.d.ts +90 -0
- package/types/components/tek-grid/row/TekGridFooterRow.ts.d.ts +90 -0
- package/types/components/tek-grid/row/TekGridGroupRow.d.ts +87 -0
- package/types/components/tek-grid/row/TekGridGroupRow.ts.d.ts +87 -0
- package/types/components/tek-user-info/TekUserInfo.d.ts +1937 -10
- package/types/components/tek-user-info/TekUserInfo.ts.d.ts +1940 -0
- package/types/components/tek-user-info/TekUserInfoList.d.ts +1014 -8
- package/types/components/tek-user-info/TekUserInfoList.ts.d.ts +1015 -0
- package/types/composables/useTableLayout.d.ts +26 -0
- package/types/index.d.ts +2 -2
- package/types/utils/isArrayOperation.d.ts +2 -0
- package/dist/tek-components-vuetify.esm.js +0 -8924
- package/dist/tek-components-vuetify.umd.js +0 -8949
- package/types/components/crud/TekCrudAddButton.d.ts +0 -14
- package/types/components/crud/TekCrudButton.d.ts +0 -12
- package/types/components/crud/TekCrudCancelButton.d.ts +0 -12
- package/types/components/crud/TekCrudDeleteButton.d.ts +0 -14
- package/types/components/crud/TekCrudForm.d.ts +0 -9
- package/types/components/crud/TekCrudSaveButton.d.ts +0 -11
- package/types/components/tek-card-title/TekCardTitle.d.ts +0 -16
- package/types/components/tek-drag-grid/TekDragGrid.d.ts +0 -20
- package/types/components/tek-grid/TekGridColumnsButton.d.ts +0 -16
- package/types/components/tek-grid/TekGridFilterButton.d.ts +0 -27
- package/types/components/tek-grid/TekGridLayoutOptions.d.ts +0 -19
- package/types/components/tek-grid/subcomponents/TekGridCellIdentation.d.ts +0 -9
- package/types/components/tek-grid/subcomponents/TekGridColumnFilter.d.ts +0 -16
- package/types/components/tek-grid/subcomponents/TekGridHeaderIndentation.d.ts +0 -5
- package/types/components/tek-image/TekImage.d.ts +0 -20
- package/types/components/tek-iterable-carousel/TekIterableCarousel.d.ts +0 -11
- package/types/components/tek-iterable-component-render/TekIterableComponentRender.d.ts +0 -9
- package/types/components/tek-loading/TekLoading.d.ts +0 -9
- package/types/components/tek-notifications/TekNotifications.d.ts +0 -12
- package/types/components/tek-product-card/TekProductCard.d.ts +0 -24
- package/types/components/tek-tree-grid/TekTreeGrid.d.ts +0 -72
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { Iterable, Modal, Select } from '@zeedhi/common';
|
|
2
|
+
import { TekGrid, TekGridColumnsButton } from '@zeedhi/teknisa-components-common';
|
|
3
|
+
import { I18n, IDictionary, IEventParam, Metadata, Singleton, Utils } from '@zeedhi/core';
|
|
4
|
+
import Sortable from 'sortablejs';
|
|
5
|
+
|
|
6
|
+
@Singleton
|
|
7
|
+
export default class TekGridColumnsOptionsController {
|
|
8
|
+
public modal: Modal;
|
|
9
|
+
|
|
10
|
+
public columnData: IDictionary<any> = {};
|
|
11
|
+
|
|
12
|
+
public fixedColumns: IDictionary<any>[] = [];
|
|
13
|
+
|
|
14
|
+
public visibleColumns: IDictionary<any>[] = [];
|
|
15
|
+
|
|
16
|
+
public groupedColumns: IDictionary<any>[] = [];
|
|
17
|
+
|
|
18
|
+
public otherColumns: IDictionary<any>[] = [];
|
|
19
|
+
|
|
20
|
+
public aggregationData: IDictionary<any>[] = [];
|
|
21
|
+
|
|
22
|
+
public selectedColumnNames: string[] = [];
|
|
23
|
+
|
|
24
|
+
public searchValue = '';
|
|
25
|
+
|
|
26
|
+
public showGroups = true;
|
|
27
|
+
|
|
28
|
+
private selectedColumnsAlignment?: string;
|
|
29
|
+
|
|
30
|
+
private selectedColumnsAggregation?: string;
|
|
31
|
+
|
|
32
|
+
private iterableComponent!: Iterable;
|
|
33
|
+
|
|
34
|
+
private instanceValue!: TekGridColumnsButton;
|
|
35
|
+
|
|
36
|
+
constructor(modal: Modal) {
|
|
37
|
+
this.modal = modal;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private updateArrays() {
|
|
41
|
+
this.fixedColumns = [];
|
|
42
|
+
this.visibleColumns = [];
|
|
43
|
+
this.groupedColumns = [];
|
|
44
|
+
this.otherColumns = [];
|
|
45
|
+
|
|
46
|
+
Object.keys(this.columnData).forEach((name) => {
|
|
47
|
+
const column = this.columnData[name];
|
|
48
|
+
|
|
49
|
+
if (this.instanceValue && this.instanceValue.ignoreColumns.indexOf(column.name) === -1) {
|
|
50
|
+
if (column.grouped) {
|
|
51
|
+
this.groupedColumns.push(column);
|
|
52
|
+
} else if (column.fixed) {
|
|
53
|
+
this.fixedColumns.push(column);
|
|
54
|
+
} else if (column.isVisible) {
|
|
55
|
+
this.visibleColumns.push(column);
|
|
56
|
+
} else {
|
|
57
|
+
this.otherColumns.push(column);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
set instance(instance: TekGridColumnsButton) {
|
|
64
|
+
this.instanceValue = instance;
|
|
65
|
+
this.iterableComponent = instance.iterableComponent;
|
|
66
|
+
this.showGroups = instance.iterableComponent instanceof TekGrid;
|
|
67
|
+
this.aggregationData = instance.getAggregationSelectData();
|
|
68
|
+
this.columnData = {};
|
|
69
|
+
|
|
70
|
+
this.iterableComponent.columns.forEach((column: any) => {
|
|
71
|
+
this.columnData[column.name] = {
|
|
72
|
+
name: column.name,
|
|
73
|
+
label: column.label,
|
|
74
|
+
fixed: column.fixed,
|
|
75
|
+
isVisible: column.isVisible,
|
|
76
|
+
align: column.align,
|
|
77
|
+
grouped: column.grouped || false,
|
|
78
|
+
groupOpened: column.groupOpened || false,
|
|
79
|
+
aggregation: column.aggregation,
|
|
80
|
+
aggregationText: this.getAggregationText(column.aggregation),
|
|
81
|
+
selected: false,
|
|
82
|
+
};
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
this.updateArrays();
|
|
86
|
+
|
|
87
|
+
this.selectedColumnNames = [];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private getAggregationText(aggregation?: string) {
|
|
91
|
+
let result = '';
|
|
92
|
+
if (aggregation) {
|
|
93
|
+
const idx = this.aggregationData.findIndex((item) => item.value === aggregation);
|
|
94
|
+
if (idx !== -1) {
|
|
95
|
+
result = ` (${this.aggregationData[idx].text})`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private columnInSearch(column: any) {
|
|
102
|
+
return !this.searchValue || Utils.normalize(column.label).indexOf(Utils.normalize(this.searchValue)) !== -1;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
get fixedColumnData() {
|
|
106
|
+
return this.fixedColumns.filter(this.columnInSearch.bind(this));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
set fixedColumnData(_data: any) {
|
|
110
|
+
// do nothing
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get visibleColumnData() {
|
|
114
|
+
return this.visibleColumns.filter(this.columnInSearch.bind(this));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
set visibleColumnData(_data: any) {
|
|
118
|
+
// do nothing
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
get groupedColumnData() {
|
|
122
|
+
return this.groupedColumns.filter(this.columnInSearch.bind(this));
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
set groupedColumnData(_data: any) {
|
|
126
|
+
// do nothing
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
get otherColumnData() {
|
|
130
|
+
return this.otherColumns.filter(this.columnInSearch.bind(this));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
set otherColumnData(_data: any) {
|
|
134
|
+
// do nothing
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get hasSelectedColumn(): boolean {
|
|
138
|
+
return this.selectedColumnNames.length > 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
get hasNoSelectedColumn(): boolean {
|
|
142
|
+
return !this.hasSelectedColumn;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
get detailColumnName(): string {
|
|
146
|
+
const columnNames = this.selectedColumnNames.length
|
|
147
|
+
? this.selectedColumnNames.join(', ')
|
|
148
|
+
: I18n.translate('TEKGRID_SELECT_COLUMN');
|
|
149
|
+
|
|
150
|
+
return `${I18n.translate('TEKGRID_DETAILS_FOR')} ${columnNames}`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
get hasNoFixedColumns(): boolean {
|
|
154
|
+
return this.fixedColumns.length === 0;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get hasNoVisibleColumns(): boolean {
|
|
158
|
+
return this.visibleColumns.length === 0;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
get hasNoGroupedColumns(): boolean {
|
|
162
|
+
return this.groupedColumns.length === 0;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
get hasNoOtherColumns(): boolean {
|
|
166
|
+
return this.otherColumns.length === 0;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
get hasNoSingleSelection(): boolean {
|
|
170
|
+
return this.selectedColumnNames.length !== 1;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get selectedColumnLabel() {
|
|
174
|
+
return this.selectedColumnNames.length === 1 ? this.columnData[this.selectedColumnNames[0]].label : '';
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
set selectedColumnLabel(value: string) {
|
|
178
|
+
if (this.selectedColumnNames.length === 1) {
|
|
179
|
+
this.columnData[this.selectedColumnNames[0]].label = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private getSameValue(propName: string) {
|
|
184
|
+
const isEqual =
|
|
185
|
+
this.selectedColumnNames.length > 0 &&
|
|
186
|
+
this.selectedColumnNames.every(
|
|
187
|
+
(name) => this.columnData[name][propName] === this.columnData[this.selectedColumnNames[0]][propName],
|
|
188
|
+
);
|
|
189
|
+
return isEqual ? this.columnData[this.selectedColumnNames[0]][propName] : undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private setSameValue(propName: string, value: any) {
|
|
193
|
+
this.selectedColumnNames.forEach((name) => {
|
|
194
|
+
this.columnData[name][propName] = value;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get groupInSelection(): boolean {
|
|
199
|
+
return this.hasNoSelectedColumn || this.selectedColumnNames.some((name) => this.columnData[name].grouped);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
get notGroupInSelection(): boolean {
|
|
203
|
+
return this.hasNoSelectedColumn || this.selectedColumnNames.some((name) => !this.columnData[name].grouped);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
get selectedColumnGroupOpened(): any {
|
|
207
|
+
return this.getSameValue('groupOpened');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
set selectedColumnGroupOpened(value: any) {
|
|
211
|
+
this.setSameValue('groupOpened', value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
public selectMounted({ component }: IEventParam<Select>) {
|
|
215
|
+
this.updatingSelect = true;
|
|
216
|
+
if (component.name === 'tekGridColumnsOptionsColumnAlignment') {
|
|
217
|
+
component.value = this.selectedColumnsAlignment;
|
|
218
|
+
} else if (component.name === 'tekGridColumnsOptionsColumnAggregation') {
|
|
219
|
+
component.value = this.selectedColumnsAggregation;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// prevent changing column value from here
|
|
223
|
+
setTimeout(() => {
|
|
224
|
+
this.updatingSelect = false;
|
|
225
|
+
}, 0);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private updatingSelect = false;
|
|
229
|
+
|
|
230
|
+
public selectChange({ component }: IEventParam<Select>) {
|
|
231
|
+
if (this.updatingSelect) return;
|
|
232
|
+
|
|
233
|
+
if (component.name === 'tekGridColumnsOptionsColumnAlignment') {
|
|
234
|
+
this.setSameValue('align', component.value);
|
|
235
|
+
} else {
|
|
236
|
+
this.setSameValue('aggregation', component.value);
|
|
237
|
+
this.setSameValue('aggregationText', this.getAggregationText(component.value));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private updateSelects() {
|
|
242
|
+
this.selectedColumnsAlignment = this.updateSelect('align');
|
|
243
|
+
this.selectedColumnsAggregation = this.updateSelect('aggregation');
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
private updateSelect(propName: string) {
|
|
247
|
+
this.updatingSelect = true;
|
|
248
|
+
const propValue = this.getSameValue(propName);
|
|
249
|
+
const selectNames: IDictionary<any> = {
|
|
250
|
+
align: 'tekGridColumnsOptionsColumnAlignment',
|
|
251
|
+
aggregation: 'tekGridColumnsOptionsColumnAggregation',
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const instances = Metadata.getInstances(selectNames[propName]);
|
|
255
|
+
if (instances[0]) {
|
|
256
|
+
(instances[0] as Select).value = propValue;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// prevent changing column value from here
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
this.updatingSelect = false;
|
|
262
|
+
}, 0);
|
|
263
|
+
return propValue;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
private columnRemoveClick(column: IDictionary) {
|
|
267
|
+
column.isVisible = false;
|
|
268
|
+
this.selectedColumnNames.splice(this.selectedColumnNames.indexOf(column.name), 1);
|
|
269
|
+
this.otherColumns.push(column);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
public columnFixedRemoveClick({ element }: IEventParam<any>) {
|
|
273
|
+
const columnName = element?.getAttribute('columnname');
|
|
274
|
+
if (columnName) {
|
|
275
|
+
const column = this.columnData[columnName];
|
|
276
|
+
this.columnRemoveClick(column);
|
|
277
|
+
this.fixedColumns.splice(this.fixedColumns.indexOf(column), 1);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
public columnVisibleRemoveClick({ element }: IEventParam<any>) {
|
|
282
|
+
const columnName = element?.getAttribute('columnname');
|
|
283
|
+
if (columnName) {
|
|
284
|
+
const column = this.columnData[columnName];
|
|
285
|
+
this.columnRemoveClick(column);
|
|
286
|
+
this.visibleColumns.splice(this.visibleColumns.indexOf(column), 1);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
public columnGroupedRemoveClick({ element }: IEventParam<any>) {
|
|
291
|
+
const columnName = element?.getAttribute('columnname');
|
|
292
|
+
if (columnName) {
|
|
293
|
+
const column = this.columnData[columnName];
|
|
294
|
+
this.columnRemoveClick(column);
|
|
295
|
+
this.groupedColumns.splice(this.groupedColumns.indexOf(column), 1);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private isMacPlatform() {
|
|
300
|
+
return /Mac/.test(navigator.platform);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
private isMobilePlatform() {
|
|
304
|
+
return /iPhone|iPad|Android/.test(navigator.platform);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
public columnClick({ element, event }: IEventParam<any>) {
|
|
308
|
+
const columnName = element!.getAttribute('columnname');
|
|
309
|
+
if (columnName) {
|
|
310
|
+
const mouseEvent = event as MouseEvent;
|
|
311
|
+
const multiple = (this.isMacPlatform() && mouseEvent.metaKey) || mouseEvent.ctrlKey || this.isMobilePlatform();
|
|
312
|
+
if (!multiple) {
|
|
313
|
+
Object.keys(this.columnData).forEach((name) => {
|
|
314
|
+
const column = this.columnData[name];
|
|
315
|
+
column.selected = column.name === columnName;
|
|
316
|
+
});
|
|
317
|
+
} else {
|
|
318
|
+
this.columnData[columnName].selected = !this.columnData[columnName].selected;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const orderedColumns = this.fixedColumns
|
|
322
|
+
.concat(this.visibleColumns)
|
|
323
|
+
.concat(this.groupedColumns)
|
|
324
|
+
.concat(this.otherColumns);
|
|
325
|
+
this.selectedColumnNames = orderedColumns.filter((column) => column.selected).map((column) => column.name);
|
|
326
|
+
this.updateSelects();
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private removeFromSourceList(columnName: string) {
|
|
331
|
+
const column = this.columnData[columnName];
|
|
332
|
+
const fixedIdx = this.fixedColumns.indexOf(column);
|
|
333
|
+
if (fixedIdx !== -1) {
|
|
334
|
+
this.fixedColumns.splice(fixedIdx, 1);
|
|
335
|
+
} else {
|
|
336
|
+
const visibleIdx = this.visibleColumns.indexOf(column);
|
|
337
|
+
if (visibleIdx !== -1) {
|
|
338
|
+
this.visibleColumns.splice(visibleIdx, 1);
|
|
339
|
+
} else {
|
|
340
|
+
const groupedIdx = this.groupedColumns.indexOf(column);
|
|
341
|
+
if (groupedIdx !== -1) {
|
|
342
|
+
this.groupedColumns.splice(groupedIdx, 1);
|
|
343
|
+
} else {
|
|
344
|
+
const otherIdx = this.otherColumns.indexOf(column);
|
|
345
|
+
if (otherIdx !== -1) {
|
|
346
|
+
this.otherColumns.splice(otherIdx, 1);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
private onDragEnd(event: any) {
|
|
354
|
+
const columnName = event.item.getAttribute('columnname');
|
|
355
|
+
if (this.selectedColumnNames.indexOf(columnName) === -1) {
|
|
356
|
+
this.selectedColumnNames = [columnName];
|
|
357
|
+
this.updateSelects();
|
|
358
|
+
|
|
359
|
+
setTimeout(() => {
|
|
360
|
+
Object.keys(this.columnData).forEach((name) => {
|
|
361
|
+
const column = this.columnData[name];
|
|
362
|
+
column.selected = column.name === columnName;
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
this.selectedColumnNames.forEach((name, index) => {
|
|
368
|
+
const newIndex = event.newIndex + index;
|
|
369
|
+
if (name) {
|
|
370
|
+
this.removeFromSourceList(name);
|
|
371
|
+
const column = this.columnData[name];
|
|
372
|
+
if (event.to.id === 'tekGridColumnsOptionsFixedColumns') {
|
|
373
|
+
column.fixed = true;
|
|
374
|
+
column.isVisible = true;
|
|
375
|
+
column.grouped = false;
|
|
376
|
+
column.groupOpened = false;
|
|
377
|
+
this.fixedColumns.splice(newIndex, 0, column);
|
|
378
|
+
} else if (event.to.id === 'tekGridColumnsOptionsVisibleColumns') {
|
|
379
|
+
column.fixed = false;
|
|
380
|
+
column.isVisible = true;
|
|
381
|
+
column.grouped = false;
|
|
382
|
+
column.groupOpened = false;
|
|
383
|
+
this.visibleColumns.splice(newIndex, 0, column);
|
|
384
|
+
} else if (event.to.id === 'tekGridColumnsOptionsOtherColumns') {
|
|
385
|
+
column.fixed = false;
|
|
386
|
+
column.isVisible = false;
|
|
387
|
+
column.grouped = false;
|
|
388
|
+
column.groupOpened = false;
|
|
389
|
+
this.otherColumns.splice(newIndex, 0, column);
|
|
390
|
+
} else if (event.to.id === 'tekGridColumnsOptionsGroupedColumns') {
|
|
391
|
+
column.fixed = false;
|
|
392
|
+
column.isVisible = true;
|
|
393
|
+
column.grouped = true;
|
|
394
|
+
column.aggregation = undefined;
|
|
395
|
+
column.aggregationText = '';
|
|
396
|
+
this.groupedColumns.splice(newIndex, 0, column);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
public columnContainerMounted({ element }: IEventParam<Modal>) {
|
|
403
|
+
if (element) {
|
|
404
|
+
Sortable.create(element, {
|
|
405
|
+
handle: '.tek-grid-column-option-box',
|
|
406
|
+
group: 'column-container',
|
|
407
|
+
filter: '.no-data, .tek-grid-column-option-grouped-true',
|
|
408
|
+
onEnd: this.onDragEnd.bind(this),
|
|
409
|
+
} as any);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
public selectAll({ component }: IEventParam<any>) {
|
|
414
|
+
let list: IDictionary<any>[];
|
|
415
|
+
if (component.name === 'tekGridColumnsOptionsFixedSelectAll') {
|
|
416
|
+
list = this.fixedColumns;
|
|
417
|
+
} else if (component.name === 'tekGridColumnsOptionsVisibleSelectAll') {
|
|
418
|
+
list = this.visibleColumns;
|
|
419
|
+
} else if (component.name === 'tekGridColumnsOptionsOtherSelectAll') {
|
|
420
|
+
list = this.otherColumns;
|
|
421
|
+
} else {
|
|
422
|
+
list = this.groupedColumns;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
this.selectedColumnNames = list.map((column) => column.name);
|
|
426
|
+
Object.keys(this.columnData).forEach((columnName) => {
|
|
427
|
+
const column = this.columnData[columnName];
|
|
428
|
+
column.selected = this.selectedColumnNames.indexOf(column.name) !== -1;
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
public cancelChanges() {
|
|
433
|
+
this.modal.hide();
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
public applyChanges({ event, element }: IEventParam<any>) {
|
|
437
|
+
const ignoredColumns = this.iterableComponent.columns.filter(
|
|
438
|
+
(column) => this.instanceValue && this.instanceValue.ignoreColumns.indexOf(column.name) !== -1,
|
|
439
|
+
);
|
|
440
|
+
const orderedColumns = this.groupedColumns
|
|
441
|
+
.concat(this.fixedColumns)
|
|
442
|
+
.concat(this.visibleColumns)
|
|
443
|
+
.concat(this.otherColumns)
|
|
444
|
+
.concat(ignoredColumns);
|
|
445
|
+
if (this.iterableComponent) {
|
|
446
|
+
this.iterableComponent.columns = orderedColumns.map((orderColumn) => {
|
|
447
|
+
const columnIdx = this.iterableComponent.columns.findIndex((column) => column.name === orderColumn.name);
|
|
448
|
+
const iterableColumn = this.iterableComponent.columns[columnIdx] as any;
|
|
449
|
+
iterableColumn.fixed = orderColumn.fixed;
|
|
450
|
+
iterableColumn.isVisible = orderColumn.isVisible;
|
|
451
|
+
iterableColumn.grouped = orderColumn.grouped;
|
|
452
|
+
iterableColumn.groupOpened = orderColumn.groupOpened;
|
|
453
|
+
iterableColumn.label = orderColumn.label;
|
|
454
|
+
iterableColumn.align = orderColumn.align;
|
|
455
|
+
iterableColumn.aggregation = orderColumn.aggregation;
|
|
456
|
+
return iterableColumn;
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const { datasource } = this.iterableComponent;
|
|
460
|
+
const order = datasource.order.filter((item) => {
|
|
461
|
+
const columnName = item.split('.')[0];
|
|
462
|
+
return this.groupedColumns.findIndex((column) => column.name === columnName) === -1;
|
|
463
|
+
});
|
|
464
|
+
datasource.order = this.groupedColumns.map((column) => `${column.name}.asc`).concat(order);
|
|
465
|
+
|
|
466
|
+
this.iterableComponent.changeLayout(event, element);
|
|
467
|
+
}
|
|
468
|
+
this.modal.hide();
|
|
469
|
+
}
|
|
470
|
+
}
|