mirror of
https://github.com/wekan/wekan.git
synced 2025-12-20 01:10:12 +01:00
✨ add and remove dropdown items
This commit is contained in:
parent
373dc5cadb
commit
457977f954
1 changed files with 65 additions and 0 deletions
|
|
@ -440,6 +440,71 @@ if (Meteor.isServer) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation add_custom_field_dropdown_items
|
||||||
|
* @summary Update a Custom Field's dropdown items
|
||||||
|
*
|
||||||
|
* @param {string[]} items names of the custom field
|
||||||
|
* @return_type {_id: string}
|
||||||
|
*/
|
||||||
|
JsonRoutes.add(
|
||||||
|
'POST',
|
||||||
|
'/api/boards/:boardId/custom-fields/:customFieldId/dropdown-items',
|
||||||
|
(req, res) => {
|
||||||
|
Authentication.checkUserId(req.userId);
|
||||||
|
|
||||||
|
if (req.body.hasOwnProperty('items')) {
|
||||||
|
CustomFields.direct.update(
|
||||||
|
{ _id: req.params.customFieldId },
|
||||||
|
{
|
||||||
|
$push: {
|
||||||
|
'settings.dropdownItems': {
|
||||||
|
$each: req.body.items.map(name => ({
|
||||||
|
_id: Random.id(6),
|
||||||
|
name,
|
||||||
|
})),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: { _id: req.params.customFieldId },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @operation delete_custom_field_dropdown_item
|
||||||
|
* @summary Update a Custom Field's dropdown items
|
||||||
|
*
|
||||||
|
* @param {string} itemId ID of the dropdown item
|
||||||
|
* @return_type {_id: string}
|
||||||
|
*/
|
||||||
|
JsonRoutes.add(
|
||||||
|
'DELETE',
|
||||||
|
'/api/boards/:boardId/custom-fields/:customFieldId/dropdown-items/:dropdownItemId',
|
||||||
|
(req, res) => {
|
||||||
|
Authentication.checkUserId(req.userId);
|
||||||
|
|
||||||
|
CustomFields.direct.update(
|
||||||
|
{ _id: req.params.customFieldId },
|
||||||
|
{
|
||||||
|
$pull: {
|
||||||
|
'settings.dropdownItems': { _id: req.params.dropdownItemId },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
JsonRoutes.sendResult(res, {
|
||||||
|
code: 200,
|
||||||
|
data: { _id: req.params.customFieldId },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @operation delete_custom_field
|
* @operation delete_custom_field
|
||||||
* @summary Delete a Custom Fields attached to a board
|
* @summary Delete a Custom Fields attached to a board
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue