@eturnity/eturnity_reusable_components 7.4.4-EPDM-7260.4 → 7.4.4-EPDM-7260.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eturnity/eturnity_reusable_components",
3
- "version": "7.4.4-EPDM-7260.4",
3
+ "version": "7.4.4-EPDM-7260.6",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vue-cli-service serve",
@@ -27,7 +27,7 @@
27
27
  <input-container
28
28
  ref="inputElement"
29
29
  :placeholder="placeholder"
30
- :isError="isError"
30
+ :isError="hasError"
31
31
  :inputWidth="inputWidth"
32
32
  :minWidth="minWidth"
33
33
  :inputHeight="inputHeight"
@@ -53,12 +53,12 @@
53
53
  >
54
54
  <icon name="current_variant" size="20px" />
55
55
  </icon-wrapper>
56
- <icon-wrapper v-if="isError" size="16px">
56
+ <icon-wrapper v-if="hasError" size="16px">
57
57
  <icon name="warning" size="16px" cursor="default" />
58
58
  </icon-wrapper>
59
59
  </icon-container>
60
- <error-message v-if="isError && errorMessage">{{
61
- errorMessage
60
+ <error-message v-if="hasError && hasErrorMessage">{{
61
+ dynamicErrorMessage
62
62
  }}</error-message>
63
63
  </input-error-wrapper>
64
64
  </input-wrapper>
@@ -70,6 +70,7 @@ import styled from 'vue-styled-components'
70
70
  import InfoText from '../../infoText'
71
71
  import Icon from '../../icon'
72
72
  import ErrorMessage from '../../errorMessage'
73
+ import InputValidations from '../../../mixins/inputValidations.js'
73
74
 
74
75
  const Container = styled.div`
75
76
  width: 100%;
@@ -229,11 +230,25 @@ export default {
229
230
  InputErrorWrapper,
230
231
  optionalLabel
231
232
  },
233
+ mixins: [InputValidations],
232
234
  data() {
233
235
  return {
234
236
  inputTypeData: 'text'
235
237
  }
236
238
  },
239
+ computed: {
240
+ hasError() {
241
+ return this.isError || this.error
242
+ },
243
+ hasErrorMessage() {
244
+ return (
245
+ (this.errorMessage && this.errorMessage.length > 0) || this.errMessage
246
+ )
247
+ },
248
+ dynamicErrorMessage() {
249
+ return this.errMessage || this.errorMessage
250
+ }
251
+ },
237
252
  props: {
238
253
  placeholder: {
239
254
  required: false,
@@ -332,6 +347,7 @@ export default {
332
347
  this.$emit('input-change', $event)
333
348
  },
334
349
  onInputBlur($event) {
350
+ this.validateInput($event.target.value)
335
351
  this.$emit('input-blur', $event.target.value)
336
352
  },
337
353
  toggleShowPassword() {
@@ -3,14 +3,14 @@
3
3
  :style="style"
4
4
  :class="className"
5
5
  @mousedown="elementMouseDown"
6
- @touchstart="elementTouchDown"
6
+ @touchend="elementTouchDown"
7
7
  >
8
8
  <div
9
9
  v-for="handle in actualHandles"
10
10
  :key="handle"
11
11
  :style="{ display: enabled ? 'block' : 'none' }"
12
12
  @mousedown.stop.prevent="handleDown(handle, $event)"
13
- @touchstart.stop.prevent="handleTouchDown(handle, $event)"
13
+ @touchend.stop.prevent="handleTouchDown(handle, $event)"
14
14
  >
15
15
  <slot :name="handle"></slot>
16
16
  </div>
@@ -443,8 +443,6 @@ export default {
443
443
  handleUp() {
444
444
  this.handle = null
445
445
 
446
- this.resetBoundsAndMouseState()
447
-
448
446
  this.dragEnable = false
449
447
  this.resizeEnable = false
450
448
 
@@ -470,7 +468,7 @@ export default {
470
468
  const val = value / this.pxPerStep
471
469
 
472
470
  const int = 1.0 / this.step
473
- return (Math.floor(val * int) / int).toFixed(2)
471
+ return (Math.round(val * int) / int).toFixed(2)
474
472
  }
475
473
  },
476
474
  computed: {
@@ -18,7 +18,7 @@
18
18
  <SliderWrapper>
19
19
  <Slider
20
20
  v-for="(bar, index) in label.selectedTariffs"
21
- :key="index"
21
+ :key="bar.id"
22
22
  :active="!disabled"
23
23
  :draggable="!disabled"
24
24
  :resizable="!disabled"
@@ -242,9 +242,9 @@ const VerticalLabel = styled.div`
242
242
  `
243
243
 
244
244
  const HandleIcon = styled(Icon)`
245
- width: auto;
245
+ width: 12px;
246
246
  min-width: 0;
247
- margin: -12px;
247
+ margin: -6px;
248
248
  `
249
249
 
250
250
  const BarOptionAttrs = { top: Number, left: Number }
@@ -370,15 +370,21 @@ export default {
370
370
 
371
371
  this.hasOverlap = this.checkOverlap(value, tariffs)
372
372
  this.OverlapId = this.hasOverlap ? entityId : null
373
+
374
+ this.$emit('has-overlap', this.hasOverlap)
373
375
  },
374
376
  checkOverlap(value, tariffs) {
375
377
  // Check if the tariffs overlap
376
- const { itemId, min, max } = value
378
+ const { itemId } = value
379
+ const min = parseFloat(value.min)
380
+ const max = parseFloat(value.max)
377
381
 
378
382
  return tariffs.some((tariff) => {
379
383
  if (tariff.id === itemId) return false
380
384
 
381
385
  return (
386
+ (min === tariff.min ) ||
387
+ (max === tariff.max) ||
382
388
  (min > tariff.min && min < tariff.max) ||
383
389
  (max > tariff.min && max < tariff.max) ||
384
390
  (min < tariff.min && max > tariff.max)
@@ -419,6 +425,8 @@ export default {
419
425
  item,
420
426
  label: this.activeLabel
421
427
  })
428
+
429
+ this.hasOverlap = this.checkOverlap(item, this.activeLabel.selectedTariffs)
422
430
  this.showBarOptions = false
423
431
  },
424
432
  setBarOptions(bar) {
@@ -434,8 +442,7 @@ export default {
434
442
  // add based on the index in the chart.
435
443
  this.barOptionsList.push({
436
444
  name: bar.name,
437
- id: bar.id,
438
- index: bar.index
445
+ id: bar.id
439
446
  })
440
447
  }
441
448
  },
@@ -446,8 +453,8 @@ export default {
446
453
  event.preventDefault()
447
454
  this.activeLabel = label
448
455
  this.barOptionsType = type
449
- // need to pass the index to setBarOptions in case it's 'add'
450
456
  this.setBarOptions(bar)
457
+
451
458
  if (this.barOptionsList.length) {
452
459
  this.showBarOptions = true
453
460
  this.barOptionsPosition = { x: event.clientX, y: event.clientY }
@@ -0,0 +1,28 @@
1
+ export const currencyMapping = (data) => {
2
+ let currency
3
+
4
+ switch (data) {
5
+ case 'EUR':
6
+ currency = 'ct'
7
+ break
8
+ case 'CHF':
9
+ currency = 'Rp.'
10
+ break
11
+ case 'SEK':
12
+ currency = 'öre'
13
+ break
14
+ case 'GBP':
15
+ currency = 'p'
16
+ break
17
+ case 'USD':
18
+ currency = 'ct'
19
+ break
20
+ case 'DKK':
21
+ currency = 'øre'
22
+ break
23
+ default:
24
+ currency = 'ct'
25
+ }
26
+
27
+ return currency
28
+ }
@@ -0,0 +1,96 @@
1
+ export default {
2
+ props: {
3
+ rules: {
4
+ type: Array,
5
+ required: false,
6
+ default: () => []
7
+ }
8
+ },
9
+ data() {
10
+ return {
11
+ error: false,
12
+ errMessage: ''
13
+ }
14
+ },
15
+ methods: {
16
+ validateInput(value) {
17
+ this.resetError()
18
+
19
+ this.rules.forEach((rule) => {
20
+ switch (rule) {
21
+ case 'required':
22
+ if (value) {
23
+ this.error = true
24
+ this.errMessage = this.$gettext('Required field')
25
+ }
26
+ break
27
+ case 'number':
28
+ this.checkNumber(value)
29
+ break
30
+ case 'string':
31
+ this.checkString(value)
32
+ break
33
+ case 'email':
34
+ this.checkEmail(value)
35
+ break
36
+ case 'phone':
37
+ this.checkPhone(value)
38
+ break
39
+ case 'year':
40
+ this.checkYear(value)
41
+ break
42
+ }
43
+ })
44
+ },
45
+
46
+ resetError() {
47
+ this.error = false
48
+ this.errMessage = ''
49
+ },
50
+
51
+ checkNumber(value) {
52
+ this.resetError()
53
+
54
+ if (value && isNaN(value)) {
55
+ this.error = true
56
+ this.errMessage = this.$gettext('invalid_number')
57
+ }
58
+ },
59
+
60
+ checkString(value) {
61
+ this.resetError()
62
+
63
+ if (value && value.length < 3) {
64
+ this.error = true
65
+ this.errMessage = this.$gettext('invalid_string')
66
+ }
67
+ },
68
+
69
+ checkEmail(value) {
70
+ this.resetError()
71
+
72
+ if (value && !value.includes('@')) {
73
+ this.error = true
74
+ this.errMessage = this.$gettext('Invalid email address')
75
+ }
76
+ },
77
+
78
+ checkPhone(value) {
79
+ this.resetError()
80
+
81
+ if (value && !/^\d{10}$/.test(value)) {
82
+ this.error = true
83
+ this.errMessage = this.$gettext('invalid_phone')
84
+ }
85
+ },
86
+
87
+ checkYear(value) {
88
+ this.resetError()
89
+
90
+ if (value && (isNaN(value) || value < 1900 || value > 2100)) {
91
+ this.error = true
92
+ this.errMessage = this.$gettext('invalid_year')
93
+ }
94
+ }
95
+ }
96
+ }