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();