@eturnity/eturnity_reusable_components 7.4.4-EPDM-7260.4 → 7.4.4-EPDM-7260.5
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
@@ -27,7 +27,7 @@
|
|
27
27
|
<input-container
|
28
28
|
ref="inputElement"
|
29
29
|
:placeholder="placeholder"
|
30
|
-
: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="
|
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="
|
61
|
-
|
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() {
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<SliderWrapper>
|
19
19
|
<Slider
|
20
20
|
v-for="(bar, index) in label.selectedTariffs"
|
21
|
-
:key="
|
21
|
+
:key="bar.id"
|
22
22
|
:active="!disabled"
|
23
23
|
:draggable="!disabled"
|
24
24
|
:resizable="!disabled"
|
@@ -370,6 +370,8 @@ 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
|
@@ -434,8 +436,7 @@ export default {
|
|
434
436
|
// add based on the index in the chart.
|
435
437
|
this.barOptionsList.push({
|
436
438
|
name: bar.name,
|
437
|
-
id: bar.id
|
438
|
-
index: bar.index
|
439
|
+
id: bar.id
|
439
440
|
})
|
440
441
|
}
|
441
442
|
},
|
@@ -446,8 +447,8 @@ export default {
|
|
446
447
|
event.preventDefault()
|
447
448
|
this.activeLabel = label
|
448
449
|
this.barOptionsType = type
|
449
|
-
// need to pass the index to setBarOptions in case it's 'add'
|
450
450
|
this.setBarOptions(bar)
|
451
|
+
|
451
452
|
if (this.barOptionsList.length) {
|
452
453
|
this.showBarOptions = true
|
453
454
|
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
|
+
}
|