diff --git a/assets/javascripts/discourse/components/wizard-links.js.es6 b/assets/javascripts/discourse/components/wizard-links.js.es6 index 0683ce4a..54a12a1a 100644 --- a/assets/javascripts/discourse/components/wizard-links.js.es6 +++ b/assets/javascripts/discourse/components/wizard-links.js.es6 @@ -68,16 +68,25 @@ export default Component.extend({ actions: { add() { - const items = this.items; + const items = this.get('items'); const itemType = this.itemType; let next = 1; - + if (items.length) { - next = Math.max.apply(Math, items.map((i) => (i.id.split('_')[1]))) + 1; + next = Math.max.apply(Math, items.map((i) => { + let parts = i.id.split('_'); + return parts[parts.length - 1]; + })) + 1; + } + + let id = `${itemType}_${next}`; + + if (itemType === 'field') { + id = `${this.parentId}_${id}`; } let params = { - id: `${itemType}_${next}`, + id, isNew: true }; diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs index 4380c862..be064200 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs @@ -97,7 +97,11 @@ {{/if}} -{{wizard-links itemType="field" current=currentField items=step.fields}} +{{wizard-links + itemType="field" + current=currentField + items=step.fields + parentId=step.id}} {{#if currentField}} {{wizard-custom-field