fix: scope create form priorities to selected group; reset on group change
This commit is contained in:
@@ -91,7 +91,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
import { computed, watch } from 'vue'
|
||||
import { Link, useForm } from '@inertiajs/vue3'
|
||||
|
||||
const props = defineProps({
|
||||
@@ -113,6 +113,14 @@ const filteredPriorities = computed(() => {
|
||||
return props.priorities.filter(p => !p.group_id || p.group_id === Number(form.group_id))
|
||||
})
|
||||
|
||||
// Reset priority if it's no longer valid for the newly selected group
|
||||
watch(() => form.group_id, () => {
|
||||
const valid = filteredPriorities.value.some(p => p.id === form.priority_id)
|
||||
if (!valid) {
|
||||
form.priority_id = null
|
||||
}
|
||||
})
|
||||
|
||||
function submit() {
|
||||
form.post(route('ticketing.store'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user