Allow use of toggle switches for checkboxes (#13)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div :class="wrapperClass">
|
||||
<v-checkbox :id="id?id:name" v-model="compVal" :disabled="disabled" :name="name" @input="$emit('input',$event)">
|
||||
{{ label }}
|
||||
{{ label }} <span v-if="required" class="text-red-500 required-dot">*</span>
|
||||
</v-checkbox>
|
||||
<small v-if="help" :class="theme.default.help">
|
||||
<slot name="help">{{ help }}</slot>
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
{{ label }}
|
||||
<span v-if="required" class="text-red-500 required-dot">*</span>
|
||||
</label>
|
||||
<small v-if="help" :class="theme.SelectInput.help" class="block mb-2">
|
||||
<slot name="help">{{ help }}</slot>
|
||||
</small>
|
||||
|
||||
<loader v-if="loading" key="loader" class="h-6 w-6 text-nt-blue mx-auto" />
|
||||
<div v-for="(option, index) in options" v-else :key="option[optionKey]"
|
||||
@@ -22,9 +25,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<small v-if="help" :class="theme.SelectInput.help">
|
||||
<slot name="help">{{ help }}</slot>
|
||||
</small>
|
||||
<has-error v-if="hasValidation" :form="form" :field="name" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
31
resources/js/components/forms/ToggleSwitchInput.vue
Normal file
31
resources/js/components/forms/ToggleSwitchInput.vue
Normal file
@@ -0,0 +1,31 @@
|
||||
<template>
|
||||
<div :class="wrapperClass">
|
||||
<div class="flex">
|
||||
<v-switch :id="id?id:name" v-model="compVal" class="inline-block mr-2" :disabled="disabled" :name="name" @input="$emit('input',$event)" />
|
||||
<span>{{ label }} <span v-if="required" class="text-red-500 required-dot">*</span></span>
|
||||
</div>
|
||||
<small v-if="help" :class="theme.default.help">
|
||||
<slot name="help">{{ help }}</slot>
|
||||
</small>
|
||||
<has-error v-if="hasValidation" :form="form" :field="name" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import inputMixin from '~/mixins/forms/input'
|
||||
|
||||
import VSwitch from './components/VSwitch'
|
||||
export default {
|
||||
name: 'ToggleSwitchInput',
|
||||
|
||||
components: { VSwitch },
|
||||
mixins: [inputMixin],
|
||||
props: {},
|
||||
|
||||
mounted () {
|
||||
this.compVal = !!this.compVal
|
||||
this.$emit('input', !!this.compVal)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
4
resources/js/components/forms/index.js
vendored
4
resources/js/components/forms/index.js
vendored
@@ -16,6 +16,7 @@ import ImageInput from './ImageInput'
|
||||
import DateInput from './DateInput';
|
||||
import RatingInput from './RatingInput';
|
||||
import FlatSelectInput from './FlatSelectInput';
|
||||
import ToggleSwitchInput from './ToggleSwitchInput';
|
||||
|
||||
// Components that are registered globaly.
|
||||
[
|
||||
@@ -34,7 +35,8 @@ import FlatSelectInput from './FlatSelectInput';
|
||||
RichTextAreaInput,
|
||||
DateInput,
|
||||
RatingInput,
|
||||
FlatSelectInput
|
||||
FlatSelectInput,
|
||||
ToggleSwitchInput
|
||||
].forEach(Component => {
|
||||
Vue.component(Component.name, Component)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user