mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
Merge pull request #2747 from liske/fixes/rest-create-checklist-2746
REST API: fix creation of Checklists (closes wekan/wekan#2746)
This commit is contained in:
commit
42d31901b5
1 changed files with 11 additions and 2 deletions
|
|
@ -276,6 +276,7 @@ if (Meteor.isServer) {
|
||||||
* @param {string} boardId the board ID
|
* @param {string} boardId the board ID
|
||||||
* @param {string} cardId the card ID
|
* @param {string} cardId the card ID
|
||||||
* @param {string} title the title of the new checklist
|
* @param {string} title the title of the new checklist
|
||||||
|
* @param {string} [items] the list of items on the new checklist
|
||||||
* @return_type {_id: string}
|
* @return_type {_id: string}
|
||||||
*/
|
*/
|
||||||
JsonRoutes.add(
|
JsonRoutes.add(
|
||||||
|
|
@ -291,11 +292,19 @@ if (Meteor.isServer) {
|
||||||
sort: 0,
|
sort: 0,
|
||||||
});
|
});
|
||||||
if (id) {
|
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({
|
ChecklistItems.insert({
|
||||||
cardId: paramCardId,
|
cardId: paramCardId,
|
||||||
checklistId: id,
|
checklistId: id,
|
||||||
title: item.title,
|
title: item,
|
||||||
sort: idx,
|
sort: idx,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue