From db666eec65f7d8695f57ed0f8d7dade77f8b68d7 Mon Sep 17 00:00:00 2001 From: Louis Orleans Date: Sat, 20 Feb 2021 09:02:12 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20updating=20fields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/customFields.js | 53 ++++++++++++------------------------------ 1 file changed, 15 insertions(+), 38 deletions(-) diff --git a/models/customFields.js b/models/customFields.js index cee4d9c1a..59e89ac2f 100644 --- a/models/customFields.js +++ b/models/customFields.js @@ -385,74 +385,51 @@ if (Meteor.isServer) { JsonRoutes.add( 'PUT', '/api/boards/:boardId/custom-fields/:customFieldId', - function(req, res) { + (req, res) => { Authentication.checkUserId(req.userId); const paramFieldId = req.params.customFieldId; - const paramBoardId = req.params.boardId; if (req.body.hasOwnProperty('name')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.name } }, + { _id: paramFieldId }, + { $set: { name: req.body.name } }, ); } if (req.body.hasOwnProperty('type')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.type } }, + { _id: paramFieldId }, + { $set: { type: req.body.type } }, ); } if (req.body.hasOwnProperty('settings')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - // TODO: should I just wholesale set the settings obj? - { $set: { title: req.body.settings } }, + { _id: paramFieldId }, + { $set: { settings: req.body.settings } }, ); } if (req.body.hasOwnProperty('showOnCard')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.showOnCard } }, + { _id: paramFieldId }, + { $set: { showOnCard: req.body.showOnCard } }, ); } if (req.body.hasOwnProperty('automaticallyOnCard')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.automaticallyOnCard } }, + { _id: paramFieldId }, + { $set: { automaticallyOnCard: req.body.automaticallyOnCard } }, ); } if (req.body.hasOwnProperty('alwaysOnCard')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.alwaysOnCard } }, + { _id: paramFieldId }, + { $set: { alwaysOnCard: req.body.alwaysOnCard } }, ); } if (req.body.hasOwnProperty('showLabelOnMiniCard')) { CustomFields.direct.update( - { - _id: paramFieldId, - boardId: paramBoardId, - }, - { $set: { title: req.body.showLabelOnMiniCard } }, + { _id: paramFieldId }, + { $set: { showLabelOnMiniCard: req.body.showLabelOnMiniCard } }, ); }