diff --git a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java index 1b8da0c1..fa9d30bc 100644 --- a/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/invoicing/InvoicingServiceImpl.java @@ -129,7 +129,7 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem @Transactional @PreAuthorize("hasPermission(this, 'PERM_READ')") public List getMaterialPendingList() { - Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser"); + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser desc"); q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); return q.list(); } @@ -139,7 +139,7 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem @Transactional @PreAuthorize("hasPermission(this, 'PERM_READ')") public List getMaterialArchiveList() { - Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser"); + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser desc"); q.setParameter("kind", Constants.REQ_TYPE_MATERIAL); return q.list(); } @@ -149,7 +149,7 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem @Transactional @PreAuthorize("hasPermission(this, 'PERM_READ')") public List getServicesPendingList() { - Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser"); + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed Is Null or inv.completed = false) and (rq.kind = :kind) order by rq.numser desc"); q.setParameter("kind", Constants.REQ_TYPE_SERVICES); return q.list(); } @@ -159,7 +159,7 @@ public class InvoicingServiceImpl extends AbstractOwnedService implem @Transactional @PreAuthorize("hasPermission(this, 'PERM_READ')") public List getServicesArchiveList() { - Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser"); + Query q = dao.getQuery("select inv from Invoicing as inv join fetch inv.requirement rq join fetch rq.ownedBy where (inv.completed = true) and (rq.kind = :kind) order by rq.numser desc"); q.setParameter("kind", Constants.REQ_TYPE_SERVICES); 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 bfa8f70a..5f42c815 100644 --- a/src/main/java/info/bukova/isspst/ui/ListViewModel.java +++ b/src/main/java/info/bukova/isspst/ui/ListViewModel.java @@ -28,6 +28,7 @@ import org.zkoss.zul.Messagebox; import org.zkoss.zul.Window; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -146,6 +147,7 @@ public class ListViewModel extends DocumentViewModel dataList = fullList; dataBean = null; selIndex = -1; + restoreSort(); } else { doFilter(); dataBean = null; @@ -285,10 +287,7 @@ public class ListViewModel extends DocumentViewModel BindUtils.postGlobalCommand(null, null, "reloadRelated", null); - if (sortHeader != null) { - sortHeader.setSortDirection("natural"); - } - + restoreUserView(); } @GlobalCommand @@ -355,23 +354,14 @@ public class ListViewModel extends DocumentViewModel } - @Command - @NotifyChange("dataBean") - public void onSort(@BindingParam("column") String column) { - if (sortCol == null || this.sortCol.equals(column)) - this.sortDesc = !this.sortDesc; - - this.sortCol = column; - selIndex = -1; - dataBean = null; - } - @Command @NotifyChange({"dataBean", "canApprove"}) public void onSortHeader(@BindingParam("header") Listheader header) { sortHeader = header; selIndex = -1; dataBean = null; + Collections.sort(dataList, + sortHeader.getSortDirection().equals("ascending") ? sortHeader.getSortDescending() : sortHeader.getSortAscending()); } public int getSelIndex() { @@ -426,7 +416,28 @@ public class ListViewModel extends DocumentViewModel protected void setFullFill(boolean fullFill) { this.fullFill = fullFill; } - + + protected void restoreUserView() { + int sel = selIndex; + + restoreFilter(); + restoreSort(); + selIndex = sel; + } + + private void restoreSort() { + if (sortHeader != null) { + Collections.sort(dataList, + sortHeader.getSortDirection().equals("ascending") ? sortHeader.getSortAscending() : sortHeader.getSortDescending()); + } + } + + private void restoreFilter() { + if (filter) { + doFilter(); + } + } + public boolean isRecordSelected() { return (dataBean != null); diff --git a/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java b/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java index 3433900e..120cc0f8 100644 --- a/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java +++ b/src/main/java/info/bukova/isspst/ui/main/ApproveDialogVM.java @@ -72,6 +72,7 @@ public class ApproveDialogVM { BindUtils.postNotifyChange(null, null, grid, "dataBean"); BindUtils.postNotifyChange(null, null, grid, "canApprove"); BindUtils.postGlobalCommand(null, null, "reload", null); + grid.refresh(); window.detach(); } catch (ApproveException ex) { Messagebox.show(StringUtils.localize(ex.getReason()), StringUtils.localize("Error"), Messagebox.OK, 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 f765fe66..078dd2b6 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 @@ -6,11 +6,6 @@ import info.bukova.isspst.filters.RequirementFilter; import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.GlobalCommand; @@ -18,6 +13,10 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + public class ReqListMyAll extends RequirementSubpage { @WireVariable @@ -55,10 +54,11 @@ public class ReqListMyAll extends RequirementSubpage } @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "fullFill" }) + @NotifyChange({ "dataList", "dataBean", "fullFill", "selIndex" }) public void reloadRelated() { this.reload(); + restoreUserView(); } @Override 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 af243b72..bce41fba 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 @@ -6,11 +6,6 @@ import info.bukova.isspst.filters.RequirementFilter; import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.GlobalCommand; @@ -18,6 +13,10 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + public class ReqListMyCenters extends RequirementSubpage { @WireVariable @@ -55,10 +54,11 @@ public class ReqListMyCenters extends RequirementSubpage } @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "fullFill" }) + @NotifyChange({ "dataList", "dataBean", "fullFill", "selIndex" }) public void reloadRelated() { this.reload(); + restoreUserView(); } @Override 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 22b7af87..abe527a8 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 @@ -6,11 +6,6 @@ import info.bukova.isspst.filters.RequirementFilter; import info.bukova.isspst.services.requirement.RequirementService; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.requirement.RequirementSubpage; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.List; - import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.BindUtils; import org.zkoss.bind.annotation.GlobalCommand; @@ -18,6 +13,10 @@ import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.List; + public class ReqListMyWorkgroups extends RequirementSubpage { @WireVariable @@ -55,10 +54,11 @@ public class ReqListMyWorkgroups extends RequirementSubpage } @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "fullFill" }) + @NotifyChange({ "dataList", "dataBean", "fullFill", "selIndex" }) public void reloadRelated() { this.reload(); + restoreUserView(); } @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 b55a1bc1..aa82716b 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListAll.java @@ -63,9 +63,10 @@ public class TripRequirementListAll extends RequirementSubpage } @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "fullFill" }) + @NotifyChange({ "dataList", "dataBean", "fullFill", "selIndex" }) public void reloadRelated() { this.reload(); + restoreUserView(); } @Override 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 e3224971..b4be9c46 100644 --- a/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java +++ b/src/main/java/info/bukova/isspst/ui/requirement/TripRequirementListCentre.java @@ -63,6 +63,7 @@ public class TripRequirementListCentre extends RequirementSubpage { } @GlobalCommand - @NotifyChange({ "dataList", "dataBean", "fullFill" }) - public void reloadRelated() - { + @NotifyChange({ "dataList", "dataBean", "fullFill", "selIndex" }) + public void reloadRelated() { this.reload(); + restoreUserView(); } } diff --git a/src/main/webapp/main/invoicing/shared/invoicingGrid.zul b/src/main/webapp/main/invoicing/shared/invoicingGrid.zul index c8acf4d9..afd77666 100644 --- a/src/main/webapp/main/invoicing/shared/invoicingGrid.zul +++ b/src/main/webapp/main/invoicing/shared/invoicingGrid.zul @@ -9,37 +9,44 @@