Skip to content

Commit 1174e48

Browse files
authored
Add Vocabulary Select implementation instead of buefy select (#276)
* Add Vocabulary Select implementation instead of buefy select * Revert "Add Vocabulary Select implementation instead of buefy select" This reverts commit 6f09c17 * Add Vocabulary Select implementation instead of buefy select (cherry picked from commit 6f09c17)
1 parent 1e82d59 commit 1174e48

File tree

2 files changed

+101
-14
lines changed

2 files changed

+101
-14
lines changed

src/Vocabulary/VSelect.vue

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<div
3+
class="control"
4+
:class="{ 'is-expanded': expanded }"
5+
>
6+
<span
7+
class="select"
8+
:class="spanClasses"
9+
>
10+
<select
11+
ref="select"
12+
v-model="computedValue"
13+
v-bind="$attrs"
14+
@blur="$emit('blur', $event)"
15+
@focus="$emit('focus', $event)"
16+
>
17+
<template v-if="placeholder">
18+
<option
19+
v-if="computedValue == null"
20+
:value="null"
21+
disabled
22+
hidden
23+
>
24+
{{ placeholder }}
25+
</option>
26+
</template>
27+
<slot />
28+
</select>
29+
</span>
30+
<slot name="left-icon" />
31+
</div>
32+
</template>
33+
34+
<script>
35+
export default {
36+
name: 'VSelect',
37+
inheritAttrs: false,
38+
props: {
39+
value: {
40+
type: [String, Number],
41+
default: null
42+
},
43+
placeholder: String,
44+
expanded: Boolean
45+
},
46+
data() {
47+
return {
48+
selected: this.value,
49+
elementRef: 'select'
50+
}
51+
},
52+
computed: {
53+
computedValue: {
54+
get() {
55+
return this.selected
56+
},
57+
set(value) {
58+
this.selected = value
59+
this.$emit('input', value)
60+
}
61+
},
62+
spanClasses() {
63+
return [this.size, this.statusType, {
64+
'is-fullwidth': this.expanded,
65+
'is-empty': this.selected === null
66+
}]
67+
}
68+
},
69+
watch: {
70+
/**
71+
* When v-model is changed:
72+
* 1. Set the selected option.
73+
* 2. If it's invalid, validate again.
74+
*/
75+
value(value) {
76+
this.selected = value
77+
}
78+
}
79+
}
80+
</script>

src/components/DropdownStep.vue

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,35 @@
11
<template>
22
<div class="step-actions">
3-
<b-field class="license-dropdown">
4-
<b-select
5-
:placeholder="$t('stepper.DD.placeholder')"
6-
:value="shortName"
7-
@input="setCurrentLicense"
3+
<v-select
4+
class="license-dropdown"
5+
:placeholder="$t('stepper.DD.placeholder')"
6+
:value="shortName"
7+
@input="setCurrentLicense"
8+
>
9+
<option
10+
v-for="license in licenseList"
11+
:key="license"
12+
:value="license"
813
>
9-
<option
10-
v-for="license in licenseList"
11-
:key="license"
12-
:value="license"
13-
>
14-
{{ license }}
15-
</option>
16-
</b-select>
17-
</b-field>
14+
{{ license }}
15+
</option>
16+
</v-select>
1817
</div>
1918
</template>
2019
<script>
2120
import { mapGetters } from 'vuex'
21+
import VSelect from '@/Vocabulary/VSelect'
2222
export default {
2323
name: 'DropdownStep',
24+
components: { VSelect },
2425
inheritAttrs: false,
2526
props: {
27+
status: {
28+
type: String,
29+
validator(value) {
30+
return ['active', 'previous', 'inactive'].includes(value)
31+
}
32+
},
2633
id: Number
2734
},
2835
data() {

0 commit comments

Comments
 (0)