Přidány sloupce pro vlastníky, střediska a komise.

Přidáno kontextové menu pro budoucí vytváření objednávek.

refs #139
multitenant
František Přibyl 10 years ago
parent 78cf41d2a0
commit 73c3ce7180

@ -1,5 +1,7 @@
package info.bukova.isspst; package info.bukova.isspst;
import java.util.List;
import org.zkoss.util.resource.Labels; import org.zkoss.util.resource.Labels;
public class StringUtils public class StringUtils
@ -91,4 +93,35 @@ public class StringUtils
return value; return value;
} }
public static String addSeparator(String value, String separator, boolean toTail)
{
if ((value != null) && (separator != null))
{
if (!value.isEmpty() && !separator.isEmpty())
{
value = (toTail ? value + separator : separator + value);
}
}
return value;
}
public static String addSeparator(String value, String separator)
{
return StringUtils.addSeparator(value, separator, true);
}
public static String join(List<String> list, String separator)
{
String result = "";
for (int i = 0; i < list.size(); i++)
{
result = StringUtils.addSeparator(result, separator);
result += list.get(i);
}
return result;
}
} }

@ -1,5 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -134,14 +136,22 @@ public class User extends Member implements UserDetails, DataModel {
this.authorities.remove(role); this.authorities.remove(role);
} }
public String getFullName() { public String getFullName()
String ret = ""; {
if (lastName != null && !lastName.isEmpty()) { List<String> list = new ArrayList<String>();
ret = lastName + " ";
if (this.lastName != null)
{
list.add(this.lastName);
}
if (this.firstName != null)
{
list.add(this.firstName);
} }
ret = ret + (firstName == null ? "" : firstName);
return ret; String result = StringUtils.join(list, " ");
return result;
} }
public String getFirstName() { public String getFirstName() {
@ -193,6 +203,28 @@ public class User extends Member implements UserDetails, DataModel {
} }
} }
public static boolean isEqualByUserForFilter(User value, User search)
{
if (search == null)
{
return true;
}
else if (value != null)
{
if (search.getFullName().isEmpty())
{
return true;
}
String valueS = value.getFullName();
String searchS = search.getFullName();
return (valueS.compareTo(searchS) == 0);
}
return false;
}
@Override @Override
public String toString() { public String toString() {
return getFullName(); return getFullName();

@ -1,5 +1,7 @@
package info.bukova.isspst.data; package info.bukova.isspst.data;
import info.bukova.isspst.StringUtils;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -103,8 +105,22 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable {
} }
@Override @Override
public String getFullName() { public String getFullName()
return code + " " + name; {
List<String> list = new ArrayList<String>();
if (this.code != null)
{
list.add(this.code);
}
if (this.name != null)
{
list.add(this.name);
}
String result = StringUtils.join(list, " ");
return result;
} }
@Override @Override
@ -136,6 +152,28 @@ public class Workgroup extends Member implements OwnedDataModel, Serializable {
return false; return false;
} }
public static boolean isEqualByWorkgroupForFilter(Workgroup value, Workgroup search)
{
if (search == null)
{
return true;
}
else if (value != null)
{
if (search.getFullName().isEmpty())
{
return true;
}
String valueS = value.getFullName();
String searchS = search.getFullName();
return (valueS.compareTo(searchS) == 0);
}
return false;
}
@Override @Override
public String toString() { public String toString() {
return getFullName(); return getFullName();

@ -4,6 +4,8 @@ import info.bukova.isspst.BigDecimalUtils;
import info.bukova.isspst.StringUtils; import info.bukova.isspst.StringUtils;
import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.MUnitEmb; import info.bukova.isspst.data.MUnitEmb;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup;
import org.hamcrest.Description; import org.hamcrest.Description;
import org.hamcrest.Factory; import org.hamcrest.Factory;
@ -17,6 +19,10 @@ public class JoinedItemFilter implements Filter<JoinedItem>
public JoinedItemFilter(JoinedItem cond) public JoinedItemFilter(JoinedItem cond)
{ {
this.condition = cond; this.condition = cond;
this.condition.setMunit(new MUnitEmb());
this.condition.setWorkgroup(new Workgroup());
this.condition.setCentre(new Workgroup());
this.condition.setOwnedBy(new User());
} }
private static class JoinedItemMatcher extends TypeSafeMatcher<JoinedItem> private static class JoinedItemMatcher extends TypeSafeMatcher<JoinedItem>
@ -44,8 +50,11 @@ public class JoinedItemFilter implements Filter<JoinedItem>
boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice()); boolean foundUnitPrice = BigDecimalUtils.isEqualByDecimalForFilter(item.getUnitPrice(), condition.getUnitPrice());
boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit()); boolean foundMUnit = MUnitEmb.isEqualMUnitEmbForFilter(item.getMunit(), condition.getMunit());
boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal()); boolean foundTotal = BigDecimalUtils.isEqualByDecimalForFilter(item.getTotal(), condition.getTotal());
boolean foundWorkgroup = Workgroup.isEqualByWorkgroupForFilter(item.getWorkgroup(), condition.getWorkgroup());
boolean foundCenter = Workgroup.isEqualByWorkgroupForFilter(item.getCentre(), condition.getCentre());
boolean foundOwner = User.isEqualByUserForFilter(item.getOwnedBy(), condition.getOwnedBy());
boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription()); boolean foundDescription = StringUtils.isEqualForFilter(item.getDescription(), condition.getDescription());
return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundDescription); return (foundCode && foundName && foundTextItem && foundDescription && foundQuantity && foundUnitPrice && foundMUnit && foundTotal && foundWorkgroup && foundCenter && foundOwner && foundDescription);
} }
@Factory @Factory

@ -11,6 +11,7 @@ import info.bukova.isspst.services.workgroups.WorkgroupService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.hibernate.Hibernate;
import org.hibernate.Query; import org.hibernate.Query;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PostFilter; import org.springframework.security.access.prepost.PostFilter;
@ -33,12 +34,17 @@ public class ApprovedServiceImpl extends AbstractService<JoinedItem> implements
public List<JoinedItem> getAll() public List<JoinedItem> getAll()
{ {
List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent()); List<Workgroup> wgList = workgroupService.getUserCentres(userService.getCurrent());
Query q = queryDao.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)"); Query q = queryDao
.getQuery("select item from RequirementItem item left join item.requirement rq join rq.centre c where rq.kind is not null and rq.state = :state and c in (:wgList)");
q.setParameterList("wgList", wgList); q.setParameterList("wgList", wgList);
q.setParameter("state", RequirementState.APPROVED); q.setParameter("state", RequirementState.APPROVED);
List<JoinedItem> items = new ArrayList<JoinedItem>(); List<JoinedItem> items = new ArrayList<JoinedItem>();
for (RequirementItem it : (List<RequirementItem>)q.list()) { for (RequirementItem it : (List<RequirementItem>) q.list())
{
// Kvůli lazy loadu načteme jakoukoli hodnotu objektu
Hibernate.initialize(it.getRequirement().getOwnedBy());
items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy())); items.add(new JoinedItem(it, it.getRequirement().getWorkgroup(), it.getRequirement().getCentre(), it.getRequirement().getOwnedBy()));
} }

@ -1,11 +1,16 @@
package info.bukova.isspst.ui.main.approved; package info.bukova.isspst.ui.main.approved;
import info.bukova.isspst.data.JoinedItem; import info.bukova.isspst.data.JoinedItem;
import info.bukova.isspst.data.User;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.filters.JoinedItemFilter; import info.bukova.isspst.filters.JoinedItemFilter;
import info.bukova.isspst.services.approved.ApprovedService; import info.bukova.isspst.services.approved.ApprovedService;
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.BigDecimalConverter;
import info.bukova.isspst.ui.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
@ -16,6 +21,12 @@ public class ApprovedList extends ListViewModel<JoinedItem>
@WireVariable @WireVariable
protected ApprovedService approvedService; protected ApprovedService approvedService;
@WireVariable
protected WorkgroupService workgroupService;
@WireVariable
protected UserService userService;
private BigDecimalConverter bigDecimalConverter; private BigDecimalConverter bigDecimalConverter;
@Init @Init
@ -37,4 +48,25 @@ public class ApprovedList extends ListViewModel<JoinedItem>
{ {
return approvedService.getAll(); return approvedService.getAll();
} }
public List<Workgroup> getWorkgroups()
{
Workgroup empty = new Workgroup();
empty.setCode("");
empty.setName("");
List<Workgroup> list = new ArrayList<Workgroup>();
list.add(empty);
list.addAll(this.workgroupService.getWorkgroups());
return list;
}
public List<Workgroup> getCenters()
{
return this.workgroupService.getCentres();
}
public List<User> getUsers()
{
return this.userService.getAll();
}
} }

@ -292,6 +292,8 @@ SelectGroup=Vybrat skupinu...
RemoveItem=Smazat RemoveItem=Smazat
Amount=Částka Amount=Částka
Owner=Vlastník
CreateOrder=Vytvořit objednávku
WorkgroupFormUserIsCenterMember=Uživatel je členem střediska, jehož je komise členem! WorkgroupFormUserIsCenterMember=Uživatel je členem střediska, jehož je komise členem!
WorkgroupFormMemberIsCenterMember=Některý ze členů přidávané komise je členem tohoto střediska! WorkgroupFormMemberIsCenterMember=Některý ze členů přidávané komise je členem tohoto střediska!

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

@ -26,6 +26,7 @@
multiple="true" multiple="true"
checkmark="true" checkmark="true"
vflex="1" vflex="1"
context="popupMenu"
model="@load(vm.dataList)"> model="@load(vm.dataList)">
<listhead menupopup="auto"> <listhead menupopup="auto">
<listheader width="27" /> <listheader width="27" />
@ -61,7 +62,19 @@
sort="auto(total)" sort="auto(total)"
label="${labels.RequirementItemTotal}" /> label="${labels.RequirementItemTotal}" />
<listheader <listheader
hflex="20" hflex="7"
sort="auto(workgroup.fullName)"
label="${labels.RequirementsGridWorkgroup}" />
<listheader
hflex="7"
sort="auto(centre.fullName)"
label="${labels.RequirementsGridCenter}" />
<listheader
hflex="7"
sort="auto(ownedBy.fullName)"
label="${labels.Owner}" />
<listheader
hflex="15"
sort="czech(description)" sort="czech(description)"
label="${labels.RequirementItemDescription}" /> label="${labels.RequirementItemDescription}" />
</listhead> </listhead>
@ -112,19 +125,19 @@
<auxheader> <auxheader>
<!-- div sclass="find-grid-cell"> <!-- div sclass="find-grid-cell">
<div sclass="find-grid-img-left"> <div sclass="find-grid-img-left">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
</div> </div>
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox <textbox
value="@bind(vm.filterTemplate.quantity)" value="@bind(vm.filterTemplate.quantity)"
instant="true" instant="true"
onChange="@command('doFilter')" onChange="@command('doFilter')"
sclass="find-grid-textbox-right" /> sclass="find-grid-textbox-right" />
</div> </div>
</div--> </div-->
</auxheader> </auxheader>
<auxheader> <auxheader>
<!-- div sclass="find-grid-cell"> <div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox <textbox
value="@bind(vm.filterTemplate.munit.name)" value="@bind(vm.filterTemplate.munit.name)"
@ -135,35 +148,92 @@
<div sclass="find-grid-img"> <div sclass="find-grid-img">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
</div> </div>
</div--> </div>
</auxheader> </auxheader>
<auxheader> <auxheader>
<!-- div sclass="find-grid-cell"> <!-- div sclass="find-grid-cell">
<div sclass="find-grid-img-left"> <div sclass="find-grid-img-left">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
</div> </div>
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox <textbox
value="@bind(vm.filterTemplate.unitPrice)" value="@bind(vm.filterTemplate.unitPrice)"
instant="true" instant="true"
onChange="@command('doFilter')" onChange="@command('doFilter')"
sclass="find-grid-textbox-right" /> sclass="find-grid-textbox-right" />
</div> </div>
</div--> </div-->
</auxheader> </auxheader>
<auxheader> <auxheader>
<!-- div sclass="find-grid-cell"> <!-- div sclass="find-grid-cell">
<div sclass="find-grid-img-left"> <div sclass="find-grid-img-left">
<image src="/img/funnel.png" />
</div>
<div sclass="find-grid-divtextbox">
<textbox
value="@bind(vm.filterTemplate.total)"
instant="true"
onChange="@command('doFilter')"
sclass="find-grid-textbox-right" />
</div>
</div-->
</auxheader>
<auxheader>
<div zclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<combobox
readonly="true"
width="100%"
selectedItem="@bind(vm.filterTemplate.workgroup)"
model="@load(vm.workgroups)"
onChange="@command('doFilter')">
<template name="model">
<comboitem label="@load(each.fullName)" />
</template>
</combobox>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" /> <image src="/img/funnel.png" />
</div> </div>
</div>
</auxheader>
<auxheader>
<div zclass="find-grid-cell">
<div sclass="find-grid-divtextbox"> <div sclass="find-grid-divtextbox">
<textbox <combobox
value="@bind(vm.filterTemplate.total)" readonly="true"
instant="true" width="100%"
onChange="@command('doFilter')" selectedItem="@bind(vm.filterTemplate.centre)"
sclass="find-grid-textbox-right" /> model="@load(vm.centers)"
onChange="@command('doFilter')">
<template name="model">
<comboitem label="@load(each.fullName)" />
</template>
</combobox>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div> </div>
</div--> </div>
</auxheader>
<auxheader>
<div zclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<combobox
readonly="true"
width="100%"
selectedItem="@bind(vm.filterTemplate.ownedBy)"
model="@load(vm.users)"
onChange="@command('doFilter')">
<template name="model">
<comboitem label="@load(each.fullName)" />
</template>
</combobox>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
</div>
</div>
</auxheader> </auxheader>
<auxheader> <auxheader>
<div sclass="find-grid-cell"> <div sclass="find-grid-cell">
@ -190,9 +260,18 @@
<listcell label="@load(each.munit.name)" /> <listcell label="@load(each.munit.name)" />
<listcell label="@load(each.unitPrice) @converter(vm.bigDecimalConverter)" /> <listcell label="@load(each.unitPrice) @converter(vm.bigDecimalConverter)" />
<listcell label="@load(each.total) @converter(vm.bigDecimalConverter)" /> <listcell label="@load(each.total) @converter(vm.bigDecimalConverter)" />
<listcell label="@load(each.workgroup.fullName)" />
<listcell label="@load(each.centre.fullName)" />
<listcell label="@load(each.ownedBy.fullName)" />
<listcell label="@load(each.description)" /> <listcell label="@load(each.description)" />
</listitem> </listitem>
</template> </template>
</listbox> </listbox>
</window> </window>
<menupopup id="popupMenu">
<menuitem
image="/img/autotruck-016.png"
label="${labels.CreateOrder}..."
onClick="" />
</menupopup>
</zk> </zk>
Loading…
Cancel
Save