Unit promotions
This commit is contained in:
@ -293,34 +293,7 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.components.units.innerHTML = this.data.units.map(unit => {
|
this.components.units.innerHTML = this.data.units.map(unit => {
|
||||||
return [
|
return this.draw.unit(unit)
|
||||||
'<div class="fields">',
|
|
||||||
'<div class="four wide field">',
|
|
||||||
`<label>${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</label>`,
|
|
||||||
`<div class="ui search selection dropdown">`,
|
|
||||||
'<input type="hidden" name="add_units[]" />',
|
|
||||||
'<i class="dropdown icon"></i>',
|
|
||||||
`<div class="default text">${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</div>`,
|
|
||||||
'<div class="menu">',
|
|
||||||
this.data.types[unit.type].map(unit => {
|
|
||||||
return `<div class="item" data-value="${unit.value}">${unit.name}</div>`
|
|
||||||
}).join(''),
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'<div class="three wide field">',
|
|
||||||
'<label>Valor</label>',
|
|
||||||
'<div class="ui right labeled input">',
|
|
||||||
'<input type="number" name="add_units_value[]" placeholder="Valor" />',
|
|
||||||
'<div class="ui basic label">UF</div>',
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
'<div class="field">',
|
|
||||||
'<label></label>',
|
|
||||||
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
|
||||||
'</div>',
|
|
||||||
'</div>',
|
|
||||||
].join('')
|
|
||||||
}).join('')
|
}).join('')
|
||||||
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
|
this.components.units.querySelectorAll('.dropdown').forEach(dropdown => {
|
||||||
$(dropdown).dropdown()
|
$(dropdown).dropdown()
|
||||||
@ -331,6 +304,52 @@
|
|||||||
this.remove(idx)
|
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 [
|
||||||
|
'<div class="fields">',
|
||||||
|
'<div class="four wide field">',
|
||||||
|
`<label>${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</label>`,
|
||||||
|
`<div class="ui search selection dropdown">`,
|
||||||
|
'<input type="hidden" name="add_units[]" />',
|
||||||
|
'<i class="dropdown icon"></i>',
|
||||||
|
`<div class="default text">${unit.type.charAt(0).toUpperCase() + unit.type.slice(1)}</div>`,
|
||||||
|
'<div class="menu">',
|
||||||
|
this.data.types[unit.type].map(unit => {
|
||||||
|
return `<div class="item" data-value="${unit.value}">${unit.name}</div>`
|
||||||
|
}).join(''),
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
'<div class="three wide field">',
|
||||||
|
'<label>Valor</label>',
|
||||||
|
'<div class="ui right labeled input">',
|
||||||
|
'<input type="number" name="add_units_value[]" placeholder="Valor" />',
|
||||||
|
'<div class="ui basic label">UF</div>',
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
promotions,
|
||||||
|
'<div class="field">',
|
||||||
|
'<label></label>',
|
||||||
|
`<button class="ui red tiny icon button remove_unit" type="button" data-id="${unit.idx}"><i class="trash icon"></i></button>`,
|
||||||
|
'</div>',
|
||||||
|
'</div>',
|
||||||
|
].join('')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reset() {
|
reset() {
|
||||||
|
Reference in New Issue
Block a user