From e30ce7805391165f80a08b48e051f85b5ecb2949 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Wed, 26 Nov 2025 23:57:49 +0000 Subject: [PATCH 1/9] add archive card to api --- models/cards.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/models/cards.js b/models/cards.js index 546efdfe6..fb52ea122 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4440,6 +4440,44 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }); }, ); + + /** + * @operation archive_card + * @summary Archive a card + * + * @description Archive a card + * @param {string} boardId the board ID of the card + * @param {string} listId the list ID of the card + * @param {string} cardId the ID of the card + * @return_type {_id: string, archived: bool, archivedAt: Date} + */ + JsonRoutes.add( + 'POST', + '/api/boards/:boardId/lists/:listId/cards/:cardId/archive', + function(req, res) { + const paramBoardId = req.params.boardId; + const paramCardId = req.params.cardId; + const paramListId = req.params.listId; + Authentication.checkBoardAccess(req.userId, paramBoardId); + const card = ReactiveCache.getCard({ + _id: paramCardId, + listId: paramListId, + boardId: paramBoardId, + archived: false, + }); + if (!card) { + throw new Meteor.Error(404, 'Card not found'); + } + const archive_res = card.archive(); + JsonRoutes.sendResult(res, { + code: 200, + data: { + _id: paramCardId, + ...archive_res.$set, + }, + }); + }, + ); } // Position history tracking methods From a81a6030311654752c953b0ec9b9951f0f1ce567 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Wed, 26 Nov 2025 23:59:00 +0000 Subject: [PATCH 2/9] update bool to boolean --- models/cards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cards.js b/models/cards.js index fb52ea122..9c48546fc 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4449,7 +4449,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( * @param {string} boardId the board ID of the card * @param {string} listId the list ID of the card * @param {string} cardId the ID of the card - * @return_type {_id: string, archived: bool, archivedAt: Date} + * @return_type {_id: string, archived: boolean, archivedAt: Date} */ JsonRoutes.add( 'POST', From 67c8a98f20fd610a27325f855ce53485d97c0fc6 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 00:05:53 +0000 Subject: [PATCH 3/9] add route to wekan.yml --- public/api/wekan.yml | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/public/api/wekan.yml b/public/api/wekan.yml index cbb1a23a6..5982969dc 100644 --- a/public/api/wekan.yml +++ b/public/api/wekan.yml @@ -2594,6 +2594,53 @@ paths: properties: _id: type: string + /api/boards/{board}/lists/{list}/cards/{card}/archive: + post: + operationId: archive_card + summary: Archive a card + description: | + Archive a card + tags: + - Cards + consumes: + - multipart/form-data + - application/json + parameters: + - name: board + in: path + description: | + the board ID of the card + type: string + required: true + - name: list + in: path + description: | + the list ID of the card + type: string + required: true + - name: card + in: path + description: | + the ID of the card + type: string + required: true + produces: + - application/json + security: + - UserSecurity: [] + responses: + '200': + description: |- + 200 response + schema: + type: object + properties: + _id: + type: string + archived: + type: boolean + archivedAt: + type: string /api/boards/{board}/lists/{list}/cards/{card}/customFields/{customField}: post: operationId: edit_card_custom_field From 36d7b0f8a7b66a458eafe76f56d1f1a9b7037303 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 00:52:28 +0000 Subject: [PATCH 4/9] correct return values --- models/cards.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/models/cards.js b/models/cards.js index 9c48546fc..eb55f4c4a 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4468,12 +4468,13 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( if (!card) { throw new Meteor.Error(404, 'Card not found'); } - const archive_res = card.archive(); + card.archive(); JsonRoutes.sendResult(res, { code: 200, data: { _id: paramCardId, - ...archive_res.$set, + archived: true, + archivedAt: new Date(), }, }); }, From 5ff9bf331f4f329ebc70dfa05cf53c4607f25861 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 08:23:56 +0000 Subject: [PATCH 5/9] add restore to api --- models/cards.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/models/cards.js b/models/cards.js index eb55f4c4a..948612bd6 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4479,6 +4479,44 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( }); }, ); + + /** + * @operation restore_card + * @summary Restore a card from the archive + * + * @description Restore a card from the archive + * @param {string} boardId the board ID of the card + * @param {string} listId the list ID of the card + * @param {string} cardId the ID of the card + * @return_type {_id: string, archived: boolean} + */ + JsonRoutes.add( + 'POST', + '/api/boards/:boardId/lists/:listId/cards/:cardId/restore', + function(req, res) { + const paramBoardId = req.params.boardId; + const paramCardId = req.params.cardId; + const paramListId = req.params.listId; + Authentication.checkBoardAccess(req.userId, paramBoardId); + const card = ReactiveCache.getCard({ + _id: paramCardId, + listId: paramListId, + boardId: paramBoardId, + archived: true, + }); + if (!card) { + throw new Meteor.Error(404, 'Card not found'); + } + card.restore(); + JsonRoutes.sendResult(res, { + code: 200, + data: { + _id: paramCardId, + archived: false, + }, + }); + }, + ); } // Position history tracking methods From a42915614a4f83175b91e2cae0d6aea854d60b58 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 08:25:59 +0000 Subject: [PATCH 6/9] add restore to wekan.yml --- public/api/wekan.yml | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/public/api/wekan.yml b/public/api/wekan.yml index 5982969dc..c06c1c263 100644 --- a/public/api/wekan.yml +++ b/public/api/wekan.yml @@ -2705,6 +2705,51 @@ paths: type: string value: type: object + /api/boards/{board}/lists/{list}/cards/{card}/restore: + post: + operationId: restore_card + summary: Restore a card from the archive + description: | + Restore a card from the archive + tags: + - Cards + consumes: + - multipart/form-data + - application/json + parameters: + - name: board + in: path + description: | + the board ID of the card + type: string + required: true + - name: list + in: path + description: | + the list ID of the card + type: string + required: true + - name: card + in: path + description: | + the ID of the card + type: string + required: true + produces: + - application/json + security: + - UserSecurity: [] + responses: + '200': + description: |- + 200 response + schema: + type: object + properties: + _id: + type: string + archived: + type: boolean /api/boards/{board}/lists/{list}/cards_count: get: operationId: get_list_cards_count From bac0fa81fc1f0624e523e4754fb35d127f6e5ddd Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 08:27:38 +0000 Subject: [PATCH 7/9] correce indent --- models/cards.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/cards.js b/models/cards.js index 948612bd6..1b1831d7d 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4512,7 +4512,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( code: 200, data: { _id: paramCardId, - archived: false, + archived: false, }, }); }, From d3c237bc664eb2f4083ff8249ab74c6858f6dc41 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 08:29:36 +0000 Subject: [PATCH 8/9] fix more indenting --- models/cards.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/cards.js b/models/cards.js index 1b1831d7d..72b353cb4 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4473,8 +4473,8 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( code: 200, data: { _id: paramCardId, - archived: true, - archivedAt: new Date(), + archived: true, + archivedAt: new Date(), }, }); }, From 003a07ebce9ec9b65c8a074f3c18712f8521d623 Mon Sep 17 00:00:00 2001 From: Mial Lewis Date: Thu, 27 Nov 2025 22:00:43 +0000 Subject: [PATCH 9/9] change restore to unarchive --- models/cards.js | 8 ++++---- public/api/wekan.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/models/cards.js b/models/cards.js index 72b353cb4..a0eaaa8ca 100644 --- a/models/cards.js +++ b/models/cards.js @@ -4481,10 +4481,10 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( ); /** - * @operation restore_card - * @summary Restore a card from the archive + * @operation unarchive_card + * @summary Unarchive card * - * @description Restore a card from the archive + * @description Unarchive card * @param {string} boardId the board ID of the card * @param {string} listId the list ID of the card * @param {string} cardId the ID of the card @@ -4492,7 +4492,7 @@ JsonRoutes.add('GET', '/api/boards/:boardId/cards_count', function( */ JsonRoutes.add( 'POST', - '/api/boards/:boardId/lists/:listId/cards/:cardId/restore', + '/api/boards/:boardId/lists/:listId/cards/:cardId/unarchive', function(req, res) { const paramBoardId = req.params.boardId; const paramCardId = req.params.cardId; diff --git a/public/api/wekan.yml b/public/api/wekan.yml index c06c1c263..947aa3862 100644 --- a/public/api/wekan.yml +++ b/public/api/wekan.yml @@ -2705,12 +2705,12 @@ paths: type: string value: type: object - /api/boards/{board}/lists/{list}/cards/{card}/restore: + /api/boards/{board}/lists/{list}/cards/{card}/unarchive: post: - operationId: restore_card - summary: Restore a card from the archive + operationId: unarchive_card + summary: Unarchive card description: | - Restore a card from the archive + Unarchive card tags: - Cards consumes: