Orden de js y FIX: cambio a estado avisos
This commit is contained in:
@ -41,57 +41,62 @@
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var edit = false
|
||||
var faqs = [
|
||||
@foreach ($faqs as $faq)
|
||||
{
|
||||
titulo: '{{$faq->titulo}}',
|
||||
contenido: '{{$faq->contenido}}'
|
||||
},
|
||||
@endforeach
|
||||
]
|
||||
$(document).ready(() => {
|
||||
$('.titulo').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var faq = {
|
||||
edit: false,
|
||||
faqs: [
|
||||
@foreach ($faqs as $faq)
|
||||
{
|
||||
titulo: '{{$faq->titulo}}',
|
||||
contenido: '{{$faq->contenido}}'
|
||||
},
|
||||
@endforeach
|
||||
],
|
||||
setup: () => {
|
||||
$('.titulo').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(faqs[id].titulo)
|
||||
$("textarea[name='contenido']").val(faqs[id].contenido)
|
||||
$('.button.enviar').html('EDITAR')
|
||||
edit = true
|
||||
})
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/faqs/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(faq.faqs[id].titulo)
|
||||
$("textarea[name='contenido']").val(faq.faqs[id].contenido)
|
||||
$('.button.enviar').html('EDITAR')
|
||||
faq.edit = true
|
||||
})
|
||||
})
|
||||
$('.button.resetear').click(() => {
|
||||
$("input[name='id']").val('')
|
||||
$('.button.enviar').html('AGREGAR')
|
||||
edit = false
|
||||
})
|
||||
$('.form').trigger('reset')
|
||||
$('.form').submit((e) => {
|
||||
e.preventDefault()
|
||||
var input = {
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("textarea[name='contenido']").val()
|
||||
}
|
||||
if (edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
var url = '{{$urls->admin}}/faqs/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/faqs/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
return false
|
||||
})
|
||||
$('.button.resetear').click(() => {
|
||||
$("input[name='id']").val('')
|
||||
$('.button.enviar').html('AGREGAR')
|
||||
faq.edit = false
|
||||
})
|
||||
$('.form').trigger('reset')
|
||||
$('.form').submit((e) => {
|
||||
e.preventDefault()
|
||||
var input = {
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("textarea[name='contenido']").val()
|
||||
}
|
||||
if (edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
var url = '{{$urls->admin}}/faqs/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
faq.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -81,93 +81,98 @@
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var edit = false
|
||||
function editAviso(id) {
|
||||
var titulo = $(".link.titulo[data-id='" + id + "']").html()
|
||||
var contenido = $(".link.contenido[data-id='" + id + "']").html()
|
||||
var home = {
|
||||
edit: false,
|
||||
editAviso: (id) => {
|
||||
var titulo = $(".link.titulo[data-id='" + id + "']").html()
|
||||
var contenido = $(".link.contenido[data-id='" + id + "']").html()
|
||||
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(titulo)
|
||||
$("input[name='contenido']").val(contenido)
|
||||
edit = true
|
||||
$('.accion').html('EDITAR')
|
||||
}
|
||||
function submitAviso(e) {
|
||||
e.preventDefault()
|
||||
input = {
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("input[name='contenido']").val()
|
||||
}
|
||||
if (edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
if (input['titulo'] == '') {
|
||||
return false
|
||||
}
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
return false
|
||||
}
|
||||
function deleteAviso(id) {
|
||||
var url = '{{$urls->admin}}/home/avisos/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.link').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
editAviso(id)
|
||||
})
|
||||
$('#avisos').trigger('reset')
|
||||
$('#avisos').submit((e) => {
|
||||
submitAviso(e)
|
||||
})
|
||||
$(".button[type='reset']").click((e) => {
|
||||
$("input[name='id']").val('')
|
||||
$('.accion').html('CREAR')
|
||||
edit = false
|
||||
})
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
deleteAviso(id)
|
||||
})
|
||||
$('.checkbox').checkbox({
|
||||
onChange: function() {
|
||||
var state = $(this).is(':checked')
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, {estado: state}, (data) => {
|
||||
console.debug(data)
|
||||
})
|
||||
}
|
||||
})
|
||||
@if ($avisos->activo)
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$('#resumen').submit((e) => {
|
||||
$("input[name='id']").val(id)
|
||||
$("input[name='titulo']").val(titulo)
|
||||
$("input[name='contenido']").val(contenido)
|
||||
home.edit = true
|
||||
$('.accion').html('EDITAR')
|
||||
},
|
||||
submitAviso: (e) => {
|
||||
e.preventDefault()
|
||||
return false
|
||||
})
|
||||
$('.guardar').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/home/resumen/edit'
|
||||
input = {
|
||||
id: id,
|
||||
titulo: $("input[name='titulo" + id + "']").val(),
|
||||
cantidad: $("input[name='cantidad" + id + "']").val()
|
||||
titulo: $("input[name='titulo']").val(),
|
||||
contenido: $("input[name='contenido']").val()
|
||||
}
|
||||
if (home.edit) {
|
||||
input['id'] = $("input[name='id']").val()
|
||||
}
|
||||
if (input['titulo'] == '') {
|
||||
return false
|
||||
}
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
return false
|
||||
},
|
||||
deleteAviso: (id) => {
|
||||
var url = '{{$urls->admin}}/home/avisos/delete'
|
||||
$.post(url, {id: id}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}, 'json')
|
||||
},
|
||||
setup: () => {
|
||||
$('.link').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
home.editAviso(id)
|
||||
})
|
||||
})
|
||||
$('#avisos').trigger('reset')
|
||||
$('#avisos').submit((e) => {
|
||||
home.submitAviso(e)
|
||||
})
|
||||
$(".button[type='reset']").click((e) => {
|
||||
$("input[name='id']").val('')
|
||||
$('.accion').html('CREAR')
|
||||
home.edit = false
|
||||
})
|
||||
$('.trash.icon').css('cursor', 'pointer').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
home.deleteAviso(id)
|
||||
})
|
||||
$('.checkbox').checkbox({
|
||||
onChange: function() {
|
||||
var state = $(this).is(':checked')
|
||||
var url = '{{$urls->admin}}/home/avisos/add'
|
||||
$.post(url, {estado: state}, (data) => {
|
||||
console.debug(data)
|
||||
})
|
||||
}
|
||||
})
|
||||
@if ($avisos->activo)
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$('#resumen').submit((e) => {
|
||||
e.preventDefault()
|
||||
return false
|
||||
})
|
||||
$('.guardar').click(function() {
|
||||
var id = $(this).attr('data-id')
|
||||
var url = '{{$urls->admin}}/home/resumen/edit'
|
||||
input = {
|
||||
id: id,
|
||||
titulo: $("input[name='titulo" + id + "']").val(),
|
||||
cantidad: $("input[name='cantidad" + id + "']").val()
|
||||
}
|
||||
$.post(url, input, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
home.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -153,112 +153,120 @@
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var months = {
|
||||
long: [],
|
||||
short: []
|
||||
}
|
||||
var date = new Date(2018, 0, 1)
|
||||
for (i = 0; i < 12; i ++) {
|
||||
date.setMonth(i)
|
||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
}
|
||||
function listImage(image) {
|
||||
var icon = $('<i></i>').attr('class', 'trash alternate outline icon')
|
||||
icon.css('cursor', 'pointer').click(function() {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagen/delete'
|
||||
$.post(url, {imagen: image}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
var producto = {
|
||||
months: {
|
||||
long: [],
|
||||
short: []
|
||||
},
|
||||
date: new Date(2018, 0, 1),
|
||||
listImage: (image) => {
|
||||
var icon = $('<i></i>').attr('class', 'trash alternate outline icon')
|
||||
icon.css('cursor', 'pointer').click(function() {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagen/delete'
|
||||
$.post(url, {imagen: image}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
$('#imagenes').append(
|
||||
$('<div></div>').attr('class', 'item').append(
|
||||
icon
|
||||
).append(
|
||||
$('<div></div>').attr('class', 'content').html(image)
|
||||
)
|
||||
)
|
||||
},
|
||||
setMonths: () => {
|
||||
for (i = 0; i < 12; i ++) {
|
||||
producto.date.setMonth(i)
|
||||
producto.months.long.push(producto.date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
producto.months.short.push(producto.date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
}
|
||||
},
|
||||
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())
|
||||
}
|
||||
})
|
||||
})
|
||||
$('#imagenes').append(
|
||||
$('<div></div>').attr('class', 'item').append(
|
||||
icon
|
||||
).append(
|
||||
$('<div></div>').attr('class', 'content').html(image)
|
||||
)
|
||||
)
|
||||
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
||||
$('.calendar').calendar('set date', entrega)
|
||||
$('.checkbox').checkbox()
|
||||
@if ($producto->destacado())
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$("input[name='imagen']").change(function() {
|
||||
var data = new FormData()
|
||||
data.append('imagen', $(this)[0].files[0])
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagenes/add'
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: data,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
@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()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
||||
$.post(url, {}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.selection.dropdown').dropdown()
|
||||
$('.selection.dropdown').dropdown('set selected', '{{$producto->segmento}}')
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: 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())
|
||||
}
|
||||
})
|
||||
var entrega = new Date('{{str_pad(implode('-', array_reverse(explode('/', $producto->entrega))), 7, '20', STR_PAD_LEFT)}}-01T01:00')
|
||||
$('.calendar').calendar('set date', entrega)
|
||||
$('.checkbox').checkbox()
|
||||
@if ($producto->destacado())
|
||||
$('.checkbox').checkbox('set checked')
|
||||
@endif
|
||||
$("input[name='imagen']").change(function() {
|
||||
var data = new FormData()
|
||||
data.append('imagen', $(this)[0].files[0])
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/imagenes/add'
|
||||
$.ajax({
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: data,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
@foreach ($producto->imagenes() as $image)
|
||||
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()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
$('.trash.video').attr('cursor', 'pointer').click(() => {
|
||||
var url = '{{$urls->admin}}/producto/{{$producto->id}}/video/delete'
|
||||
$.post(url, {}, (data) => {
|
||||
if (data.estado) {
|
||||
window.location.reload()
|
||||
}
|
||||
})
|
||||
})
|
||||
producto.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
@ -127,40 +127,48 @@
|
||||
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
var months = {
|
||||
long: [],
|
||||
short: []
|
||||
}
|
||||
var date = new Date(2018, 0, 1)
|
||||
for (i = 0; i < 12; i ++) {
|
||||
date.setMonth(i)
|
||||
months.long.push(date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
var producto = {
|
||||
months: {
|
||||
long: [],
|
||||
short: []
|
||||
},
|
||||
date: new Date(2018, 0, 1),
|
||||
setMonths: () => {
|
||||
for (i = 0; i < 12; i ++) {
|
||||
producto.date.setMonth(i)
|
||||
producto.months.long.push(producto.date.toLocaleString('es-ES', {month: "long"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
producto.months.short.push(producto.date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
}
|
||||
},
|
||||
setup: () => {
|
||||
producto.setMonths()
|
||||
$('.selection.dropdown').dropdown()
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: months.short
|
||||
},
|
||||
formatInput: false,
|
||||
onChange: function(a) {
|
||||
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
||||
}
|
||||
))
|
||||
months.short.push(date.toLocaleString('es-ES', {month: "short"}).replace(
|
||||
/\w\S*/g,
|
||||
function(txt) {
|
||||
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
|
||||
}
|
||||
))
|
||||
})
|
||||
$('.checkbox').checkbox()
|
||||
}
|
||||
}
|
||||
$(document).ready(() => {
|
||||
$('.selection.dropdown').dropdown()
|
||||
$('.calendar').calendar({
|
||||
type: 'month',
|
||||
text: {
|
||||
months: months.long,
|
||||
monthsShort: months.short
|
||||
},
|
||||
formatInput: false,
|
||||
onChange: function(a) {
|
||||
$(this).find('input').val(('0' + (a.getMonth() + 1)).slice(-2) + '/' + a.getFullYear())
|
||||
}
|
||||
})
|
||||
$('.checkbox').checkbox()
|
||||
producto.setup()
|
||||
})
|
||||
</script>
|
||||
@endpush
|
||||
|
Reference in New Issue
Block a user