1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 07:39:44 +02:00

feat: Sort cards within list (#717)

Closes #390
This commit is contained in:
Samuel 2024-04-22 21:56:07 +02:00 committed by GitHub
parent 2c84316fe0
commit 934dcdf39b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 419 additions and 18 deletions

View file

@ -0,0 +1,65 @@
const Errors = {
NOT_ENOUGH_RIGHTS: {
notEnoughRights: 'Not enough rights',
},
LIST_NOT_FOUND: {
listNotFound: 'List not found',
},
};
module.exports = {
inputs: {
id: {
type: 'string',
regex: /^[0-9]+$/,
required: true,
},
type: {
type: 'string',
isIn: Object.values(List.SortTypes),
},
},
exits: {
notEnoughRights: {
responseType: 'forbidden',
},
listNotFound: {
responseType: 'notFound',
},
},
async fn(inputs) {
const { currentUser } = this.req;
const { list } = await sails.helpers.lists
.getProjectPath(inputs.id)
.intercept('pathNotFound', () => Errors.LIST_NOT_FOUND);
const boardMembership = await BoardMembership.findOne({
boardId: list.boardId,
userId: currentUser.id,
});
if (!boardMembership) {
throw Errors.LIST_NOT_FOUND;
}
if (boardMembership.role !== BoardMembership.Roles.EDITOR) {
throw Errors.NOT_ENOUGH_RIGHTS;
}
const cards = await sails.helpers.lists.sortOne.with({
record: list,
type: inputs.type,
request: this.req,
});
return {
item: list,
included: {
cards,
},
};
},
};