mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Add API endpoint to edit a list with various properties
This commit is contained in:
parent
f3d384c1dd
commit
6d7c20f397
2 changed files with 222 additions and 0 deletions
155
models/lists.js
155
models/lists.js
|
|
@ -600,6 +600,161 @@ if (Meteor.isServer) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation edit_list
|
||||||
|
* @summary Edit a List
|
||||||
|
*
|
||||||
|
* @description This updates a list on a board.
|
||||||
|
* You can update the title, color, wipLimit, starred, and collapsed properties.
|
||||||
|
*
|
||||||
|
* @param {string} boardId the board ID
|
||||||
|
* @param {string} listId the ID of the list to update
|
||||||
|
* @param {string} [title] the new title of the list
|
||||||
|
* @param {string} [color] the new color of the list
|
||||||
|
* @param {Object} [wipLimit] the WIP limit configuration
|
||||||
|
* @param {boolean} [starred] whether the list is starred
|
||||||
|
* @param {boolean} [collapsed] whether the list is collapsed
|
||||||
|
* @return_type {_id: string}
|
||||||
|
*/
|
||||||
|
JsonRoutes.add('PUT', '/api/boards/:boardId/lists/:listId', function(
|
||||||
|
req,
|
||||||
|
res,
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const paramBoardId = req.params.boardId;
|
||||||
|
const paramListId = req.params.listId;
|
||||||
|
let updated = false;
|
||||||
|
Authentication.checkBoardAccess(req.userId, paramBoardId);
|
||||||
|
|
||||||
|
const list = ReactiveCache.getList({
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!list) {
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 404,
|
||||||
|
data: { error: 'List not found' },
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update title if provided
|
||||||
|
if (req.body.title) {
|
||||||
|
const newTitle = req.body.title;
|
||||||
|
Lists.direct.update(
|
||||||
|
{
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
title: newTitle,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update color if provided
|
||||||
|
if (req.body.color) {
|
||||||
|
const newColor = req.body.color;
|
||||||
|
Lists.direct.update(
|
||||||
|
{
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
color: newColor,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update starred status if provided
|
||||||
|
if (req.body.hasOwnProperty('starred')) {
|
||||||
|
const newStarred = req.body.starred;
|
||||||
|
Lists.direct.update(
|
||||||
|
{
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
starred: newStarred,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update collapsed status if provided
|
||||||
|
if (req.body.hasOwnProperty('collapsed')) {
|
||||||
|
const newCollapsed = req.body.collapsed;
|
||||||
|
Lists.direct.update(
|
||||||
|
{
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
collapsed: newCollapsed,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update wipLimit if provided
|
||||||
|
if (req.body.wipLimit) {
|
||||||
|
const newWipLimit = req.body.wipLimit;
|
||||||
|
Lists.direct.update(
|
||||||
|
{
|
||||||
|
_id: paramListId,
|
||||||
|
boardId: paramBoardId,
|
||||||
|
archived: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
$set: {
|
||||||
|
wipLimit: newWipLimit,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
updated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if update is true or false
|
||||||
|
if (!updated) {
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 404,
|
||||||
|
data: {
|
||||||
|
message: 'Error',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: {
|
||||||
|
_id: paramListId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: error,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @operation delete_list
|
* @operation delete_list
|
||||||
* @summary Delete a List
|
* @summary Delete a List
|
||||||
|
|
|
||||||
|
|
@ -1784,6 +1784,73 @@ paths:
|
||||||
200 response
|
200 response
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Lists"
|
$ref: "#/definitions/Lists"
|
||||||
|
put:
|
||||||
|
operationId: edit_list
|
||||||
|
summary: Edit a List
|
||||||
|
description: |
|
||||||
|
This updates a list on a board.
|
||||||
|
You can update the title, color, wipLimit, starred, and collapsed properties.
|
||||||
|
tags:
|
||||||
|
- Lists
|
||||||
|
consumes:
|
||||||
|
- multipart/form-data
|
||||||
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- name: title
|
||||||
|
in: formData
|
||||||
|
description: |
|
||||||
|
the new title of the list
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
- name: color
|
||||||
|
in: formData
|
||||||
|
description: |
|
||||||
|
the new color of the list
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
- name: starred
|
||||||
|
in: formData
|
||||||
|
description: |
|
||||||
|
whether the list is starred
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
- name: collapsed
|
||||||
|
in: formData
|
||||||
|
description: |
|
||||||
|
whether the list is collapsed
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
- name: wipLimit
|
||||||
|
in: formData
|
||||||
|
description: |
|
||||||
|
the WIP limit configuration
|
||||||
|
type: object
|
||||||
|
required: false
|
||||||
|
- name: board
|
||||||
|
in: path
|
||||||
|
description: |
|
||||||
|
the board ID
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
- name: list
|
||||||
|
in: path
|
||||||
|
description: |
|
||||||
|
the ID of the list to update
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
security:
|
||||||
|
- UserSecurity: []
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: |-
|
||||||
|
200 response
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
_id:
|
||||||
|
type: string
|
||||||
delete:
|
delete:
|
||||||
operationId: delete_list
|
operationId: delete_list
|
||||||
summary: Delete a List
|
summary: Delete a List
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue