From 882993ef1753587d22f7c2dd0f13d1de837c3b0c Mon Sep 17 00:00:00 2001 From: Franta Pribyl Date: Fri, 17 Oct 2014 05:48:44 +0200 Subject: [PATCH] =?UTF-8?q?Ag.=20Vytvo=C5=99en=C3=A9=20objedn=C3=A1vky=20?= =?UTF-8?q?=E2=80=A2=20vlo=C5=BEen=20k=C3=B3d=20pro=20barevn=C3=A9=20rozli?= =?UTF-8?q?=C5=A1en=C3=AD=20Listitem=20v=20objedn=C3=A1vk=C3=A1ch=20pomoc?= =?UTF-8?q?=C3=AD=20styl=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #160 --- .../ui/main/orders/created/OrderList.java | 14 ++++++ .../ui/renderers/GenericListitemRenderer.java | 50 +++++++++++++++++++ .../renderers/OrderCreatedItemRenderer.java | 38 ++++++++++++++ src/main/webapp/css/zk-modify.css | 28 +++++++---- src/main/webapp/main/orders/created/grid.zul | 1 + 5 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 src/main/java/info/bukova/isspst/ui/renderers/GenericListitemRenderer.java create mode 100644 src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java diff --git a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderList.java b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderList.java index a5eb63ba..dd4b3403 100644 --- a/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderList.java +++ b/src/main/java/info/bukova/isspst/ui/main/orders/created/OrderList.java @@ -13,6 +13,7 @@ import info.bukova.isspst.services.approved.OrderService; import info.bukova.isspst.services.settings.GlobalSettingsService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.ui.ListViewModel; +import info.bukova.isspst.ui.renderers.OrderCreatedItemRenderer; import java.util.ArrayList; import java.util.List; @@ -47,6 +48,8 @@ public class OrderList extends ListViewModel protected List orderItems; + protected OrderCreatedItemRenderer orderCreatedItemRenderer; + @Init(superclass = true) public void initOrderList() { @@ -55,6 +58,7 @@ public class OrderList extends ListViewModel formZul = "orderForm.zul"; dataFilter = new OrderFilter(getFilterTemplate()); this.orderItems = new ArrayList(); + this.orderCreatedItemRenderer = new OrderCreatedItemRenderer(); } public List getSuppAddresses() @@ -117,6 +121,16 @@ public class OrderList extends ListViewModel this.orderItems = orderItems; } + public OrderCreatedItemRenderer getOrderCreatedItemRenderer() + { + return orderCreatedItemRenderer; + } + + public void setOrderCreatedItemRenderer(OrderCreatedItemRenderer orderCreatedItemRenderer) + { + this.orderCreatedItemRenderer = orderCreatedItemRenderer; + } + @Command @NotifyChange("orderItems") public void onChangeSelectOrder(@BindingParam("ctrl") Listbox lb) diff --git a/src/main/java/info/bukova/isspst/ui/renderers/GenericListitemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/GenericListitemRenderer.java new file mode 100644 index 00000000..4e8170a4 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/renderers/GenericListitemRenderer.java @@ -0,0 +1,50 @@ +package info.bukova.isspst.ui.renderers; + +import org.zkoss.bind.impl.BindListitemRenderer; +import org.zkoss.zk.ui.Component; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listitem; + +@SuppressWarnings("serial") +public abstract class GenericListitemRenderer extends BindListitemRenderer +{ + protected abstract void changeProperties(Listbox lb, Listitem li, int index, String varnm); + + protected T objectOfStates; + + public T getObjectOfStates() + { + return objectOfStates; + } + + public void setObjectOfStates(T objectOfStates) + { + this.objectOfStates = objectOfStates; + } + + @SuppressWarnings("unchecked") + @Override + public void render(Listitem item, Object data, int index) throws Exception + { + this.objectOfStates = (T) data; + + super.render(item, data, index); + } + + @Override + protected void addItemReference(Component modelOwner, Component comp, int index, String varnm) + { + if (this.objectOfStates != null) + { + if (modelOwner != null && modelOwner instanceof Listbox) + { + if (comp != null && comp instanceof Listitem) + { + this.changeProperties((Listbox) modelOwner, (Listitem) comp, index, varnm); + } + } + } + + super.addItemReference(modelOwner, comp, index, varnm); + } +} diff --git a/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java new file mode 100644 index 00000000..60d73c50 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/renderers/OrderCreatedItemRenderer.java @@ -0,0 +1,38 @@ +package info.bukova.isspst.ui.renderers; + +import info.bukova.isspst.data.Order; + +import java.math.BigDecimal; + +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listitem; + +@SuppressWarnings("serial") +public class OrderCreatedItemRenderer extends GenericListitemRenderer +{ + @Override + protected void changeProperties(Listbox lb, Listitem li, int index, String varnm) + { + Order order = this.getObjectOfStates(); + + boolean objednano = order.isOrdered(); + + BigDecimal invoiceTotal = order.getInvoiceTotal(); + boolean zakoupeno = ((invoiceTotal != null) && (invoiceTotal.compareTo(BigDecimal.ZERO) != 0)); + + boolean doruceno = (zakoupeno && (order.getDeliveredDate() != null)); + + if (doruceno) + { + li.setSclass("order-select-delivered"); + } + else if (zakoupeno) + { + li.setSclass("order-select-invoiced"); + } + else if (objednano) + { + li.setSclass("order-select-ordered"); + } + } +} diff --git a/src/main/webapp/css/zk-modify.css b/src/main/webapp/css/zk-modify.css index 7bf6088b..bcd15cd5 100644 --- a/src/main/webapp/css/zk-modify.css +++ b/src/main/webapp/css/zk-modify.css @@ -8,10 +8,8 @@ text-shadow: 2px 2px 2px #000000; } -.addScrollbar { - +.addScrollbar { overflow: auto; - } .find-grid-cell { @@ -41,29 +39,41 @@ .find-grid-textbox-right { width: 100%; - text-align: right; + text-align: right; } -.grid-textbox-max { +.grid-textbox-max { width: 100%; } -.grid-textbox-max-right { +.grid-textbox-max-right { width: 100%; text-align: right; } -.row-title { +.row-title { /* ve formuláři zarovná u víceřádkových editů label nahoru */ vertical-align: top; } -.z-listcell-content { +.z-listcell-content { /* při úzkém sloupci gridu neodřádkuje slova podle mezer */ white-space: nowrap; } -.combo { +.combo { width: 100%; min-width: 0; } + +.order-select-ordered { + background-color: #98fb98 !important; +} + +.order-select-invoiced { + background-color: #fff44f !important; +} + +.order-select-delivered { + background-color: #d19fe8 !important; +} \ No newline at end of file diff --git a/src/main/webapp/main/orders/created/grid.zul b/src/main/webapp/main/orders/created/grid.zul index 9d9ab996..0ba90053 100644 --- a/src/main/webapp/main/orders/created/grid.zul +++ b/src/main/webapp/main/orders/created/grid.zul @@ -21,6 +21,7 @@