diff options
-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) { |