Merge branch 'melhoria_pesquisa' of http://18.235.188.113:3000/adm/VentaBoletosAdm.git into melhoria_pesquisa
commit
32c0c53a39
|
@ -13,9 +13,13 @@ import org.springframework.stereotype.Controller;
|
||||||
import org.zkoss.util.resource.Labels;
|
import org.zkoss.util.resource.Labels;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.Event;
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zk.ui.util.Clients;
|
||||||
import org.zkoss.zul.Caption;
|
import org.zkoss.zul.Caption;
|
||||||
import org.zkoss.zul.Menubar;
|
import org.zkoss.zul.Menubar;
|
||||||
import org.zkoss.zul.Toolbarbutton;
|
import org.zkoss.zul.Toolbarbutton;
|
||||||
|
import org.zkoss.zul.api.Window;
|
||||||
|
|
||||||
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
import com.rjconsultores.ventaboletos.entidad.Usuario;
|
||||||
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
import com.rjconsultores.ventaboletos.service.ConstanteService;
|
||||||
|
@ -23,6 +27,7 @@ import com.rjconsultores.ventaboletos.service.FlywayUtilService;
|
||||||
import com.rjconsultores.ventaboletos.service.UsuarioService;
|
import com.rjconsultores.ventaboletos.service.UsuarioService;
|
||||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.ItemMenuSistema;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.MenuFactory;
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.MenuFactory;
|
||||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.MenuFactoryPropertiesImpl;
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.MenuFactoryPropertiesImpl;
|
||||||
|
|
||||||
|
@ -46,6 +51,8 @@ public class IndexController extends MyGenericForwardComposer {
|
||||||
private Toolbarbutton toolBarUser;
|
private Toolbarbutton toolBarUser;
|
||||||
private Menubar menubar;
|
private Menubar menubar;
|
||||||
private Caption lblNombreAplicacion;
|
private Caption lblNombreAplicacion;
|
||||||
|
private Window win;
|
||||||
|
private HashMap<String, ItemMenuSistema> menuItems;
|
||||||
|
|
||||||
public Toolbarbutton getToolBar() {
|
public Toolbarbutton getToolBar() {
|
||||||
return toolBar;
|
return toolBar;
|
||||||
|
@ -93,6 +100,15 @@ public class IndexController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
openWindow("/login.zul", Labels.getLabel("winLogin.title"), arg, MODAL, Boolean.FALSE);
|
openWindow("/login.zul", Labels.getLabel("winLogin.title"), arg, MODAL, Boolean.FALSE);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
win.setCtrlKeys("^q");
|
||||||
|
win.addEventListener(Events.ON_CTRL_KEY, new EventListener() {
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
openSearchMenu(event);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
usuario = usuarioService.obtenerID(usuario.getUsuarioId());
|
usuario = usuarioService.obtenerID(usuario.getUsuarioId());
|
||||||
|
|
||||||
toolBarUser.setVisible(Boolean.TRUE);
|
toolBarUser.setVisible(Boolean.TRUE);
|
||||||
|
@ -103,6 +119,7 @@ public class IndexController extends MyGenericForwardComposer {
|
||||||
}
|
}
|
||||||
MenuFactory menuFactory = new MenuFactoryPropertiesImpl(desktop, usuario.getUsuarioPerfilList());
|
MenuFactory menuFactory = new MenuFactoryPropertiesImpl(desktop, usuario.getUsuarioPerfilList());
|
||||||
menuFactory.construirMenu(menubar);
|
menuFactory.construirMenu(menubar);
|
||||||
|
menuItems = menuFactory.getMenuItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,4 +133,19 @@ public class IndexController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
openWindow("/gui/seguridad/editarUsuario.zul", Labels.getLabel("editarUsuarioController.window.title"), args, MODAL);
|
openWindow("/gui/seguridad/editarUsuario.zul", Labels.getLabel("editarUsuarioController.window.title"), args, MODAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
public void openSearchMenu(Event ev) {
|
||||||
|
Map args = new HashMap();
|
||||||
|
args.put("menuItems", menuItems);
|
||||||
|
openWindow("/gui/catalogos/searchMenu.zul", Labels.getLabel("lb.btnPesquisa.label"), args, MODAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HashMap<String, ItemMenuSistema> getMenuItems() {
|
||||||
|
return menuItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMenuItems(HashMap<String, ItemMenuSistema> menuItems) {
|
||||||
|
this.menuItems = menuItems;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
/*
|
||||||
|
* To change this template, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
import org.springframework.context.annotation.Scope;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.zkoss.zk.ui.Component;
|
||||||
|
import org.zkoss.zk.ui.Executions;
|
||||||
|
import org.zkoss.zk.ui.event.ForwardEvent;
|
||||||
|
import org.zkoss.zk.ui.event.InputEvent;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.utilerias.StringHelper;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.ItemMenuSistema;
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderSearchMenu;
|
||||||
|
|
||||||
|
@Controller("searchMenuController")
|
||||||
|
@Scope("prototype")
|
||||||
|
public class SearchMenuController extends MyGenericForwardComposer {
|
||||||
|
|
||||||
|
private static Logger log = Logger.getLogger(SearchMenuController.class);
|
||||||
|
private HashMap<String, ItemMenuSistema> menuItems;
|
||||||
|
private MyListbox searchResultList;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void doAfterCompose(Component comp) throws Exception {
|
||||||
|
super.doAfterCompose(comp);
|
||||||
|
searchResultList.setItemRenderer(new RenderSearchMenu());
|
||||||
|
menuItems = (HashMap<String, ItemMenuSistema>) Executions.getCurrent().getArg().get("menuItems");
|
||||||
|
searchResultList.setData(new ArrayList<ItemMenuSistema>());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onChanging$bd(InputEvent ie) {
|
||||||
|
List<ItemMenuSistema> list = new ArrayList<ItemMenuSistema>();
|
||||||
|
if (ie.getValue().length() > 0) {
|
||||||
|
searchResultList.clear();
|
||||||
|
String searchValue = StringHelper.replaceAcento(ie.getValue().toLowerCase());
|
||||||
|
for (Map.Entry<String, ItemMenuSistema> entry : menuItems.entrySet()) {
|
||||||
|
String key = StringHelper.replaceAcento(entry.getKey().toLowerCase());
|
||||||
|
if (key.contains(searchValue)) {
|
||||||
|
ItemMenuSistema value = entry.getValue();
|
||||||
|
list.add(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Collections.sort(list, new Comparator<ItemMenuSistema>() {
|
||||||
|
@Override
|
||||||
|
public int compare(ItemMenuSistema o1, ItemMenuSistema o2) {
|
||||||
|
return o1.getDescItemMenu().compareTo(o2.getDescItemMenu());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
searchResultList.setData(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSelect$searchResultList(ForwardEvent ev) {
|
||||||
|
this.closeWindow();
|
||||||
|
ItemMenuSistema value = (ItemMenuSistema) searchResultList.getSelected();
|
||||||
|
value.ejecutar();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
package com.rjconsultores.ventaboletos.web.utilerias.menu;
|
package com.rjconsultores.ventaboletos.web.utilerias.menu;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.zkoss.zul.api.Menubar;
|
import org.zkoss.zul.api.Menubar;
|
||||||
|
|
||||||
public interface MenuFactory {
|
public interface MenuFactory {
|
||||||
|
@ -9,4 +11,6 @@ public interface MenuFactory {
|
||||||
*/
|
*/
|
||||||
public void construirMenu(Menubar menuBar);
|
public void construirMenu(Menubar menuBar);
|
||||||
|
|
||||||
|
public HashMap<String, ItemMenuSistema> getMenuItems();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
private Desktop desktop; // Desktop de la aplicación
|
private Desktop desktop; // Desktop de la aplicación
|
||||||
private List<UsuarioPerfil> listUsuarioPerfil;// El perfil del usuario
|
private List<UsuarioPerfil> listUsuarioPerfil;// El perfil del usuario
|
||||||
private HashMap<String, Boolean> listClavesPermisos;
|
private HashMap<String, Boolean> listClavesPermisos;
|
||||||
|
private HashMap<String, ItemMenuSistema> itemsMenuSistema = new HashMap<String, ItemMenuSistema>();
|
||||||
|
|
||||||
public MenuFactoryPropertiesImpl() {
|
public MenuFactoryPropertiesImpl() {
|
||||||
|
|
||||||
|
@ -195,12 +196,20 @@ public class MenuFactoryPropertiesImpl implements MenuFactory {
|
||||||
if (item.getClaveMenu() != null) {
|
if (item.getClaveMenu() != null) {
|
||||||
j.setVisible(listClavesPermisos.containsKey(item.getClaveMenu()));
|
j.setVisible(listClavesPermisos.containsKey(item.getClaveMenu()));
|
||||||
item.setIsReadOnly(listClavesPermisos.get(item.getClaveMenu()) != null ? listClavesPermisos.get(item.getClaveMenu()) : Boolean.FALSE );
|
item.setIsReadOnly(listClavesPermisos.get(item.getClaveMenu()) != null ? listClavesPermisos.get(item.getClaveMenu()) : Boolean.FALSE );
|
||||||
|
if (j.isVisible()) {
|
||||||
|
itemsMenuSistema.put(item.getDescItemMenu(), item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, ItemMenuSistema> getMenuItems() {
|
||||||
|
return itemsMenuSistema;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crea una instancia del menu especificado
|
* Crea una instancia del menu especificado
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.rjconsultores.ventaboletos.web.utilerias.render;
|
||||||
|
|
||||||
|
import org.zkoss.zul.Listcell;
|
||||||
|
import org.zkoss.zul.Listitem;
|
||||||
|
import org.zkoss.zul.ListitemRenderer;
|
||||||
|
|
||||||
|
import com.rjconsultores.ventaboletos.web.utilerias.menu.ItemMenuSistema;
|
||||||
|
|
||||||
|
public class RenderSearchMenu implements ListitemRenderer {
|
||||||
|
|
||||||
|
public void render(Listitem lstm, Object o) throws Exception {
|
||||||
|
ItemMenuSistema itemMenuSistema = (ItemMenuSistema) o;
|
||||||
|
|
||||||
|
Listcell lc = new Listcell(itemMenuSistema.getDescItemMenu());
|
||||||
|
lc.setParent(lstm);
|
||||||
|
|
||||||
|
lstm.setAttribute("data", itemMenuSistema);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<?page contentType="text/html;charset=UTF-8"?>
|
||||||
|
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||||
|
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="win"?>
|
||||||
|
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||||
|
|
||||||
|
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||||
|
|
||||||
|
<window id="winSearchMenu" border="normal"
|
||||||
|
apply="${searchMenuController}"
|
||||||
|
width="400px" height="457x" contentStyle="overflow:auto"
|
||||||
|
title="${c:l('lb.btnPesquisa.label')}" sizable="false" >
|
||||||
|
|
||||||
|
<bandbox id="bd" width="300px" mold="rounded" autodrop="true" >
|
||||||
|
<bandpopup>
|
||||||
|
<vbox>
|
||||||
|
<listbox width="300px" id="searchResultList"
|
||||||
|
mold="paging"
|
||||||
|
use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox">
|
||||||
|
<listhead>
|
||||||
|
<listheader
|
||||||
|
label="${c:l('lb.dec')}"
|
||||||
|
width="100%" />
|
||||||
|
</listhead>
|
||||||
|
</listbox>
|
||||||
|
|
||||||
|
</vbox>
|
||||||
|
</bandpopup>
|
||||||
|
</bandbox>
|
||||||
|
|
||||||
|
</window>
|
||||||
|
</zk>
|
Loading…
Reference in New Issue