diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java index 2198f5b62..ce48ecb9a 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/componente/esquemaoperacional/GridRutaTramoCoeficiente.java @@ -14,6 +14,7 @@ import org.zkoss.zkplus.spring.SpringUtil; import org.zkoss.zul.Column; import org.zkoss.zul.Columns; import org.zkoss.zul.Combobox; +import org.zkoss.zul.Comboitem; import org.zkoss.zul.Grid; import org.zkoss.zul.Hbox; import org.zkoss.zul.Intbox; @@ -135,6 +136,10 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende Column columnVia = new Column(Labels.getLabel("gridRutaSecuencia.columnVia.label")); columnVia.setWidth("15%"); columns.appendChild(columnVia); + + Column permiteVenda = new Column(Labels.getLabel("gridRutaSecuencia.columnVenda.label")); + permiteVenda.setWidth("6%"); + columns.appendChild(permiteVenda); Column kmsReal = new Column(Labels.getLabel("gridRutaSecuencia.columnKmsReal.label")); kmsReal.setWidth("6%"); @@ -276,6 +281,47 @@ public class GridRutaTramoCoeficiente extends Grid implements RowRenderer, Rende } }); row.appendChild(cboVia); + + // Cell Venda + final Combobox cboVenda = new Combobox(); + cboVenda.setId(cboVenda.getUuid()); + cboVenda.setReadonly(true); + cboVenda.setWidth("100%"); + cboVenda.setConstraint("no empty"); + + ListModelList listCboVenda = new ListModelList(); + + final Comboitem cbiSim = new Comboitem("Sim"); + cbiSim.setValue("Sim"); + + final Comboitem cbiNao = new Comboitem("Não"); + cbiNao.setValue("Não"); + + listCboVenda.add(cbiSim.getValue()); + listCboVenda.add(cbiNao.getValue()); + + if (secuenciaRutaTramoCoeficienteVO.getPermiteVenda() == null && this.getId().equalsIgnoreCase("gridrutasecuenciaida")){ + listCboVenda.addSelection(cbiNao.getValue()); + secuenciaRutaTramoCoeficienteVO.setPermiteVenda(Boolean.FALSE); + } else if (this.getId().equalsIgnoreCase("gridrutasecuenciavolta")){ + listCboVenda.addSelection(secuenciaRutaTramoCoeficienteVO.getPermiteVenda()?cbiSim.getValue():cbiNao.getValue()); + } + + cboVenda.setModel(listCboVenda); + + cboVenda.addEventListener(Events.ON_CHANGE, new EventListener() { + + @Override + public void onEvent(Event evt) throws Exception { + if (cboVenda.getSelectedItem().getValue().equals(cbiSim.getValue())){ + secuenciaRutaTramoCoeficienteVO.setPermiteVenda(Boolean.TRUE); + } else if (cboVenda.getSelectedItem().getValue().equals(cbiNao.getValue())){ + secuenciaRutaTramoCoeficienteVO.setPermiteVenda(Boolean.FALSE); + } + } + }); + row.appendChild(cboVenda); + boolean esTramoEditable = (secuenciaRutaTramoCoeficienteVO.getTramoId() == null); boolean esTramoServicioEditable = (secuenciaRutaTramoCoeficienteVO.getTramoServicioId() == null); boolean esTramoCoeficienteEditable = (secuenciaRutaTramoCoeficienteVO.getOrgaoTramoId() == null); diff --git a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/generaciontramosrutas/EditarTramoRutaController.java b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/generaciontramosrutas/EditarTramoRutaController.java index cefc243f5..6e8ba8d52 100644 --- a/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/generaciontramosrutas/EditarTramoRutaController.java +++ b/src/java/com/rjconsultores/ventaboletos/web/gui/controladores/esquemaoperacional/generaciontramosrutas/EditarTramoRutaController.java @@ -94,17 +94,16 @@ public class EditarTramoRutaController extends MyGenericForwardComposer { gridRutaSecuencia.setLsVias(viaService.obtenerTodos()); } - public void onSelect$cmbClaseServicio(Event e)throws InterruptedException { - if (!validarPreenchimentoEmpresa()){ + public void onBlur$cmbClaseServicio(Event e)throws InterruptedException { + if (cmbClaseServicio.getSelectedItem() != null && !validarPreenchimentoEmpresa()){ cmbClaseServicio.setSelectedItem(null); return; } } - public void onSelect$cmbOrgaoConcedente(Event e)throws InterruptedException { - - if (!validarPreenchimentoEmpresa()){ - cmbOrgaoConcedente.setSelectedItem(null); + public void onBlur$cmbOrgaoConcedente(Event e)throws InterruptedException { + if (cmbOrgaoConcedente.getSelectedItem() != null && !validarPreenchimentoEmpresa()){ + cmbClaseServicio.setSelectedItem(null); return; } }