Skip to content

Commit

Permalink
feat: allow pdf files to be uploaded on the card. gustavosizilio#5
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolgois committed Jun 9, 2024
1 parent d5b38a1 commit aebaf6f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/components/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
type="checkbox"
data-cy="card-checkbox"
:checked="card.completed"
@click.stop="patchCard(card, { completed: !card.completed })"
@click.stop="putCard(card, { completed: !card.completed })"
>
</label>
</template>
Expand All @@ -19,7 +19,7 @@ defineProps({
type: Object as PropType<Card>,
},
});
const { patchCard } = useStore();
const { putCard } = useStore();
</script>

<style lang="postcss" scoped>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Dropzone.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
for="dropzoneFile"
class="self-start place-self-center py-1.5 px-3 mt-2 text-gray1 bg-gray-400 cursor-pointer"
:class="isDragActive && 'bg-gray-800'"
>select image</label>
>select file</label>
</div>
<input
id="dropzoneFile"
type="file"
class="hidden"
accept="image/png, image/jpeg"
accept="image/png, image/jpeg, application/pdf"
@input="upload"
>
</div>
Expand Down
20 changes: 13 additions & 7 deletions src/components/card/CardDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,13 @@
</div>
<div class="col-span-4 font-bold ">
<span>{{ activeCard.image.split('&value=')[0].replace(`name=`, '') }}</span>
<a
<div
class="block font-normal underline cursor-pointer"
data-cy="image-delete"
:href="'/backend' + activeCard.image"
download
data-cy="image-download"
@click="downloadFile(activeCard)"
>
<Download class="inline-block mb-1 w-4" />Download
</a>
</div>
<div
class="block font-normal underline cursor-pointer"
data-cy="image-delete"
Expand Down Expand Up @@ -239,8 +238,15 @@ const clickAwayDate = () => {
showDate.value = false;
};
function test(event: any){
console.log(activeCard.value.description)
function downloadFile(card: Card){
if(card.image){
const blobUrl = card.image.split('&value=')[1];
const link = document.createElement('a');
link.href = blobUrl;
link.download = card.image.split('&value=')[0].replace('name=', '');
link.click();
document.body.removeChild(link);
}
}
const updateDate = (data: string) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/list/ListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const inputActive = ref(false);
const isDragging = ref(false);
const { lists, loadingListCards } = storeToRefs(useStore());
const { patchCard, patchList } = useStore();
const { putCard, patchList } = useStore();
const onClickAway = () => {
inputActive.value = false;
Expand All @@ -79,7 +79,7 @@ const sortCards = () => {
const listIndex = lists.value.find((l: List) => l.id === props.list.id);
// trigget PATCH request for every car that was dragged
lists.value[listIndex].cards.forEach((card: Card, order: Card['order']) => {
patchCard(card, { listId: props.list.id, order });
putCard(card, { listId: props.list.id, order });
});
};
</script>

0 comments on commit aebaf6f

Please sign in to comment.