This commit is contained in:
Lauri Ojansivu 2024-03-10 08:42:04 +02:00 committed by Edouard Gaulué
parent 1783257c0e
commit 5dd318a481
2 changed files with 57 additions and 1 deletions

View file

@ -2239,6 +2239,37 @@ if (Meteor.isServer) {
}
});
/**
* @operation copy_board
* @summary Copy a board to a new one
*
* @description If your are board admin or wekan admin, this copies the
* given board to a new one.
*
* @param {string} boardId the board
* @param {string} title the title of the new board (default to old one)
*
* @return_type string
*/
JsonRoutes.add('POST', '/api/boards/:boardId/copy', function(req, res) {
const id = req.params.boardId;
const board = ReactiveCache.getBoard(id);
const adminAccess = board.members.some(e => e.userId === req.userId && e.isAdmin);
Authentication.checkAdminOrCondition(req.userId, adminAccess);
try {
board['title'] = req.body.title || Boards.uniqueTitle(board.title);
ret = board.copy();
JsonRoutes.sendResult(res, {
code: 200,
data: ret,
});
} catch (error) {
JsonRoutes.sendResult(res, {
data: error,
});
}
});
/**
* @operation set_board_member_permission
* @tag Users