From b89519e3ca0e9bb3afcbbf01d7372ed4f551acb1 Mon Sep 17 00:00:00 2001 From: Josef Rokos Date: Mon, 29 Sep 2014 22:20:46 +0200 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1na=20podpora=20pro=20v=C3=BDb?= =?UTF-8?q?=C4=9Br=20z=C3=A1znamu=20v=20gridu=20p=C5=99es=20ID=20p=C5=99ed?= =?UTF-8?q?an=C3=A9=20jako=20parametr=20"select"=20v=20URL.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../isspst/security/LoginSuccessHandler.java | 5 +- .../info/bukova/isspst/ui/ListViewModel.java | 30 +++++++++++- .../bukova/isspst/ui/main/TabPanelsVM.java | 49 ++++++++++++++++++- .../orders/requirements/ReqListMyAll.java | 5 ++ .../orders/requirements/ReqListMyCenters.java | 5 ++ .../requirements/ReqListMyWorkgroups.java | 5 ++ .../requirement/TripRequirementListAll.java | 5 ++ .../TripRequirementListCentre.java | 5 ++ .../TripRequirementListWorkgroup.java | 5 ++ src/main/webapp/main/tabPanels.zul | 9 ++-- 10 files changed, 116 insertions(+), 7 deletions(-) diff --git a/src/main/java/info/bukova/isspst/security/LoginSuccessHandler.java b/src/main/java/info/bukova/isspst/security/LoginSuccessHandler.java index d237ad96..2d16b541 100644 --- a/src/main/java/info/bukova/isspst/security/LoginSuccessHandler.java +++ b/src/main/java/info/bukova/isspst/security/LoginSuccessHandler.java @@ -22,8 +22,9 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; +import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler; -public class LoginSuccessHandler implements AuthenticationSuccessHandler { +public class LoginSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler implements AuthenticationSuccessHandler { @Autowired private SessionData sessionData; @@ -61,7 +62,7 @@ public class LoginSuccessHandler implements AuthenticationSuccessHandler { userService.update(u); } - response.sendRedirect("app/"); + super.onAuthenticationSuccess(request, response, auth); } } diff --git a/src/main/java/info/bukova/isspst/ui/ListViewModel.java b/src/main/java/info/bukova/isspst/ui/ListViewModel.java index 008789cc..c41677ad 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -10,6 +10,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.dao.DataIntegrityViolationException; import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; @@ -44,7 +46,7 @@ public class ListViewModel { protected Class dataClass; protected String formZul; protected Filter dataFilter; - + public List getDataList() { if (dataList == null) { dataList = new ArrayList(); @@ -266,10 +268,36 @@ public class ListViewModel { newRec = false; } + Map map = Executions.getCurrent().getParameterMap(); + int id = -1; + + try { + if (map.get("select") != null) { + id = Integer.parseInt(map.get("select")[0]); + } + } catch (NumberFormatException e) { + Logger logger = LoggerFactory.getLogger(this.getClass()); + logger.warn("ID is not number: " + map.get("select")[0]); + } + + if (id > 0) { + for (int i = 0; i < dataList.size(); i++) { + if (dataList.get(i).getId() == id) { + selIndex = i; + beforeSelectViaUrl(); + break; + } + } + } + if (selIndex > -1) { this.setDataBean(dataList.get(selIndex)); } } + + protected void beforeSelectViaUrl() { + + } @Command @NotifyChange("dataBean") diff --git a/src/main/java/info/bukova/isspst/ui/main/TabPanelsVM.java b/src/main/java/info/bukova/isspst/ui/main/TabPanelsVM.java index ab16deed..dc047eb2 100644 --- a/src/main/java/info/bukova/isspst/ui/main/TabPanelsVM.java +++ b/src/main/java/info/bukova/isspst/ui/main/TabPanelsVM.java @@ -9,6 +9,10 @@ public class TabPanelsVM private boolean showCentre; private boolean showWorkgroup; private boolean showAll; + private boolean selectMy; + private boolean selectCentre; + private boolean selectWorkgroup; + private boolean selectAll; @Init public void init() @@ -16,8 +20,13 @@ public class TabPanelsVM showCentre = true; showWorkgroup = true; showAll = true; + + selectMy = true; + selectCentre = false; + selectWorkgroup = false; + selectAll = false; } - + @GlobalCommand @NotifyChange("showCentre") public void disableCentre() @@ -38,6 +47,27 @@ public class TabPanelsVM { showAll = false; } + + @GlobalCommand + @NotifyChange("selectCentre") + public void selectCentre() { + selectMy = false; + selectCentre = true; + } + + @GlobalCommand + @NotifyChange("selectWorkgroup") + public void selectWorkgroup() { + selectMy = false; + selectWorkgroup = true; + } + + @GlobalCommand + @NotifyChange("selectAll") + public void selectAll() { + selectMy = false; + selectAll = true; + } public boolean isShowCentre() { @@ -53,4 +83,21 @@ public class TabPanelsVM { return showAll; } + + public boolean isSelectMy() { + return selectMy; + } + + public boolean isSelectCentre() { + return selectCentre; + } + + public boolean isSelectWorkgroup() { + return selectWorkgroup; + } + + public boolean isSelectAll() { + return selectAll; + } + } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java index 9448cb95..5ffc7f2f 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyAll.java @@ -64,4 +64,9 @@ public class ReqListMyAll extends RequirementSubpage { this.reload(); } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectAll", null); + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java index 0ca89e74..737d67c4 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyCenters.java @@ -64,4 +64,9 @@ public class ReqListMyCenters extends RequirementSubpage { this.reload(); } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectCentre", null); + } } diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java index 52ebb05d..568bfd9e 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/requirements/ReqListMyWorkgroups.java @@ -64,4 +64,9 @@ public class ReqListMyWorkgroups extends RequirementSubpage { this.reload(); } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectWorkgroup", null); + } } 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 6e0fec74..4d46242c 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java @@ -59,5 +59,10 @@ public class TripRequirementListAll extends RequirementSubpage public void reloadRelated() { this.reload(); } + + @Override + protected void beforeSelectViaUrl() { + BindUtils.postGlobalCommand(null, null, "selectAll", null); + } } 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 ba8d87d5..bf50a9c6 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java @@ -56,5 +56,10 @@ public class TripRequirementListCentre extends RequirementSubpage + disabled="@load(not vm.showCentre)" + selected="@load(vm.selectCentre)" /> + disabled="@load(not vm.showWorkgroup)" + selected="@load(vm.selectWorkgroup)" /> + disabled="@load(not vm.showAll)" + selected="@load(vm.selectAll)" />