Refactor task description handling in SelfServeTaskList.vue:

- Add `hasTaskDescription` utility to validate and handle task descriptions more robustly.
- Update template to conditionally render task descriptions using the new utility.
This commit is contained in:
Jeppe Bundgaard
2026-03-18 13:49:28 +01:00
parent 9a62417981
commit 65b173094f
@@ -19,6 +19,16 @@ const isImageAttachment = (attachment: any) => (
&& !!attachment.content?.other
&& attachment.content.other.match(/\.(jpg|jpeg|png|gif|webp|svg)$/i)
);
const hasTaskDescription = (task: any) => {
const description = task?.description;
if (typeof description !== "string") {
return !!description;
}
const trimmedDescription = description.trim();
return trimmedDescription.length > 0 && trimmedDescription !== "-";
};
</script>
<template>
@@ -45,15 +55,10 @@ const isImageAttachment = (attachment: any) => (
</div>
<div class="column">
<p><strong>{{ task.task }}</strong></p>
<p v-if="task.description" class="is-size-7">{{ task.description }}</p>
<p v-if="hasTaskDescription(task)" class="is-size-7">{{ task.description }}</p>
<div v-if="task.services?.length" class="tags mt-2">
<span v-for="service in task.services" :key="service" class="tag is-success">{{ service }}</span>
</div>
<div v-if="task.buttons?.length" class="tags mt-2">
<span v-for="buttonId in task.buttons" :key="buttonId" class="tag is-link is-light">
Button {{ buttonId }}
</span>
</div>
<div v-if="task.attachments && task.attachments.length > 0" class="mt-2">
<div v-for="attachment in task.attachments" :key="attachment.id" class="mb-2">
<template v-if="isImageAttachment(attachment)">