Skip to content

Commit

Permalink
Merge pull request #855 from dhruvmisra/UniqueIDFix
Browse files Browse the repository at this point in the history
[Issue #854] Fixed uniquie ID issue on Vote and Curriculum
  • Loading branch information
llaske authored Sep 23, 2020
2 parents 0d74bae + ce302e4 commit a6c461a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions activities/Curriculum.activity/js/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ var CategorySettings = {
},

addCategory: function() {
var nextId = this.categories.length;
this.category.id = nextId;
var maxId = this.categories.reduce((max, category) => max = Math.max(category.id, max), -1);
this.category.id = maxId + 1;
this.categories.push(this.category);
setTimeout(function () {
content.scrollTop = content.scrollHeight;
}, 250);
this.$set(this.user.skills, nextId, new Object());
this.$set(this.user.skills, maxId + 1, new Object());
}
}
}
Expand Down Expand Up @@ -239,13 +239,13 @@ var SkillSettings = {
},

addSkill: function(catIndex) {
var nextId = this.categories[catIndex].skills.length;
this.skill.id = nextId;
var maxId = this.categories[catIndex].skills.reduce((max, skill) => max = Math.max(skill.id, max), -1);
this.skill.id = maxId + 1;
this.categories[catIndex].skills.push(this.skill);
setTimeout(function () {
content.scrollTop = content.scrollHeight;
}, 250);
this.$set(this.user.skills[this.categoryId], nextId, {
this.$set(this.user.skills[this.categoryId], maxId + 1, {
acquired: 0,
media: {}
});
Expand Down
4 changes: 2 additions & 2 deletions activities/Vote.activity/js/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ var PollSettings = {
},

addPoll() {
var nextId = this.polls.length;
this.poll.id = nextId;
var maxId = this.polls.reduce((max, poll) => max = Math.max(poll.id, max), -1);
this.poll.id = maxId + 1;
this.polls.push(this.poll);
this.$emit('poll-added', this.poll.id);
}
Expand Down

0 comments on commit a6c461a

Please sign in to comment.