@eturnity/eturnity_reusable_components 8.16.2--EPDM-14330.4 → 8.16.2--EPDM-14330.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/package.json
CHANGED
@@ -10,6 +10,144 @@
|
|
10
10
|
<ButtonWrapper v-if="isOptionsVisible">
|
11
11
|
<BoxContainer class="box-container">
|
12
12
|
<BoxTitle>{{ $gettext('sort') }}</BoxTitle>
|
13
|
+
<SortOptionsContainer>
|
14
|
+
<template v-if="selectedSort.length > 0">
|
15
|
+
<SortDropdownContainer
|
16
|
+
v-for="(item, index) in selectedSort"
|
17
|
+
:key="index"
|
18
|
+
>
|
19
|
+
<SelectComponent
|
20
|
+
ref="selectSortDropdown"
|
21
|
+
align-items="vertical"
|
22
|
+
class="sort-dropdown"
|
23
|
+
:dropdown-auto-close="false"
|
24
|
+
select-height="40px"
|
25
|
+
@input-change="
|
26
|
+
onSelectSort({
|
27
|
+
type: 'column',
|
28
|
+
value: $event,
|
29
|
+
index: index,
|
30
|
+
})
|
31
|
+
"
|
32
|
+
>
|
33
|
+
<template #selector>
|
34
|
+
<SelectedText>{{
|
35
|
+
getSelectedLabel({ type: 'column', value: item.column }) ||
|
36
|
+
$gettext('category')
|
37
|
+
}}</SelectedText>
|
38
|
+
</template>
|
39
|
+
<template #dropdown>
|
40
|
+
<SelectOption
|
41
|
+
v-for="(item, index) in sortOptions"
|
42
|
+
:key="item.value"
|
43
|
+
:value="item.value"
|
44
|
+
>
|
45
|
+
{{ item.label }}
|
46
|
+
</SelectOption>
|
47
|
+
</template>
|
48
|
+
</SelectComponent>
|
49
|
+
<SelectComponent
|
50
|
+
ref="selectSortDropdown"
|
51
|
+
align-items="vertical"
|
52
|
+
class="sort-dropdown"
|
53
|
+
:dropdown-auto-close="false"
|
54
|
+
select-height="40px"
|
55
|
+
@input-change="
|
56
|
+
onSelectSort({
|
57
|
+
type: 'direction',
|
58
|
+
value: $event,
|
59
|
+
index: index,
|
60
|
+
})
|
61
|
+
"
|
62
|
+
>
|
63
|
+
<template #selector>
|
64
|
+
<SelectedText>{{
|
65
|
+
getSelectedLabel({
|
66
|
+
type: 'direction',
|
67
|
+
value: item.direction,
|
68
|
+
}) || $gettext('constraint')
|
69
|
+
}}</SelectedText>
|
70
|
+
</template>
|
71
|
+
<template #dropdown>
|
72
|
+
<SelectOption
|
73
|
+
v-for="(item, index) in directionOptions"
|
74
|
+
:key="item.value"
|
75
|
+
:value="item.value"
|
76
|
+
>
|
77
|
+
{{ item.label }}
|
78
|
+
</SelectOption>
|
79
|
+
</template>
|
80
|
+
</SelectComponent>
|
81
|
+
<IconContainer>
|
82
|
+
<RCIcon
|
83
|
+
:color="theme.semanticColors.teal[800]"
|
84
|
+
cursor="pointer"
|
85
|
+
name="close"
|
86
|
+
size="14px"
|
87
|
+
@click.stop="removeItem(index)"
|
88
|
+
/>
|
89
|
+
</IconContainer>
|
90
|
+
</SortDropdownContainer>
|
91
|
+
</template>
|
92
|
+
<template v-else>
|
93
|
+
<SortDropdownContainer>
|
94
|
+
<SelectComponent
|
95
|
+
ref="selectSortDropdown"
|
96
|
+
align-items="vertical"
|
97
|
+
class="sort-dropdown"
|
98
|
+
:dropdown-auto-close="false"
|
99
|
+
select-height="40px"
|
100
|
+
@input-change="
|
101
|
+
onSelectSort({
|
102
|
+
type: 'column',
|
103
|
+
value: $event,
|
104
|
+
index: 0,
|
105
|
+
})
|
106
|
+
"
|
107
|
+
>
|
108
|
+
<template #selector>
|
109
|
+
<SelectedText>{{ $gettext('category') }}</SelectedText>
|
110
|
+
</template>
|
111
|
+
<template #dropdown>
|
112
|
+
<SelectOption
|
113
|
+
v-for="(item, index) in sortOptions"
|
114
|
+
:key="item.value"
|
115
|
+
:value="item.value"
|
116
|
+
>
|
117
|
+
{{ item.label }}
|
118
|
+
</SelectOption>
|
119
|
+
</template>
|
120
|
+
</SelectComponent>
|
121
|
+
<SelectComponent
|
122
|
+
ref="selectSortDropdown"
|
123
|
+
align-items="vertical"
|
124
|
+
class="sort-dropdown"
|
125
|
+
:dropdown-auto-close="false"
|
126
|
+
select-height="40px"
|
127
|
+
@input-change="
|
128
|
+
onSelectSort({
|
129
|
+
type: 'direction',
|
130
|
+
value: $event,
|
131
|
+
index: 0,
|
132
|
+
})
|
133
|
+
"
|
134
|
+
>
|
135
|
+
<template #selector>
|
136
|
+
<SelectedText>{{ $gettext('constraint') }}</SelectedText>
|
137
|
+
</template>
|
138
|
+
<template #dropdown>
|
139
|
+
<SelectOption
|
140
|
+
v-for="(item, index) in directionOptions"
|
141
|
+
:key="item.value"
|
142
|
+
:value="item.value"
|
143
|
+
>
|
144
|
+
{{ item.label }}
|
145
|
+
</SelectOption>
|
146
|
+
</template>
|
147
|
+
</SelectComponent>
|
148
|
+
</SortDropdownContainer>
|
149
|
+
</template>
|
150
|
+
</SortOptionsContainer>
|
13
151
|
</BoxContainer>
|
14
152
|
</ButtonWrapper>
|
15
153
|
</PageContainer>
|
@@ -18,6 +156,10 @@
|
|
18
156
|
<script>
|
19
157
|
import styled from 'vue3-styled-components'
|
20
158
|
import ButtonIcon from '../buttons/buttonIcon/index.vue'
|
159
|
+
import SelectComponent from '../inputs/select/index.vue'
|
160
|
+
import SelectOption from '../inputs/select/option/index.vue'
|
161
|
+
import RCIcon from '../icon'
|
162
|
+
import theme from '../../assets/theme'
|
21
163
|
|
22
164
|
const PageContainer = styled.div``
|
23
165
|
|
@@ -45,6 +187,30 @@
|
|
45
187
|
margin-bottom: 16px;
|
46
188
|
`
|
47
189
|
|
190
|
+
const SortOptionsContainer = styled.div`
|
191
|
+
display: flex;
|
192
|
+
flex-direction: column;
|
193
|
+
gap: 16px;
|
194
|
+
white-space: nowrap;
|
195
|
+
`
|
196
|
+
|
197
|
+
const SortDropdownContainer = styled.div`
|
198
|
+
display: flex;
|
199
|
+
flex-direction: row;
|
200
|
+
gap: 8px;
|
201
|
+
align-items: center;
|
202
|
+
`
|
203
|
+
|
204
|
+
const SelectedText = styled.div`
|
205
|
+
font-size: 14px;
|
206
|
+
font-weight: 400;
|
207
|
+
color: ${(props) => props.theme.semanticColors.grey[800]};
|
208
|
+
`
|
209
|
+
|
210
|
+
const IconContainer = styled.div`
|
211
|
+
margin-left: 12px;
|
212
|
+
`
|
213
|
+
|
48
214
|
export default {
|
49
215
|
name: 'ViewSettings',
|
50
216
|
components: {
|
@@ -53,40 +219,99 @@
|
|
53
219
|
ButtonWrapper,
|
54
220
|
BoxContainer,
|
55
221
|
BoxTitle,
|
222
|
+
SortOptionsContainer,
|
223
|
+
SortDropdownContainer,
|
224
|
+
SelectComponent,
|
225
|
+
SelectOption,
|
226
|
+
SelectedText,
|
227
|
+
RCIcon,
|
228
|
+
IconContainer,
|
229
|
+
},
|
230
|
+
props: {
|
231
|
+
sortOptions: {
|
232
|
+
type: Array,
|
233
|
+
required: true,
|
234
|
+
},
|
235
|
+
selectedSort: {
|
236
|
+
type: Array,
|
237
|
+
required: true,
|
238
|
+
},
|
56
239
|
},
|
57
|
-
props: {},
|
58
240
|
data() {
|
59
241
|
return {
|
60
242
|
isOptionsVisible: false,
|
61
243
|
}
|
62
244
|
},
|
63
|
-
|
64
|
-
|
245
|
+
computed: {
|
246
|
+
directionOptions() {
|
247
|
+
return [
|
248
|
+
{
|
249
|
+
value: 'ascending',
|
250
|
+
label: this.$gettext('ascending'),
|
251
|
+
},
|
252
|
+
{
|
253
|
+
value: 'descending',
|
254
|
+
label: this.$gettext('descending'),
|
255
|
+
},
|
256
|
+
]
|
257
|
+
},
|
258
|
+
theme() {
|
259
|
+
return theme
|
260
|
+
},
|
65
261
|
},
|
262
|
+
mounted() {},
|
66
263
|
beforeUnmount() {
|
67
264
|
document.removeEventListener('click', this.handleClickOutside)
|
68
265
|
},
|
69
266
|
methods: {
|
70
|
-
toggleOptions() {
|
71
|
-
this.isOptionsVisible = !this.isOptionsVisible
|
72
|
-
if (this.isOptionsVisible) {
|
73
|
-
document.addEventListener('click', this.handleClickOutside)
|
74
|
-
} else {
|
75
|
-
document.removeEventListener('click', this.handleClickOutside)
|
76
|
-
}
|
77
|
-
},
|
78
267
|
handleClickOutside(event) {
|
79
268
|
const buttonIcon = this.$el.querySelector('.button-icon')
|
80
269
|
const boxContainer = this.$el.querySelector('.box-container')
|
270
|
+
const isClickInDropdown = event.target.closest('.sort-dropdown')
|
81
271
|
|
82
272
|
if (
|
83
273
|
!buttonIcon.contains(event.target) &&
|
84
|
-
!boxContainer.contains(event.target)
|
274
|
+
!boxContainer.contains(event.target) &&
|
275
|
+
!isClickInDropdown
|
85
276
|
) {
|
86
277
|
this.isOptionsVisible = false
|
87
278
|
document.removeEventListener('click', this.handleClickOutside)
|
88
279
|
}
|
89
280
|
},
|
281
|
+
toggleOptions() {
|
282
|
+
this.isOptionsVisible = !this.isOptionsVisible
|
283
|
+
if (this.isOptionsVisible) {
|
284
|
+
document.addEventListener('click', this.handleClickOutside)
|
285
|
+
} else {
|
286
|
+
document.removeEventListener('click', this.handleClickOutside)
|
287
|
+
}
|
288
|
+
},
|
289
|
+
getSelectedLabel({ type, value }) {
|
290
|
+
// debugger
|
291
|
+
if (!value) return
|
292
|
+
if (type === 'column') {
|
293
|
+
return this.sortOptions.find((option) => option.value === value).label
|
294
|
+
} else if (type === 'direction') {
|
295
|
+
return this.directionOptions.find((option) => option.value === value)
|
296
|
+
.label
|
297
|
+
}
|
298
|
+
},
|
299
|
+
onSelectSort({ type, value, index }) {
|
300
|
+
console.log(type, value, index)
|
301
|
+
|
302
|
+
this.$emit('on-sort-change', {
|
303
|
+
type,
|
304
|
+
value,
|
305
|
+
index,
|
306
|
+
})
|
307
|
+
this.isOptionsVisible = true
|
308
|
+
},
|
309
|
+
removeItem(index) {
|
310
|
+
this.$emit('on-sort-change', {
|
311
|
+
type: 'remove',
|
312
|
+
index,
|
313
|
+
})
|
314
|
+
},
|
90
315
|
},
|
91
316
|
}
|
92
317
|
</script>
|