FIX: varias observaciones

This commit is contained in:
2020-06-03 23:54:15 -04:00
parent 5864efd24f
commit 4923c6c67d
5 changed files with 73 additions and 341 deletions

View File

@ -31,7 +31,7 @@
<div class="column">
<div class="field">
<label>Segmento</label>
<div class="ui selection dropdown">
<div class="ui selection dropdown" id="segmento">
<input type="hidden" name="segmento" />
<i class="dropdown icon"></i>
<div class="default text">Segmento</div>
@ -67,10 +67,12 @@
</div>
@endforeach
<span id="end_campos"></span>
<div class="ten wide column">
<div class="field">
<label>Descripci&oacute;n</label>
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
<div class="row">
<div class="ten wide column">
<div class="field">
<label>Descripci&oacute;n</label>
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
</div>
</div>
</div>
<div class="column">
@ -80,25 +82,6 @@
</div>
<div id="imagenes" class="ui list"></div>
</div>
<?php
/*
<div class="column">
<div class="field">
<label>Video</label>
<input type="file" name="video" />
</div>
<div class="ui list">
@if (isset($producto->video))
<div class="item">
<i class="trash alternate outline icon video"></i>
<div class="content">
{{$producto->video}}
</div>
</div>
@endif
</div>
</div>
*/?>
</div>
<br />
<button class="ui button">GUARDAR</button>
@ -150,24 +133,13 @@
},
setup: () => {
producto.setMonths()
$('.selection.dropdown').dropdown()
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
$('.calendar').calendar({
type: 'month',
text: {
months: producto.months.long,
monthsShort: producto.months.short
},
formatInput: false,
onChange: function(a, b) {
if (typeof a == 'undefined') {
a = new Date()
}
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
$('#segmento').dropdown({
onChange: () => {
producto.changeSegmento()
}
})
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
$('.calendar').calendar('set date', entrega)
$('#segmento').dropdown('set selected', '{{$producto->segmento}}')
producto.linkCalendar()
$('.checkbox').checkbox()
@if ($producto->destacado())
$('.checkbox').checkbox('set checked')
@ -192,44 +164,50 @@
@foreach ($producto->imagenes() as $image)
producto.listImage('{{$image}}')
@endforeach
$("input[name='video']").change(function() {
var fData = new FormData()
fData.append('video', $("input[name='video']")[0].files[0])
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/set'
$.ajax({
url: url,
method: 'post',
data: fData,
contentType: false,
processData: false,
success: (data) => {
if (data.estado) {
window.location.reload()
}
},
linkCalendar: () => {
var div = $("input[name='entrega']").parent()
div.find('input').remove()
div.append(
$('<div></div>').attr('class', 'ui calendar').append(
$('<input />').attr('type', 'text').attr('name', 'entrega').attr('placeholder', 'Entrega')
)
)
$('.calendar').calendar({
type: 'month',
text: {
months: producto.months.long,
monthsShort: producto.months.short
},
formatInput: false,
onChange: function(a, b) {
if (typeof a == 'undefined') {
a = new Date()
}
})
})
$('.trash.video').attr('cursor', 'pointer').click(() => {
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
$.post(url, {}, (data) => {
if (data.estado) {
window.location.reload()
}
})
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
}
})
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
$('.calendar').calendar('set date', entrega)
},
changeSegmento: () => {
var segmento = $('#segmento').dropdown('get value')
if (segmento == '{{$producto->segmento}}') {
return
}
var url = '{{$urls->admin}}/productos/campos'
$.post(url, {segmento: segmento}, (data) => {
var div = $('#campos')
var end = $('#end_campos')
var current = div.next()
var next = current.next()
while (next != end) {
current.remove()
current = next
next = next.next()
if (current[0] == end[0] || next[0] == end[0]) {
} else {
while (next[0] != end[0] || next.length == 0) {
current.remove()
current = next
next = next.next()
}
}
$.each(data.fields, (i, el) => {
var campo = $('<div></div>').attr('class', 'column').append(
@ -241,6 +219,7 @@
)
end.before(campo)
})
producto.linkCalendar()
})
}
}