1
0
Fork 0

FIX: fix wizard index creation

Dieser Commit ist enthalten in:
Angus McLeod 2022-10-12 10:57:40 +02:00
Ursprung b2a5558de1
Commit 4ab7c77257

Datei anzeigen

@ -71,6 +71,16 @@ export default Component.extend({
}); });
}, },
getNextIndex() {
const items = this.items;
if (!items || items.length === 0) {
return 0;
}
const lastItem = items[items.length - 1];
const lastNumber = lastItem.id.split("_").pop();
return Number(lastNumber);
},
actions: { actions: {
add() { add() {
const items = this.get("items"); const items = this.get("items");
@ -78,7 +88,7 @@ export default Component.extend({
let params = setWizardDefaults({}, itemType); let params = setWizardDefaults({}, itemType);
params.isNew = true; params.isNew = true;
params.index = items.length; params.index = this.getNextIndex();
let id = `${itemType}_${params.index + 1}`; let id = `${itemType}_${params.index + 1}`;
if (itemType === "field") { if (itemType === "field") {