Skip to content

Commit

Permalink
fix question name generator when there is no number
Browse files Browse the repository at this point in the history
  • Loading branch information
leiyre committed Nov 7, 2024
1 parent d48f327 commit de9ef07
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export default {
return Math.max(
...this.dataset.selectedSubset.questions.map((question) => {
const numberInName = question.name.split("_").pop();
return parseInt(numberInName) || 0;
return parseInt(numberInName);
})
);
},
Expand All @@ -155,7 +155,7 @@ export default {
},
generateName(type, number) {
const typeName = this.$t(`config.questionId.${type}`);
return `${typeName}_${number}`;
return `${typeName}_${parseInt(number) || 0}`;
},
addQuestion(type) {
const questionName = this.generateName(
Expand All @@ -167,7 +167,7 @@ export default {
});
},
onTypeIsChanged(oldName, type) {
const numberInName = oldName.split("_")[1];
const numberInName = oldName.split("_").pop();
const index = this.dataset.selectedSubset.questions.findIndex(
(q) => q.name === oldName
);
Expand Down

0 comments on commit de9ef07

Please sign in to comment.