From eb198490b529459db1f5257f1f582d097e01f591 Mon Sep 17 00:00:00 2001 From: "Alice K." Date: Mon, 24 Jun 2024 19:28:50 +0200 Subject: [PATCH] frontend: remove need to check color inputs on save --- frontend/components/admin/families/EditForm.vue | 7 ------- frontend/components/admin/input/ColorField.vue | 5 +++-- frontend/pages/admin/[familyId]/categories/[id].vue | 7 ------- frontend/pages/admin/tags/[id].vue | 7 ------- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/frontend/components/admin/families/EditForm.vue b/frontend/components/admin/families/EditForm.vue index 1cd5d04..22edcd1 100644 --- a/frontend/components/admin/families/EditForm.vue +++ b/frontend/components/admin/families/EditForm.vue @@ -760,13 +760,6 @@ async function onSave() { field.user_facing = true field.display_weight = pseudo_display_index } - if (field.field_type == 'EventList') { - field.field_type_metadata?.event_types.forEach((event_type) => { - if (event_type.color.length == 6) { - event_type.color = `#${event_type.color}` - } - }) - } } } // Send the request to the server and process the response diff --git a/frontend/components/admin/input/ColorField.vue b/frontend/components/admin/input/ColorField.vue index 27f0e87..2b4ff42 100644 --- a/frontend/components/admin/input/ColorField.vue +++ b/frontend/components/admin/input/ColorField.vue @@ -35,11 +35,12 @@ const emit = defineEmits(['update:modelValue', 'update:invalid']) function isHexColor(colorText: string | undefined) { if (colorText == undefined) return false - if (colorText[0] == '#') return colorText.length === 7 && [...colorText.slice(1)].every(c => '0123456789abcdefABCDEF'.includes(c)) - return colorText.length === 6 && [...colorText].every(c => '0123456789abcdefABCDEF'.includes(c)) + return colorText.length === 7 && [...colorText.slice(1)].every(c => '0123456789abcdefABCDEF'.includes(c)) } function updateValue(value: string | undefined) { + if (value && value[0] !== '#') + value = '#' + value emit('update:modelValue', value) emit('update:invalid', !isHexColor(value)) } diff --git a/frontend/pages/admin/[familyId]/categories/[id].vue b/frontend/pages/admin/[familyId]/categories/[id].vue index e11ab0f..53cd185 100644 --- a/frontend/pages/admin/[familyId]/categories/[id].vue +++ b/frontend/pages/admin/[familyId]/categories/[id].vue @@ -123,13 +123,6 @@ function hasBeenEdited(field: keyof NewOrUpdateCategory) { async function onSave() { processingRequest.value = true try { - if (editedCategory.value.border_color.length == 6) { - editedCategory.value.border_color = `#${editedCategory.value.border_color}` - } - if (editedCategory.value.fill_color.length == 6) { - editedCategory.value.fill_color = `#${editedCategory.value.fill_color}` - } - if (isNew) { const { id } = await state.createCategory(editedCategory.value) navigateTo(`/admin/${familyId}/categories/new-icon-${id}`) diff --git a/frontend/pages/admin/tags/[id].vue b/frontend/pages/admin/tags/[id].vue index b081295..dc00ad1 100644 --- a/frontend/pages/admin/tags/[id].vue +++ b/frontend/pages/admin/tags/[id].vue @@ -130,13 +130,6 @@ function hasBeenEdited(field: keyof NewOrUpdateTag) { } async function onSave() { - if (editedTag.value.border_color.length == 6) { - editedTag.value.border_color = `#${editedTag.value.border_color}` - } - if (editedTag.value.fill_color.length == 6) { - editedTag.value.fill_color = `#${editedTag.value.fill_color}` - } - try { processingRequest.value = true if (isNew) {