forked from openWB/openwb-ui-settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOpenwbBaseButtonGroupInput2.vue
83 lines (80 loc) · 1.78 KB
/
OpenwbBaseButtonGroupInput2.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<template>
<openwb-base-setting-element>
<template #title>{{ title }}</template>
<template #help>
<slot name="help"></slot>
</template>
<template #default>
<div class="btn-group btn-block btn-group-toggle">
<label
v-for="button in buttons"
:key="button.value"
class="btn"
:class="[
value == button.buttonValue ? 'active' : '',
button.class ? button.class : 'btn-outline-info',
]"
>
<input
type="radio"
v-model="value"
:value="button.buttonValue"
v-bind="$attrs"
/>
{{ button.text }}
<font-awesome-icon
:icon="['fas', 'check']"
:style="[
value == button.buttonValue
? 'visibility: visible'
: 'visibility: hidden',
]"
/>
</label>
</div>
</template>
</openwb-base-setting-element>
</template>
<script>
import { library } from "@fortawesome/fontawesome-svg-core";
import {
faQuestionCircle as fasQuestionCircle,
faCheck as fasCheck,
} from "@fortawesome/free-solid-svg-icons";
import { faQuestionCircle as farQuestionCircle } from "@fortawesome/free-regular-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
library.add(fasQuestionCircle, farQuestionCircle, fasCheck);
export default {
name: "OpenwbButtonGroupInput",
inheritAttrs: false,
props: {
title: String,
modelValue: { type: [String, Number, Boolean] },
buttons: Object,
},
emits: ["update:modelValue"],
data() {
return {
showHelp: false,
};
},
computed: {
value: {
get() {
return this.modelValue;
},
set(newValue) {
this.$emit("update:modelValue", newValue);
},
},
},
methods: {
toggleHelp() {
this.showHelp = !this.showHelp && this.$slots.help !== undefined;
},
},
components: {
FontAwesomeIcon,
},
};
</script>