0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 09:20:29 +01:00

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: {
add() {
const items = this.get("items");
@ -78,7 +88,7 @@ export default Component.extend({
let params = setWizardDefaults({}, itemType);
params.isNew = true;
params.index = items.length;
params.index = this.getNextIndex();
let id = `${itemType}_${params.index + 1}`;
if (itemType === "field") {