Filling edit form

This commit is contained in:
Juan Pablo Vial
2025-11-12 19:49:08 -03:00
parent e278695137
commit 54969eeeab
6 changed files with 116 additions and 89 deletions

View File

@ -30,6 +30,7 @@
const idx = Math.max(this.data.selected.length, 0, Math.max(...this.data.selected) + 1)
this.data.selected.push(idx)
this.draw.promotions()
return idx
}
reset() {
this.data.selected = []
@ -86,6 +87,16 @@
})
}
}
async fill(promotions) {
if (reservations.locks.promotions !== null) {
await reservations.locks.promotions
}
promotions.forEach(promotion => {
const idx = this.add()
const dropdown = $(this.components.promotions.querySelector(`div.promotion[data-id="${idx}"]`).querySelector('div.dropdown'))
dropdown.dropdown('set selected', promotion.id)
})
}
setup() {
this.components.button = document.getElementById(this.ids.button)
this.components.promotions = document.getElementById(this.ids.elements)