summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-06-28 10:44:45 +0300
committerLauri Ojansivu <x@xet7.org>2017-06-28 10:44:45 +0300
commit5854805bdc93c9a97068e140516e90b4120c7001 (patch)
treeda97809dba709eefb337c298ef5d49fb20839373
parent1ba0f912f1f86801500373bce101880f73283df5 (diff)
parente03c69ab8febc6093d092221724b3190a2da351d (diff)
downloadwekan-5854805bdc93c9a97068e140516e90b4120c7001.tar.gz
wekan-5854805bdc93c9a97068e140516e90b4120c7001.tar.bz2
wekan-5854805bdc93c9a97068e140516e90b4120c7001.zip
Merge branch 'fix-checklist' of https://github.com/nztqa/wekan into nztqa-fix-checklist
-rw-r--r--models/checklists.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/models/checklists.js b/models/checklists.js
index 537aecb0..0ee62fa2 100644
--- a/models/checklists.js
+++ b/models/checklists.js
@@ -86,7 +86,13 @@ Checklists.mutations({
//for items in checklist
addItem(title) {
const itemCount = this.itemCount();
- const _id = `${this._id}${itemCount}`;
+ let idx = 0;
+ if (itemCount > 0) {
+ const lastId = this.items[itemCount - 1]._id;
+ const lastIdSuffix = lastId.substr(this._id.length);
+ idx = parseInt(lastIdSuffix, 10) + 1;
+ }
+ const _id = `${this._id}${idx}`;
return { $addToSet: { items: { _id, title, isFinished: false } } };
},
removeItem(itemId) {