FIX: Show global promotions correctly
This commit is contained in:
@ -188,7 +188,8 @@
|
|||||||
elements: ''
|
elements: ''
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
promotions: []
|
promotions: [],
|
||||||
|
selected: []
|
||||||
}
|
}
|
||||||
components = {
|
components = {
|
||||||
button: null,
|
button: null,
|
||||||
@ -206,16 +207,16 @@
|
|||||||
this.setup()
|
this.setup()
|
||||||
}
|
}
|
||||||
add() {
|
add() {
|
||||||
const idx = Math.max(this.data.promotions.length, 0, Math.max(...this.data.promotions) + 1)
|
const idx = Math.max(this.data.selected.length, 0, Math.max(...this.data.selected) + 1)
|
||||||
this.data.promotions.push(idx)
|
this.data.selected.push(idx)
|
||||||
this.draw.promotions()
|
this.draw.promotions()
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
this.data.promotions = []
|
this.data.selected = []
|
||||||
this.draw.promotions()
|
this.draw.promotions()
|
||||||
}
|
}
|
||||||
remove(idx) {
|
remove(idx) {
|
||||||
this.data.promotions = this.data.promotions.filter(promotion => promotion !== idx)
|
this.data.selected = this.data.selected.filter(promotion => promotion !== idx)
|
||||||
this.draw.promotions()
|
this.draw.promotions()
|
||||||
}
|
}
|
||||||
draw = {
|
draw = {
|
||||||
@ -248,7 +249,10 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.components.button.parentElement.style.display = this.display.button
|
this.components.button.parentElement.style.display = this.display.button
|
||||||
this.components.promotions.innerHTML = this.data.promotions.map((promotion, idx) => {
|
if (this.data.selected.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.components.promotions.innerHTML = this.data.selected.map(idx => {
|
||||||
return this.draw.promotion(idx)
|
return this.draw.promotion(idx)
|
||||||
}).join('')
|
}).join('')
|
||||||
this.components.promotions.querySelectorAll('.dropdown').forEach(dropdown => {
|
this.components.promotions.querySelectorAll('.dropdown').forEach(dropdown => {
|
||||||
@ -611,8 +615,8 @@
|
|||||||
this.get.promotions(project_id).then(promotions => {
|
this.get.promotions(project_id).then(promotions => {
|
||||||
this.components.promotions.data.promotions = promotions.map(promotion => {
|
this.components.promotions.data.promotions = promotions.map(promotion => {
|
||||||
return {
|
return {
|
||||||
text: promotion.name,
|
text: promotion.description,
|
||||||
name: promotion.name,
|
name: promotion.description,
|
||||||
value: promotion.id
|
value: promotion.id
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user