From 5b54ab7c460a1c192ed790a96cbde35fb6ddcb0f Mon Sep 17 00:00:00 2001 From: Alex <41288429+Dvinyanin@users.noreply.github.com> Date: Tue, 19 Apr 2022 22:37:19 +0700 Subject: [PATCH] Add ArchiveCard action (#1456) Signed-off-by: Dvinyanin Alexandr --- plugins/board-resources/src/index.ts | 7 +++++-- plugins/board-resources/src/utils/CardUtils.ts | 12 ++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/plugins/board-resources/src/index.ts b/plugins/board-resources/src/index.ts index ac45156a4e..d8abf04e4c 100644 --- a/plugins/board-resources/src/index.ts +++ b/plugins/board-resources/src/index.ts @@ -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 { showPopup(MoveView, { object }) @@ -57,7 +57,10 @@ export default async (): Promise => ({ Join: addCurrentUser, Move: showMoveCardPopup, Dates: showDatePickerPopup, - Labels: showCardLabelsPopup + Labels: showCardLabelsPopup, + Archive: archiveCard, + SendToBoard: unarchiveCard, + Delete: deleteCard }, cardActionSupportedHandler: { Join: canAddCurrentUser, diff --git a/plugins/board-resources/src/utils/CardUtils.ts b/plugins/board-resources/src/utils/CardUtils.ts index 136643f71a..76104e0fe5 100644 --- a/plugins/board-resources/src/utils/CardUtils.ts +++ b/plugins/board-resources/src/utils/CardUtils.ts @@ -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) +}