-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make whole preservation task card a button
- Loading branch information
Showing
3 changed files
with
142 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<script setup lang="ts"> | ||
import StatusBadge from "@/components/StatusBadge.vue"; | ||
import { toRefs } from "vue"; | ||
import IconChevronDown from "~icons/bi/chevron-down"; | ||
import type { EnduroPackagePreservationTask } from "@/openapi-generator"; | ||
export type TaskCard = EnduroPackagePreservationTask & { | ||
index: number; | ||
isOpen: boolean; | ||
more: string; | ||
}; | ||
const props = defineProps<{ | ||
task: TaskCard; | ||
}>(); | ||
const { task: card } = toRefs(props); | ||
const isComplete = (task: EnduroPackagePreservationTask) => { | ||
return task.status == "done" || task.status == "error"; | ||
}; | ||
const toggleCard = (card: TaskCard, ev: Event) => { | ||
if (!card.more) { | ||
return; | ||
} | ||
card.isOpen = !card.isOpen; | ||
ev.preventDefault(); | ||
}; | ||
</script> | ||
|
||
<template> | ||
<button | ||
:class="{ 'card-body': true, disabled: !task.more }" | ||
:aria-controls="'note-' + card.index + '-more'" | ||
aria-label="Toggle display of additional notes" | ||
:aria-disabled="!task.more" | ||
@click="toggleCard(task, $event)" | ||
> | ||
<div class="d-flex flex-row align-start gap-3"> | ||
<div class="fd-flex"> | ||
<span | ||
class="fs-6 badge rounded-pill border border-primary text-primary" | ||
> | ||
{{ card.index }} | ||
</span> | ||
</div> | ||
<div class="d-flex flex-column flex-grow-1 align-content-stretch min-w-0"> | ||
<div class="d-flex flex-wrap pt-1"> | ||
<div class="me-auto text-truncate fw-bold"> | ||
{{ card.name }} | ||
</div> | ||
<div class="me-3"> | ||
<span | ||
v-if=" | ||
!isComplete(card) && $filters.formatDateTime(card.startedAt) | ||
" | ||
> | ||
Started: | ||
{{ $filters.formatDateTime(card.startedAt) }} | ||
</span> | ||
<span | ||
v-if=" | ||
isComplete(card) && $filters.formatDateTime(card.completedAt) | ||
" | ||
> | ||
Completed: | ||
{{ $filters.formatDateTime(card.completedAt) }} | ||
</span> | ||
</div> | ||
</div> | ||
<div class="d-flex flex-row gap-4"> | ||
<div class="flex-grow-1 line-break text-start"> | ||
{{ card.note }} | ||
<Transition name="fade"> | ||
<p v-show="card.isOpen" :id="'note-' + card.index + '-more'"> | ||
{{ card.more }} | ||
</p> | ||
</Transition> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="d-flex flex-column pt-1"> | ||
<div> | ||
<StatusBadge :status="card.status" /> | ||
</div> | ||
<div class="align-self-end"> | ||
<IconChevronDown | ||
v-if="card.more" | ||
:class="card.isOpen ? 'expander open' : 'expander closed'" | ||
:alt="card.isOpen ? 'Collapse note' : 'Expand note'" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</button> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters