FIX: varias observaciones
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
use ProVM\KI\Common\Controller\Web\Admin\Productos;
|
||||
|
||||
$app->group('/productos', function($app) {
|
||||
$app->post('/campos', [Productos::class, 'fields']);
|
||||
$app->group('/add', function($app) {
|
||||
$app->get('[/]', [Productos::class, 'add']);
|
||||
$app->post('[/]', [Productos::class, 'do_add']);
|
||||
|
@ -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ón</label>
|
||||
<textarea rows="1" name="descripcion">{{$producto->descripcion ?? ''}}</textarea>
|
||||
<div class="row">
|
||||
<div class="ten wide column">
|
||||
<div class="field">
|
||||
<label>Descripció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()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -58,75 +58,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="campos"></div>
|
||||
@foreach ($properties as $property)
|
||||
<div class="column">
|
||||
<div id="end_campos"></div>
|
||||
<div class="row">
|
||||
<div class="ten wide column">
|
||||
<div class="field">
|
||||
<label>{{$property->label}}</label>
|
||||
<input type="text" name="{{$property->name}}" />
|
||||
<label>Descripción</label>
|
||||
<textarea rows="1" name="descripcion"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<!-- <div class="column">
|
||||
<div class="field">
|
||||
<label>Bono Pie en UF</label>
|
||||
<input type="text" name="bono" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Rentabilidad %</label>
|
||||
<input type="text" name="rentabilidad" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Valor Cuota en UF</label>
|
||||
<input type="text" name="cuota" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Entrega Estimada</label>
|
||||
<div class="ui calendar">
|
||||
<input type="text" name="entrega" placeholder="Entrega" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Estado</label>
|
||||
<input type="text" name="estado" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Unidades</label>
|
||||
<input type="text" name="unidades" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="field">
|
||||
<label>Modelos</label>
|
||||
<input type="text" name="modelos" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="column">
|
||||
<div class="fields">
|
||||
<div class="field">
|
||||
<label>Tamaño Mínimo</label>
|
||||
<input type="text" name="tamaño_min" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label>Tamaño Máximo</label>
|
||||
<input type="text" name="tamaño_max" />
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div class="ten wide column">
|
||||
<div class="field">
|
||||
<label>Descripción</label>
|
||||
<textarea rows="1" name="descripcion"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
@ -161,12 +100,16 @@
|
||||
},
|
||||
setup: () => {
|
||||
producto.setMonths()
|
||||
$('#segmento').dropdown()
|
||||
$('#segmento').dropdown({
|
||||
onChange: () => {
|
||||
producto.changeSegmento()
|
||||
}
|
||||
})
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: months.short
|
||||
months: producto.months.long,
|
||||
monthsShort: producto.months.short
|
||||
},
|
||||
formatInput: false,
|
||||
onChange: function(a) {
|
||||
@ -180,6 +123,17 @@
|
||||
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()
|
||||
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(
|
||||
$('<div></div>').attr('class', 'field').append(
|
||||
@ -188,6 +142,7 @@
|
||||
$('<input />').attr('type', 'text').attr('name', el.name)
|
||||
)
|
||||
)
|
||||
end.before(campo)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user