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