feat: add receipt support for attachments (#89)

* add receipt support for attachments

* fix show logic
This commit is contained in:
Hayden 2022-10-15 19:45:36 -08:00 committed by GitHub
parent dbaaf4ad0a
commit 57f9372e49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 4 deletions

View file

@ -31,6 +31,7 @@
attachments: ItemAttachment[];
warranty: ItemAttachment[];
manuals: ItemAttachment[];
receipts: ItemAttachment[];
};
const attachments = computed<FilteredAttachments>(() => {
@ -40,6 +41,7 @@
attachments: [],
manuals: [],
warranty: [],
receipts: [],
};
}
@ -51,6 +53,8 @@
acc.warranty.push(attachment);
} else if (attachment.type === "manual") {
acc.manuals.push(attachment);
} else if (attachment.type === "receipt") {
acc.receipts.push(attachment);
} else {
acc.attachments.push(attachment);
}
@ -61,6 +65,7 @@
attachments: [] as ItemAttachment[],
warranty: [] as ItemAttachment[],
manuals: [] as ItemAttachment[],
receipts: [] as ItemAttachment[],
}
);
});
@ -103,7 +108,8 @@
attachments.value.photos.length > 0 ||
attachments.value.attachments.length > 0 ||
attachments.value.warranty.length > 0 ||
attachments.value.manuals.length > 0
attachments.value.manuals.length > 0 ||
attachments.value.receipts.length > 0
);
});
@ -134,6 +140,10 @@
push("Manuals");
}
if (attachments.value.receipts.length > 0) {
push("Receipts");
}
return details;
});
@ -323,6 +333,13 @@
:item-id="item.id"
/>
</template>
<template #receipts>
<ItemAttachmentsList
v-if="attachments.receipts.length > 0"
:attachments="attachments.receipts"
:item-id="item.id"
/>
</template>
</DetailsSection>
</BaseCard>