Add ArchiveCard action (#1456)

Signed-off-by: Dvinyanin Alexandr <dvinyanin.alexandr@gmail.com>
This commit is contained in:
Alex 2022-04-19 22:37:19 +07:00 committed by GitHub
parent f043b7a2e1
commit 5b54ab7c46
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View File

@ -28,7 +28,7 @@ import KanbanView from './components/KanbanView.svelte'
import CardLabelsPicker from './components/popups/CardLabelsPicker.svelte'
import MoveView from './components/popups/MoveCard.svelte'
import DateRangePicker from './components/popups/DateRangePicker.svelte'
import { addCurrentUser, canAddCurrentUser, isArchived, isUnarchived } from './utils/CardUtils'
import { addCurrentUser, canAddCurrentUser, isArchived, isUnarchived, archiveCard, unarchiveCard, deleteCard } from './utils/CardUtils'
async function showMoveCardPopup (object: Card): Promise<void> {
showPopup(MoveView, { object })
@ -57,7 +57,10 @@ export default async (): Promise<Resources> => ({
Join: addCurrentUser,
Move: showMoveCardPopup,
Dates: showDatePickerPopup,
Labels: showCardLabelsPopup
Labels: showCardLabelsPopup,
Archive: archiveCard,
SendToBoard: unarchiveCard,
Delete: deleteCard
},
cardActionSupportedHandler: {
Join: canAddCurrentUser,

View File

@ -9,6 +9,10 @@ export function updateCard (client: Client, card: Card, field: string, value: an
client.update(card, { [field]: value })
}
export function deleteCard (card: Card, client: Client): void {
client.remove(card)
}
export function isArchived (card: Card): boolean {
return !!card.isArchived
}
@ -45,3 +49,11 @@ export function addCurrentUser (card: Card, client: Client): void {
members.push(employee)
updateCard(client, card, 'members', members)
}
export function archiveCard (card: Card, client: Client): void {
updateCard(client, card, 'isArchived', true)
}
export function unarchiveCard (card: Card, client: Client): void {
updateCard(client, card, 'isArchived', false)
}