Select field selection handling (#158)

This commit is contained in:
formsdev 2023-07-26 13:19:31 +05:30 committed by GitHub
parent b55c3e6164
commit e28d80e7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 20 deletions

View File

@ -122,7 +122,8 @@ export default {
data () { data () {
return { return {
isOpen: false, isOpen: false,
searchTerm: '' searchTerm: '',
defaultValue: this.value ?? null
} }
}, },
computed: { computed: {
@ -212,7 +213,7 @@ export default {
this.$emit('input', emitValue) this.$emit('input', emitValue)
} else { } else {
if (this.value === value) { if (this.value === value) {
this.$emit('input', null) this.$emit('input', this.defaultValue ?? null)
} else { } else {
this.$emit('input', value) this.$emit('input', value)
} }

View File

@ -4,7 +4,7 @@
Logic Logic
<pro-tag/> <pro-tag/>
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 text-xs mb-5">
Add some logic to this block. Start by adding some conditions, and then add some actions. Add some logic to this block. Start by adding some conditions, and then add some actions.
</p> </p>
<div class="relative flex"> <div class="relative flex">
@ -47,7 +47,7 @@
<h3 class="font-semibold block text-lg"> <h3 class="font-semibold block text-lg">
Copy logic from another field Copy logic from another field
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 text-xs mb-5">
Select another field/block to copy its logic and apply it to "{{ field.name }}". Select another field/block to copy its logic and apply it to "{{ field.name }}".
</p> </p>
<select-input v-model="copyFrom" name="copy_from" emit-key="value" <select-input v-model="copyFrom" name="copy_from" emit-key="value"

View File

@ -31,7 +31,7 @@
<h3 class="font-semibold block text-lg"> <h3 class="font-semibold block text-lg">
General General
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Exclude this field or make it required. Exclude this field or make it required.
</p> </p>
<v-checkbox v-model="field.hidden" class="mb-3" <v-checkbox v-model="field.hidden" class="mb-3"
@ -153,7 +153,24 @@ export default {
computed: {}, computed: {},
watch: {}, watch: {
'field.width': {
handler (val) {
if (val === undefined || val === null) {
this.$set(this.field, 'width', 'full')
}
},
immediate: true
},
'field.align': {
handler (val) {
if (val === undefined || val === null) {
this.$set(this.field, 'align', 'left')
}
},
immediate: true
}
},
mounted() { mounted() {

View File

@ -38,7 +38,7 @@
<h3 class="font-semibold block text-lg"> <h3 class="font-semibold block text-lg">
General General
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Exclude this field or make it required. Exclude this field or make it required.
</p> </p>
<v-checkbox v-model="field.hidden" class="mb-3" <v-checkbox v-model="field.hidden" class="mb-3"
@ -66,7 +66,7 @@
<h3 class="font-semibold block text-lg"> <h3 class="font-semibold block text-lg">
Checkbox Checkbox
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Advanced options for checkbox. Advanced options for checkbox.
</p> </p>
<v-checkbox v-model="field.use_toggle_switch" class="mt-4" <v-checkbox v-model="field.use_toggle_switch" class="mt-4"
@ -74,7 +74,7 @@
> >
Use toggle switch Use toggle switch
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
If enabled, checkbox will be replaced with a toggle switch If enabled, checkbox will be replaced with a toggle switch
</p> </p>
</div> </div>
@ -106,7 +106,7 @@
> >
Rating Rating
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
If enabled then this field will be star rating input. If enabled then this field will be star rating input.
</p> </p>
@ -121,7 +121,7 @@
<h3 class="font-semibold block text-lg"> <h3 class="font-semibold block text-lg">
Text Options Text Options
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Keep it simple or make it a multi-lines input. Keep it simple or make it a multi-lines input.
</p> </p>
<v-checkbox v-model="field.multi_lines" <v-checkbox v-model="field.multi_lines"
@ -144,7 +144,7 @@
> >
Date Range Date Range
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Adds an end date. This cannot be used with the time option yet. Adds an end date. This cannot be used with the time option yet.
</p> </p>
<v-checkbox v-model="field.with_time" <v-checkbox v-model="field.with_time"
@ -153,7 +153,7 @@
> >
Date with time Date with time
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Include time. Or not. This cannot be used with the date range option yet. Include time. Or not. This cannot be used with the date range option yet.
</p> </p>
@ -168,7 +168,7 @@
> >
Prefill with 'today' Prefill with 'today'
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
if enabled we will pre-fill this field with the current date if enabled we will pre-fill this field with the current date
</p> </p>
@ -193,7 +193,7 @@
Select Options Select Options
<pro-tag/> <pro-tag/>
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Advanced options for your select/multiselect fields. Advanced options for your select/multiselect fields.
</p> </p>
<text-area-input v-model="optionsText" :name="field.id+'_options_text'" class="mt-4" <text-area-input v-model="optionsText" :name="field.id+'_options_text'" class="mt-4"
@ -211,7 +211,7 @@
> >
Always show all select options Always show all select options
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5">Options won't be in a dropdown anymore, but will all be visible</p> <p class="text-gray-400 mb-5 text-xs">Options won't be in a dropdown anymore, but will all be visible</p>
</div> </div>
<!-- Customization - Placeholder, Prefill, Relabel, Field Help --> <!-- Customization - Placeholder, Prefill, Relabel, Field Help -->
@ -221,7 +221,7 @@
<pro-tag/> <pro-tag/>
</h3> </h3>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
Change your form field name, pre-fill a value, add hints, etc. Change your form field name, pre-fill a value, add hints, etc.
</p> </p>
@ -331,7 +331,7 @@
> >
Generates a unique id on submission Generates a unique id on submission
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
If you enable this, we will hide this field and fill it a unique id (UUID format) on each new form submission If you enable this, we will hide this field and fill it a unique id (UUID format) on each new form submission
</p> </p>
@ -341,7 +341,7 @@
> >
Generates an auto-incremented id on submission Generates an auto-incremented id on submission
</v-checkbox> </v-checkbox>
<p class="text-gray-400 mb-5"> <p class="text-gray-400 mb-5 text-xs">
If you enable this, we will hide this field and fill it a unique number on each new form submission If you enable this, we will hide this field and fill it a unique number on each new form submission
</p> </p>
</div> </div>
@ -431,7 +431,22 @@ export default {
}, },
}, },
watch: {}, watch: {
'field.width': {
handler (val) {
if (val === undefined || val === null) {
this.$set(this.field, 'width', 'full')
}
},
immediate: true
}
},
created () {
if (this.field.width === undefined || this.field.width === null) {
this.$set(this.field, 'width', 'full')
}
},
mounted() { mounted() {
if (['text', 'number', 'url', 'email', 'phone_number'].includes(this.field.type) && !this.field.max_char_limit) { if (['text', 'number', 'url', 'email', 'phone_number'].includes(this.field.type) && !this.field.max_char_limit) {