@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.
Files changed (67) hide show
  1. package/.prettierrc +7 -0
  2. package/package.json +20 -6
  3. package/public/favicon.ico +0 -0
  4. package/public/index.html +17 -0
  5. package/src/App.vue +70 -75
  6. package/src/assets/svgIcons/copy.svg +10 -0
  7. package/src/components/addNewButton/index.vue +27 -24
  8. package/src/components/banner/actionBanner/index.vue +30 -32
  9. package/src/components/banner/banner/index.vue +80 -88
  10. package/src/components/banner/infoBanner/index.vue +44 -36
  11. package/src/components/buttons/buttonIcon/index.vue +78 -83
  12. package/src/components/buttons/closeButton/index.vue +26 -26
  13. package/src/components/buttons/mainButton/index.vue +76 -80
  14. package/src/components/card/index.vue +52 -56
  15. package/src/components/collapsableInfoText/index.vue +76 -81
  16. package/src/components/deleteIcon/index.vue +28 -31
  17. package/src/components/draggableInputHandle/index.vue +17 -20
  18. package/src/components/dropdown/Dropdown.stories.js +8 -8
  19. package/src/components/dropdown/index.vue +72 -75
  20. package/src/components/errorMessage/index.vue +23 -23
  21. package/src/components/filter/filterSettings.vue +329 -349
  22. package/src/components/filter/index.vue +130 -130
  23. package/src/components/filter/parentDropdown.vue +40 -43
  24. package/src/components/icon/Icons.stories.js +4 -4
  25. package/src/components/icon/iconCache.js +1 -1
  26. package/src/components/icon/iconCollection.vue +37 -40
  27. package/src/components/icon/index.vue +65 -72
  28. package/src/components/iconWrapper/index.vue +118 -122
  29. package/src/components/infoCard/index.vue +17 -20
  30. package/src/components/infoText/index.vue +82 -88
  31. package/src/components/inputs/checkbox/index.vue +94 -91
  32. package/src/components/inputs/inputNumber/index.vue +488 -508
  33. package/src/components/inputs/inputNumberQuestion/index.vue +124 -127
  34. package/src/components/inputs/inputText/index.vue +252 -265
  35. package/src/components/inputs/radioButton/index.vue +120 -135
  36. package/src/components/inputs/searchInput/index.vue +81 -84
  37. package/src/components/inputs/select/index.vue +631 -644
  38. package/src/components/inputs/select/option/index.vue +91 -91
  39. package/src/components/inputs/select/select.stories.js +7 -7
  40. package/src/components/inputs/slider/index.vue +46 -46
  41. package/src/components/inputs/switchField/index.vue +152 -159
  42. package/src/components/inputs/textAreaInput/index.vue +113 -120
  43. package/src/components/inputs/toggle/index.vue +127 -137
  44. package/src/components/label/index.vue +61 -64
  45. package/src/components/markerItem/index.vue +40 -40
  46. package/src/components/modals/actionModal/index.vue +29 -32
  47. package/src/components/modals/infoModal/index.vue +27 -34
  48. package/src/components/modals/modal/index.vue +80 -88
  49. package/src/components/navigationTabs/index.vue +47 -50
  50. package/src/components/pageSubtitle/index.vue +29 -33
  51. package/src/components/pageTitle/index.vue +39 -47
  52. package/src/components/pagination/index.vue +62 -64
  53. package/src/components/progressBar/index.vue +67 -70
  54. package/src/components/projectMarker/index.vue +163 -172
  55. package/src/components/rangeSlider/Slider.vue +449 -449
  56. package/src/components/rangeSlider/index.vue +270 -282
  57. package/src/components/rangeSlider/utils/dom.js +3 -3
  58. package/src/components/selectedOptions/index.vue +51 -51
  59. package/src/components/sideMenu/index.vue +109 -117
  60. package/src/components/spinner/index.vue +34 -37
  61. package/src/components/tableDropdown/index.vue +326 -343
  62. package/src/components/tables/mainTable/index.vue +106 -109
  63. package/src/components/tables/viewTable/index.vue +92 -105
  64. package/src/components/threeDots/index.vue +171 -174
  65. package/src/components/videoThumbnail/index.vue +59 -67
  66. package/src/components/videoThumbnail/videoThumbnail.stories.js +6 -6
  67. 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
- :data-id="`slider_bar_item_${dataLocation}_${label.id}_${bar.name}`"
35
- :draggable="!disabled"
36
- :max="bar.max"
31
+ :minWidth="minWidth"
37
32
  :min="bar.min"
38
- :min-width="minWidth"
39
- :resizable="!disabled"
40
- :step="step"
41
- :step-count="stepCount"
42
- :sub-step-count="subStepCount"
33
+ :max="bar.max"
43
34
  :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="
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
- @resize-stop="
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
- <BarOptionsContainer
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
- <BarItemContainer
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
- <BarItemText>{{ item.name }}</BarItemText>
109
- </BarItemContainer>
110
- </BarOptionsContainer>
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
- import styled from 'vue3-styled-components'
116
- import handleSVG from '../../assets/svgIcons/handle.svg'
117
- import add from '../../assets/svgIcons/add_icon.svg'
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
- import SliderComponent from './Slider'
107
+ import SliderComponent from './Slider'
120
108
 
121
- const wrapperAttrs = { width: String, height: String }
122
- const SliderWrapper = styled('div', wrapperAttrs)`
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
- const sliderAttrs = { color: String, draggable: Boolean }
130
- const Slider = styled(SliderComponent, sliderAttrs)`
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
- const ErrorMessage = styled.p`
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
- const Bar = styled.div`
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
- const Ruler = styled.div`
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
- const RulerRule = styled.div`
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
- const SubRuler = styled.div`
163
+ const SubRuler = styled.div`
176
164
  margin: -7px 0px -5px 0px;
177
165
  display: flex;
178
166
  `
179
167
 
180
- const RulerSubRule = styled.div`
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
- const BarSlider = styled.div`
186
+ const BarSlider = styled.div`
199
187
  width: 100%;
200
188
  `
201
189
 
202
- const BarContainer = styled.div`
190
+ const BarContainer = styled.div`
203
191
  display: flex;
204
192
  flex-direction: column;
205
193
  `
206
194
 
207
- const BarWrapper = styled.div`
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
- const RangeSliderContainer = styled.div`
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
- const Labels = styled.div`
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
- const Label = styled.div`
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
- const VerticalLabel = styled.div`
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
- const AddIcon = styled(add)`
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
- const HandleIcon = styled(handleSVG)`
240
+ const HandleIcon = styled(handleSVG)`
253
241
  width: 13px;
254
242
  min-width: 0;
255
243
  margin: -6px;
256
244
  `
257
245
 
258
- const BarOptionAttrs = { top: Number, left: Number }
259
- const BarOptionsContainer = styled('div', BarOptionAttrs)`
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
- const BarItemContainer = styled.div`
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
- const BarItemText = styled.div`
273
+ const BarItemText = styled.div`
286
274
  font-size: 13px;
287
275
  `
288
276
 
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
312
- },
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 }
322
- },
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
- }
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
- 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
- }
329
+ minimum() {
330
+ if (!this.labels.length) return
363
331
 
364
- return Math.floor((this.maximum - this.minimum) / this.step)
365
- },
366
- subStepCount() {
367
- let labels = this.topLabels || []
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
- if (labels.length && this.step) {
370
- return (this.maximum - this.minimum) / this.step
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
- return 0
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
- 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
- }
354
+ subStepCount() {
355
+ let labels = this.topLabels || []
396
356
 
397
- const hasOverlap = overlapContainer.length > 0
357
+ if (labels.length && this.step) {
358
+ return (this.maximum - this.minimum) / this.step
359
+ }
398
360
 
399
- if (!hasOverlap) {
400
- this.OverlapId = []
401
- } else {
402
- this.OverlapId = [...new Set(overlapContainer)]
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
- this.hasOverlap = hasOverlap
406
- this.$emit('has-overlap', hasOverlap)
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
- beforeDestroy() {
411
- // Remove the global click event listener to prevent memory leaks
412
- document.removeEventListener('click', this.handleOutsideClick)
396
+ onDeactivateBar() {
397
+ this.$emit('deactivate')
398
+ this.activeItem = null
413
399
  document.removeEventListener('keydown', this.onKeyDownDelete)
414
400
  },
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
- )
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
- 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
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
- this.$emit('on-bar-tariff-click', {
470
- type,
471
- item,
472
- label
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
- this.activeLabel = label
476
- this.barOptionsType = type
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
- 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
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
- 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)
502
+
503
+ const hasOverlap = overlapContainer.length > 0
504
+
505
+ if (!hasOverlap) {
506
+ this.OverlapId = []
511
507
  } else {
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)
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>