diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-06-28 11:14:04 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-06-28 11:14:04 +0300 |
commit | b0367491b920f1ac8a77dce542643f2a21d32cbc (patch) | |
tree | b60ebe0a096ca8fd1125bd65def0d215b1b98afc | |
parent | 1ba0f912f1f86801500373bce101880f73283df5 (diff) | |
parent | f682de9690d0485586cf240009835611822cc69a (diff) | |
download | wekan-b0367491b920f1ac8a77dce542643f2a21d32cbc.tar.gz wekan-b0367491b920f1ac8a77dce542643f2a21d32cbc.tar.bz2 wekan-b0367491b920f1ac8a77dce542643f2a21d32cbc.zip |
Merge branch 'nztqa-fix-checklist' into devel
Fix duplicate id generation. Thanks to nztqa ! Closes #1090
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | models/checklists.js | 8 |
2 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e8602046..1dc87821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ This release adds the following new features: and fixes the following bugs: * [Fix incorrect attachment link with subfolder in the url](https://github.com/wekan/wekan/pull/1086); -* [Fix link to card](https://github.com/wekan/wekan/pull/1087). +* [Fix link to card](https://github.com/wekan/wekan/pull/1087); +* [Fix duplicate id generation](https://github.com/wekan/wekan/pull/1093). Thanks to GitHub users kubiko and nztqa for their contributions. 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) { |