diff options
author | Lauri Ojansivu <x@xet7.org> | 2019-10-07 00:22:49 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-07 00:22:49 +0300 |
commit | 42d31901b58c1a3aa6b323641ea0cf9b3201bcb9 (patch) | |
tree | 54a7f65ef11347dc34b9dd6cc22cf7dddbba53c3 | |
parent | 4d30503cb5176228e6ccc446fed61118734df3d1 (diff) | |
parent | 72b22a73b68dd86c84bacee9fb407c555e63248f (diff) | |
download | wekan-42d31901b58c1a3aa6b323641ea0cf9b3201bcb9.tar.gz wekan-42d31901b58c1a3aa6b323641ea0cf9b3201bcb9.tar.bz2 wekan-42d31901b58c1a3aa6b323641ea0cf9b3201bcb9.zip |
Merge pull request #2747 from liske/fixes/rest-create-checklist-2746
REST API: fix creation of Checklists (closes wekan/wekan#2746)
-rw-r--r-- | models/checklists.js | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/models/checklists.js b/models/checklists.js index 7ad9cae5..3b50cda6 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, }); }); |