From e03c69ab8febc6093d092221724b3190a2da351d Mon Sep 17 00:00:00 2001 From: nztqa Date: Wed, 28 Jun 2017 15:19:53 +0900 Subject: [PATCH 1/2] Fix: id generation --- models/checklists.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/models/checklists.js b/models/checklists.js index 537aecb02..0ee62fa26 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) { From f682de9690d0485586cf240009835611822cc69a Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Wed, 28 Jun 2017 11:13:39 +0300 Subject: [PATCH 2/2] Fix duplicate id generation. Thanks to nztqa ! Closes #1090 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8602046b..1dc878216 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.