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