From b8ffde15257d67568014b5b7f78f7e539f0456a0 Mon Sep 17 00:00:00 2001 From: Jakob Wierzba Date: Mon, 9 Sep 2024 13:33:18 +0200 Subject: [PATCH] improve form status combo code --- .../components/postupload/post-upload.vue | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/frontend/javascript/components/postupload/post-upload.vue b/frontend/javascript/components/postupload/post-upload.vue index 15d13fe77..0cc6b1909 100644 --- a/frontend/javascript/components/postupload/post-upload.vue +++ b/frontend/javascript/components/postupload/post-upload.vue @@ -96,23 +96,14 @@ const formStatusWasResolved = formStatus.value === 'resolved' const formStatusIsResolved = computed(() => formStatus.value === 'resolved') // remove nonsensical combos -const formStatusChoices = computed(() => - props.status_form.fields.resolution.choices.filter((choice) => { - if (formIsSent.value) { - switch (choice.value) { - case '': - case 'successful': - case 'partially_successful': - case 'not_held': - case 'refused': - return false - } - } else { - if (choice.value === 'user_withdrew_costs') return false - } - return true - }) -) +const formStatusChoices = computed(() => { + const badCombinations = formIsSent.value + ? ['', 'successful', 'partially_successful', 'not_held', 'refused'] + : ['user_withdrew_costs'] + return props.status_form.fields.resolution.choices.filter( + (choice) => !badCombinations.includes(choice.value) + ) +}) const formCost = props.status_form.fields.costs.initial?.intValue || 0 const formHasHadCost = formCost > 0