@zeedhi/teknisa-components-vuetify 3.1.0 → 3.3.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/teknisa-components-vuetify.es.js +3235 -0
- package/dist/teknisa-components-vuetify.es.js.map +1 -0
- package/dist/teknisa-vuetify.css +1 -1
- package/dist/types/components/index.d.ts +6 -0
- package/dist/types/components/public.d.ts +11 -0
- package/dist/types/components/tek-breadcrumb-header/TekBreadcrumbHeader.d.ts +3 -0
- package/dist/types/components/tek-grid/TekGrid.d.ts +3 -0
- package/dist/types/components/tek-grid/column-filter/TekGridColumnFilter.d.ts +36 -0
- package/dist/types/components/tek-grid/column-header/TekGridHeaderRow.d.ts +2 -0
- package/dist/types/components/tek-grid/columns-button/TekGridColumnsButton.d.ts +3 -0
- package/{types → dist/types}/components/tek-grid/columns-button/TekGridColumnsOptionsController.d.ts +1 -0
- package/{types → dist/types}/components/tek-grid/columns-button/TekGridColumnsOptionsModal.d.ts +1 -0
- package/dist/types/components/tek-grid/filter-button/TekGridFilterButton.d.ts +3 -0
- package/dist/types/components/tek-grid/indentation/TekGridIndentation.d.ts +2 -0
- package/dist/types/components/tek-grid/layout-options/TekGridLayoutOptions.d.ts +3 -0
- package/dist/types/components/tek-grid/row/TekGridFooterRow.d.ts +2 -0
- package/dist/types/components/tek-grid/row/TekGridGroupRow.d.ts +2 -0
- package/dist/types/components/tek-loading/TekLoading.d.ts +3 -0
- package/dist/types/components/tek-user-info/TekUserInfo.d.ts +3 -0
- package/dist/types/components/tek-user-info/TekUserInfoList.d.ts +2 -0
- package/{types → dist/types}/composables/useTableLayout.d.ts +3 -3
- package/{types → dist/types}/index.d.ts +0 -1
- package/package.json +40 -20
- package/src/index.ts +5 -0
- package/dist/teknisa-vuetify.js +0 -4117
- package/environments.json +0 -16
- package/jest.config.cjs +0 -31
- package/rollup.scss.config.js +0 -13
- package/src/components/index.ts +0 -41
- package/src/components/public.ts +0 -45
- package/src/components/tek-breadcrumb-header/TekBreadcrumbHeader.ts +0 -41
- package/src/components/tek-breadcrumb-header/TekBreadcrumbHeader.vue +0 -76
- package/src/components/tek-grid/TekGrid.ts +0 -332
- package/src/components/tek-grid/TekGrid.vue +0 -235
- package/src/components/tek-grid/column-filter/TekGridColumnFilter.ts +0 -244
- package/src/components/tek-grid/column-filter/TekGridColumnFilter.vue +0 -93
- package/src/components/tek-grid/column-header/TekGridHeaderRow.ts +0 -147
- package/src/components/tek-grid/column-header/TekGridHeaderRow.vue +0 -78
- package/src/components/tek-grid/columns-button/TekGridColumnsButton.ts +0 -97
- package/src/components/tek-grid/columns-button/TekGridColumnsButton.vue +0 -273
- package/src/components/tek-grid/columns-button/TekGridColumnsOptionsController.ts +0 -470
- package/src/components/tek-grid/columns-button/TekGridColumnsOptionsModal.ts +0 -513
- package/src/components/tek-grid/filter-button/TekGridFilterButton.ts +0 -48
- package/src/components/tek-grid/filter-button/TekGridFilterButton.vue +0 -28
- package/src/components/tek-grid/indentation/TekGridIndentation.ts +0 -21
- package/src/components/tek-grid/indentation/TekGridIndentation.vue +0 -33
- package/src/components/tek-grid/layout-options/TekGridLayoutOptions.ts +0 -124
- package/src/components/tek-grid/layout-options/TekGridLayoutOptions.vue +0 -172
- package/src/components/tek-grid/row/TekGridFooterRow.ts +0 -62
- package/src/components/tek-grid/row/TekGridFooterRow.vue +0 -64
- package/src/components/tek-grid/row/TekGridGroupRow.ts +0 -65
- package/src/components/tek-grid/row/TekGridGroupRow.vue +0 -65
- package/src/components/tek-loading/TekLoading.ts +0 -30
- package/src/components/tek-loading/TekLoading.vue +0 -18
- package/src/components/tek-user-info/TekUserInfo.ts +0 -52
- package/src/components/tek-user-info/TekUserInfo.vue +0 -53
- package/src/components/tek-user-info/TekUserInfoList.ts +0 -44
- package/src/components/tek-user-info/TekUserInfoList.vue +0 -12
- package/src/composables/useTableLayout.ts +0 -290
- package/src/shims-vue.d.ts +0 -6
- package/src/styles/index.scss +0 -0
- package/src/utils/isArrayOperation.ts +0 -5
- package/tsconfig.eslint.json +0 -9
- package/types/components/index.d.ts +0 -6
- package/types/components/public.d.ts +0 -11
- package/types/components/tek-breadcrumb-header/TekBreadcrumbHeader.d.ts +0 -1168
- package/types/components/tek-breadcrumb-header/TekBreadcrumbHeader.ts.d.ts +0 -1168
- package/types/components/tek-grid/TekGrid.d.ts +0 -6443
- package/types/components/tek-grid/TekGrid.ts.d.ts +0 -6443
- package/types/components/tek-grid/column-filter/TekGridColumnFilter.d.ts +0 -130
- package/types/components/tek-grid/column-filter/TekGridColumnFilter.ts.d.ts +0 -130
- package/types/components/tek-grid/column-header/TekGridHeaderRow.d.ts +0 -225
- package/types/components/tek-grid/column-header/TekGridHeaderRow.ts.d.ts +0 -225
- package/types/components/tek-grid/columns-button/TekGridColumnsButton.d.ts +0 -2933
- package/types/components/tek-grid/columns-button/TekGridColumnsButton.ts.d.ts +0 -2933
- package/types/components/tek-grid/filter-button/TekGridFilterButton.d.ts +0 -3580
- package/types/components/tek-grid/filter-button/TekGridFilterButton.ts.d.ts +0 -3580
- package/types/components/tek-grid/indentation/TekGridIndentation.d.ts +0 -32
- package/types/components/tek-grid/indentation/TekGridIndentation.ts.d.ts +0 -32
- package/types/components/tek-grid/layout-options/TekGridLayoutOptions.d.ts +0 -2394
- package/types/components/tek-grid/layout-options/TekGridLayoutOptions.ts.d.ts +0 -2394
- package/types/components/tek-grid/row/TekGridFooterRow.d.ts +0 -90
- package/types/components/tek-grid/row/TekGridFooterRow.ts.d.ts +0 -90
- package/types/components/tek-grid/row/TekGridGroupRow.d.ts +0 -87
- package/types/components/tek-grid/row/TekGridGroupRow.ts.d.ts +0 -87
- package/types/components/tek-loading/TekLoading.d.ts +0 -663
- package/types/components/tek-loading/TekLoading.ts.d.ts +0 -663
- package/types/components/tek-user-info/TekUserInfo.d.ts +0 -2459
- package/types/components/tek-user-info/TekUserInfo.ts.d.ts +0 -2459
- package/types/components/tek-user-info/TekUserInfoList.d.ts +0 -1245
- package/types/components/tek-user-info/TekUserInfoList.ts.d.ts +0 -1245
- /package/{types → dist/types}/utils/isArrayOperation.d.ts +0 -0
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-data-table
|
|
3
|
-
v-show="instance.isVisible"
|
|
4
|
-
ref="root"
|
|
5
|
-
:id="instance.name"
|
|
6
|
-
v-model="selectedRows"
|
|
7
|
-
:class="[
|
|
8
|
-
'zd-grid',
|
|
9
|
-
'tek-grid',
|
|
10
|
-
'zd-grid-editable',
|
|
11
|
-
instance.cssClass,
|
|
12
|
-
{
|
|
13
|
-
'zd-grid--loading': instance.datasource.loading,
|
|
14
|
-
'zd-grid--cell-selection': instance.cellSelection,
|
|
15
|
-
},
|
|
16
|
-
]"
|
|
17
|
-
:style="[
|
|
18
|
-
cssColorVars,
|
|
19
|
-
{
|
|
20
|
-
height: $formatSize(instance.height),
|
|
21
|
-
width: $formatSize(instance.width),
|
|
22
|
-
maxHeight: $formatSize(instance.maxHeight),
|
|
23
|
-
minHeight: $formatSize(instance.minHeight),
|
|
24
|
-
maxWidth: $formatSize(instance.maxWidth),
|
|
25
|
-
minWidth: $formatSize(instance.minWidth),
|
|
26
|
-
},
|
|
27
|
-
$styleObject(instance.cssStyle),
|
|
28
|
-
]"
|
|
29
|
-
:theme="instance.theme"
|
|
30
|
-
sort-asc-icon="$collapse"
|
|
31
|
-
sort-desc-icon="$expand"
|
|
32
|
-
fixed-header
|
|
33
|
-
multi-sort
|
|
34
|
-
hide-default-footer
|
|
35
|
-
:name="instance.name"
|
|
36
|
-
:headers="headers"
|
|
37
|
-
:items="renderedData"
|
|
38
|
-
:search="instance.datasource.search"
|
|
39
|
-
:density="instance.dense ? 'compact' : 'default'"
|
|
40
|
-
:loading="instance.datasource.loading"
|
|
41
|
-
:item-value="instance.datasource.uniqueKey"
|
|
42
|
-
:items-per-page="-1"
|
|
43
|
-
no-filter
|
|
44
|
-
:sort-by="sortBy"
|
|
45
|
-
disable-sort
|
|
46
|
-
return-object
|
|
47
|
-
tabindex="0"
|
|
48
|
-
@update:sort-by="updateSortBy($event)"
|
|
49
|
-
>
|
|
50
|
-
<template v-slot:top>
|
|
51
|
-
<zd-grid-toolbar v-if="!hasToolbarSlot"></zd-grid-toolbar>
|
|
52
|
-
<slot name="toolbarSlot"></slot>
|
|
53
|
-
</template>
|
|
54
|
-
|
|
55
|
-
<template
|
|
56
|
-
v-slot:headers="{ columns: tableColumns, isSorted, getSortIcon, toggleSort, sortBy }"
|
|
57
|
-
>
|
|
58
|
-
<tek-grid-header-row
|
|
59
|
-
v-if="instance.showHeader"
|
|
60
|
-
:name="instance.name"
|
|
61
|
-
:selectable="instance.selectable"
|
|
62
|
-
:headerBackground="instance.headerBackground"
|
|
63
|
-
:showSelectAll="instance.showSelectAll"
|
|
64
|
-
:allselectedState="allselectedState"
|
|
65
|
-
:visibleColumns="visibleColumns"
|
|
66
|
-
:dragColumns="instance.dragColumns"
|
|
67
|
-
:headerCellTextColor="instance.headerCellTextColor"
|
|
68
|
-
:resizeColumns="instance.resizeColumns"
|
|
69
|
-
:getSortIcon="getSortIcon"
|
|
70
|
-
:toggleSort="toggleSort"
|
|
71
|
-
:sortBy="sortBy"
|
|
72
|
-
:tableColumns="tableColumns"
|
|
73
|
-
:isSorted="isSorted"
|
|
74
|
-
:disableCheckbox="instance.editing"
|
|
75
|
-
:instanceName="instance.name"
|
|
76
|
-
:filterRelationsDatasource="instance.filterRelationsDatasource"
|
|
77
|
-
:filterOperationsDatasource="instance.filterOperationsDatasource"
|
|
78
|
-
:modelValue="filter"
|
|
79
|
-
:columnFilterButton="instance.columnFilterButton"
|
|
80
|
-
:columnHasFilter="columnHasFilter"
|
|
81
|
-
:level="groupColumnNames.length"
|
|
82
|
-
@update:modelValue="setFilter($event)"
|
|
83
|
-
@resizeMousedown="resizeMouseDownHandler($event.column, $event.event)"
|
|
84
|
-
@resizeClick="resizeClickHandler($event.event)"
|
|
85
|
-
@selectAllClick="selectAllClick($event)"
|
|
86
|
-
></tek-grid-header-row>
|
|
87
|
-
</template>
|
|
88
|
-
|
|
89
|
-
<template
|
|
90
|
-
v-if="addTopPadding()"
|
|
91
|
-
v-slot:body.prepend="{ headers }"
|
|
92
|
-
>
|
|
93
|
-
<tr>
|
|
94
|
-
<td
|
|
95
|
-
:colspan="headers.length"
|
|
96
|
-
:style="`padding-top:${scrollData.startHeight}px`"
|
|
97
|
-
>
|
|
98
|
-
</td>
|
|
99
|
-
</tr>
|
|
100
|
-
</template>
|
|
101
|
-
|
|
102
|
-
<template
|
|
103
|
-
v-if="addBottomPadding()"
|
|
104
|
-
v-slot:body.append="{ headers }"
|
|
105
|
-
>
|
|
106
|
-
<tr>
|
|
107
|
-
<td
|
|
108
|
-
:colspan="headers.length"
|
|
109
|
-
:style="`padding-top:${scrollData.endHeight}px`"
|
|
110
|
-
>
|
|
111
|
-
</td>
|
|
112
|
-
</tr>
|
|
113
|
-
</template>
|
|
114
|
-
|
|
115
|
-
<template
|
|
116
|
-
v-if="instance.datasource.data.length"
|
|
117
|
-
v-slot:body="{ internalItems, isSelected }"
|
|
118
|
-
>
|
|
119
|
-
<template v-for="(item, i) in visibleData">
|
|
120
|
-
<template v-if="isRowVisible(item, i)">
|
|
121
|
-
<tek-grid-group-row
|
|
122
|
-
v-if="isGroup(item)"
|
|
123
|
-
:key="item.groupColumnName + item.groupValue"
|
|
124
|
-
:row="item"
|
|
125
|
-
:is-current-row="isCurrentRowGroup(item)"
|
|
126
|
-
:selectable="instance.selectable"
|
|
127
|
-
:selectionDisabled="instance.callDisableSelection(item)"
|
|
128
|
-
:cellSelection="instance.cellSelection"
|
|
129
|
-
:is-current="isCurrent"
|
|
130
|
-
:isSelected="isGroupSelected(item)"
|
|
131
|
-
:indeterminate="isGroupSelectIndeterminate(item)"
|
|
132
|
-
@click="rowClick(item, $event)"
|
|
133
|
-
@checkboxClick="selectGroup(item, $event)"
|
|
134
|
-
@focusin="cellFocusIn($event)"
|
|
135
|
-
@expandClick="openGroup(item)"
|
|
136
|
-
></tek-grid-group-row>
|
|
137
|
-
|
|
138
|
-
<zd-grid-editable-row
|
|
139
|
-
v-else-if="!isFooter(item)"
|
|
140
|
-
:key="instance.getRowKey(item)"
|
|
141
|
-
:isSelected="isSelected(internalItems[i])"
|
|
142
|
-
:isCurrentRow="isCurrentRow(item)"
|
|
143
|
-
:selectable="instance.selectable"
|
|
144
|
-
:selectionDisabled="instance.callDisableSelection(item)"
|
|
145
|
-
:cellSelection="instance.cellSelection"
|
|
146
|
-
:isCurrent="isCurrent"
|
|
147
|
-
:columns="visibleColumns"
|
|
148
|
-
:row="item"
|
|
149
|
-
:fixedLeft="fixedLeft"
|
|
150
|
-
:fixedRight="fixedRight"
|
|
151
|
-
:isEditing="isEditing"
|
|
152
|
-
@cellFocus="cellFocus($event)"
|
|
153
|
-
@cellClick="cellClick($event)"
|
|
154
|
-
@click="rowClick(item, $event)"
|
|
155
|
-
@focusin="cellFocusIn($event)"
|
|
156
|
-
@checkboxClick="selectRowClick(item, !isSelected(internalItems[i]), $event)"
|
|
157
|
-
@cellEnterEdit="cellEnterEdit($event)"
|
|
158
|
-
@cellKeydown="cellKeydown($event)"
|
|
159
|
-
>
|
|
160
|
-
<template #cell-prepend="{ index }">
|
|
161
|
-
<tek-grid-indentation
|
|
162
|
-
v-if="index === 0 && groupColumnNames.length > 0"
|
|
163
|
-
:level="item.groupHeaders?.length"
|
|
164
|
-
></tek-grid-indentation>
|
|
165
|
-
</template>
|
|
166
|
-
</zd-grid-editable-row>
|
|
167
|
-
|
|
168
|
-
<tek-grid-footer-row
|
|
169
|
-
v-else
|
|
170
|
-
:key="'footer' + item.groupColumnName + item.groupValue"
|
|
171
|
-
:isSelected="isSelected(internalItems[i])"
|
|
172
|
-
:selectable="instance.selectable"
|
|
173
|
-
:selectionDisabled="instance.callDisableSelection(item)"
|
|
174
|
-
:cellSelection="instance.cellSelection"
|
|
175
|
-
:isCurrent="isCurrent"
|
|
176
|
-
:columns="visibleColumns"
|
|
177
|
-
:row="item"
|
|
178
|
-
:fixedLeft="fixedLeft"
|
|
179
|
-
:fixedRight="fixedRight"
|
|
180
|
-
@cellFocus="cellFocus($event)"
|
|
181
|
-
@focusin="cellFocusIn($event)"
|
|
182
|
-
></tek-grid-footer-row>
|
|
183
|
-
</template>
|
|
184
|
-
</template>
|
|
185
|
-
</template>
|
|
186
|
-
|
|
187
|
-
<template v-slot:no-data>
|
|
188
|
-
<zd-iterable-no-data>
|
|
189
|
-
<template v-slot:errorSlot>
|
|
190
|
-
<slot name="errorSlot"></slot>
|
|
191
|
-
</template>
|
|
192
|
-
<template v-slot:noResultSlot>
|
|
193
|
-
<slot name="noResultSlot"></slot>
|
|
194
|
-
</template>
|
|
195
|
-
<template v-slot:noDataSlot>
|
|
196
|
-
<slot name="noDataSlot"></slot>
|
|
197
|
-
</template>
|
|
198
|
-
</zd-iterable-no-data>
|
|
199
|
-
</template>
|
|
200
|
-
|
|
201
|
-
<template v-slot:bottom>
|
|
202
|
-
<zd-grid-footer v-if="instance.showFooter && !hasFooterSlot"></zd-grid-footer>
|
|
203
|
-
<slot name="footerSlot"></slot>
|
|
204
|
-
</template>
|
|
205
|
-
</v-data-table>
|
|
206
|
-
</template>
|
|
207
|
-
|
|
208
|
-
<script lang="ts" src="./TekGrid.ts"></script>
|
|
209
|
-
|
|
210
|
-
<style lang="scss">
|
|
211
|
-
.tek-grid {
|
|
212
|
-
.zd-grid__row:not(.tek-grid-group-row) {
|
|
213
|
-
:nth-child(1 of td:not(.zd-grid__selectable-cell)) {
|
|
214
|
-
display: flex;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.is-rotated {
|
|
219
|
-
transform: rotate(180deg);
|
|
220
|
-
transition: transform 0.3s ease;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.zd-grid__toolbar {
|
|
224
|
-
height: 38px;
|
|
225
|
-
|
|
226
|
-
.toolbar-divider {
|
|
227
|
-
margin: 10px;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
.zd-search {
|
|
231
|
-
width: 200px;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
</style>
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
import { Input, Radio, Select } from '@zeedhi/common';
|
|
2
|
-
import { IDynamicFilterItem } from '@zeedhi/teknisa-components-common';
|
|
3
|
-
import { Config, IEventParam, Metadata, Utils, dayjs } from '@zeedhi/core';
|
|
4
|
-
import cloneDeep from 'lodash.clonedeep';
|
|
5
|
-
import debounce from 'lodash.debounce';
|
|
6
|
-
import { PropType, computed, defineComponent, reactive } from 'vue';
|
|
7
|
-
import { isArrayOperation } from '../../../utils/isArrayOperation';
|
|
8
|
-
|
|
9
|
-
export const TekGridColumnFilterProps = {
|
|
10
|
-
hasFilterData: {
|
|
11
|
-
type: Boolean,
|
|
12
|
-
default: false,
|
|
13
|
-
},
|
|
14
|
-
column: {
|
|
15
|
-
type: Object,
|
|
16
|
-
required: true,
|
|
17
|
-
},
|
|
18
|
-
modelValue: {
|
|
19
|
-
type: Array as PropType<IDynamicFilterItem[]>,
|
|
20
|
-
default: [],
|
|
21
|
-
},
|
|
22
|
-
instanceName: {
|
|
23
|
-
type: String,
|
|
24
|
-
required: true,
|
|
25
|
-
},
|
|
26
|
-
filterRelationsDatasource: {
|
|
27
|
-
type: [Object, null] as PropType<boolean | null>,
|
|
28
|
-
required: false,
|
|
29
|
-
},
|
|
30
|
-
filterOperationsDatasource: {
|
|
31
|
-
type: [Object, null] as PropType<boolean | null>,
|
|
32
|
-
required: false,
|
|
33
|
-
},
|
|
34
|
-
isHovering: {
|
|
35
|
-
type: Boolean,
|
|
36
|
-
default: false,
|
|
37
|
-
},
|
|
38
|
-
multiple: {
|
|
39
|
-
type: Boolean,
|
|
40
|
-
required: true,
|
|
41
|
-
},
|
|
42
|
-
} as const;
|
|
43
|
-
|
|
44
|
-
type InputType = Input | Select | Radio;
|
|
45
|
-
|
|
46
|
-
const tekGridColumnFilter = defineComponent({
|
|
47
|
-
props: TekGridColumnFilterProps,
|
|
48
|
-
inheritAttrs: false,
|
|
49
|
-
emits: ['update:modelValue'],
|
|
50
|
-
setup(props, ctx) {
|
|
51
|
-
const getValueInputName = (index: number) => `${props.instanceName}-${props.column.name}-filter-value-${index}`;
|
|
52
|
-
|
|
53
|
-
const focusValueInput = (index: number) => {
|
|
54
|
-
const valueInputName = getValueInputName(index);
|
|
55
|
-
const input = Metadata.getInstance<Input>(valueInputName);
|
|
56
|
-
|
|
57
|
-
input.setFocus();
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const createNewFilter = () => {
|
|
61
|
-
return reactive<IDynamicFilterItem>({
|
|
62
|
-
operation: 'CONTAINS',
|
|
63
|
-
relation: 'AND',
|
|
64
|
-
value: undefined,
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
let newFilter = createNewFilter();
|
|
69
|
-
|
|
70
|
-
const convertToDateFormat = (value: string, revert: boolean) => {
|
|
71
|
-
const dateFormat = props.column!.componentProps.dateFormat || Config.dateFormat;
|
|
72
|
-
const displayFormat = props.column!.componentProps.displayFormat || Config.displayFormat;
|
|
73
|
-
|
|
74
|
-
if (revert) {
|
|
75
|
-
if (dayjs(value, displayFormat).isValid() || !dayjs(value, dateFormat).isValid()) {
|
|
76
|
-
return value;
|
|
77
|
-
}
|
|
78
|
-
return dayjs(value, dateFormat).format(displayFormat);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (dayjs(value, dateFormat).isValid() || !dayjs(value, displayFormat).isValid()) {
|
|
82
|
-
return value;
|
|
83
|
-
}
|
|
84
|
-
return dayjs(value, displayFormat).format(dateFormat);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const checkDateValueFormat = (value: string | string[], revert = false) => {
|
|
88
|
-
if (!['ZdDate', 'ZdDateRange'].includes(props.column!.componentProps.component)) return value;
|
|
89
|
-
|
|
90
|
-
if (Array.isArray(value)) {
|
|
91
|
-
return value.map((item) => convertToDateFormat(item, revert));
|
|
92
|
-
}
|
|
93
|
-
return convertToDateFormat(value, revert);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// use WeakMap to avoid memory leaks
|
|
97
|
-
const idMap = new WeakMap<object, string>();
|
|
98
|
-
let idCounter = 0;
|
|
99
|
-
|
|
100
|
-
// retrieves a unique id for each item
|
|
101
|
-
const getId = (item: object) => {
|
|
102
|
-
if (!idMap.has(item)) {
|
|
103
|
-
idMap.set(item, `__item__${idCounter++}`);
|
|
104
|
-
}
|
|
105
|
-
return idMap.get(item)!;
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// use computed to generate unique ids for each filter item
|
|
109
|
-
// this is needed for the v-for :key updates
|
|
110
|
-
const modelWithIds = computed(() => {
|
|
111
|
-
if (!props.multiple) {
|
|
112
|
-
if (props.modelValue.length > 0) {
|
|
113
|
-
return [{ id: getId(props.modelValue[0]), item: props.modelValue[0] }];
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return [{ id: getId(newFilter), item: newFilter }];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return [...props.modelValue, newFilter].map((item) => ({
|
|
120
|
-
id: getId(item),
|
|
121
|
-
item,
|
|
122
|
-
}));
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
const debounceUpdateModel = debounce((modelValue: IDynamicFilterItem[]) => {
|
|
126
|
-
if (Utils.isEqual(modelValue, props.modelValue)) return;
|
|
127
|
-
ctx.emit('update:modelValue', modelValue);
|
|
128
|
-
newFilter = createNewFilter();
|
|
129
|
-
}, 500);
|
|
130
|
-
|
|
131
|
-
const changeRelation = (index: number, { component }: IEventParam<InputType>) => {
|
|
132
|
-
const modelValue = cloneDeep(props.modelValue);
|
|
133
|
-
const isNewFilter = index === modelValue.length;
|
|
134
|
-
const filter = isNewFilter ? newFilter : modelValue[index];
|
|
135
|
-
const { value } = component;
|
|
136
|
-
|
|
137
|
-
focusValueInput(index);
|
|
138
|
-
|
|
139
|
-
// update item type value
|
|
140
|
-
filter.relation = value;
|
|
141
|
-
|
|
142
|
-
if (isNewFilter) return;
|
|
143
|
-
|
|
144
|
-
debounceUpdateModel(modelValue);
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const changeOperation = (index: number, { component }: IEventParam<InputType>) => {
|
|
148
|
-
const modelValue = cloneDeep(props.modelValue);
|
|
149
|
-
const filterItem = modelValue[index];
|
|
150
|
-
const isNewFilter = index === modelValue.length;
|
|
151
|
-
const filter = isNewFilter ? newFilter : filterItem;
|
|
152
|
-
const { value } = component;
|
|
153
|
-
|
|
154
|
-
focusValueInput(index);
|
|
155
|
-
|
|
156
|
-
// if operation is IN, NOT_IN or BETWEEN, value should be an array
|
|
157
|
-
if (isArrayOperation(value)) {
|
|
158
|
-
filter.value = Array.isArray(filterItem.value) ? filterItem.value : [filterItem.value];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// update item type value
|
|
162
|
-
filter.operation = value;
|
|
163
|
-
|
|
164
|
-
if (isNewFilter) return;
|
|
165
|
-
|
|
166
|
-
debounceUpdateModel(modelValue);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const changeValue = (item: IDynamicFilterItem, index: number, { component }: IEventParam<InputType>) => {
|
|
170
|
-
const modelValue = cloneDeep(props.modelValue);
|
|
171
|
-
const filter = cloneDeep(item);
|
|
172
|
-
const { value } = component;
|
|
173
|
-
const isNewFilter = props.multiple && index === modelValue.length;
|
|
174
|
-
let formattedValue = value;
|
|
175
|
-
|
|
176
|
-
if (value && isArrayOperation(filter.operation)) {
|
|
177
|
-
formattedValue = value.split(';');
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
filter.value = checkDateValueFormat(formattedValue);
|
|
181
|
-
|
|
182
|
-
if (!props.multiple) {
|
|
183
|
-
debounceUpdateModel([filter]);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (isNewFilter) {
|
|
188
|
-
// only emit event when newFilter has value
|
|
189
|
-
if (!filter.value) return;
|
|
190
|
-
|
|
191
|
-
debounceUpdateModel([...modelValue, filter]);
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (!filter.value) {
|
|
196
|
-
// when removing the last (not new) filter, should pass its operation and relation to the new filter
|
|
197
|
-
if (index === modelValue.length - 1) {
|
|
198
|
-
newFilter.operation = filter.operation;
|
|
199
|
-
newFilter.relation = filter.relation;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
modelValue.splice(index, 1);
|
|
203
|
-
|
|
204
|
-
// if the removed filter was the first, should set the new first relation to AND
|
|
205
|
-
if (modelValue.length > 0 && index === 0) {
|
|
206
|
-
modelValue[0].relation = 'AND';
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// if the removed filter was the last, should set the newFilter relation to AND
|
|
210
|
-
if (modelValue.length === 0) {
|
|
211
|
-
newFilter.relation = 'AND';
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
debounceUpdateModel(modelValue);
|
|
216
|
-
};
|
|
217
|
-
|
|
218
|
-
const getComponentType = (operation: string) => {
|
|
219
|
-
return isArrayOperation(operation) ? 'ZdTextInput' : props.column.componentProps.component;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const getComponentHint = (operation: string) => {
|
|
223
|
-
return isArrayOperation(operation) ? 'TEKGRID_MULTIPLE_VALUE_HINT' : '';
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
const getItemValue = (item: IDynamicFilterItem) => {
|
|
227
|
-
return isArrayOperation(item.operation) ? item.value.join(';') : item.value;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
return {
|
|
231
|
-
changeValue,
|
|
232
|
-
changeRelation,
|
|
233
|
-
changeOperation,
|
|
234
|
-
getValueInputName,
|
|
235
|
-
newFilter,
|
|
236
|
-
getComponentType,
|
|
237
|
-
getComponentHint,
|
|
238
|
-
modelWithIds,
|
|
239
|
-
getItemValue,
|
|
240
|
-
};
|
|
241
|
-
},
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
export default tekGridColumnFilter;
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-menu
|
|
3
|
-
offset-overflow
|
|
4
|
-
offset-y
|
|
5
|
-
transition="scale-transition"
|
|
6
|
-
content-class="tek-grid-column-filter__menu"
|
|
7
|
-
:close-on-content-click="false"
|
|
8
|
-
>
|
|
9
|
-
<template #activator="{ props }">
|
|
10
|
-
<zd-grid-header-icon
|
|
11
|
-
v-bind="props"
|
|
12
|
-
:icon="$getIcon('filter')"
|
|
13
|
-
:hidden="!isHovering && !hasFilterData"
|
|
14
|
-
:color="hasFilterData ? 'primary' : ''"
|
|
15
|
-
></zd-grid-header-icon>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<v-card
|
|
19
|
-
class="zd-pa-4 zd-pb-0"
|
|
20
|
-
:min-width="200"
|
|
21
|
-
:max-height="300"
|
|
22
|
-
>
|
|
23
|
-
<template
|
|
24
|
-
v-for="({ item, id }, filterIndex) in modelWithIds"
|
|
25
|
-
:key="id"
|
|
26
|
-
>
|
|
27
|
-
<!-- relation -->
|
|
28
|
-
<zd-radio
|
|
29
|
-
v-if="multiple && filterIndex > 0"
|
|
30
|
-
:name="`${instanceName}-${column.name}-filter-relation-${filterIndex}`"
|
|
31
|
-
v-bind="{
|
|
32
|
-
showLabel: false,
|
|
33
|
-
showHelper: false,
|
|
34
|
-
vertical: false,
|
|
35
|
-
cssClass: 'zd-mb-2',
|
|
36
|
-
datasource: filterRelationsDatasource,
|
|
37
|
-
dataValue: 'value',
|
|
38
|
-
dataLabel: 'text',
|
|
39
|
-
value: item.relation,
|
|
40
|
-
events: {
|
|
41
|
-
change: (params) => changeRelation(filterIndex, params),
|
|
42
|
-
},
|
|
43
|
-
}"
|
|
44
|
-
/>
|
|
45
|
-
|
|
46
|
-
<!-- operation -->
|
|
47
|
-
<zd-select
|
|
48
|
-
v-if="multiple && item.operation"
|
|
49
|
-
:name="`${instanceName}-${column.name}-filter-operation-${filterIndex}`"
|
|
50
|
-
v-bind="{
|
|
51
|
-
autocomplete: false,
|
|
52
|
-
showLabel: false,
|
|
53
|
-
showHelper: false,
|
|
54
|
-
clearable: false,
|
|
55
|
-
cssClass: 'zd-mb-2',
|
|
56
|
-
datasource: filterOperationsDatasource,
|
|
57
|
-
dataValue: 'value',
|
|
58
|
-
dataText: 'text',
|
|
59
|
-
value: item.operation,
|
|
60
|
-
events: {
|
|
61
|
-
change: (params) => changeOperation(filterIndex, params),
|
|
62
|
-
},
|
|
63
|
-
}"
|
|
64
|
-
/>
|
|
65
|
-
|
|
66
|
-
<!-- value -->
|
|
67
|
-
<component
|
|
68
|
-
:name="`${instanceName}-${column.name}-filter-value-${filterIndex}`"
|
|
69
|
-
:is="getComponentType(item.operation)"
|
|
70
|
-
v-bind="{
|
|
71
|
-
...column.componentProps,
|
|
72
|
-
showLabel: false,
|
|
73
|
-
showHelper: true,
|
|
74
|
-
autofill: false,
|
|
75
|
-
cssClass: 'zd-mb-2',
|
|
76
|
-
value: getItemValue(item),
|
|
77
|
-
persistentHint: true,
|
|
78
|
-
hint: getComponentHint(item.operation),
|
|
79
|
-
events: {
|
|
80
|
-
input: (params) => changeValue(item, filterIndex, params),
|
|
81
|
-
change: (params) => changeValue(item, filterIndex, params),
|
|
82
|
-
},
|
|
83
|
-
}"
|
|
84
|
-
/>
|
|
85
|
-
</template>
|
|
86
|
-
</v-card>
|
|
87
|
-
</v-menu>
|
|
88
|
-
</template>
|
|
89
|
-
|
|
90
|
-
<script lang="ts" src="./TekGridColumnFilter.ts"></script>
|
|
91
|
-
|
|
92
|
-
<style lang="scss">
|
|
93
|
-
</style>
|