From e5a8e0f0d9299d7a3bf9592c8cb7e992ab1771ac Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Sun, 17 May 2015 21:52:46 +0200 Subject: [PATCH] =?UTF-8?q?Po=20otev=C5=99en=C3=AD=20dialogu=20pro=20zobra?= =?UTF-8?q?zen=C3=AD=20vy=C3=BA=C4=8Dtov=C3=A1n=C3=AD=20SC=20se=20p=C5=99e?= =?UTF-8?q?pne=20na=20prvn=C3=AD=20z=C3=A1lo=C5=BEku,=20kterou=20m=C5=AF?= =?UTF-8?q?=C5=BEe=20schv=C3=A1lit=20aktu=C3=A1ln=C4=9B=20p=C5=99ihl=C3=A1?= =?UTF-8?q?=C5=A1en=C3=BD=20u=C5=BEivatel.=20closes=20#217?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isspst/ui/tripbill/TripBillSummaryVM.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillSummaryVM.java b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillSummaryVM.java index b3548f27..5f6e2e48 100644 --- a/src/main/java/info/bukova/isspst/ui/tripbill/TripBillSummaryVM.java +++ b/src/main/java/info/bukova/isspst/ui/tripbill/TripBillSummaryVM.java @@ -6,6 +6,7 @@ import info.bukova.isspst.data.TripBillApproval; import info.bukova.isspst.services.requirement.TripRequirementService; import info.bukova.isspst.services.tripbill.TripBillApprovalService; import info.bukova.isspst.services.tripbill.TripBillService; +import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.ui.requirement.RequirementSubpage; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; @@ -33,6 +34,8 @@ public class TripBillSummaryVM extends RequirementSubpage { private TripBillService tripBillService; @WireVariable private TripRequirementService tripRequirementService; + @WireVariable + private UserService userService; private TripBill bill; private Map selTab; @@ -71,11 +74,8 @@ public class TripBillSummaryVM extends RequirementSubpage { bills.add(this.bill); - if (bill.getApproval() != null && bill.getApproval().getState() != RequirementState.APPROVED) { + if (selectTab(bill)) { isSelectedTad = true; - selTab.put(bill.getId(), true); - } else { - selTab.put(bill.getId(), false); } for (TripBill b : tripRequirementService.getBills(bill.getRequirement())) { @@ -83,11 +83,8 @@ public class TripBillSummaryVM extends RequirementSubpage { tripBillService.loadLazyData(b); bills.add(b); - if (!isSelectedTad && b.getApproval() != null && b.getApproval().getState() != RequirementState.APPROVED) { - setBill(b); + if (!isSelectedTad && selectTab(b)) { isSelectedTad = true; - } else { - selTab.put(b.getId(), false); } } } @@ -99,6 +96,19 @@ public class TripBillSummaryVM extends RequirementSubpage { return bills; } + private boolean selectTab(TripBill bill) { + if (bill.getApproval() != null + && bill.getApproval().getState() != RequirementState.APPROVED + && tripBillApprovalService.getNextApprover(bill.getApproval()).contains(userService.getCurrent())) { + setBill(bill); + return true; + } else { + selTab.put(bill.getId(), false); + } + + return false; + } + @Command public void showBill(@BindingParam("bill") TripBill bill) { Map params = new HashMap();