From 72b22a73b68dd86c84bacee9fb407c555e63248f Mon Sep 17 00:00:00 2001 From: Thomas Liske Date: Sun, 6 Oct 2019 22:53:43 +0200 Subject: [PATCH] REST API: fix creation of Checklists (closes wekan/wekan#2746) --- models/checklists.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/models/checklists.js b/models/checklists.js index 7ad9cae55..3b50cda66 100644 --- a/models/checklists.js +++ b/models/checklists.js @@ -276,6 +276,7 @@ if (Meteor.isServer) { * @param {string} boardId the board ID * @param {string} cardId the card ID * @param {string} title the title of the new checklist + * @param {string} [items] the list of items on the new checklist * @return_type {_id: string} */ JsonRoutes.add( @@ -291,11 +292,19 @@ if (Meteor.isServer) { sort: 0, }); if (id) { - req.body.items.forEach(function(item, idx) { + let items = req.body.items || []; + if (_.isString(items)) { + if (items === '') { + items = []; + } else { + items = [items]; + } + } + items.forEach(function(item, idx) { ChecklistItems.insert({ cardId: paramCardId, checklistId: id, - title: item.title, + title: item, sort: idx, }); });