Skip to content

Commit

Permalink
frontend: remove need to check color inputs on save
Browse files Browse the repository at this point in the history
  • Loading branch information
Synar committed Jun 24, 2024
1 parent f55470d commit eb19849
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 23 deletions.
7 changes: 0 additions & 7 deletions frontend/components/admin/families/EditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions frontend/components/admin/input/ColorField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
7 changes: 0 additions & 7 deletions frontend/pages/admin/[familyId]/categories/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
Expand Down
7 changes: 0 additions & 7 deletions frontend/pages/admin/tags/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit eb19849

Please sign in to comment.