From 24035329b8249c83ac323ddfdabeceb5da0768a1 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Sat, 20 Feb 2021 13:50:24 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20edit=20custom=20field=20dropdown=20?= =?UTF-8?q?item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/customFields.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/models/customFields.js b/models/customFields.js index 276177fe9..cb69a761b 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -476,6 +476,43 @@ if (Meteor.isServer) { }, ); + /** + * @operation edit_custom_field_dropdown_item + * @summary Update a Custom Field's dropdown item + * + * @param {string} name names of the custom field + * @return_type {_id: string} + */ + JsonRoutes.add( + 'PUT', + '/api/boards/:boardId/custom-fields/:customFieldId/dropdown-items/:dropdownItemId', + (req, res) => { + Authentication.checkUserId(req.userId); + + if (req.body.hasOwnProperty('name')) { + CustomFields.direct.update( + { + _id: req.params.customFieldId, + 'settings.dropdownItems._id': req.params.dropdownItemId, + }, + { + $set: { + 'settings.dropdownItems.$': { + _id: req.params.dropdownItemId, + name: req.body.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