Merge branch 'nztqa-fix-checklist' into devel

Fix duplicate id generation. Thanks to nztqa ! Closes #1090
This commit is contained in:
Lauri Ojansivu 2017-06-28 11:14:04 +03:00
commit b0367491b9
2 changed files with 9 additions and 2 deletions

View file

@ -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.

View file

@ -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) {