Fix reset workingFromStore, fix star rating required, fix checkboxes
This commit is contained in:
parent
b4d0008766
commit
1a6b5dd5d7
|
@ -69,9 +69,12 @@ class AnswerFormRequest extends FormRequest
|
|||
if (FormLogicPropertyResolver::isRequired($property, $data)) {
|
||||
$rules[] = 'required';
|
||||
|
||||
// Required for checkboxes means true
|
||||
if ($property['type'] == 'checkbox') {
|
||||
// Required for checkboxes means true
|
||||
$rules[] = 'accepted';
|
||||
} else if ($property['type'] == 'number' && isset($property['is_rating']) && $property['is_rating']) {
|
||||
// For star rating, needs a minimum of 1 star
|
||||
$rules[] = 'min:1';
|
||||
}
|
||||
} else {
|
||||
$rules[] = 'nullable';
|
||||
|
@ -148,7 +151,7 @@ class AnswerFormRequest extends FormRequest
|
|||
return ['string'];
|
||||
case 'number':
|
||||
if ($property['is_rating'] ?? false) {
|
||||
return ['numeric', 'min:1'];
|
||||
return ['numeric'];
|
||||
}
|
||||
return ['numeric'];
|
||||
case 'select':
|
||||
|
|
|
@ -40,7 +40,9 @@ export default {
|
|||
},
|
||||
|
||||
mounted () {
|
||||
this.compVal = !!this.compVal
|
||||
if (!this.compVal) {
|
||||
this.compVal = false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -3,12 +3,11 @@
|
|||
<input
|
||||
:id="id || name"
|
||||
:name="name"
|
||||
:checked="internalValue"
|
||||
v-model="internalValue"
|
||||
type="checkbox"
|
||||
:class="sizeClasses"
|
||||
class="rounded border-gray-500 cursor-pointer"
|
||||
:disabled="disabled?true:null"
|
||||
@click="handleClick"
|
||||
>
|
||||
<label :for="id || name" class="text-gray-700 dark:text-gray-300 ml-2" :class="{'!cursor-not-allowed':disabled}">
|
||||
<slot />
|
||||
|
@ -27,7 +26,6 @@ const props = defineProps({
|
|||
id: { type: String, default: null },
|
||||
name: { type: String, default: 'checkbox' },
|
||||
modelValue: { type: [Boolean, String], default: false },
|
||||
checked: { type: Boolean, default: false },
|
||||
disabled: { type: Boolean, default: false },
|
||||
sizeClasses: { type: String, default: 'w-4 h-4' }
|
||||
})
|
||||
|
@ -53,20 +51,9 @@ watch(() => internalValue.value, (val, oldVal) => {
|
|||
}
|
||||
})
|
||||
|
||||
if ('checked' in props) {
|
||||
internalValue.value = props.checked
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
emit('update:modelValue', internalValue.value)
|
||||
if (internalValue.value === null) {
|
||||
internalValue.value = false
|
||||
}
|
||||
})
|
||||
|
||||
const handleClick = (e) => {
|
||||
emit('click', e)
|
||||
|
||||
if (!e.isPropagationStopped) {
|
||||
internalValue.value = e.target.checked
|
||||
emit('update:modelValue', internalValue.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -179,7 +179,7 @@ const tabsList = [
|
|||
]
|
||||
|
||||
onMounted(() => {
|
||||
workingFormStore.set(null) // Reset old working form
|
||||
workingFormStore.reset()
|
||||
if (form.value) {
|
||||
workingFormStore.set(form.value)
|
||||
} else {
|
||||
|
|
|
@ -45,6 +45,12 @@ export const useWorkingFormStore = defineStore('working_form', {
|
|||
this.selectedFieldIndex = null
|
||||
this.showAddFieldSidebar = false
|
||||
this.showEditFieldSidebar = false
|
||||
},
|
||||
reset() {
|
||||
this.content = null
|
||||
this.selectedFieldIndex = null
|
||||
this.showEditFieldSidebar = null
|
||||
this.showAddFieldSidebar = null
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue