Merge branch 'master' of https://git.bukova.info/repos/git/isspst
This commit is contained in:
@@ -1,13 +1,48 @@
|
||||
package info.bukova.isspst;
|
||||
|
||||
import org.jfree.util.Log;
|
||||
|
||||
public class BooleanUtils
|
||||
{
|
||||
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
|
||||
private static final String TAG = BooleanUtils.class.getSimpleName();
|
||||
|
||||
public static boolean isEqualByBooleanValue(Boolean b1, Boolean b2)
|
||||
{
|
||||
boolean bool1 = ((b1 == null) ? false : b1.booleanValue());
|
||||
boolean bool2 = ((b2 == null) ? false : b2.booleanValue());
|
||||
boolean equals = (bool1 == bool2);
|
||||
return equals;
|
||||
}
|
||||
|
||||
public static boolean isEqualByBoolean(Boolean b1, Boolean b2)
|
||||
{
|
||||
if ((b1 == null) && (b2 == null))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ((b1 != null) && (b2 != null))
|
||||
{
|
||||
return (b1.booleanValue() == b2.booleanValue());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isEqualFilterByBoolean(Boolean value, Boolean filterValue)
|
||||
{
|
||||
if (filterValue == null)
|
||||
{
|
||||
// Show all records
|
||||
return true;
|
||||
}
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
// Fuck!!! Tri-state data (null, false, true)... We need new solution for selecting ALL data
|
||||
Log.warn(TAG + "\nVelky Boolean v databazi... Pozor na filtrovani.");
|
||||
return true;
|
||||
}
|
||||
|
||||
return (value.booleanValue() == filterValue.booleanValue());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package info.bukova.isspst.data;
|
||||
|
||||
import info.bukova.isspst.Constants;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -220,6 +222,23 @@ public class JoinedItem implements DataModel, FilterableRequirement
|
||||
this.ownedBy = owner;
|
||||
}
|
||||
|
||||
protected Boolean itemMaterial;
|
||||
|
||||
public boolean isItemMaterialReal()
|
||||
{
|
||||
return ((this.requirement != null) && (this.requirement.getKind() == Constants.REQ_TYPE_MATERIAL));
|
||||
}
|
||||
|
||||
public Boolean getItemMaterial()
|
||||
{
|
||||
return this.itemMaterial;
|
||||
}
|
||||
|
||||
public void setItemMaterial(Boolean value)
|
||||
{
|
||||
this.itemMaterial = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.zkoss.zul.Listbox;
|
||||
import org.zkoss.zul.Listitem;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class BooleanFilterListbox extends Listbox
|
||||
{
|
||||
class TristateBooleanListItem extends TristateBoolean
|
||||
{
|
||||
public TristateBooleanListItem(String text, int value)
|
||||
{
|
||||
this.setText(text);
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
private String text;
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text)
|
||||
{
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
public BooleanFilterListbox()
|
||||
{
|
||||
super();
|
||||
|
||||
List<TristateBooleanListItem> list = new ArrayList<TristateBooleanListItem>();
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelAll"), TristateBoolean.NULL));
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelNo"), TristateBoolean.FALSE));
|
||||
list.add(new TristateBooleanListItem(StringUtils.localize("LabelYes"), TristateBoolean.TRUE));
|
||||
|
||||
for (int i = 0; i < list.size(); i++)
|
||||
{
|
||||
TristateBooleanListItem triStateItem = (TristateBooleanListItem) list.get(i);
|
||||
this.appendItem(triStateItem.getText(), "");
|
||||
|
||||
Listitem item = this.getItemAtIndex(i);
|
||||
item.setValue((TristateBoolean) triStateItem);
|
||||
}
|
||||
|
||||
this.setSelectedIndex(0);
|
||||
// this.setHflex("1");
|
||||
this.setMold("select");
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import info.bukova.isspst.BooleanUtils;
|
||||
import info.bukova.isspst.StringUtils;
|
||||
import info.bukova.isspst.data.JoinedItem;
|
||||
import info.bukova.isspst.data.MUnitEmb;
|
||||
@@ -42,6 +43,7 @@ public class JoinedItemFilter implements Filter<JoinedItem>
|
||||
@Override
|
||||
public boolean matchesSafely(JoinedItem item)
|
||||
{
|
||||
boolean foundItemMaterial = BooleanUtils.isEqualFilterByBoolean(item.isItemMaterialReal(), condition.getItemMaterial());
|
||||
boolean foundCode = StringUtils.isEqualForFilter(item.getCode(), condition.getCode());
|
||||
boolean foundName = StringUtils.isEqualForFilter(item.getName(), condition.getName());
|
||||
boolean foundTextItem = StringUtils.isEqualForFilter(item.getTextItem(), condition.getTextItem());
|
||||
@@ -56,7 +58,18 @@ public class JoinedItemFilter implements Filter<JoinedItem>
|
||||
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
|
||||
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription);
|
||||
return (foundItemMaterial
|
||||
&& foundCode
|
||||
&& foundName
|
||||
&& foundTextItem
|
||||
&& foundDescription
|
||||
&& foundQuantity
|
||||
&& foundUnitPrice
|
||||
&& foundMUnit
|
||||
&& foundTotal
|
||||
&& foundWorkgroup
|
||||
&& foundCenter
|
||||
&& foundOwner && foundDescription);
|
||||
}
|
||||
|
||||
@Factory
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RequirementFilter implements Filter<Requirement>
|
||||
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
|
||||
boolean foundDeliveryDate = DateTimeUtils.isEqualByDateForFilter(item.getDeliveryDate(), condition.getDeliveryDate());
|
||||
boolean foundUser = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
|
||||
boolean foundProject = BooleanUtils.isEqualByBoolean(item.getProject(), condition.getProject());
|
||||
boolean foundProject = BooleanUtils.isEqualByBooleanValue(item.getProject(), condition.getProject());
|
||||
return (foundNumser && foundReqDate && foundCenter && foundDescription && foundDeliveryDate && foundUser && foundProject);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package info.bukova.isspst.filters;
|
||||
|
||||
import org.jfree.util.Log;
|
||||
|
||||
public class TristateBoolean
|
||||
{
|
||||
private static final String TAG = TristateBoolean.class.getSimpleName();
|
||||
|
||||
public static final int NULL = -1;
|
||||
public static final int FALSE = 0;
|
||||
public static final int TRUE = 1;
|
||||
|
||||
public static final int getValidValue(final int value)
|
||||
{
|
||||
if ((value != TristateBoolean.NULL) && (value != TristateBoolean.FALSE) && (value != TristateBoolean.TRUE))
|
||||
{
|
||||
Log.warn(TAG + "\nBad tristate boolean value.");
|
||||
return TristateBoolean.NULL;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public TristateBoolean()
|
||||
{
|
||||
this.setValue(TristateBoolean.NULL);
|
||||
}
|
||||
|
||||
public TristateBoolean(boolean value)
|
||||
{
|
||||
this.setValue(value ? TristateBoolean.TRUE : TristateBoolean.FALSE);
|
||||
}
|
||||
|
||||
public TristateBoolean(int value)
|
||||
{
|
||||
this.setValue(value);
|
||||
}
|
||||
|
||||
protected int value;
|
||||
|
||||
public int getValue()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(int value)
|
||||
{
|
||||
this.value = TristateBoolean.getValidValue(value);
|
||||
}
|
||||
|
||||
public Boolean getBoolean()
|
||||
{
|
||||
switch (this.value)
|
||||
{
|
||||
case TristateBoolean.FALSE:
|
||||
return new Boolean(false);
|
||||
|
||||
case TristateBoolean.TRUE:
|
||||
return new Boolean(true);
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (obj != null)
|
||||
{
|
||||
if (obj instanceof TristateBoolean)
|
||||
{
|
||||
TristateBoolean item = (TristateBoolean) obj;
|
||||
int thisValue = this.getValue();
|
||||
int itemValue = item.getValue();
|
||||
return (thisValue == itemValue);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean equals(int value)
|
||||
{
|
||||
return (this.getValue() == value);
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import info.bukova.isspst.data.Order;
|
||||
import info.bukova.isspst.data.User;
|
||||
import info.bukova.isspst.data.Workgroup;
|
||||
import info.bukova.isspst.filters.JoinedItemFilter;
|
||||
import info.bukova.isspst.filters.TristateBoolean;
|
||||
import info.bukova.isspst.services.orders.ApprovedService;
|
||||
import info.bukova.isspst.services.orders.OrderService;
|
||||
import info.bukova.isspst.services.users.UserService;
|
||||
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
||||
import info.bukova.isspst.ui.BigDecimalConverter;
|
||||
import info.bukova.isspst.ui.ListViewModel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -38,24 +38,17 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
@WireVariable
|
||||
protected OrderService orderService;
|
||||
|
||||
private BigDecimalConverter bigDecimalConverter;
|
||||
|
||||
protected List<JoinedItem> selectedItems;
|
||||
|
||||
@Init
|
||||
|
||||
@Init(superclass = true)
|
||||
public void initApprovedList()
|
||||
{
|
||||
service = approvedService;
|
||||
dataClass = JoinedItem.class;
|
||||
// formZul = "form.zul";
|
||||
dataFilter = new JoinedItemFilter(getFilterTemplate());
|
||||
bigDecimalConverter = new BigDecimalConverter();
|
||||
selectedItems = new ArrayList<JoinedItem>();
|
||||
}
|
||||
|
||||
public BigDecimalConverter getBigDecimalConverter()
|
||||
{
|
||||
return bigDecimalConverter;
|
||||
this.itemMaterial = new TristateBoolean();
|
||||
}
|
||||
|
||||
public List<JoinedItem> getItems()
|
||||
@@ -123,4 +116,17 @@ public class ApprovedList extends ListViewModel<JoinedItem>
|
||||
return new ArrayList<JoinedItem>();
|
||||
}
|
||||
}
|
||||
|
||||
protected TristateBoolean itemMaterial;
|
||||
|
||||
public TristateBoolean getItemMaterial()
|
||||
{
|
||||
return this.itemMaterial;
|
||||
}
|
||||
|
||||
public void setItemMaterial(TristateBoolean tristate)
|
||||
{
|
||||
this.itemMaterial = tristate;
|
||||
this.getFilterTemplate().setItemMaterial(tristate.getBoolean());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE xml>
|
||||
<language-addon>
|
||||
<addon-name>BooleanFilterListbox</addon-name>
|
||||
<language-name>xul/html</language-name>
|
||||
<component>
|
||||
<component-name>booleanfilterlistbox</component-name>
|
||||
<extends>listbox</extends>
|
||||
<component-class>info.bukova.isspst.filters.BooleanFilterListbox</component-class>
|
||||
</component>
|
||||
</language-addon>
|
||||
@@ -289,6 +289,9 @@ DbValidationError=Chyba validace
|
||||
true=Ano
|
||||
false=Ne
|
||||
|
||||
LabelAll=Vše
|
||||
LabelYes=Ano
|
||||
LabelNo=Ne
|
||||
|
||||
|
||||
Information=Informace
|
||||
@@ -301,6 +304,7 @@ MaterialRequirements=Požadavky na materiál
|
||||
ServiceRequirement=Požadavek na službu
|
||||
ServiceRequirements=Požadavky na služby
|
||||
ApprovedRequirementItems=Schválené položky požadavků
|
||||
Material = Materiál
|
||||
|
||||
CurrentRequirements=Aktuální požadavky
|
||||
CreatedOrders=Vytvořené objednávky
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<addon-uri>/WEB-INF/lang-addons/mapa-lang-addon.xml</addon-uri>
|
||||
<addon-uri>/WEB-INF/lang-addons/ckez-bind-lang-addon.xml</addon-uri>
|
||||
<addon-uri>/WEB-INF/lang-addons/CzechSortListheader.xml</addon-uri>
|
||||
<addon-uri>/WEB-INF/lang-addons/BooleanFilterListbox.xml</addon-uri>
|
||||
</language-config>
|
||||
<desktop-config>
|
||||
<theme-uri>/css/zk-modify.css</theme-uri>
|
||||
|
||||
@@ -32,9 +32,13 @@
|
||||
<listhead menupopup="auto">
|
||||
<listheader width="27" />
|
||||
<listheader
|
||||
hflex="6"
|
||||
sort="czech(requirement.numser)"
|
||||
label="${labels.InvoicingRequirementNumber}" />
|
||||
hflex="4"
|
||||
sort="auto(itemMaterialReal)"
|
||||
label="${labels.Material}" />
|
||||
<listheader
|
||||
hflex="6"
|
||||
sort="czech(requirement.numser)"
|
||||
label="${labels.InvoicingRequirementNumber}" />
|
||||
<listheader
|
||||
hflex="7"
|
||||
sort="czech(code)"
|
||||
@@ -86,20 +90,25 @@
|
||||
<auxhead visible="@load(vm.filter)">
|
||||
<auxheader />
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.requirement.numser)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
maxlength="@load(vm.lengthText)"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<booleanfilterlistbox
|
||||
selectedItem="@bind(vm.itemMaterial)"
|
||||
onSelect="@command('doFilter')" />
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
<textbox
|
||||
value="@bind(vm.filterTemplate.requirement.numser)"
|
||||
instant="true"
|
||||
onChange="@command('doFilter')"
|
||||
maxlength="@load(vm.lengthText)"
|
||||
sclass="find-grid-textbox" />
|
||||
</div>
|
||||
<div sclass="find-grid-img">
|
||||
<image src="/img/funnel.png" />
|
||||
</div>
|
||||
</div>
|
||||
</auxheader>
|
||||
<auxheader>
|
||||
<div sclass="find-grid-cell">
|
||||
<div sclass="find-grid-divtextbox">
|
||||
@@ -287,14 +296,15 @@
|
||||
<template name="model">
|
||||
<listitem context="popupMenu">
|
||||
<listcell />
|
||||
<listcell label="@load(each.requirement.numser)"/>
|
||||
<listcell label="@load(each.itemMaterialReal) @converter(vm.standardBoolConverter)" />
|
||||
<listcell label="@load(each.requirement.numser)" />
|
||||
<listcell label="@load(each.code)" />
|
||||
<listcell label="@load(each.name)" />
|
||||
<listcell label="@load(each.textItem)" />
|
||||
<listcell label="@load(each.quantity) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.quantity) @converter(vm.standardBigDecimalConverter)" />
|
||||
<listcell label="@load(each.munit.name)" />
|
||||
<listcell label="@load(each.unitPrice) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.total) @converter(vm.bigDecimalConverter)" />
|
||||
<listcell label="@load(each.unitPrice) @converter(vm.standardBigDecimalConverter)" />
|
||||
<listcell label="@load(each.total) @converter(vm.standardBigDecimalConverter)" />
|
||||
<listcell label="@load(each.workgroup.fullName)" />
|
||||
<listcell label="@load(each.centre.fullName)" />
|
||||
<listcell label="@load(each.ownedBy.fullName)" />
|
||||
|
||||
Reference in New Issue
Block a user