[EDIT] CAMBIOS PARA LA EDICION DE MENU Y PERMISOS POR VISTA

parent 72fb43bf
...@@ -8,91 +8,98 @@ package com.mycompany.moduloseguridad.dao; ...@@ -8,91 +8,98 @@ package com.mycompany.moduloseguridad.dao;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.sql.SQLException;
/** /**
*
* @author sistem17user * @author sistem17user
*/ */
public interface MenuDAO { public interface MenuDAO {
public JSONArray listarProyecto(int estado) throws Exception; JSONArray listarProyecto(int estado) throws Exception;
JSONArray listarTipoDeUsuario(int proyecto) throws Exception;
JSONArray listarTituloCompleto(int proyecto_detalle, int proyecto, int tipo) throws Exception;
JSONArray listarModuloCompleto(int titulo, int proyecto_detalle, int proyecto, int tipo) throws Exception;
public JSONArray listarTipoDeUsuario(int proyecto) throws Exception; JSONArray listarCategoriaCompleto(int modulo, int proyecto_detalle, int proyecto, int tipo) throws Exception;
public JSONArray listarTituloCompleto(int proyecto_detalle, int proyecto, int tipo) throws Exception; JSONArray listarSubCategoriaCompleto(int categoria, int proyecto_detalle, int proyecto, int tipo) throws Exception;
public JSONArray listarModuloCompleto(int titulo, int proyecto_detalle, int proyecto, int tipo) throws Exception; JSONObject editarTitulo(JSONObject datos) throws Exception;
public JSONArray listarCategoriaCompleto(int modulo, int proyecto_detalle, int proyecto, int tipo) throws Exception; JSONObject editarModulo(JSONObject datos) throws Exception;
public JSONArray listarSubCategoriaCompleto(int categoria, int proyecto_detalle, int proyecto, int tipo) throws Exception; JSONObject editarCategoria(JSONObject datos) throws Exception;
public JSONObject editarTitulo(JSONObject datos) throws Exception; JSONObject editarSubCategoria(JSONObject datos) throws Exception;
public JSONObject editarModulo(JSONObject datos) throws Exception; JSONObject nuevoTitulo(JSONObject datos) throws Exception;
public JSONObject editarCategoria(JSONObject datos) throws Exception; JSONObject nuevoModulo(JSONObject datos) throws Exception;
public JSONObject editarSubCategoria(JSONObject datos) throws Exception; JSONObject nuevoCategoria(JSONObject datos) throws Exception;
public JSONObject nuevoTitulo(JSONObject datos) throws Exception; JSONObject nuevoSubCategoria(JSONObject datos) throws Exception;
public JSONObject nuevoModulo(JSONObject datos) throws Exception; JSONObject eliminarDetalleTitulo(JSONObject datos) throws Exception;
public JSONObject nuevoCategoria(JSONObject datos) throws Exception; JSONObject eliminarDetalleModulo(JSONObject datos) throws Exception;
public JSONObject nuevoSubCategoria(JSONObject datos) throws Exception; JSONObject eliminarDetalleCategoria(JSONObject datos) throws Exception;
public JSONObject eliminarDetalleTitulo(JSONObject datos) throws Exception; JSONObject eliminarDetalleSubCategoria(JSONObject datos) throws Exception;
public JSONObject eliminarDetalleModulo(JSONObject datos) throws Exception; JSONObject cambiarOrdenTitulo(JSONObject datos) throws Exception;
public JSONObject eliminarDetalleCategoria(JSONObject datos) throws Exception; JSONObject cambiarOrdenModulo(JSONObject datos) throws Exception;
public JSONObject eliminarDetalleSubCategoria(JSONObject datos) throws Exception; JSONObject cambiarOrdenCategoria(JSONObject datos) throws Exception;
public JSONObject cambiarOrdenTitulo(JSONObject datos) throws Exception; JSONObject cambiarOrdenSubCategoria(JSONObject datos) throws Exception;
public JSONObject cambiarOrdenModulo(JSONObject datos) throws Exception; JSONObject reconocerNombreSimilar(JSONObject datos) throws Exception;
public JSONObject cambiarOrdenCategoria(JSONObject datos) throws Exception; JSONObject nuevoTituloExistente(JSONObject datos) throws Exception;
public JSONObject cambiarOrdenSubCategoria(JSONObject datos) throws Exception; JSONObject nuevoModuloExistente(JSONObject datos) throws Exception;
public JSONObject reconocerNombreSimilar(JSONObject datos) throws Exception; JSONObject nuevoCategoriaExistente(JSONObject datos) throws Exception;
public JSONObject nuevoTituloExistente(JSONObject datos) throws Exception; JSONObject nuevoSubCategoriaExistente(JSONObject datos) throws Exception;
public JSONObject nuevoModuloExistente(JSONObject datos) throws Exception; JSONObject validarEdicionTitulo(JSONObject datos) throws Exception;
public JSONObject nuevoCategoriaExistente(JSONObject datos) throws Exception; JSONObject validarEdicionModulo(JSONObject datos) throws Exception;
public JSONObject nuevoSubCategoriaExistente(JSONObject datos) throws Exception; JSONObject validarEdicionCategoria(JSONObject datos) throws Exception;
public JSONObject validarEdicionTitulo(JSONObject datos) throws Exception; JSONObject validarEdicionSubCategoria(JSONObject datos) throws Exception;
public JSONObject validarEdicionModulo(JSONObject datos) throws Exception; JSONObject listarTitulo(JSONObject datos, String draw, String start, String length) throws Exception;
public JSONObject validarEdicionCategoria(JSONObject datos) throws Exception; JSONObject listarModulo(JSONObject datos, String draw, String start, String length) throws Exception;
public JSONObject validarEdicionSubCategoria(JSONObject datos) throws Exception; JSONObject listarCategoria(JSONObject datos, String draw, String start, String length) throws Exception;
public JSONObject listarTitulo(JSONObject datos, String draw, String start, String length) throws Exception; JSONObject listarSubCategoria(JSONObject datos, String draw, String start, String length) throws Exception;
public JSONObject listarModulo(JSONObject datos, String draw, String start, String length) throws Exception; JSONObject validarElminarTitulo(JSONObject datos) throws Exception;
public JSONObject listarCategoria(JSONObject datos, String draw, String start, String length) throws Exception; JSONObject validarElminarModulo(JSONObject datos) throws Exception;
public JSONObject listarSubCategoria(JSONObject datos, String draw, String start, String length) throws Exception; JSONObject validarElminarCategoria(JSONObject datos) throws Exception;
public JSONObject validarElminarTitulo(JSONObject datos) throws Exception; JSONObject validarElminarSubCategoria(JSONObject datos) throws Exception;
public JSONObject validarElminarModulo(JSONObject datos) throws Exception; JSONObject eliminarMenusAninado(JSONObject datos) throws Exception;
public JSONObject validarElminarCategoria(JSONObject datos) throws Exception; JSONObject eliminarMenusAninadoGeneral(JSONObject datos) throws Exception;
public JSONObject validarElminarSubCategoria(JSONObject datos) throws Exception; JSONArray obtenerAcciones(int codigo, int jerarquia, int tipo_usuario) throws Exception;
public JSONObject eliminarMenusAninado(JSONObject datos) throws Exception; JSONObject listarPermisosPorVista(JSONObject datos) throws Exception;
public JSONObject eliminarMenusAninadoGeneral(JSONObject datos) throws Exception; JSONObject asignarAccionesPorVista(JSONObject json) throws SQLException;
} }
\ No newline at end of file
...@@ -225,7 +225,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -225,7 +225,7 @@ public class MenuMYSQLDAO implements MenuDAO {
if (tipo == 1) { if (tipo == 1) {
extra = " -1 "; extra = " -1 ";
} }
query = "select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, 0, 0, count(*) as cant " query = "select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, 0, 0, count(*) as cant, c.esvisible "
+ "from categoria_configuracion tc " + "from categoria_configuracion tc "
+ "left join proyecto_detalle as pd " + "left join proyecto_detalle as pd "
+ "on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle " + "on tc.cod_proyecto_detalle = pd.cod_proyecto_detalle "
...@@ -241,7 +241,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -241,7 +241,7 @@ public class MenuMYSQLDAO implements MenuDAO {
+ "where cod_proyecto = " + proyecto + " " + "where cod_proyecto = " + proyecto + " "
+ ") "; + ") ";
} else { } else {
query = " select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, cc.cod_categoria_configuracion, cc.ord from categoria as c " query = " select c.cod_modulo, c.cod_categoria, c.nom, c.url, c.tip, c.est, cc.cod_categoria_configuracion, cc.ord, c.esvisible from categoria as c "
+ " inner join categoria_configuracion as cc" + " inner join categoria_configuracion as cc"
+ " on cc.cod_categoria = c.cod_categoria " + " on cc.cod_categoria = c.cod_categoria "
+ " where cod_proyecto_detalle = " + proyecto_detalle + " " + " where cod_proyecto_detalle = " + proyecto_detalle + " "
...@@ -261,6 +261,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -261,6 +261,7 @@ public class MenuMYSQLDAO implements MenuDAO {
obj.put("estadoCategoria", rs.getString(6)); obj.put("estadoCategoria", rs.getString(6));
obj.put("configuracionCategoria", rs.getString(7)); obj.put("configuracionCategoria", rs.getString(7));
obj.put("ordenCategoria", rs.getString(8)); obj.put("ordenCategoria", rs.getString(8));
obj.put("esVisible", rs.getBoolean(9));
lista.put(obj); lista.put(obj);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -288,7 +289,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -288,7 +289,7 @@ public class MenuMYSQLDAO implements MenuDAO {
if (tipo == 1) { if (tipo == 1) {
extra = " -1 "; extra = " -1 ";
} }
query = "select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, 0, 0, count(*) as cant " query = "select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, 0, 0, count(*) as cant, s.esvisible "
+ "from subcategoria_configuracion sc " + "from subcategoria_configuracion sc "
+ "left join proyecto_detalle as pd " + "left join proyecto_detalle as pd "
+ "on sc.cod_proyecto_detalle = pd.cod_proyecto_detalle " + "on sc.cod_proyecto_detalle = pd.cod_proyecto_detalle "
...@@ -304,7 +305,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -304,7 +305,7 @@ public class MenuMYSQLDAO implements MenuDAO {
+ "where cod_proyecto = " + proyecto + " " + "where cod_proyecto = " + proyecto + " "
+ ") "; + ") ";
} else { } else {
query = " select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, sc.cod_subcategoria_configuracion, sc.ord from subcategoria as s" query = " select s.cod_subcategoria, s.cod_categoria, s.nom, s.url, s.est, sc.cod_subcategoria_configuracion, sc.ord, s.esvisible from subcategoria as s"
+ " inner join subcategoria_configuracion as sc " + " inner join subcategoria_configuracion as sc "
+ " on sc.cod_subcategoria = s.cod_subcategoria " + " on sc.cod_subcategoria = s.cod_subcategoria "
+ " where cod_proyecto_detalle = " + proyecto_detalle + " " + " where cod_proyecto_detalle = " + proyecto_detalle + " "
...@@ -323,6 +324,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -323,6 +324,7 @@ public class MenuMYSQLDAO implements MenuDAO {
obj.put("estadoSubCategoria", rs.getString(5)); obj.put("estadoSubCategoria", rs.getString(5));
obj.put("configuracionSubCategoria", rs.getString(6)); obj.put("configuracionSubCategoria", rs.getString(6));
obj.put("ordenSubCategoria", rs.getString(7)); obj.put("ordenSubCategoria", rs.getString(7));
obj.put("esVisible", rs.getBoolean(8));
lista.put(obj); lista.put(obj);
} }
} catch (Exception e) { } catch (Exception e) {
...@@ -2081,7 +2083,7 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -2081,7 +2083,7 @@ public class MenuMYSQLDAO implements MenuDAO {
try { try {
con = MySQLDAOFactory.getConnectionSQL(base); con = MySQLDAOFactory.getConnectionSQL(base);
sql = "select a.cod_subcategoria, a.nom, a.url, " sql = "select a.cod_subcategoria, a.nom, a.url, "
+ "ISNULL( " + "IFNULL( "
+ "(select count(*) as cant " + "(select count(*) as cant "
+ "from subcategoria_configuracion as sc " + "from subcategoria_configuracion as sc "
+ "inner join proyecto_detalle as pd " + "inner join proyecto_detalle as pd "
...@@ -2795,7 +2797,150 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -2795,7 +2797,150 @@ public class MenuMYSQLDAO implements MenuDAO {
return jsonReturn; return jsonReturn;
} }
@Override @Override
public JSONArray obtenerAcciones(int codigo, int jerarquia, int tipo_usuario) {
Connection con = null;
JSONArray rs = new JSONArray();
try {
PreparedStatement pst = null;
ResultSet rSet = null;
String sql = "";
con = MySQLDAOFactory.getConnectionSQL("SECURITY");
if (jerarquia == 2) {
sql = "select\n" +
" modulo.cod_modulo as codigo,\n" +
" modulo.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.modulo_acciones\n" +
" left join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n" +
" left join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n" +
"where modulo.cod_modulo = ? and modulo_acciones.cod_tipo_usuario = ?;\n";
} else if (jerarquia == 3) {
sql = "select\n" +
" categoria.cod_categoria as codigo,\n" +
" categoria.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.categoria_acciones\n" +
" left join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n" +
" left join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n" +
"where categoria.cod_categoria = ? and categoria_acciones.cod_tipo_usuario = ?;\n";
} else if (jerarquia == 4) {
sql = "select\n" +
" subcategoria.cod_subcategoria as codigo,\n" +
" subcategoria.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.subcategoria_acciones\n" +
" left join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n" +
" left join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n" +
"where subcategoria.cod_subcategoria = ? and subcategoria_acciones.cod_tipo_usuario = ?;";
}
pst = con.prepareStatement(sql);
pst.setInt(1, codigo);
pst.setInt(2, tipo_usuario);
rSet = pst.executeQuery();
while (rSet.next()) {
JSONObject json = new JSONObject();
json.put("codigo",rSet.getInt("codigo"));
json.put("nom_padre",rSet.getString("nom_padre"));
json.put("cod_accion",rSet.getInt("cod_accion"));
json.put("nom_accion",rSet.getString("nom_accion"));
rs.put(json);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return rs;
}
@Override
public JSONObject listarPermisosPorVista(JSONObject datos) throws Exception {
Connection con = null;
PreparedStatement pst = null;
ResultSet rSet = null;
JSONObject jsonReturn = new JSONObject();
JSONArray rs = new JSONArray();
try{
con = MySQLDAOFactory.getConnectionSQL("SECURITY");
String sql = "";
if(datos.getInt("jerarquia") == 2){
sql = "select\n" +
" modulo_acciones.cod_mod_acc as codigo,\n" +
" modulo.cod_modulo,\n" +
" modulo.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.modulo_acciones\n" +
" left join seguridad.modulo on modulo_acciones.cod_modulo = modulo.cod_modulo\n" +
" left join seguridad.accion on modulo_acciones.cod_accion = accion.cod_accion\n" +
"where modulo.cod_modulo = ?;";
}else if (datos.getInt("jerarquia") == 3){
sql = "select\n" +
" categoria_acciones.cod_cat_acc as codigo,\n" +
" categoria.cod_categoria,\n" +
" categoria.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.categoria_acciones\n" +
" left join seguridad.categoria on categoria_acciones.cod_categoria = categoria.cod_categoria\n" +
" left join seguridad.accion on categoria_acciones.cod_accion = accion.cod_accion\n" +
"where categoria.cod_categoria = ?;";
}else if (datos.getInt("jerarquia") == 4){
sql = "select\n" +
" subcategoria_acciones.cod_sub_acc as codigo,\n" +
" subcategoria.cod_subcategoria,\n" +
" subcategoria.nom as nom_padre,\n" +
" accion.cod_accion,\n" +
" accion.nom_accion\n" +
"from seguridad.subcategoria_acciones\n" +
" left join seguridad.subcategoria on subcategoria_acciones.cod_subcategoria = subcategoria.cod_subcategoria\n" +
" left join seguridad.accion on subcategoria_acciones.cod_accion = accion.cod_accion\n" +
"where subcategoria.cod_subcategoria = ?;";
}
pst = con.prepareStatement(sql);
pst.setInt(1, datos.getInt("codigo"));
rSet = pst.executeQuery();
while (rSet.next()){
JSONObject json = new JSONObject();
json.put("codigo",rSet.getInt("codigo"));
// json.put("cod_modulo",rSet.getInt("cod_modulo"));
json.put("nom_padre",rSet.getString("nom_padre"));
json.put("cod_accion",rSet.getInt("cod_accion"));
json.put("nom_accion",rSet.getString("nom_accion"));
rs.put(json);
}
jsonReturn.put("message","Consulta exitosa");
jsonReturn.put("status",true);
}catch (Exception e) {
jsonReturn.put("message",e.getMessage());
jsonReturn.put("status",false);
e.printStackTrace();
}finally {
try {
if (con != null) {
con.close();
}
}catch (SQLException e) {
e.printStackTrace();
}
}
return jsonReturn.put("data",rs);
}
@Override
public JSONObject eliminarMenusAninado(JSONObject datos) throws Exception { public JSONObject eliminarMenusAninado(JSONObject datos) throws Exception {
JSONObject jsonReturn; JSONObject jsonReturn;
Connection con = null; Connection con = null;
...@@ -2893,4 +3038,42 @@ public class MenuMYSQLDAO implements MenuDAO { ...@@ -2893,4 +3038,42 @@ public class MenuMYSQLDAO implements MenuDAO {
return jsonReturn; return jsonReturn;
} }
public JSONObject asignarAccionesPorVista(JSONObject json) throws SQLException {
JSONObject jsonReturn = new JSONObject();
Connection con = null;
PreparedStatement pst = null;
ResultSet rSet = null;
try{
con = MySQLDAOFactory.getConnectionSQL("SECURITY");
con.setAutoCommit(false);
String sql = "{CALL SP_TA_ACCIONES_POR_VISTA(?,?,?,?,?,?,?,?)}";
pst = con.prepareStatement(sql);
pst.setInt(1,json.getInt("tipo_accion"));
pst.setInt(2,json.getInt("v_cod_accion"));
pst.setString(3,json.getString("v_nom_accion"));
pst.setInt(4,json.getInt("v_jerarquia"));
pst.setInt(5,json.getInt("v_cod_proyecto"));
pst.setInt(6,json.getInt("v_cod_vista"));
pst.setInt(7,json.getInt("v_cod_vista_acc"));
pst.setInt(8,json.getInt("v_tipo_usuario"));
rSet = pst.executeQuery();
if(json.getInt("tipo_accion") == 3) {
while(rSet.next()) {
jsonReturn.put("status",rSet.getInt("result"));
jsonReturn.put("message","todo bien");
}
}else{
jsonReturn.put("status",true);
jsonReturn.put("message","todo bien");
}
con.commit();
} catch (SQLException e) {
con.rollback();
jsonReturn.put("status",false);
jsonReturn.put("message",e.getMessage());
throw new RuntimeException(e);
}
return jsonReturn;
}
} }
\ No newline at end of file
...@@ -429,4 +429,33 @@ public class MenuService { ...@@ -429,4 +429,33 @@ public class MenuService {
return obj; return obj;
} }
public JSONObject listarPermisosPorVista(JSONObject datos) {
JSONObject obj = null;
try {
obj = dao.listarPermisosPorVista(datos);
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
public JSONArray obtenerAcciones(int codigo, int jerarquia, int tipo_usuario) {
JSONArray obj = null;
try {
obj = dao.obtenerAcciones(codigo,jerarquia,tipo_usuario);
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
public JSONObject asignarAccionesPorVista(JSONObject json) {
JSONObject obj = null;
try {
obj = dao.asignarAccionesPorVista(json);
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
} }
\ No newline at end of file
...@@ -7,6 +7,7 @@ package com.mycompany.moduloseguridad.servlets; ...@@ -7,6 +7,7 @@ package com.mycompany.moduloseguridad.servlets;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.util.Objects;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -65,10 +66,16 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -65,10 +66,16 @@ public class MantenimientoMenuServlet extends HttpServlet {
case "eliminarMenusAninado": case "eliminarMenusAninado":
eliminarMenusAninado(request, response); eliminarMenusAninado(request, response);
break; break;
case "listarPermisosPorVista":
listarPermisosPorVista(request, response);
break;
case "asignarAccionesPorVista":
asignarAccionesPorVista(request, response);
break;
default: default:
break; break;
} }
} }
private void listarProyecto(HttpServletRequest request, HttpServletResponse response) throws IOException { private void listarProyecto(HttpServletRequest request, HttpServletResponse response) throws IOException {
...@@ -84,7 +91,7 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -84,7 +91,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
response.setContentType("application/json"); response.setContentType("application/json");
PrintWriter out = response.getWriter(); PrintWriter out = response.getWriter();
MenuService srv = new MenuService(); MenuService srv = new MenuService();
int codigo = Integer.parseInt(request.getParameter("codigo")); int codigo = Integer.parseInt(Objects.equals(request.getParameter("codigo"), "") ? "0" : request.getParameter("codigo"));
JSONArray rs = srv.listarTipoDeUsuario(codigo); JSONArray rs = srv.listarTipoDeUsuario(codigo);
out.println(rs); out.println(rs);
} }
...@@ -129,8 +136,7 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -129,8 +136,7 @@ public class MantenimientoMenuServlet extends HttpServlet {
int iCategoria = 0; int iCategoria = 0;
JSONObject obj2 = new JSONObject(); JSONObject obj2 = new JSONObject();
JSONObject objModulo = (JSONObject) listaModulo.get(j); JSONObject objModulo = (JSONObject) listaModulo.get(j);
System.out.println("objModulo "+i + " - "+j+" : "+ objModulo); boolean esVisible1 = objModulo.getBoolean("esVisible");
boolean esVisible = objModulo.getBoolean("esVisible");
String nombreModulo = objModulo.getString("nombreModulo"); String nombreModulo = objModulo.getString("nombreModulo");
int codigoModulo = objModulo.getInt("codigoModulo"); int codigoModulo = objModulo.getInt("codigoModulo");
int configuracionModulo = objModulo.getInt("configuracionModulo"); int configuracionModulo = objModulo.getInt("configuracionModulo");
...@@ -150,14 +156,32 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -150,14 +156,32 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj2.put("configuracion", configuracionModulo); obj2.put("configuracion", configuracionModulo);
obj2.put("padre", padreModulo); obj2.put("padre", padreModulo);
obj2.put("orden", ordenModulo); obj2.put("orden", ordenModulo);
obj2.put("esVisible", esVisible); obj2.put("esVisible", esVisible1);
lista.put(obj2); lista.put(obj2);
JSONArray listarModuloAcc = srv.obtenerAcciones(codigoModulo, 2,proyecto_detalle);
for(int modacc = 0; modacc < listarModuloAcc.length(); modacc++) {
JSONObject objModuloAcc = (JSONObject) listarModuloAcc.get(modacc);
JSONObject objModuloAcc2 = new JSONObject();
objModuloAcc2.put("conta", modacc + 1);
objModuloAcc2.put("jerarquia", 5);
objModuloAcc2.put("nombre", objModuloAcc.getString("nom_accion"));
objModuloAcc2.put("codigo", objModuloAcc.getInt("cod_accion"));
objModuloAcc2.put("icono", "");
objModuloAcc2.put("url", "");
objModuloAcc2.put("tipo", 3);
objModuloAcc2.put("configuracion", 0);
objModuloAcc2.put("padre", codigoModulo);
objModuloAcc2.put("orden", 0);
// objModuloAcc2.put("esVisible", true);
lista.put(objModuloAcc2);
}
JSONArray listaCategoria = srv.listarCategoriaCompleto(codigoModulo, proyecto_detalle, proyecto, tipo); JSONArray listaCategoria = srv.listarCategoriaCompleto(codigoModulo, proyecto_detalle, proyecto, tipo);
for (int k = 0; k < listaCategoria.length(); k++) { for (int k = 0; k < listaCategoria.length(); k++) {
int iSubCategoria = 0; int iSubCategoria = 0;
JSONObject obj3 = new JSONObject(); JSONObject obj3 = new JSONObject();
JSONObject objCategoria = (JSONObject) listaCategoria.get(k); JSONObject objCategoria = (JSONObject) listaCategoria.get(k);
String nombreCategoria = objCategoria.getString("nombreCategoria"); String nombreCategoria = objCategoria.getString("nombreCategoria");
boolean esVisible2 = objModulo.getBoolean("esVisible");
int codigoCategoria = objCategoria.getInt("codigoCategoria"); int codigoCategoria = objCategoria.getInt("codigoCategoria");
int configuracionCategoria = objCategoria.getInt("configuracionCategoria"); int configuracionCategoria = objCategoria.getInt("configuracionCategoria");
String urlCategoria = objCategoria.getString("urlCategoria"); String urlCategoria = objCategoria.getString("urlCategoria");
...@@ -175,12 +199,30 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -175,12 +199,30 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj3.put("configuracion", configuracionCategoria); obj3.put("configuracion", configuracionCategoria);
obj3.put("padre", padreCategoria); obj3.put("padre", padreCategoria);
obj3.put("orden", ordenCategoria); obj3.put("orden", ordenCategoria);
obj3.put("esVisible", esVisible2);
lista.put(obj3); lista.put(obj3);
JSONArray listarCategoriaAcc = srv.obtenerAcciones(codigoCategoria, 3,proyecto_detalle);
for(int catacc = 0; catacc < listarCategoriaAcc.length(); catacc++) {
JSONObject objCategoriaAcc = (JSONObject) listarCategoriaAcc.get(catacc);
JSONObject objCategoriaAcc2 = new JSONObject();
objCategoriaAcc2.put("conta", catacc + 1);
objCategoriaAcc2.put("jerarquia", 6);
objCategoriaAcc2.put("nombre", objCategoriaAcc.getString("nom_accion"));
objCategoriaAcc2.put("codigo", objCategoriaAcc.getInt("cod_accion"));
objCategoriaAcc2.put("icono", "");
objCategoriaAcc2.put("url", "");
objCategoriaAcc2.put("tipo", 3);
objCategoriaAcc2.put("configuracion", 0);
objCategoriaAcc2.put("padre", codigoCategoria);
objCategoriaAcc2.put("orden", 0);
lista.put(objCategoriaAcc2);
}
JSONArray listaSubCategoria = srv.listarSubCategoriaCompleto(codigoCategoria, proyecto_detalle, proyecto, tipo); JSONArray listaSubCategoria = srv.listarSubCategoriaCompleto(codigoCategoria, proyecto_detalle, proyecto, tipo);
for (int l = 0; l < listaSubCategoria.length(); l++) { for (int l = 0; l < listaSubCategoria.length(); l++) {
JSONObject obj4 = new JSONObject(); JSONObject obj4 = new JSONObject();
JSONObject objSubCategoria = (JSONObject) listaSubCategoria.get(l); JSONObject objSubCategoria = (JSONObject) listaSubCategoria.get(l);
String nombreSubCategoria = objSubCategoria.getString("nombreSubCategoria"); String nombreSubCategoria = objSubCategoria.getString("nombreSubCategoria");
boolean esVisible3 = objSubCategoria.getBoolean("esVisible");
int codigoSubCategoria = objSubCategoria.getInt("codigoSubCategoria"); int codigoSubCategoria = objSubCategoria.getInt("codigoSubCategoria");
int configuracionSubCategoria = objSubCategoria.getInt("configuracionSubCategoria"); int configuracionSubCategoria = objSubCategoria.getInt("configuracionSubCategoria");
String urlSubCategoria = objSubCategoria.getString("urlSubCategoria"); String urlSubCategoria = objSubCategoria.getString("urlSubCategoria");
...@@ -197,7 +239,24 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -197,7 +239,24 @@ public class MantenimientoMenuServlet extends HttpServlet {
obj4.put("configuracion", configuracionSubCategoria); obj4.put("configuracion", configuracionSubCategoria);
obj4.put("padre", padreSubCategoria); obj4.put("padre", padreSubCategoria);
obj4.put("orden", ordenSubCategoria); obj4.put("orden", ordenSubCategoria);
obj4.put("esVisible", esVisible3);
lista.put(obj4); lista.put(obj4);
JSONArray listarSubAcc = srv.obtenerAcciones(codigoSubCategoria, 4,proyecto_detalle);
for(int subacc = 0; subacc < listarSubAcc.length(); subacc++) {
JSONObject objSubAcc = (JSONObject) listarSubAcc.get(subacc);
JSONObject objSubAcc2 = new JSONObject();
objSubAcc2.put("conta", subacc + 1);
objSubAcc2.put("jerarquia", 7);
objSubAcc2.put("nombre", objSubAcc.getString("nom_accion"));
objSubAcc2.put("codigo", objSubAcc.getInt("cod_accion"));
objSubAcc2.put("icono", "");
objSubAcc2.put("url", "");
objSubAcc2.put("tipo", 3);
objSubAcc2.put("configuracion", 0);
objSubAcc2.put("padre", codigoSubCategoria);
objSubAcc2.put("orden", 0);
lista.put(objSubAcc2);
}
} }
} }
} }
...@@ -449,4 +508,42 @@ public class MantenimientoMenuServlet extends HttpServlet { ...@@ -449,4 +508,42 @@ public class MantenimientoMenuServlet extends HttpServlet {
out.print(rs); out.print(rs);
} }
private void listarPermisosPorVista(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
MenuService srv = new MenuService();
JSONObject rs;
int codigo = Integer.parseInt(request.getParameter("codigo"));
int jerarquia = Integer.parseInt(request.getParameter("jerarquia"));
JSONObject json = new JSONObject().put("codigo", codigo).put("jerarquia", jerarquia);
rs = srv.listarPermisosPorVista(json);
out.print(rs);
}
public void asignarAccionesPorVista(HttpServletRequest request, HttpServletResponse response) throws IOException {
response.setContentType("application/json");
PrintWriter out = response.getWriter();
MenuService srv = new MenuService();
JSONObject rs;
int tipo_accion = Integer.parseInt( request.getParameter("tipo_accion"));
int v_cod_accion = Integer.parseInt( request.getParameter("v_cod_accion"));
String v_nom_accion = request.getParameter("v_nom_accion");
int v_jerarquia = Integer.parseInt( request.getParameter("v_jerarquia"));
int v_cod_proyecto = Integer.parseInt( request.getParameter("v_cod_proyecto"));
int v_cod_vista = Integer.parseInt( request.getParameter("v_cod_vista"));
int v_cod_vista_acc = Integer.parseInt( request.getParameter("v_cod_vista_acc"));
int v_tipo_usuario = Integer.parseInt(request.getParameter("v_tipo_usuario"));
JSONObject json = new JSONObject()
.put("tipo_accion", tipo_accion)
.put("v_cod_accion", v_cod_accion)
.put("v_nom_accion", v_nom_accion)
.put("v_jerarquia", v_jerarquia)
.put("v_cod_proyecto", v_cod_proyecto)
.put("v_cod_vista", v_cod_vista)
.put("v_cod_vista_acc", v_cod_vista_acc)
.put("v_tipo_usuario", v_tipo_usuario);
rs = srv.asignarAccionesPorVista(json);
out.print(rs);
}
} }
\ No newline at end of file
...@@ -312,6 +312,10 @@ table.display tbody tr:hover td { ...@@ -312,6 +312,10 @@ table.display tbody tr:hover td {
padding-left: 15vw; padding-left: 15vw;
} }
.supercategoria{
padding-left: 20vw;
}
.modal-header[class*=bg-] { .modal-header[class*=bg-] {
padding: 10px 15px; padding: 10px 15px;
} }
......
/* global bootbox */ let tipo_usuario = 0
let tipo_usuario_nombre = "";
function segundaCarga() { function segundaCarga() {
listarProyectos(); listarProyectos();
...@@ -73,8 +74,11 @@ ...@@ -73,8 +74,11 @@
var json = { var json = {
"codigo": detalle, "codigo": detalle,
"proyecto": proyecto, "proyecto": proyecto,
"tipo": 0 "tipo": 0,
"tipo_usuario": tipo_usuario
}; };
tipo_usuario = $('#cboTipoUsuario').val();
tipo_usuario_nombre = $('#cboTipoUsuario option:selected').text();
if (detalle !== "") { if (detalle !== "") {
$('#panelTabla').removeClass('hide'); $('#panelTabla').removeClass('hide');
table = $("#tblMenu").DataTable({ table = $("#tblMenu").DataTable({
...@@ -85,7 +89,7 @@ ...@@ -85,7 +89,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"paginate": { "paginate": {
"first": "First", "first": "First",
"last": "Last", "last": "Last",
...@@ -132,6 +136,13 @@ ...@@ -132,6 +136,13 @@
retorno = `<span class='categoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-orange border-orange-600" style="color: white">${row.nombre}</span></span>`; retorno = `<span class='categoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-orange border-orange-600" style="color: white">${row.nombre}</span></span>`;
} else if (data === 4) { } else if (data === 4) {
retorno = `<span class='subcategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-danger border-danger-600" style="color: white">${row.nombre}</span></span>`; retorno = `<span class='subcategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-danger border-danger-600" style="color: white">${row.nombre}</span></span>`;
}else if( data === 5){
retorno = `<span class='categoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-grey-600 border-grey-700" style="color: white">${row.nombre}</span></span>`;
}else if( data === 6){
retorno = `<span class='subcategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-grey-600 border-grey-700" style="color: white">${row.nombre}</span></span>`;
}
else if( data === 7){
retorno = `<span class='supercategoria'><i class="fa fa-level-up fa-rotate-90" style="font-size: 16px;"></i>&nbsp;<span class="label bg-grey-600 border-grey-700" style="color: white">${row.nombre}</span></span>`;
} }
return retorno; return retorno;
} }
...@@ -146,6 +157,8 @@ ...@@ -146,6 +157,8 @@
retorno = "<span class='label bg-slate-600 border-slate-700' style='color: white'>ÚNICO</span>"; retorno = "<span class='label bg-slate-600 border-slate-700' style='color: white'>ÚNICO</span>";
} else if (data === 2) { } else if (data === 2) {
retorno = '<span class="label bg-info-600 border-info-700" style="color: white">DESPLEGABLE</span>'; retorno = '<span class="label bg-info-600 border-info-700" style="color: white">DESPLEGABLE</span>';
}else if (data === 3) {
retorno = '<span class="label bg-blue-400 border-grey-700" style="color: white">PERMISO</span>';
} }
return retorno; return retorno;
} }
...@@ -168,15 +181,21 @@ ...@@ -168,15 +181,21 @@
nombre = "Nada"; nombre = "Nada";
break; break;
} }
if (data !== 4 && row.url === '#' || row.url === '') {
if([5,6,7].includes(Number(data))){
}else if (data !== 4 && row.url === '#' || row.url === '') {
retorno += `<span data-toggle="tooltip" title="Crear ${nombre}" style="cursor: pointer"> <i class='crear glyphicon glyphicon-plus text-slate-800' style="font-size: 15px"></i>&nbsp;&nbsp; </span>`; retorno += `<span data-toggle="tooltip" title="Crear ${nombre}" style="cursor: pointer"> <i class='crear glyphicon glyphicon-plus text-slate-800' style="font-size: 15px"></i>&nbsp;&nbsp; </span>`;
} }
retorno += `<span data-toggle="tooltip" title="Editar" style="cursor: pointer"> <i class='editar glyphicon glyphicon-pencil text-teal-800' style="font-size: 15px"></i>&nbsp;&nbsp; </span>`; if(![5,6,7].includes(Number(data))){
retorno += `<span data-toggle="tooltip" title="Editar" style="cursor: pointer"> <i class='editar glyphicon glyphicon-pencil text-teal-800' style="font-size: 15px"></i>&nbsp;&nbsp; </span>`;
retorno += `<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`;
}
if (row.configuracion !== 0) { if (row.configuracion !== 0) {
retorno += `<span data-toggle="tooltip" title="Bajar" style="cursor: pointer"> <i class='abajo fa fa-chevron-circle-down text-primary-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`; retorno += `<span data-toggle="tooltip" title="Bajar" style="cursor: pointer"> <i class='abajo fa fa-chevron-circle-down text-primary-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`;
retorno += `<span data-toggle="tooltip" title="Subir" style="cursor: pointer"> <i class='arriba fa fa-chevron-circle-up text-primary-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`; retorno += `<span data-toggle="tooltip" title="Subir" style="cursor: pointer"> <i class='arriba fa fa-chevron-circle-up text-primary-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`;
} }
retorno += `<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`; // retorno += `<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer"> <i class='eliminar fa fa-trash text-danger-800' style="font-size: 16px"></i>&nbsp;&nbsp; </span>`;
return retorno; return retorno;
} }
...@@ -184,8 +203,9 @@ ...@@ -184,8 +203,9 @@
], initComplete: function (nopor, data) { ], initComplete: function (nopor, data) {
$("#tblMenu").addClass("table table-responsive table-striped table-hover table-bordered"); $("#tblMenu").addClass("table table-responsive table-striped table-hover table-bordered");
}, rowCallback: function (row, data) { }, rowCallback: function (row, data) {
if(data.esVisible === false){ if(data.esVisible === false && data.jerarquia !== 4){
$(row).css("background-color","#ffeaea"); $(row).css("background-color","#e0f8ff");
// $(row).css('opacity',0.5);
} }
}, },
}); });
...@@ -237,22 +257,23 @@ ...@@ -237,22 +257,23 @@
function crearFormEdicion(data) { function crearFormEdicion(data) {
console.log(data); console.log(data);
var tipo = data["tipo"]; let tipo = data["tipo"];
var codigo = data["codigo"]; let codigo = data["codigo"];
var jerarquia = data["jerarquia"]; let jerarquia = data["jerarquia"];
var nombre = data["nombre"]; let nombre = data["nombre"];
var url = data["url"]; let url = data["url"];
var visible = data["esVisible"]; let visible = data["esVisible"];
var txturl; let txturl;
if (tipo === 1 || jerarquia === 4) { if (tipo === 1 || jerarquia === 4) {
txturl = url.slice(0, -4); txturl = url.slice(0, -4);
} else { } else {
txturl = url; txturl = url;
} }
var icono = data["icono"]; const icono = data["icono"];
var formEditar = bootbox.dialog({ const formEditar = bootbox.dialog({
title: "<span><i class='ace-icon fa fa-tags'></i> <span>EDITAR MENU</span>", title: "<span><i class='ace-icon fa fa-tags'></i> <span>EDITAR MENU</span>",
headerClass: "modal-bg-primary", headerClass: "modal-bg-primary",
className: "tablaFormEdicion",
size: "medium", size: "medium",
message: `<form id="formEditarMenu" onsubmit="return false" autocomplete="off"> message: `<form id="formEditarMenu" onsubmit="return false" autocomplete="off">
<div class='divCont row'> <div class='divCont row'>
...@@ -292,18 +313,37 @@ ...@@ -292,18 +313,37 @@
<span class="input-group-addon"><div class="" style="color:#848484">.jsp</div></span> <span class="input-group-addon"><div class="" style="color:#848484">.jsp</div></span>
</div> </div>
</div> </div>
<div class='frm col-md-6' id="formEsVisible"> <div class='frm col-md-6 hidden' id="formEsVisible">
<label style="font-size: small"> <label style="font-size: small">
Es visible: Es visible:
</label> </label>
<input id="chkVisible" name="chkEsVisible" class="icp-opts form-control switch" type="checkbox"/> <input id="chkVisible" name="chkEsVisible" class="icp-opts form-control switch " type="checkbox"/>
</div> </div>
<div class="frm col-md-12" id ="formPermisos">
<span>Permisos</span> <div class="frm col-md-12 ${tipo === 1 || jerarquia === 4 ? '' : 'hidden' }" id ="formPermisos">
<table id="tablaPermisosVista"> <div class="panel-heading" style="padding: 8px 15px; background: #2196f3; color: white">
<h6 class="panel-title" style="font-size: 15px; font-family: inherit"><i class="fa fa-list"></i>&nbsp; Permisos<a class="heading-elements-toggle"><i class="icon-more"></i></a></h6>
<div class="heading-elements">
<button id="bttnAsignarAcciones" type="button" class="btn bg-slate-600 border-slate-800 btn-xs">
<i class="glyphicon glyphicon-plus"></i>&nbsp; Asignar Acciones
</button>
</div>
</div>
<div class="table-responsive" style="overflow-y: auto;height: 17.5rem;">
<table id="tablaPermisosVista" class="table table-striped table-hover table-sm table-bordered display no-footer dataTable table-responsive">
<thead>
<tr>
<th style="text-align:center;">Nº</th>
<th style="text-align:center;">CODIGO</th>
<th style="text-align:center;">NOMBRE</th>
<th style="text-align:center;">ACCION</th>
</tr>
</thead>
<tbody>
</tbody>
</table> </table>
</div>
</div> </div>
</div> </div>
<div class="col-md-12 pull-right form-group"> <div class="col-md-12 pull-right form-group">
<div class="text-right" style="font-size: small"> <div class="text-right" style="font-size: small">
...@@ -316,7 +356,7 @@ ...@@ -316,7 +356,7 @@
label: "<i class='fa fa-check bigger-110'></i>&nbsp; Editar", label: "<i class='fa fa-check bigger-110'></i>&nbsp; Editar",
className: "btn bg-primary border-primary-600 btn-xs buttonOk", className: "btn bg-primary border-primary-600 btn-xs buttonOk",
callback: function () { callback: function () {
var validar = $("#formEditarMenu").validate({ const validar = $("#formEditarMenu").validate({
rules: { rules: {
txtNombre: {required: true}, txtNombre: {required: true},
txtIcono: {required: true}, txtIcono: {required: true},
...@@ -330,13 +370,13 @@ ...@@ -330,13 +370,13 @@
txtUrl: {required: "<b>&times; Ingrese una Url</b>"} txtUrl: {required: "<b>&times; Ingrese una Url</b>"}
}, },
errorPlacement: errorPlacement:
function (error, element) { function (error, element) {
if (element.attr("id") === "editarUrl") { if (element.attr("id") === "editarUrl") {
error.insertAfter("#formClave"); error.insertAfter("#formClave");
} else { } else {
error.insertAfter(element); error.insertAfter(element);
} }
} }
}); });
if (validar.form()) { if (validar.form()) {
editarMenu(data); editarMenu(data);
...@@ -354,6 +394,7 @@ ...@@ -354,6 +394,7 @@
} }
}); });
formEditar.init(function () { formEditar.init(function () {
$('#editarTipo').val(tipo); $('#editarTipo').val(tipo);
validarInput(); validarInput();
if (tipo === 2) { if (tipo === 2) {
...@@ -362,19 +403,314 @@ ...@@ -362,19 +403,314 @@
if (jerarquia === 2 || jerarquia === 3) { if (jerarquia === 2 || jerarquia === 3) {
validarDependenciaEditar(data); validarDependenciaEditar(data);
} }
if(jerarquia === 2 ){
if(!visible){ $('#formEsVisible').removeClass('hidden');
}
if (!visible) {
$("#chkVisible").prop("checked", true); $("#chkVisible").prop("checked", true);
}else{ } else {
$("#chkVisible").removeAttr("checked"); $("#chkVisible").removeAttr("checked");
} }
validarFormulario(jerarquia); validarFormulario(jerarquia);
submitKey('formEditarMenu', '.buttonOk'); submitKey('formEditarMenu', '.buttonOk');
validCaracForm(); validCaracForm();
cargarPermisosPorVista(data).then(r => {
$('#bttnAsignarAcciones').off('click').on('click', () => {
asignarAcciones(codigo,jerarquia);
});
});
});
}
function asignarAcciones(vista,jerarquia){
$(".tablaFormEdicion").addClass("hide");
var listadoAcciones = bootbox.dialog({
title: "<span><i class='ace-icon fa fa-tags'></i> ASIGNAR ACCION - "+tipo_usuario_nombre+"</span>",
headerClass: "modal-bg-primary",
size: "small",
message: `<form id="formCrearTipoUsuario" onsubmit="return false" autocomplete="off">
<div class='col-md-12'>
<div class="form-group">
<label style="font-size: small">
Acciones:
</label>
<span id="spanAterik" class="asterisk"> (*)</span>
<select class="form-control" id="cboListadoAcciones" name="cboListAcciones">
</select>
<br>
<div class="text-right" style="font-size: small">
<span class="text-danger">(*) </span> Campo obligatorio
</div>
</div>
</div>
</form>`,
buttons: {
confirm: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; Asignar",
className: "btn-primary buttonOk",
callback: function () {
let nom_accion = $('#cboListadoAcciones').val();
let result_accion = $('#cboListadoAcciones').siblings("ul").find('li').get().filter( li => li.innerText.toUpperCase() === nom_accion.toUpperCase());
let cod_accion = result_accion.length > 0 ? result_accion[0].value : 0;
if(nom_accion !== ""){
crearAcciones(vista, jerarquia, cod_accion, nom_accion);
}else{
alert("Tienes que asignar una accion valida.");
$(".tablaFormEdicion").removeClass("hide");
}
}
},
cancel: {
label: "<i class='fa fa-times bigger-110'></i>&nbsp; Cancelar",
className: "btn-danger",
callback: function () {
$(".tablaFormEdicion").removeClass("hide");
}
}
}
});
listadoAcciones.init(function () {
listarCboAcciones();
});
}
function listarCboAcciones(){
return new Promise((resolve, reject) => {
$.ajax({
type: 'POST',
url: "../servlet/TipoUsuarioServlet?accion=listarCboAcciones",
dataType: 'json',
success: function (data, textStatus, jqXHR) {
resolve(data);
}, error: function (jqXHR, textStatus, errorThrown) {
reject("Error al listar las asignaciones.");
}
});
}).then(data => {
let print = '';
if (data.status) {
let print = "";
var lista = data.data;
lista.forEach(v => {
print += '<option value="' + v.codAccion +'">'+v.nombreAccion+'</option>';
});
$("#cboListadoAcciones").html(print);
$("#cboListadoAcciones").editableSelect();
}
});
}
let lastdata = null;
async function cargarPermisosPorVista(data = null){
let json = null;
if(data != null){
lastdata = data;
json = {
codigo : data.codigo,
jerarquia : data.jerarquia
}
}else{
json = {
codigo : lastdata.codigo,
jerarquia : lastdata.jerarquia
}
}
$.ajax({
type: 'POST',
url: "../servlet/MantenimientoMenuServlet?accion=listarPermisosPorVista",
dataType: 'JSON',
data: json,
success: function (result) {
$('#tablaPermisosVista tbody').html(`
${result.data. map((item, index) => `
<tr>
<td style="text-align: center">${index + 1}</td>
<td style="text-align: center">${item.cod_accion}</td>
<td style="text-align: left">${item.nom_accion}</td>
<td style="text-align: center">
<span data-toggle="tooltip" title="Eliminar" style="cursor: pointer" data-original-title="Eliminar">
<i class="eliminar_${item.codigo} fa fa-trash text-danger-800" style="font-size: 16px"></i>&nbsp;&nbsp;
</span>
</td>
</tr>`).join('')
}`);
result.data.forEach( item => {
$('.eliminar_'+item["codigo"]).off('click').on('click', () => {
eliminarAcciones(item["codigo"], data.jerarquia);
});
});
}
});
}
function eliminarAcciones(codigo, jerarquia){
$(".tablaFormEdicion").addClass("hide");
return new Promise((resolve, reject) => {
$.ajax({
type: 'POST',
url: "../servlet/MantenimientoMenuServlet?accion=asignarAccionesPorVista",
dataType: 'json',
data:{
"tipo_accion": 2,
"v_cod_accion": 0,
"v_nom_accion": "",
"v_jerarquia": jerarquia,
"v_cod_proyecto": proyecto,
"v_cod_vista": codigo,
"v_cod_vista_acc": codigo,
"v_tipo_usuario": tipo_usuario,
},
success: function (data, textStatus, jqXHR) {
resolve(data);
}, error: function (jqXHR, textStatus, errorThrown) {
reject("Error al listar las asignaciones.");
}
});
}).then(data => {
if(data === null){
bootbox.dialog({
title: "<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>",
headerClass: "modal-bg-warning",
message: "Ha ocurrido un error",
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-warning",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
}
}
}
});
}else if (data.status) {
bootbox.dialog({
className: "dialogExtraSmall",
title: "<i class='ace-icon fa fa-tags white'></i> <span class='white'>Notificación</span>",
headerClass: "modal-bg-success",
message: data.message,
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-success",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
$("#tblMenu").DataTable().ajax.reload();
cargarPermisosPorVista(lastdata);
}
}
}
});
}else{
bootbox.dialog({
title: "<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>",
headerClass: "modal-bg-warning",
message: "Ha ocurrido un error",
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-warning",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
}
}
}
});
}
}).catch(error => {
console.log(error);
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
$("#tblDetalleAcciones").DataTable().ajax.reload();
}); });
} }
function crearAcciones(vista, jerarquia,accion, nom_accion){
return new Promise((resolve, reject) => {
$.ajax({
type: 'POST',
url: "../servlet/MantenimientoMenuServlet?accion=asignarAccionesPorVista",
dataType: 'json',
data:{
"tipo_accion": 1,
"v_cod_accion": accion,
"v_nom_accion": nom_accion,
"v_jerarquia": jerarquia,
"v_cod_proyecto": proyecto,
"v_cod_vista": vista,
"v_cod_vista_acc": 0,
"v_tipo_usuario": tipo_usuario,
},
success: function (data, textStatus, jqXHR) {
resolve(data);
}, error: function (jqXHR, textStatus, errorThrown) {
reject("Error al listar las asignaciones.");
}
});
}).then(data => {
if(data === null){
bootbox.dialog({
title: "<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>",
headerClass: "modal-bg-warning",
message: "Ha ocurrido un error",
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-warning",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
}
}
}
});
}else if (data.status) {
bootbox.dialog({
className: "dialogExtraSmall",
title: "<i class='ace-icon fa fa-tags white'></i> <span class='white'>Notificación</span>",
headerClass: "modal-bg-success",
message: data.message,
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-success",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
$("#tblMenu").DataTable().ajax.reload();
cargarPermisosPorVista(lastdata);
}
}
}
});
}else{
bootbox.dialog({
title: "<i class='ace-icon fa fa-exclamation-circle white'></i> <span class='white'>Advertencia</span>",
headerClass: "modal-bg-warning",
message: "Ha ocurrido un error",
buttons: {
si: {
label: "<i class='fa fa-check bigger-110'></i>&nbsp; OK",
className: "btn-warning",
callback: function () {
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
}
}
}
});
}
}).catch(error => {
console.log(error);
$(".tablaListadoAcciones").removeClass("hide");
$(".tablaFormEdicion").removeClass("hide");
$("#tblDetalleAcciones").DataTable().ajax.reload();
});
}
function recargar() { function recargar() {
table.destroy(); table.destroy();
listarMenu(); listarMenu();
...@@ -428,9 +764,11 @@ ...@@ -428,9 +764,11 @@
if (tipo === "2") { if (tipo === "2") {
$('#editarUrl').attr('disabled', true); $('#editarUrl').attr('disabled', true);
$('#editarUrl').val("#"); $('#editarUrl').val("#");
$('#formPermisos').addClass('hidden');
} else { } else {
$('#editarUrl').attr('disabled', false); $('#editarUrl').attr('disabled', false);
$('#editarUrl').val(""); $('#editarUrl').val("");
$('#formPermisos').removeClass('hidden');
} }
}); });
} }
...@@ -444,7 +782,7 @@ ...@@ -444,7 +782,7 @@
} else { } else {
txturl = url; txturl = url;
} }
var json = { var json = {
"codigo": data.codigo, "codigo": data.codigo,
"jerarquia": data.jerarquia, "jerarquia": data.jerarquia,
...@@ -538,7 +876,7 @@ ...@@ -538,7 +876,7 @@
function nuevoMenuTabla(codigo, apunta) { function nuevoMenuTabla(codigo, apunta) {
$('#btnNuevoMenu').on('click', function () { $('#btnNuevoMenu').on('click', function () {
$('.tablaMenus').addClass('hide'); $('.tablaMenus').addClass('hide');
formcrearMenu(codigo, apunta, 0, ""); formcrearMenu(codigo, apunta, 0, "");
}); });
} }
...@@ -1402,7 +1740,7 @@ ...@@ -1402,7 +1740,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"scrollY": false, "scrollY": false,
"paginate": { "paginate": {
"first": "First", "first": "First",
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"scrollY": false, "scrollY": false,
"paginate": { "paginate": {
"first": "First", "first": "First",
...@@ -683,7 +683,7 @@ ...@@ -683,7 +683,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"scrollY": false, "scrollY": false,
"paginate": { "paginate": {
"first": "First", "first": "First",
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"scrollY": false, "scrollY": false,
"paginate": { "paginate": {
"first": "First", "first": "First",
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
"infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros", "infoEmpty": "&nbsp;&nbsp;&nbsp; Mostrando 0 de 0 registros",
"search": "Filtrar:", "search": "Filtrar:",
"loadingRecords": "Cargando...", "loadingRecords": "Cargando...",
"processing": '<span style="width:100%;"><img src="http://www.snacklocal.com/images/ajaxload.gif"></span>', "processing": '<span style="width:100%;"><img src="https://upload.wikimedia.org/wikipedia/commons/7/7a/Ajax_loader_metal_512.gif?20180219130538"></span>',
"scrollY": false, "scrollY": false,
"paginate": { "paginate": {
"first": "First", "first": "First",
...@@ -980,9 +980,7 @@ ...@@ -980,9 +980,7 @@
} }
} }
}); });
listadoAcciones.init(function () { listadoAcciones.init(function () {
//cargar el combo de acciones
listarCboAcciones(); listarCboAcciones();
}); });
} }
......
...@@ -45,8 +45,11 @@ ...@@ -45,8 +45,11 @@
<div class="translucentMe card-3"></div> <div class="translucentMe card-3"></div>
<div class="contentMe"> <div class="contentMe">
<div class="text-center"> <div class="text-center">
<div class="icon-object border-white text-white"><img src="../img/securityIconWhite.png" alt="" style="width: 85px; height: 85px;"></div> <div class="icon-object border-white text-white">
<h5 class="content-group text-white">MÓDULO DE SEGURIDAD<small class="display-block" style="color: white">LOGIN</small></h5> <img src="../img/securityIconBlack.png" alt="" style="width: 85px; height: 85px;filter: brightness(1000)"></div>
<h5 class="content-group text-white">MÓDULO DE SEGURIDAD
<small class="display-block" style="color: white">LOGIN</small>
</h5>
</div> </div>
<div class="form-group has-feedback has-feedback-left"> <div class="form-group has-feedback has-feedback-left">
...@@ -125,4 +128,4 @@ ...@@ -125,4 +128,4 @@
})(window); })(window);
</script> </script>
</body> </body>
</html> </html>
\ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<link href="../css/lib/jquery-editable-select.min.css" rel="stylesheet" type="text/css"/>
<%@include file="templates/header.jsp" %> <%@include file="templates/header.jsp" %>
<!--template-core--> <!--template-core-->
...@@ -122,7 +123,7 @@ ...@@ -122,7 +123,7 @@
<div> <div>
No visibles : No visibles :
</div> </div>
<div style="background: #ffeaea; width: 1rem; height: 1rem; border: 1px solid black; display: block"></div> <div style="background: #e0f8ff; width: 1.5rem; height: 1.5rem; border: 1px solid black; display: block"></div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
...@@ -170,7 +171,7 @@ ...@@ -170,7 +171,7 @@
</div> </div>
<%@include file="templates/footer-body.jsp" %> <%@include file="templates/footer-body.jsp" %>
<script src="../js/lib/jquery-editable-select.min.js" type="text/javascript"></script>
<script src="../js/pages/MantenimientoMenu.js" type="text/javascript"></script> <script src="../js/pages/MantenimientoMenu.js" type="text/javascript"></script>
<script> <script>
let switchery = new Switchery(document.querySelector('#cbkEstado'), {color: 'red', secondaryColor: 'green'}) let switchery = new Switchery(document.querySelector('#cbkEstado'), {color: 'red', secondaryColor: 'green'})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment