From 773ba7c4a8bbddd954e683089662e811508bf691 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Fri, 18 Jul 2014 07:41:02 +0200 Subject: [PATCH] =?UTF-8?q?Filtrov=C3=A1n=C3=AD=20po=C5=BEadavk=C5=AF=20p?= =?UTF-8?q?=C5=99ihl=C3=A1=C5=A1en=C3=A9ho=20u=C5=BEivatele.=20Refresh=20t?= =?UTF-8?q?ab=C5=AF=20v=20po=C5=BEadavc=C3=ADch=20na=20slu=C5=BEebn=C3=AD?= =?UTF-8?q?=20cesty.=20refs=20#108=20refs=20#100?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TripRequirementServiceImpl.java | 9 +++-- .../info/bukova/isspst/ui/ListViewModel.java | 14 +++++++- .../ui/requirement/RequirementSubpage.java | 2 ++ .../requirement/TripRequirementListAll.java | 8 +++++ .../TripRequirementListCentre.java | 8 ++++- .../TripRequirementListWorkgroup.java | 8 +++++ .../webapp/trips/requirement/requirements.zul | 34 ++++++++++++------- 7 files changed, 65 insertions(+), 18 deletions(-) diff --git a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java index ad384152..d506a5ca 100644 --- a/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/requirement/TripRequirementServiceImpl.java @@ -52,8 +52,9 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl getAll() { - Query q = dao.getQuery("from TripRequirement where ownedBy = :owner"); + Query q = dao.getQuery("from TripRequirement where ownedBy = :owner and state != :state"); q.setParameter("owner", getLoggedInUser()); + q.setParameter("state", RequirementState.APPROVED); return q.list(); } @@ -64,8 +65,9 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl getCentreReq() { List wgList = workgroupService.getUserCentres(getLoggedInUser()); - Query q = dao.getQuery("select tr from TripRequirement tr join tr.centre c where c in (:wgList)"); + Query q = dao.getQuery("select tr from TripRequirement tr join tr.centre c where tr.state != :state and c in (:wgList)"); q.setParameterList("wgList", wgList); + q.setParameter("state", RequirementState.APPROVED); return q.list(); } @@ -76,8 +78,9 @@ public class TripRequirementServiceImpl extends RequirementBaseServiceImpl getWorkgroupReq() { List wgList = workgroupService.getUserWorkgroups(getLoggedInUser()); - Query q = dao.getQuery("select tr from TripRequirement tr join tr.workgroup w where w in (:wgList)"); + Query q = dao.getQuery("select tr from TripRequirement tr join tr.workgroup w where tr.state != :state and w in (:wgList)"); q.setParameterList("wgList", wgList); + q.setParameter("state", RequirementState.APPROVED); return q.list(); } diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index a0106159..e7438b62 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -231,6 +231,10 @@ public class ListViewModel { if (!newRec && editBean != null) { dataList.set(selIndex, editBean); } + + if (newRec) { + BindUtils.postGlobalCommand(null, null, "reloadRelated", null); + } } @GlobalCommand @@ -242,7 +246,7 @@ public class ListViewModel { } @Command - @NotifyChange("selIndex") + @NotifyChange({"selIndex", "dataBean"}) public void afterRender() { if (editBean != null && !editBean.isValid()) { return; @@ -256,6 +260,10 @@ public class ListViewModel { selIndex = dataList.size() - 1; newRec = false; } + + if (selIndex > -1) { + this.setDataBean(dataList.get(selIndex)); + } } @Command @@ -272,6 +280,10 @@ public class ListViewModel { public int getSelIndex() { return this.selIndex; } + + public void setSelIndex(int selIndex) { + this.selIndex = selIndex; + } @Command @NotifyChange({ "dataList", "fullFill" }) diff --git a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java index 7cbed31f..f2efd1e9 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/RequirementSubpage.java @@ -4,6 +4,7 @@ import info.bukova.isspst.data.RequirementBase; import info.bukova.isspst.services.requirement.RequirementBaseService; import info.bukova.isspst.ui.ListViewModel; +import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.NotifyChange; @@ -24,6 +25,7 @@ public class RequirementSubpage extends ListViewModel @NotifyChange({"dataBean", "canApprove"}) public void approve() { this.getReqService().approve(getDataBean()); + BindUtils.postGlobalCommand(null, null, "reload", null); } @Override diff --git a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java index 3d527af2..463e7f72 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java @@ -11,7 +11,9 @@ import java.util.List; import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; public class TripRequirementListAll extends RequirementSubpage { @@ -51,5 +53,11 @@ public class TripRequirementListAll extends RequirementSubpage public List getAllWorkgroups() { return allWorkgroups; } + + @GlobalCommand + @NotifyChange({ "dataList", "dataBean", "fullFill" }) + public void reloadRelated() { + this.reload(); + } } diff --git a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java index 2304a186..ba8d87d5 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java @@ -12,7 +12,9 @@ import java.util.List; import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; +import org.zkoss.bind.annotation.GlobalCommand; import org.zkoss.bind.annotation.Init; +import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; public class TripRequirementListCentre extends RequirementSubpage { @@ -49,6 +51,10 @@ public class TripRequirementListCentre extends RequirementSubpage { @@ -54,5 +56,11 @@ public class TripRequirementListWorkgroup extends RequirementSubpage getMyWorkgroups() { return myWorkgroups; } + + @GlobalCommand + @NotifyChange({ "dataList", "dataBean", "fullFill" }) + public void reloadRelated() { + this.reload(); + } } diff --git a/src/main/webapp/trips/requirement/requirements.zul b/src/main/webapp/trips/requirement/requirements.zul index d445a0e5..affd1278 100644 --- a/src/main/webapp/trips/requirement/requirements.zul +++ b/src/main/webapp/trips/requirement/requirements.zul @@ -22,28 +22,30 @@ - + selectedItem="@bind(vm.dataBean)" + onAfterRender="@command('afterRender')" + selectedIndex="@bind(vm.selIndex)"> + + width="180px" /> + width="200px" /> + /> + /> + />