@eturnity/eturnity_reusable_components 7.30.3 → 7.32.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/.eslintrc.js +184 -0
- package/.prettierrc +8 -6
- package/package.json +9 -21
- package/src/App.vue +79 -78
- package/src/assets/theme.js +3 -3
- package/src/components/addNewButton/AddNewButton.stories.js +2 -2
- package/src/components/addNewButton/index.vue +48 -51
- package/src/components/banner/actionBanner/index.vue +54 -55
- package/src/components/banner/banner/banner.stories.js +5 -5
- package/src/components/banner/banner/index.vue +159 -159
- package/src/components/banner/infoBanner/index.vue +41 -53
- package/src/components/buttons/buttonIcon/index.vue +125 -122
- package/src/components/buttons/closeButton/CloseButton.stories.js +3 -3
- package/src/components/buttons/closeButton/index.vue +49 -49
- package/src/components/buttons/mainButton/index.vue +108 -108
- package/src/components/card/index.vue +70 -70
- package/src/components/collapsableInfoText/index.vue +96 -94
- package/src/components/deleteIcon/DeleteIcon.stories.js +4 -4
- package/src/components/deleteIcon/index.vue +54 -54
- package/src/components/draggableInputHandle/index.vue +37 -37
- package/src/components/dropdown/Dropdown.stories.js +9 -10
- package/src/components/dropdown/index.vue +106 -106
- package/src/components/errorMessage/index.vue +52 -52
- package/src/components/filter/filterSettings.vue +428 -422
- package/src/components/filter/index.vue +135 -135
- package/src/components/filter/parentDropdown.vue +73 -73
- package/src/components/icon/Icons.stories.js +7 -7
- package/src/components/icon/iconCollection.vue +53 -53
- package/src/components/icon/index.vue +122 -122
- package/src/components/iconWrapper/index.vue +156 -156
- package/src/components/infoCard/index.vue +30 -32
- package/src/components/infoText/index.vue +142 -137
- package/src/components/inputs/checkbox/Checkbox.stories.js +8 -8
- package/src/components/inputs/checkbox/index.vue +190 -180
- package/src/components/inputs/inputNumber/InputNumber.stories.js +41 -41
- package/src/components/inputs/inputNumber/index.vue +696 -696
- package/src/components/inputs/inputNumberQuestion/index.vue +185 -182
- package/src/components/inputs/inputText/InputText.stories.js +22 -22
- package/src/components/inputs/inputText/index.vue +337 -336
- package/src/components/inputs/radioButton/RadioButton.stories.js +16 -16
- package/src/components/inputs/radioButton/index.vue +222 -219
- package/src/components/inputs/searchInput/SearchInput.stories.js +8 -8
- package/src/components/inputs/searchInput/index.vue +127 -126
- package/src/components/inputs/select/index.vue +792 -791
- package/src/components/inputs/select/option/index.vue +124 -124
- package/src/components/inputs/select/select.stories.js +31 -32
- package/src/components/inputs/slider/index.vue +99 -99
- package/src/components/inputs/switchField/index.vue +220 -222
- package/src/components/inputs/textAreaInput/TextAreaInput.stories.js +57 -57
- package/src/components/inputs/textAreaInput/index.vue +171 -173
- package/src/components/inputs/toggle/Toggle.stories.js +14 -14
- package/src/components/inputs/toggle/index.vue +214 -217
- package/src/components/label/index.vue +82 -82
- package/src/components/markerItem/index.vue +68 -66
- package/src/components/modals/actionModal/index.vue +54 -54
- package/src/components/modals/infoModal/index.vue +39 -36
- package/src/components/modals/modal/index.vue +134 -134
- package/src/components/modals/modal/modal.stories.js +5 -5
- package/src/components/navigationTabs/index.vue +96 -94
- package/src/components/pageSubtitle/index.vue +55 -49
- package/src/components/pageTitle/index.vue +56 -56
- package/src/components/pagination/index.vue +92 -89
- package/src/components/progressBar/index.vue +107 -107
- package/src/components/projectMarker/index.vue +246 -244
- package/src/components/rangeSlider/Slider.vue +491 -465
- package/src/components/rangeSlider/index.vue +410 -410
- package/src/components/rangeSlider/utils/dom.js +5 -5
- package/src/components/selectedOptions/index.vue +119 -119
- package/src/components/sideMenu/index.vue +199 -199
- package/src/components/spinner/index.vue +57 -57
- package/src/components/tableDropdown/index.vue +520 -520
- package/src/components/tables/mainTable/index.vue +417 -400
- package/src/components/tables/viewTable/index.vue +171 -171
- package/src/components/threeDots/index.vue +340 -334
- package/src/components/videoThumbnail/index.vue +86 -86
- package/src/components/videoThumbnail/videoThumbnail.stories.js +14 -16
- package/src/helpers/numberConverter.js +2 -2
- package/src/helpers/translateLang.js +9 -9
- package/src/mixins/inputValidations.js +5 -5
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -17
@@ -11,50 +11,50 @@
|
|
11
11
|
<VerticalLabel>{{ label.name }}</VerticalLabel>
|
12
12
|
<BarSlider>
|
13
13
|
<Bar
|
14
|
+
:data-id="`slider_bar_${dataLocation}_${label.id}`"
|
14
15
|
@click.native.stop="
|
15
16
|
onBarRightClick({ event: $event, label, type: 'add' })
|
16
17
|
"
|
17
|
-
:data-id="`slider_bar_${dataLocation}_${label.id}`"
|
18
18
|
>
|
19
19
|
<SliderWrapper>
|
20
20
|
<Slider
|
21
21
|
v-for="(bar, index) in label.selectedTariffs"
|
22
|
-
:dataId="`slider_bar_item_${dataLocation}_${label.id}_${bar.name}`"
|
23
22
|
:key="bar.id"
|
24
|
-
:draggable="!disabled"
|
25
|
-
:resizable="!disabled"
|
26
23
|
:color="
|
27
24
|
hasOverlap && OverlapId.includes(label.id)
|
28
25
|
? '#ff5656'
|
29
26
|
: bar.color
|
30
27
|
"
|
31
|
-
:
|
32
|
-
:
|
28
|
+
:data-id="`slider_bar_item_${dataLocation}_${label.id}_${bar.name}`"
|
29
|
+
:draggable="!disabled"
|
33
30
|
:max="bar.max"
|
34
|
-
:
|
31
|
+
:min="bar.min"
|
32
|
+
:min-width="minWidth"
|
33
|
+
:resizable="!disabled"
|
35
34
|
:step="step"
|
36
|
-
:
|
37
|
-
:
|
38
|
-
|
35
|
+
:step-count="stepCount"
|
36
|
+
:sub-step-count="subStepCount"
|
37
|
+
:z="index"
|
38
|
+
@activated="onActivateBar({ item: bar })"
|
39
|
+
@click.native.stop="
|
40
|
+
onBarTariffClick({ item: bar, type: 'delete', label })
|
41
|
+
"
|
42
|
+
@deactivated="onDeactivateBar()"
|
43
|
+
@drag-stop="
|
39
44
|
onChange('drag', {
|
40
45
|
itemId: bar.id,
|
41
46
|
parentId: bar.parentId,
|
42
47
|
entityId: label.id,
|
43
|
-
...$event
|
48
|
+
...$event,
|
44
49
|
})
|
45
50
|
"
|
46
|
-
@
|
51
|
+
@resize-stop="
|
47
52
|
onChange('resize', {
|
48
53
|
itemId: bar.id,
|
49
54
|
entityId: label.id,
|
50
|
-
...$event
|
55
|
+
...$event,
|
51
56
|
})
|
52
57
|
"
|
53
|
-
@click.native.stop="
|
54
|
-
onBarTariffClick({ item: bar, type: 'delete', label })
|
55
|
-
"
|
56
|
-
@activated="onActivateBar({ item: bar })"
|
57
|
-
@deactivated="onDeactivateBar()"
|
58
58
|
>
|
59
59
|
<template #mr>
|
60
60
|
<HandleIcon />
|
@@ -66,10 +66,10 @@
|
|
66
66
|
</SliderWrapper>
|
67
67
|
</Bar>
|
68
68
|
<Ruler>
|
69
|
-
<RulerRule v-for="n in stepCount" :key="n"
|
69
|
+
<RulerRule v-for="n in stepCount" :key="n" />
|
70
70
|
</Ruler>
|
71
71
|
<SubRuler>
|
72
|
-
<RulerSubRule v-for="n in subStepCount" :key="n"
|
72
|
+
<RulerSubRule v-for="n in subStepCount" :key="n" />
|
73
73
|
</SubRuler>
|
74
74
|
<ErrorMessage
|
75
75
|
v-if="!canOverlap && hasOverlap && OverlapId.includes(label.id)"
|
@@ -79,13 +79,13 @@
|
|
79
79
|
</BarSlider>
|
80
80
|
</BarWrapper>
|
81
81
|
</BarContainer>
|
82
|
-
<
|
82
|
+
<BarOptionsContainer
|
83
83
|
v-if="showBarOptions"
|
84
|
-
:top="barOptionsPosition.y"
|
85
|
-
:left="barOptionsPosition.x"
|
86
84
|
ref="barDropdown"
|
85
|
+
:left="barOptionsPosition.x"
|
86
|
+
:top="barOptionsPosition.y"
|
87
87
|
>
|
88
|
-
<
|
88
|
+
<BarItemContainer
|
89
89
|
v-for="item in barOptionsList"
|
90
90
|
:key="item.id"
|
91
91
|
@click="
|
@@ -93,143 +93,143 @@
|
|
93
93
|
"
|
94
94
|
>
|
95
95
|
<AddIcon />
|
96
|
-
<
|
97
|
-
</
|
98
|
-
</
|
96
|
+
<BarItemText>{{ item.name }}</BarItemText>
|
97
|
+
</BarItemContainer>
|
98
|
+
</BarOptionsContainer>
|
99
99
|
</RangeSliderContainer>
|
100
100
|
</template>
|
101
101
|
|
102
102
|
<script>
|
103
|
-
import styled from 'vue3-styled-components'
|
104
|
-
import handleSVG from '../../assets/svgIcons/handle.svg'
|
105
|
-
import add from '../../assets/svgIcons/add_icon.svg'
|
106
|
-
|
107
|
-
import SliderComponent from './Slider'
|
108
|
-
|
109
|
-
const wrapperAttrs = { width: String, height: String }
|
110
|
-
const SliderWrapper = styled('div', wrapperAttrs)`
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
`
|
116
|
-
|
117
|
-
const sliderAttrs = { color: String, draggable: Boolean }
|
118
|
-
const Slider = styled(SliderComponent, sliderAttrs)`
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
`
|
127
|
-
|
128
|
-
const ErrorMessage = styled.p`
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
`
|
134
|
-
|
135
|
-
const Bar = styled.div`
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
`
|
143
|
-
|
144
|
-
const Ruler = styled.div`
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
`
|
149
|
-
|
150
|
-
const RulerRule = styled.div`
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
`
|
162
|
-
|
163
|
-
const SubRuler = styled.div`
|
164
|
-
|
165
|
-
|
166
|
-
`
|
167
|
-
|
168
|
-
const RulerSubRule = styled.div`
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
&:nth-child(odd) {
|
181
|
-
margin-top: -5px;
|
182
|
-
padding: 5px 0px;
|
183
|
-
}
|
184
|
-
`
|
185
|
-
|
186
|
-
const BarSlider = styled.div`
|
187
|
-
width: 100%;
|
188
|
-
`
|
189
|
-
|
190
|
-
const BarContainer = styled.div`
|
191
|
-
display: flex;
|
192
|
-
flex-direction: column;
|
193
|
-
`
|
194
|
-
|
195
|
-
const BarWrapper = styled.div`
|
196
|
-
display: flex;
|
197
|
-
flex-direction: row;
|
198
|
-
margin: 20px 0px;
|
199
|
-
align-items: center;
|
200
|
-
`
|
201
|
-
|
202
|
-
const RangeSliderContainer = styled.div`
|
203
|
-
display: flex;
|
204
|
-
position: relative;
|
205
|
-
padding: 20px 10px;
|
206
|
-
flex-direction: column;
|
207
|
-
user-select: none;
|
208
|
-
width: 100%;
|
209
|
-
`
|
210
|
-
|
211
|
-
const Labels = styled.div`
|
212
|
-
display: flex;
|
213
|
-
justify-content: space-between;
|
214
|
-
padding: 0px;
|
215
|
-
margin: 10px -100px 0px 100px;
|
216
|
-
width: calc(100% - 100px);
|
217
|
-
`
|
218
|
-
|
219
|
-
const Label = styled.div`
|
220
|
-
font-size: 80%;
|
221
|
-
display: flex;
|
222
|
-
width: 1px;
|
223
|
-
justify-content: center;
|
224
|
-
`
|
225
|
-
|
226
|
-
const VerticalLabel = styled.div`
|
227
|
-
text-align: left;
|
228
|
-
min-width: 100px;
|
229
|
-
font-size: 13px;
|
230
|
-
`
|
103
|
+
import styled from 'vue3-styled-components'
|
104
|
+
import handleSVG from '../../assets/svgIcons/handle.svg'
|
105
|
+
import add from '../../assets/svgIcons/add_icon.svg'
|
106
|
+
|
107
|
+
import SliderComponent from './Slider'
|
108
|
+
|
109
|
+
const wrapperAttrs = { width: String, height: String }
|
110
|
+
const SliderWrapper = styled('div', wrapperAttrs)`
|
111
|
+
position: relative;
|
112
|
+
display: flex;
|
113
|
+
height: ${(props) => props.height || '24px'};
|
114
|
+
width: ${(props) => props.width || '100%'};
|
115
|
+
`
|
116
|
+
|
117
|
+
const sliderAttrs = { color: String, draggable: Boolean }
|
118
|
+
const Slider = styled(SliderComponent, sliderAttrs)`
|
119
|
+
cursor: ${(props) => (props.draggable ? 'pointer' : 'not-allowed')};
|
120
|
+
opacity: 0.7;
|
121
|
+
display: flex;
|
122
|
+
justify-content: space-between;
|
123
|
+
align-items: center;
|
124
|
+
border: unset !important;
|
125
|
+
background-color: ${(props) => props.color};
|
126
|
+
`
|
127
|
+
|
128
|
+
const ErrorMessage = styled.p`
|
129
|
+
color: ${(props) => props.theme.colors.red};
|
130
|
+
font-style: italic;
|
131
|
+
font-size: 13px;
|
132
|
+
margin-top: 5px;
|
133
|
+
`
|
134
|
+
|
135
|
+
const Bar = styled.div`
|
136
|
+
display: flex;
|
137
|
+
margin-bottom: -30px;
|
138
|
+
margin-left: 1px;
|
139
|
+
background-color: #f6faff;
|
140
|
+
width: 100%;
|
141
|
+
background-color: ${(props) => props.theme.colors.gray1};
|
142
|
+
`
|
143
|
+
|
144
|
+
const Ruler = styled.div`
|
145
|
+
margin: 10px 0px -5px 0px;
|
146
|
+
display: flex;
|
147
|
+
overflow: hidden;
|
148
|
+
`
|
149
|
+
|
150
|
+
const RulerRule = styled.div`
|
151
|
+
border-left: solid 1px ${(props) => props.theme.colors.grey2};
|
152
|
+
border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
|
153
|
+
display: flex;
|
154
|
+
flex-grow: 1;
|
155
|
+
flex-shrink: 1;
|
156
|
+
padding: 10px 0px;
|
157
|
+
|
158
|
+
&:last-child {
|
159
|
+
border-right: solid 1px ${(props) => props.theme.colors.grey2};
|
160
|
+
}
|
161
|
+
`
|
162
|
+
|
163
|
+
const SubRuler = styled.div`
|
164
|
+
margin: -7px 0px -5px 0px;
|
165
|
+
display: flex;
|
166
|
+
`
|
167
|
+
|
168
|
+
const RulerSubRule = styled.div`
|
169
|
+
border-left: solid 1px ${(props) => props.theme.colors.grey2};
|
170
|
+
border-bottom: solid 1px ${(props) => props.theme.colors.grey2};
|
171
|
+
display: flex;
|
172
|
+
flex-grow: 1;
|
173
|
+
flex-shrink: 1;
|
174
|
+
padding: 3px 0px;
|
175
|
+
|
176
|
+
&:last-child {
|
177
|
+
border-right: solid 1px ${(props) => props.theme.colors.grey2};
|
178
|
+
}
|
231
179
|
|
232
|
-
|
180
|
+
&:nth-child(odd) {
|
181
|
+
margin-top: -5px;
|
182
|
+
padding: 5px 0px;
|
183
|
+
}
|
184
|
+
`
|
185
|
+
|
186
|
+
const BarSlider = styled.div`
|
187
|
+
width: 100%;
|
188
|
+
`
|
189
|
+
|
190
|
+
const BarContainer = styled.div`
|
191
|
+
display: flex;
|
192
|
+
flex-direction: column;
|
193
|
+
`
|
194
|
+
|
195
|
+
const BarWrapper = styled.div`
|
196
|
+
display: flex;
|
197
|
+
flex-direction: row;
|
198
|
+
margin: 20px 0px;
|
199
|
+
align-items: center;
|
200
|
+
`
|
201
|
+
|
202
|
+
const RangeSliderContainer = styled.div`
|
203
|
+
display: flex;
|
204
|
+
position: relative;
|
205
|
+
padding: 20px 10px;
|
206
|
+
flex-direction: column;
|
207
|
+
user-select: none;
|
208
|
+
width: 100%;
|
209
|
+
`
|
210
|
+
|
211
|
+
const Labels = styled.div`
|
212
|
+
display: flex;
|
213
|
+
justify-content: space-between;
|
214
|
+
padding: 0px;
|
215
|
+
margin: 10px -100px 0px 100px;
|
216
|
+
width: calc(100% - 100px);
|
217
|
+
`
|
218
|
+
|
219
|
+
const Label = styled.div`
|
220
|
+
font-size: 80%;
|
221
|
+
display: flex;
|
222
|
+
width: 1px;
|
223
|
+
justify-content: center;
|
224
|
+
`
|
225
|
+
|
226
|
+
const VerticalLabel = styled.div`
|
227
|
+
text-align: left;
|
228
|
+
min-width: 100px;
|
229
|
+
font-size: 13px;
|
230
|
+
`
|
231
|
+
|
232
|
+
const AddIcon = styled(add)`
|
233
233
|
width: 33px;
|
234
234
|
height: 29px;
|
235
235
|
fill: black
|
@@ -237,281 +237,281 @@ const AddIcon = styled(add)`
|
|
237
237
|
margin-top: -10px;
|
238
238
|
`
|
239
239
|
|
240
|
-
const HandleIcon = styled(handleSVG)`
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
`
|
245
|
-
|
246
|
-
const BarOptionAttrs = { top: Number, left: Number }
|
247
|
-
const BarOptionsContainer = styled('div', BarOptionAttrs)`
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
`
|
258
|
-
|
259
|
-
const BarItemContainer = styled.div`
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
}
|
271
|
-
`
|
272
|
-
|
273
|
-
const BarItemText = styled.div`
|
274
|
-
font-size: 13px;
|
275
|
-
`
|
276
|
-
|
277
|
-
export default {
|
278
|
-
name: 'RangeSlider',
|
279
|
-
props: {
|
280
|
-
dataLocation: { type: String, default: '' },
|
281
|
-
tariffItems: { type: Array, default: () => [] },
|
282
|
-
labels: { type: Array, default: () => [] },
|
283
|
-
rangeMargin: { type: Number, default: 1 },
|
284
|
-
step: { type: Number, default: 1 },
|
285
|
-
minWidth: { type: Number, default: 1 },
|
286
|
-
canOverlap: { type: Boolean, default: true },
|
287
|
-
disabled: { type: Boolean, default: false }
|
288
|
-
},
|
289
|
-
components: {
|
290
|
-
Bar,
|
291
|
-
Label,
|
292
|
-
Labels,
|
293
|
-
Ruler,
|
294
|
-
Slider,
|
295
|
-
AddIcon,
|
296
|
-
SubRuler,
|
297
|
-
BarSlider,
|
298
|
-
RulerRule,
|
299
|
-
HandleIcon,
|
300
|
-
BarWrapper,
|
301
|
-
ErrorMessage,
|
302
|
-
RulerSubRule,
|
303
|
-
BarContainer,
|
304
|
-
SliderWrapper,
|
305
|
-
VerticalLabel,
|
306
|
-
RangeSliderContainer,
|
307
|
-
BarOptionsContainer,
|
308
|
-
BarItemContainer,
|
309
|
-
BarItemText
|
310
|
-
},
|
311
|
-
data() {
|
312
|
-
return {
|
313
|
-
showBarOptions: false,
|
314
|
-
barOptionsPosition: { x: 0, y: 0 },
|
315
|
-
barOptionsList: [],
|
316
|
-
barOptionsType: null, // can be "add" or "delete"
|
317
|
-
activeLabel: null,
|
318
|
-
activeItem: null,
|
319
|
-
OverlapId: [],
|
320
|
-
hasOverlap: false
|
240
|
+
const HandleIcon = styled(handleSVG)`
|
241
|
+
width: 13px;
|
242
|
+
min-width: 0;
|
243
|
+
margin: -6px;
|
244
|
+
`
|
245
|
+
|
246
|
+
const BarOptionAttrs = { top: Number, left: Number }
|
247
|
+
const BarOptionsContainer = styled('div', BarOptionAttrs)`
|
248
|
+
display: grid;
|
249
|
+
position: fixed;
|
250
|
+
z-index: 9999;
|
251
|
+
border-radius: 4px;
|
252
|
+
background-color: ${(props) => props.theme.colors.white};
|
253
|
+
padding: 6px 10px;
|
254
|
+
border: 1px solid ${(props) => props.theme.colors.grey4};
|
255
|
+
top: ${(props) => props.top + 'px'};
|
256
|
+
left: ${(props) => props.left + 'px'};
|
257
|
+
`
|
258
|
+
|
259
|
+
const BarItemContainer = styled.div`
|
260
|
+
display: grid;
|
261
|
+
grid-template-columns: auto 1fr;
|
262
|
+
grid-gap: 12px;
|
263
|
+
align-items: center;
|
264
|
+
cursor: pointer;
|
265
|
+
padding: 6px 10px;
|
266
|
+
border-radius: 4px;
|
267
|
+
|
268
|
+
&:hover {
|
269
|
+
background-color: ${(props) => props.theme.colors.lightGray};
|
321
270
|
}
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
271
|
+
`
|
272
|
+
|
273
|
+
const BarItemText = styled.div`
|
274
|
+
font-size: 13px;
|
275
|
+
`
|
276
|
+
|
277
|
+
export default {
|
278
|
+
name: 'RangeSlider',
|
279
|
+
components: {
|
280
|
+
Bar,
|
281
|
+
Label,
|
282
|
+
Labels,
|
283
|
+
Ruler,
|
284
|
+
Slider,
|
285
|
+
AddIcon,
|
286
|
+
SubRuler,
|
287
|
+
BarSlider,
|
288
|
+
RulerRule,
|
289
|
+
HandleIcon,
|
290
|
+
BarWrapper,
|
291
|
+
ErrorMessage,
|
292
|
+
RulerSubRule,
|
293
|
+
BarContainer,
|
294
|
+
SliderWrapper,
|
295
|
+
VerticalLabel,
|
296
|
+
RangeSliderContainer,
|
297
|
+
BarOptionsContainer,
|
298
|
+
BarItemContainer,
|
299
|
+
BarItemText,
|
328
300
|
},
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
301
|
+
props: {
|
302
|
+
dataLocation: { type: String, default: '' },
|
303
|
+
tariffItems: { type: Array, default: () => [] },
|
304
|
+
labels: { type: Array, default: () => [] },
|
305
|
+
rangeMargin: { type: Number, default: 1 },
|
306
|
+
step: { type: Number, default: 1 },
|
307
|
+
minWidth: { type: Number, default: 1 },
|
308
|
+
canOverlap: { type: Boolean, default: true },
|
309
|
+
disabled: { type: Boolean, default: false },
|
333
310
|
},
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
311
|
+
data() {
|
312
|
+
return {
|
313
|
+
showBarOptions: false,
|
314
|
+
barOptionsPosition: { x: 0, y: 0 },
|
315
|
+
barOptionsList: [],
|
316
|
+
barOptionsType: null, // can be "add" or "delete"
|
317
|
+
activeLabel: null,
|
318
|
+
activeItem: null,
|
319
|
+
OverlapId: [],
|
320
|
+
hasOverlap: false,
|
321
|
+
}
|
344
322
|
},
|
345
|
-
|
346
|
-
|
323
|
+
computed: {
|
324
|
+
maximum() {
|
325
|
+
if (!this.labels.length) return
|
326
|
+
|
327
|
+
return this.topLabels.at(-1)
|
328
|
+
},
|
329
|
+
minimum() {
|
330
|
+
if (!this.labels.length) return
|
331
|
+
|
332
|
+
return this.topLabels[0]
|
333
|
+
},
|
334
|
+
topLabels() {
|
335
|
+
if (!this.labels.length) return
|
336
|
+
const labels = this.labels.find((label) => label.placement === 'top')
|
337
|
+
|
338
|
+
return labels ? labels.value : []
|
339
|
+
},
|
340
|
+
leftLabels() {
|
341
|
+
if (!this.labels.length) return
|
342
|
+
const labels = this.labels.find((label) => label.placement === 'left')
|
343
|
+
return labels ? labels.value : []
|
344
|
+
},
|
345
|
+
stepCount() {
|
346
|
+
let labels = this.topLabels || []
|
347
|
+
|
348
|
+
if (labels.length) {
|
349
|
+
return labels.length - 1
|
350
|
+
}
|
347
351
|
|
348
|
-
|
349
|
-
|
350
|
-
|
352
|
+
return Math.floor((this.maximum - this.minimum) / this.step)
|
353
|
+
},
|
354
|
+
subStepCount() {
|
355
|
+
let labels = this.topLabels || []
|
356
|
+
|
357
|
+
if (labels.length && this.step) {
|
358
|
+
return (this.maximum - this.minimum) / this.step
|
359
|
+
}
|
351
360
|
|
352
|
-
|
361
|
+
return 0
|
362
|
+
},
|
353
363
|
},
|
354
|
-
|
355
|
-
|
364
|
+
watch: {
|
365
|
+
labels(newVal, oldVal) {
|
366
|
+
const overlapContainer = []
|
367
|
+
|
368
|
+
//check items for overlap
|
369
|
+
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
|
370
|
+
const labels = newVal.find((label) => label.placement === 'left')
|
371
|
+
|
372
|
+
if (labels) {
|
373
|
+
labels.value.forEach((label) => {
|
374
|
+
label.selectedTariffs.forEach((tariff) => {
|
375
|
+
const hasOverlap = this.checkOverlap(
|
376
|
+
tariff,
|
377
|
+
label.selectedTariffs
|
378
|
+
)
|
379
|
+
|
380
|
+
if (hasOverlap) overlapContainer.push(label.id)
|
381
|
+
})
|
382
|
+
})
|
383
|
+
}
|
356
384
|
|
357
|
-
|
358
|
-
return (this.maximum - this.minimum) / this.step
|
359
|
-
}
|
385
|
+
const hasOverlap = overlapContainer.length > 0
|
360
386
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
this.$emit(type, value)
|
367
|
-
},
|
368
|
-
checkOverlap(value, tariffs) {
|
369
|
-
// Check if the tariffs overlap
|
370
|
-
const min = parseFloat(value.min)
|
371
|
-
const max = parseFloat(value.max)
|
372
|
-
|
373
|
-
return tariffs.some((tariff) => {
|
374
|
-
if (tariff.id === value.itemId || tariff.id === value.id) return false
|
375
|
-
|
376
|
-
return (
|
377
|
-
min === tariff.min ||
|
378
|
-
max === tariff.max ||
|
379
|
-
(min > tariff.min && min < tariff.max) ||
|
380
|
-
(max > tariff.min && max < tariff.max) ||
|
381
|
-
(min < tariff.min && max > tariff.max)
|
382
|
-
)
|
383
|
-
})
|
384
|
-
},
|
385
|
-
barOptionLabel(value) {
|
386
|
-
if (this.barOptionsType === 'add')
|
387
|
-
return `${this.$gettext('Add')} ${value}`
|
387
|
+
if (!hasOverlap) {
|
388
|
+
this.OverlapId = []
|
389
|
+
} else {
|
390
|
+
this.OverlapId = [...new Set(overlapContainer)]
|
391
|
+
}
|
388
392
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
this.activeItem = item
|
394
|
-
document.addEventListener('keydown', this.onKeyDownDelete)
|
393
|
+
this.hasOverlap = hasOverlap
|
394
|
+
this.$emit('has-overlap', hasOverlap)
|
395
|
+
}
|
396
|
+
},
|
395
397
|
},
|
396
|
-
|
397
|
-
|
398
|
-
this.
|
398
|
+
beforeDestroy() {
|
399
|
+
// Remove the global click event listener to prevent memory leaks
|
400
|
+
document.removeEventListener('click', this.handleOutsideClick)
|
399
401
|
document.removeEventListener('keydown', this.onKeyDownDelete)
|
400
402
|
},
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
403
|
+
methods: {
|
404
|
+
onChange(type, value) {
|
405
|
+
this.$emit(type, value)
|
406
|
+
},
|
407
|
+
checkOverlap(value, tariffs) {
|
408
|
+
// Check if the tariffs overlap
|
409
|
+
const min = parseFloat(value.min)
|
410
|
+
const max = parseFloat(value.max)
|
411
|
+
|
412
|
+
return tariffs.some((tariff) => {
|
413
|
+
if (tariff.id === value.itemId || tariff.id === value.id) return false
|
414
|
+
|
415
|
+
return (
|
416
|
+
min === tariff.min ||
|
417
|
+
max === tariff.max ||
|
418
|
+
(min > tariff.min && min < tariff.max) ||
|
419
|
+
(max > tariff.min && max < tariff.max) ||
|
420
|
+
(min < tariff.min && max > tariff.max)
|
421
|
+
)
|
411
422
|
})
|
423
|
+
},
|
424
|
+
barOptionLabel(value) {
|
425
|
+
if (this.barOptionsType === 'add')
|
426
|
+
return `${this.$gettext('Add')} ${value}`
|
427
|
+
|
428
|
+
return `${this.$gettext('Remove')} ${value}`
|
429
|
+
},
|
430
|
+
onActivateBar({ item }) {
|
431
|
+
this.$emit('activate')
|
432
|
+
this.activeItem = item
|
433
|
+
document.addEventListener('keydown', this.onKeyDownDelete)
|
434
|
+
},
|
435
|
+
onDeactivateBar() {
|
436
|
+
this.$emit('deactivate')
|
412
437
|
this.activeItem = null
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
438
|
+
document.removeEventListener('keydown', this.onKeyDownDelete)
|
439
|
+
},
|
440
|
+
onKeyDownDelete(event) {
|
441
|
+
// Check if the pressed key is the Delete or Backspace key
|
442
|
+
if (
|
443
|
+
(event.key === 'Delete' || event.key === 'Backspace') &&
|
444
|
+
this.activeItem
|
445
|
+
) {
|
446
|
+
this.$emit('on-bar-tariff-click', {
|
447
|
+
type: 'delete',
|
448
|
+
item: this.activeItem,
|
449
|
+
label: this.activeLabel,
|
450
|
+
})
|
451
|
+
this.activeItem = null
|
452
|
+
}
|
453
|
+
},
|
454
|
+
onBarTariffClick({ item, type, label }) {
|
455
|
+
if (this.disabled) return
|
430
456
|
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
}
|
436
|
-
})
|
437
|
-
} else {
|
438
|
-
// add based on the index in the chart.
|
439
|
-
this.barOptionsList.push({
|
440
|
-
name: bar.name,
|
441
|
-
id: bar.id
|
457
|
+
this.$emit('on-bar-tariff-click', {
|
458
|
+
type,
|
459
|
+
item,
|
460
|
+
label,
|
442
461
|
})
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
if (this.disabled) return
|
447
|
-
|
448
|
-
// type can be "add", "delete"
|
449
|
-
// if "add", show all tariffItems for the group
|
450
|
-
// if "delete", only show the delete with the tariff name
|
451
|
-
event.preventDefault()
|
452
|
-
this.activeLabel = label
|
453
|
-
this.barOptionsType = type
|
454
|
-
this.setBarOptions(bar)
|
455
|
-
|
456
|
-
if (this.barOptionsList.length) {
|
457
|
-
this.showBarOptions = true
|
458
|
-
this.barOptionsPosition = { x: event.clientX, y: event.clientY }
|
459
|
-
document.addEventListener('click', this.handleOutsideClick)
|
460
|
-
} else {
|
461
|
-
this.showBarOptions = false
|
462
|
-
}
|
463
|
-
},
|
464
|
-
handleOutsideClick(event) {
|
465
|
-
// Check if the click occurred outside the dropdown
|
466
|
-
if (
|
467
|
-
this.$refs.barDropdown &&
|
468
|
-
!this.$refs.barDropdown.$el.contains(event.target)
|
469
|
-
) {
|
470
|
-
// Hide the dropdown
|
462
|
+
|
463
|
+
this.activeLabel = label
|
464
|
+
this.barOptionsType = type
|
471
465
|
this.showBarOptions = false
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
if (JSON.stringify(newVal) !== JSON.stringify(oldVal)) {
|
488
|
-
const labels = newVal.find((label) => label.placement === 'left')
|
489
|
-
|
490
|
-
if (labels) {
|
491
|
-
labels.value.forEach((label) => {
|
492
|
-
label.selectedTariffs.forEach((tariff) => {
|
493
|
-
const hasOverlap = this.checkOverlap(
|
494
|
-
tariff,
|
495
|
-
label.selectedTariffs
|
496
|
-
)
|
497
|
-
|
498
|
-
if (hasOverlap) overlapContainer.push(label.id)
|
499
|
-
})
|
466
|
+
},
|
467
|
+
setBarOptions(bar) {
|
468
|
+
this.barOptionsList = []
|
469
|
+
|
470
|
+
if (this.barOptionsType === 'add') {
|
471
|
+
this.tariffItems.forEach((item) => {
|
472
|
+
if (item.name && item.name.length) {
|
473
|
+
this.barOptionsList.push(item)
|
474
|
+
}
|
475
|
+
})
|
476
|
+
} else {
|
477
|
+
// add based on the index in the chart.
|
478
|
+
this.barOptionsList.push({
|
479
|
+
name: bar.name,
|
480
|
+
id: bar.id,
|
500
481
|
})
|
501
482
|
}
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
483
|
+
},
|
484
|
+
onBarRightClick({ event, label, type, bar }) {
|
485
|
+
if (this.disabled) return
|
486
|
+
|
487
|
+
// type can be "add", "delete"
|
488
|
+
// if "add", show all tariffItems for the group
|
489
|
+
// if "delete", only show the delete with the tariff name
|
490
|
+
event.preventDefault()
|
491
|
+
this.activeLabel = label
|
492
|
+
this.barOptionsType = type
|
493
|
+
this.setBarOptions(bar)
|
494
|
+
|
495
|
+
if (this.barOptionsList.length) {
|
496
|
+
this.showBarOptions = true
|
497
|
+
this.barOptionsPosition = { x: event.clientX, y: event.clientY }
|
498
|
+
document.addEventListener('click', this.handleOutsideClick)
|
507
499
|
} else {
|
508
|
-
this.
|
500
|
+
this.showBarOptions = false
|
509
501
|
}
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
502
|
+
},
|
503
|
+
handleOutsideClick(event) {
|
504
|
+
// Check if the click occurred outside the dropdown
|
505
|
+
if (
|
506
|
+
this.$refs.barDropdown &&
|
507
|
+
!this.$refs.barDropdown.$el.contains(event.target)
|
508
|
+
) {
|
509
|
+
// Hide the dropdown
|
510
|
+
this.showBarOptions = false
|
511
|
+
// Remove the global click event listener
|
512
|
+
document.removeEventListener('click', this.handleOutsideClick)
|
513
|
+
}
|
514
|
+
},
|
515
|
+
},
|
515
516
|
}
|
516
|
-
}
|
517
517
|
</script>
|