Unit promotions
This commit is contained in:
@ -293,6 +293,34 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.components.units.innerHTML = this.data.units.map(unit => {
|
this.components.units.innerHTML = this.data.units.map(unit => {
|
||||||
|
return this.draw.unit(unit)
|
||||||
|
}).join('')
|
||||||
|
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
|
||||||
|
$(dropdown).dropdown()
|
||||||
|
})
|
||||||
|
this.components.units.querySelectorAll('.remove_unit').forEach(button => {
|
||||||
|
button.addEventListener('click', () => {
|
||||||
|
const idx = Number(button.dataset.id)
|
||||||
|
this.remove(idx)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
unit: unit => {
|
||||||
|
let promotions = ''
|
||||||
|
if (unit.type === 'departamento') {
|
||||||
|
promotions = [
|
||||||
|
'<div class="three wide field>',
|
||||||
|
'<label>Promociones</label>',
|
||||||
|
'<div class="ui multiple search selection dropdown add_promotions_unit">',
|
||||||
|
'<input type="hidden" name="add_units_promotions[]" />',
|
||||||
|
'<i class="dropdown icon"></i>',
|
||||||
|
'<div class="default text">Promociones</div>',
|
||||||
|
'<div class="menu">',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>'
|
||||||
|
].join('')
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
'<div class="fields">',
|
'<div class="fields">',
|
||||||
'<div class="four wide field">',
|
'<div class="four wide field">',
|
||||||
@ -315,22 +343,13 @@
|
|||||||
'<div class="ui basic label">UF</div>',
|
'<div class="ui basic label">UF</div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
|
promotions,
|
||||||
'<div class="field">',
|
'<div class="field">',
|
||||||
'<label></label>',
|
'<label></label>',
|
||||||
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
||||||
'</div>',
|
'</div>',
|
||||||
'</div>',
|
'</div>',
|
||||||
].join('')
|
].join('')
|
||||||
}).join('')
|
|
||||||
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
|
|
||||||
$(dropdown).dropdown()
|
|
||||||
})
|
|
||||||
this.components.units.querySelectorAll('.remove_unit').forEach(button => {
|
|
||||||
button.addEventListener('click', () => {
|
|
||||||
const idx = Number(button.dataset.id)
|
|
||||||
this.remove(idx)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
Reference in New Issue
Block a user