diff --git a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj index 43b5c68c7..aeae5b7df 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj +++ b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj @@ -7675,6 +7675,7 @@ + @@ -7719,6 +7720,7 @@ + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs index 3c29cb140..1450e3544 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs +++ b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs @@ -35,7 +35,11 @@ namespace AYA.SlnSinort.Controllers.Catalogos InitControllers(); return View(); } - + public ActionResult Contenido() + { + InitControllers(); + return View(); + } } } \ No newline at end of file diff --git a/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js b/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js index 0887a2749..33014bdb3 100644 Binary files a/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js and b/AYA.SlnSynor/AYA.SlnSynor/Scripts/_references.js differ diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Contenido.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Contenido.js new file mode 100644 index 000000000..9e9fabf8e --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Contenido.js @@ -0,0 +1,200 @@ +var DataCatalogo; +var id_column = 1; +var Item = {}; + + +jQuery(document).ready(function () { + + getDataModel(); + +}); + +this.getDataModel = function () { + + $('#txtDescripcion').attr('size', 50); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + + $('#btnLimpiarControles').click(function () { + LimpiarControles(); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + }); + + $('#btnGuardar').click(function () { + ActualizarItem(); + }); + + $('#btnInsertar').click(function () { + InsertarItem(); + }); + + + $('#TableItems').TableInit(0, false, true, true, false, null, null); + ObtenerContenido(); + +} + +this.CargarGridContenido = function (data) { + + var TableItems = $('#TableItems').DataTable(); + var lista = data; + + $.each(lista, function (key, item) { + + var option = $("#ucItemsCatalogo").html(); + + option = replaceAll("[$CodItem]", item.IdContenido, option); + + var stateIcon = $("#ucItemsIcon").html(); + + if (item.Estado == false) { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "muted", stateIcon); + + option = replaceAll("[$opcion]", "Habilitar", option); + option = replaceAll("[$icon]", "fa-check", option); + option = replaceAll("[$value]", "1", option); + } + else { + stateIcon = replaceAll("[$icon]", "fa-check-circle", stateIcon); + stateIcon = replaceAll("[$state_color]", "success", stateIcon); + + option = replaceAll("[$opcion]", "Deshabilitar", option); + option = replaceAll("[$icon]", "fa-times", option); + option = replaceAll("[$value]", "0", option); + } + TableItems.column(1).visible(false); + TableItems.row.add([stateIcon, + item.IdContenido, + item.Descripcion, + option]).draw(); + + }); + + ENDREQUEST(); +} + +this.ObtenerContenido = function () { + + var uri = CatalogosWCF + '/api/ObtenerContenido'; + AjaxPostData(uri, null, false, false, CargarGridContenido, null, null); + +} + +this.EditarItem = function (id) { + + TableItems = $('#TableItems').DataTable(); + LimpiarControles(); + var indexes = getRowIndex(TableItems, id_column, id); + + if (indexes != null) { + + $('#hiddenId').val(id) + $('#txtDescripcion').val(TableItems.cell(indexes, 2).data()); + + $("#formCatalogo").validateElement("#txtDescripcion"); + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Editar Valor de Campo ID: ' + id); + + $('#btnInsertar').hide(); + $('#btnGuardar').show(); + } +} + +this.toggleEnabledItem = function (id, value) { + + var msg = '¿Está seguro que desea habilitar el Contenido?'; + + if (value == 0) { + msg = '¿Está seguro que desea deshabilitar el Contendido?'; + } + + if (id == null || value == null) { + toastr.warning("No se pudo obtener el ID del Contenido seleccionado."); + return; + } + + if (!confirm(msg)) + { return; } + + TableItems = $('#TableItems').DataTable(); + + Contenido = { + IdContenido: id, + Estado: value, + } + + var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; + AjaxPostData(uri, Contenido, true, true, CompletarAccion, null, null); +} + +this.ActualizarItem = function () { + + if (!$("#formCatalogo").valid()) { + toastr.warning("Ingresar todos los campos que son requeridos."); + return false; + } + + if (!confirm("Se guardarán los cambios.\n ¿Desea continuar?")) + { return; } + + TableItems = $('#TableItems').DataTable(); + + Contenido = { + IdContenido: $('#hiddenId').val(), + Descripcion: $('#txtDescripcion').val(), + Estado: 1, + } + + var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; + AjaxPostData(uri, Contenido, true, true, CompletarAccion, null, null); +} + +this.InsertarItem = function () { + + + if (!$("#formCatalogo").valid()) { + toastr.warning("Ingresar todos los campos que son requeridos."); + return false; + } + + if (!confirm("Va a ingresar un nuevo Emisor .\n ¿Desea continuar?")) + { return; } + + + TableItems = $('#TableItems').DataTable(); + Contenido = { + IdContenido: 1, + Descripcion: $("#txtDescripcion").val(), + } + + var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; + AjaxPostData(uri, Contenido , true, true, CompletarAccion, null, null); + +} + +this.CompletarAccion = function () { + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + TableItems.clear().draw(); + ObtenerContenido(); + LimpiarControles(); + ENDREQUEST(); +} + +this.LimpiarControles = function () { + + $('#txtDescripcion').val(''); + $("#formCatalogo").validateElement("#txtDescripcion"); + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Ingresar Nuevo Contenido'); +} + + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Contenido.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Contenido.cshtml new file mode 100644 index 000000000..28fc4a279 --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/Contenido.cshtml @@ -0,0 +1,105 @@ +@{ + ViewBag.Title = "Contenido"; + Layout = "~/Views/Shared/_Layout.cshtml"; + +} + + + + Contenido + + + + + + + + + + + + ID + Descripción + @*Tipo Emisor*@ + + + + + + + + + + + + + + Opciones + + + Editar + [$opcion] + + + + + + + + + + + Ingresar Nuevo Contenido + + + + + @*Descripción*@ + + + + + Descripción + + + + + + + + + + + Limpiar + + + + + + + Insertar + + + Guardar + + + + + + + + + + + + + + + + +@Scripts.Render("~/Sinort-Scripts/Contenido.js") + + + + +