mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 23:59:48 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
|
@ -26,32 +26,23 @@ module.exports = {
|
|||
async fn(inputs, exits) {
|
||||
const { currentUser } = this.req;
|
||||
|
||||
const { board, project } = await sails.helpers
|
||||
.getBoardToProjectPath(inputs.boardId)
|
||||
const { board } = await sails.helpers.boards
|
||||
.getProjectPath(inputs.boardId)
|
||||
.intercept('pathNotFound', () => Errors.BOARD_NOT_FOUND);
|
||||
|
||||
const isUserMemberForProject = await sails.helpers.isUserMemberForProject(
|
||||
project.id,
|
||||
currentUser.id,
|
||||
);
|
||||
const isBoardMember = await sails.helpers.users.isBoardMember(currentUser.id, board.id);
|
||||
|
||||
if (!isUserMemberForProject) {
|
||||
if (!isBoardMember) {
|
||||
throw Errors.BOARD_NOT_FOUND; // Forbidden
|
||||
}
|
||||
|
||||
const cards = await sails.helpers.getCardsForBoard(board, inputs.beforeId);
|
||||
const cardIds = sails.helpers.mapRecords(cards);
|
||||
const cards = await sails.helpers.boards.getCards(board, inputs.beforeId);
|
||||
const cardIds = sails.helpers.utils.mapRecords(cards);
|
||||
|
||||
const cardSubscriptions = await sails.helpers.getSubscriptionsByUserForCard(
|
||||
cardIds,
|
||||
currentUser.id,
|
||||
);
|
||||
|
||||
const cardMemberships = await sails.helpers.getMembershipsForCard(cardIds);
|
||||
const cardLabels = await sails.helpers.getCardLabelsForCard(cardIds);
|
||||
|
||||
const tasks = await sails.helpers.getTasksForCard(cardIds);
|
||||
const attachments = await sails.helpers.getAttachmentsForCard(cardIds);
|
||||
const cardSubscriptions = await sails.helpers.cardSubscriptions.getMany({
|
||||
cardId: cardIds,
|
||||
userId: currentUser.id,
|
||||
});
|
||||
|
||||
const isSubscribedByCardId = cardSubscriptions.reduce(
|
||||
(result, cardSubscription) => ({
|
||||
|
@ -61,10 +52,14 @@ module.exports = {
|
|||
{},
|
||||
);
|
||||
|
||||
cards.map((card) => ({
|
||||
...card,
|
||||
isSubscribed: isSubscribedByCardId[card.id] || false,
|
||||
}));
|
||||
cards.forEach((card) => {
|
||||
card.isSubscribed = isSubscribedByCardId[card.id] || false; // eslint-disable-line no-param-reassign
|
||||
});
|
||||
|
||||
const cardMemberships = await sails.helpers.cards.getCardMemberships(cardIds);
|
||||
const cardLabels = await sails.helpers.cards.getCardLabels(cardIds);
|
||||
const tasks = await sails.helpers.cards.getTasks(cardIds);
|
||||
const attachments = await sails.helpers.cards.getAttachments(cardIds);
|
||||
|
||||
return exits.success({
|
||||
items: cards,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue