diff --git a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj index aeae5b7df..1a04af18a 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj +++ b/AYA.SlnSynor/AYA.SlnSynor/AYA.SlnSinort.csproj @@ -7685,6 +7685,7 @@ + @@ -7721,6 +7722,7 @@ + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs index 1450e3544..551e0305c 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs +++ b/AYA.SlnSynor/AYA.SlnSynor/Controllers/Catalogos/CatalogosController.cs @@ -40,6 +40,10 @@ namespace AYA.SlnSinort.Controllers.Catalogos InitControllers(); return View(); } - + public ActionResult SubCategoriaContenido() + { + 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 33014bdb3..1e4c3d865 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 index 9e9fabf8e..d83cae9cc 100644 --- a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Contenido.js +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/Contenido.js @@ -111,7 +111,7 @@ 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?'; + msg = '¿Está seguro que desea deshabilitar el Contenido?'; } if (id == null || value == null) { @@ -126,7 +126,7 @@ this.toggleEnabledItem = function (id, value) { Contenido = { IdContenido: id, - Estado: value, + Estado: value } var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; @@ -147,8 +147,8 @@ this.ActualizarItem = function () { Contenido = { IdContenido: $('#hiddenId').val(), - Descripcion: $('#txtDescripcion').val(), - Estado: 1, + Descripcion: $('#txtDescripcion').val() + } var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; @@ -163,14 +163,14 @@ this.InsertarItem = function () { return false; } - if (!confirm("Va a ingresar un nuevo Emisor .\n ¿Desea continuar?")) + if (!confirm("Va a ingresar un nuevo Contenido .\n ¿Desea continuar?")) { return; } TableItems = $('#TableItems').DataTable(); Contenido = { - IdContenido: 1, - Descripcion: $("#txtDescripcion").val(), + Estado: 1, + Descripcion: $("#txtDescripcion").val() } var uri = CatalogosWCF + '/api/InsertarActualizarContenido'; diff --git a/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/SubCategoriaContenido.js b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/SubCategoriaContenido.js new file mode 100644 index 000000000..b7a911473 --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Sinort-Scripts/SubCategoriaContenido.js @@ -0,0 +1,277 @@ +var DataCatalogo; +var id_column = 1; +var Item = {}; + + +jQuery(document).ready(function () { + + getDataModel(); + +}); + +this.getDataModel = function () { + + CargarContenido(); + + + $('#txtDescripcion').attr('size', 50); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + + $('#btnLimpiarControles').click(function () { + LimpiarControles(); + + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + }); + + $('#btnGuardar').click(function () { + ActualizarItem(); + }); + + $('#btnInsertar').click(function () { + InsertarItem(); + }); + + + $("#btnBuscarContenido").unbind("click"); + $("#btnBuscarContenido").click(function () { + + SelectedCatalog = 'Contenido'; + + if ($.fn.DataTable.isDataTable('#tableContenido')) { + + LoadMessage(); + + $('#tableContenido').DataTable().search('').draw(); + + $('#modalContenido').modal('show'); + + ENDREQUEST(); + + } + }); + + + $('#tableContenido').on('click', 'button', function () { + + var data = $('#tableContenido').DataTable().row($(this).parents('tr')).data(); + + if (SelectedCatalog == "Contenido") { + + $('#hiddenContenido').val(data.codigo); + $('#txtContenido').val(data.descripcion); + } + $('#modalContenido').modal('hide'); + + }); + + + + + $('#TableItems').TableInit(0, false, true, true, false, null, null); + ObtenerSubCategoriaContenido(); + +} + + +this.CargarContenido = function (filtro) { + + var uri = CatalogosWCF + '/api/ObtenerContenidoPopUp'; + var model = { + + filtro: filtro == null ? '' : '&filtro=' + filtro + } + + AjaxPostData(uri, model, false, false, CargarGridContenido, null, null); + +} + + +this.CargarGridContenido = function (data) { + + if (data != null) { + + listaContenido = data; + + var Seleccionar = $("#ucBtnSeleccionarCatalogo").html(); + + var columnDefinition = [ + { "data": null, className: "center", defaultContent: Seleccionar }, + { "data": "codigo" }, + { "data": "descripcion" } + ]; + + $('#tableContenido').TableInit(0, false, true, true, false, columnDefinition, listaContenido, false); + } + + else { + + toastr.error("Ha ocurrido un error inesperado. Vuelva a intentarlo mas tarde", Message_Error); + } +} + +this.CargarGridSubCategoriaContenido = function (data) { + + var TableItems = $('#TableItems').DataTable(); + var lista = data; + + $.each(lista, function (key, item) { + + var option = $("#ucItemsCatalogo").html(); + + option = replaceAll("[$CodItem]", item.IdSubCategoriaContenido, 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.IdSubCategoriaContenido, + item.Descripcion, + item.Contenido.Descripcion, + option]).draw(); + + }); + + ENDREQUEST(); +} + +this.ObtenerSubCategoriaContenido = function () { + + var uri = CatalogosWCF + '/api/ObtenerSubCategoriaContenido'; + AjaxPostData(uri, null, false, false, CargarGridSubCategoriaContenido, 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 la Sub Categoria de Contenido ?'; + + if (value == 0) { + msg = '¿Está seguro que desea deshabilitar la Sub Categoria de Contenido ?'; + } + + if (id == null || value == null) { + toastr.warning("No se pudo obtener el ID de la Sub Categoria de Contenido seleccionada."); + return; + } + + if (!confirm(msg)) + { return; } + + TableItems = $('#TableItems').DataTable(); + + SubCategoriaContenido = { + IdSubCategoriaContenido: id, + Estado: value + } + + var uri = CatalogosWCF + '/api/InsertarActualizarSubCategoriaContenido'; + AjaxPostData(uri, SubCategoriaContenido, 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(); + + SubCategoriaContenido = { + IdSubCategoriaContenido: $('#hiddenId').val(), + Descripcion: $('#txtDescripcion').val() + + } + + var uri = CatalogosWCF + '/api/InsertarActualizarSubCategoriaContenido'; + AjaxPostData(uri, SubCategoriaContenido, 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 una nueva Sub Categoria de Contenido .\n ¿Desea continuar?")) + { return; } + + + TableItems = $('#TableItems').DataTable(); + Contenido = { + Estado : 1, + IdContenido: $("#hiddenContenido").val(), + Descripcion: $("#txtDescripcion").val() + } + + var uri = CatalogosWCF + '/api/InsertarActualizarSubCategoriaContenido'; + AjaxPostData(uri, Contenido, true, true, CompletarAccion, null, null); + +} + +this.CompletarAccion = function () { + $('#btnGuardar').hide(); + $('#btnInsertar').show(); + + TableItems.clear().draw(); + ObtenerSubCategoriaContenido(); + LimpiarControles(); + ENDREQUEST(); +} + +this.LimpiarControles = function () { + + $('#txtDescripcion').val(''); + $("#formCatalogo").validateElement("#txtDescripcion"); + + $('#lbTituloAccion').empty(); + $('#lbTituloAccion').append('Ingresar Nueva Sub Categoria de Contenido'); +} + + diff --git a/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/SubCategoriaContenido.cshtml b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/SubCategoriaContenido.cshtml new file mode 100644 index 000000000..5a3d4d4da --- /dev/null +++ b/AYA.SlnSynor/AYA.SlnSynor/Views/Catalogos/SubCategoriaContenido.cshtml @@ -0,0 +1,184 @@ +@{ + ViewBag.Title = "Contenido"; + Layout = "~/Views/Shared/_Layout.cshtml"; + +} + + + + + + SubCategoria Contenido + + + + + + + + + + @*--------------------- Catalogo de contenido ---------------------------------------------------------*@ + + + Contenido + + + + + + + + + + + + + + + + @*--------------------- Fin Catalogo de contenido ---------------------------------------------------------*@ + + + + + + + + ID + Descripción + Contenido + + + + + + + + + + + + + + Opciones + + + Editar + [$opcion] + + + + + + + + + + + Ingresar Nueva SubCategoria Contenido + + + + + @*Descripción*@ + + + + + Descripción + + + + + + + + + + + Limpiar + + + + + + + Insertar + + + Guardar + + + + + + + + + + + + + + + + + + + + + + + + +@section Modals{ + + @*---------------------Catalogo Contenido ---------------------------------------------------------*@ + + + + + × + Catálogo Contenido + + + + + + + + + + + + + Código + Descripción + + + + + + + + + + + + + + + + + +} + +@Scripts.Render("~/Sinort-Scripts/SubCategoriaContenido.js") + + + + + + +