Doladěno UI agendy na definici středisek a komisí.

closes #97
multitenant
Josef Rokos 11 years ago
parent bfb0782674
commit 53d5d262b1

@ -68,4 +68,9 @@ public class JobMapping {
return false;
}
@Override
public String toString() {
return this.getMember() + " - " + this.getRole().getDescription();
}
}

@ -26,7 +26,7 @@ public abstract class Member implements DataModel {
private boolean valid;
public abstract String getFullName();
public abstract boolean isHasJob();
public abstract boolean isPerson();
public int getId() {
return id;

@ -192,7 +192,7 @@ public class User extends Member implements UserDetails, DataModel {
}
@Override
public boolean isHasJob() {
public boolean isPerson() {
return true;
}

@ -90,11 +90,11 @@ public class Workgroup extends Member implements OwnedDataModel {
@Override
public String getFullName() {
return name;
return code + " " + name;
}
@Override
public boolean isHasJob() {
public boolean isPerson() {
return false;
}
@ -122,4 +122,9 @@ public class Workgroup extends Member implements OwnedDataModel {
return false;
}
@Override
public String toString() {
return getFullName();
}
}

@ -0,0 +1,56 @@
package info.bukova.isspst.filters;
import static info.bukova.isspst.StringUtils.nullStr;
import info.bukova.isspst.data.Workgroup;
import org.hamcrest.Description;
import org.hamcrest.Factory;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
public class WorkgroupFilter implements Filter<Workgroup> {
private Workgroup condWorkgroup;
public WorkgroupFilter(Workgroup condWorkgroup) {
this.condWorkgroup = condWorkgroup;
}
private static class WorkgroupMatcher extends TypeSafeMatcher<Workgroup> {
private Workgroup condWorkgroup;
public WorkgroupMatcher(Workgroup cond) {
this.condWorkgroup = cond;
}
@Override
public void describeTo(Description desc) {
desc.appendText("material matches");
}
@Override
public boolean matchesSafely(Workgroup item) {
return nullStr(item.getCode()).toLowerCase().contains(nullStr(condWorkgroup.getCode()).toLowerCase())
&& nullStr(item.getName()).toLowerCase().contains(nullStr(condWorkgroup.getName()).toLowerCase())
&& item.isCentre() == condWorkgroup.isCentre();
}
@Factory
public static Matcher<Workgroup> matchBuilding(Workgroup material) {
return new WorkgroupMatcher(material);
}
}
@Override
public WorkgroupMatcher matcher() {
return new WorkgroupMatcher(condWorkgroup);
}
@Override
public String queryString() {
// TODO query string
return "";
}
}

@ -12,6 +12,7 @@ public class WorkgroupException extends IsspstException {
public final static String NO_WORGROUP = "WorkgroupNotAllowed";
public final static String MSUT_HAS_CENTER = "RoleMustHasCentre";
public final static String MUST_HAS_WORKGROUP = "WorkgroupMustHasCentre";
public final static String CYCLIC_MEMBER = "CyclicMembership";
public WorkgroupException(String message) {
super(message);

@ -15,7 +15,7 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
@Override
public void addMember(Workgroup workgroup, Member member, Role role) {
if (!member.isHasJob() && !role.getAuthority().equals(Constants.ROLE_USER)) {
if (!member.isPerson() && !role.getAuthority().equals(Constants.ROLE_USER)) {
throw new WorkgroupException(WorkgroupException.NO_WORGROUP);
}
if (workgroup.isCentre() && !role.isCentre()) {
@ -25,6 +25,14 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
throw new WorkgroupException(WorkgroupException.MUST_HAS_WORKGROUP);
}
if (!checkGroups(workgroup, member)) {
throw new WorkgroupException(WorkgroupException.CYCLIC_MEMBER);
}
if (!member.isPerson() && !checkGroups((Workgroup)member, workgroup)) {
throw new WorkgroupException(WorkgroupException.CYCLIC_MEMBER);
}
JobMapping mapping = new JobMapping(member, role);
if (!workgroup.getMembers().contains(mapping)) {
workgroup.getMembers().add(mapping);
@ -54,4 +62,39 @@ public class WorkgroupServiceImpl extends AbstractOwnedService<Workgroup> implem
return false;
}
private boolean checkGroups(Workgroup workgroup, Member member) {
if (member.equals(workgroup)) {
return false;
}
if (member.isPerson()) {
return true;
}
Workgroup toAdd = Workgroup.class.cast(member);
for (JobMapping jm : toAdd.getMembers()) {
if (!jm.getMember().isPerson() && !checkGroups(workgroup, jm.getMember())) {
return false;
}
}
return true;
}
/* private boolean noIntersect(Workgroup w1, Workgroup w2) {
for (JobMapping jm1 : w1.getMembers()) {
for (JobMapping jm2 : w2.getMembers()) {
if (jm1.equals(jm2)) {
return false;
}
}
}
return true;
}
private boolean checkIntersect() {
return true;
}*/
}

@ -0,0 +1,21 @@
package info.bukova.isspst.ui;
import info.bukova.isspst.StringUtils;
import org.zkoss.bind.BindContext;
import org.zkoss.bind.Converter;
import org.zkoss.zk.ui.Component;
public class BoolConverter implements Converter<String, Boolean, Component> {
@Override
public Boolean coerceToBean(String str, Component component, BindContext cx) {
return false;
}
@Override
public String coerceToUi(Boolean val, Component component, BindContext cx) {
return StringUtils.localize(val.toString());
}
}

@ -35,16 +35,23 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
public void init() {
users = new ArrayList<Member>();
users.addAll(userService.getAll());
List<Workgroup> wg = workgroupService.getWorkgroups();
}
public List<Member> getUsers() {
if (getDataBean().isCentre()) {
List<Member> listWithWg = new ArrayList<Member>(users);
for (Workgroup w : wg) {
if (!workgroupService.isMember(getDataBean(), w)) {
users.add(w);
List<Workgroup> wg = workgroupService.getWorkgroups();
for (Workgroup w : wg) {
if (!workgroupService.isMember(getDataBean(), w)) {
listWithWg.add(w);
}
}
return listWithWg;
}
}
public List<Member> getUsers() {
return users;
}
@ -56,7 +63,7 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
}
}
@NotifyChange({"workgroupRoles", "centre"})
@NotifyChange({"workgroupRoles", "centre", "users"})
public void setCentre(boolean centre) {
getDataBean().setCentre(centre);
}
@ -106,7 +113,7 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
if (!target.equals("users")) {
moveUser(u.getMember(), event);
} else if (!u.getMember().isHasJob()) {
} else if (!u.getMember().isPerson()) {
users.add(u.getMember());
}
}
@ -121,7 +128,7 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
workgroupService.addMember(getDataBean(), u, roleService.getRoleByAuthority(target));
if (!u.isHasJob()) {
if (!u.isPerson()) {
users.remove(u);
}
}

@ -1,5 +1,7 @@
package info.bukova.isspst.ui.workgroups;
import org.zkoss.bind.annotation.Command;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.WireVariable;
@ -8,7 +10,9 @@ import org.zkoss.zul.TreeNode;
import info.bukova.isspst.data.Member;
import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.filters.WorkgroupFilter;
import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.BoolConverter;
import info.bukova.isspst.ui.ListViewModel;
public class WorkgroupList extends ListViewModel<Workgroup> {
@ -16,13 +20,16 @@ public class WorkgroupList extends ListViewModel<Workgroup> {
@WireVariable
private WorkgroupService workgroupService;
private WorkgroupTreeFactory treeFactory;
private BoolConverter boolConverter;
@Init
public void init() {
service = workgroupService;
dataClass = Workgroup.class;
formZul = "workgroupForm.zul";
dataFilter = new WorkgroupFilter(getFilterTemplate());
treeFactory = new WorkgroupTreeFactory();
boolConverter = new BoolConverter();
}
public TreeModel<TreeNode<Member>> getWorkgroupTreeModel() {
@ -38,4 +45,22 @@ public class WorkgroupList extends ListViewModel<Workgroup> {
super.setDataBean(data);
}
@Override
@GlobalCommand
@NotifyChange({ "dataList", "dataBean", "workgroupTreeModel" })
public void refresh() {
super.refresh();
}
@Override
@Command
@NotifyChange({ "filter", "dataList", "dataBean", "workgroupTreeModel" })
public void filter() {
super.filter();
}
public BoolConverter getBoolConverter() {
return boolConverter;
}
}

@ -25,7 +25,7 @@ public class WorkgroupTreeFactory {
Workgroup workgroup = Workgroup.class.cast(member);
for (JobMapping jm : workgroup.getMembers()) {
if (jm.getRole().getAuthority().equals(Constants.ROLE_USER) && jm.getMember().isHasJob()) {
if (jm.getRole().getAuthority().equals(Constants.ROLE_USER) && jm.getMember().isPerson()) {
children.add(new WorkgroupTreeNode(jm.getMember()));
} else if (jm.getRole().getAuthority().equals(Constants.ROLE_USER)) {
children.add(new WorkgroupTreeNode(jm.getMember(), generateChildren(jm.getMember())));

@ -36,3 +36,7 @@ lastName=Příjmení
notify=Posílat oznámení
personalNumber=Osobní číslo
username=Uživatelské jméno
#Skupiny
centre=Středisko
members=Členové

@ -87,7 +87,7 @@ UsersGridColumnSureName=Příjmení
AgendaMaterial=Materiál
MaterialFormTitle=Materiál
AgendaWorkgroups=Pracovní skupiny
AgendaWorkgroups=Střediska / komise
WorkgroupFormTitle=Pracvní skupina
ButtonStorno=Storno
@ -121,3 +121,6 @@ DbCannotDelete=Chyba při mazání záznamu: Záznam nelze smazat protože na n
DbSaveError=Chyba při ukládání záznamu
DbValidationError=Chyba validace
true=Ano
false=Ne

@ -1,4 +1,4 @@
<?page title="${labels.AgendaCommissions}" contentType="text/html;charset=UTF-8"?>
<?page title="${labels.AgendaWorkgroups}" contentType="text/html;charset=UTF-8"?>
<zk>
<zscript>

@ -24,26 +24,56 @@
</row>
<row>
<cell>
<checkbox label="Středisko" checked="@bind(vm.centre)"/>
<checkbox label="Středisko" checked="@bind(vm.centre)" disabled="@load(not empty vm.dataBean.created)"/>
</cell>
</row>
</rows>
</grid>
<label value="Přetáhněte myší:"/>
<hlayout>
<listbox id="users" model="@bind(vm.users)" height="280px" width="200px" multiple="true"
<listbox id="users" model="@bind(vm.users)" height="380px" width="300px" multiple="true"
droppable="true" onDrop="@command('addMember', event=event)">
<listhead>
<listheader label="Uživatelé" sort="czech(fullName)"/>
</listhead>
<template name="model">
<listitem image="@load(each.hasJob ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.fullName)" draggable="user" droppable="user"
<listitem image="@load(each.person ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.fullName)" draggable="user" droppable="user"
onDrop="@command('addMember', event=event)" attributes.item="@load(each)"/>
</template>
</listbox>
<tabbox mold="accordion" width="300px">
<tabs children="@load(vm.workgroupRoles)">
<template name="children">
<tab label="@load(each.description)" />
</template>
</tabs>
<tabpanels children="@load(vm.workgroupRoles)">
<template name="children">
<tabpanel>
<listbox id="@load(each.authority)"
model="@bind(vm.dataBean.members)" height="200px" width="290px"
multiple="true" droppable="true"
onDrop="@command('addMember', event=event)">
<!-- <listhead>
<listheader label="@load(each.description)" sort="czech(fullName)"/>
</listhead> -->
<template name="model" var="member">
<listitem
image="@load(member.member.person ? '/img/user-small.png' : '/img/commission-small.png')"
label="@load(member.member.fullName)" draggable="user"
droppable="user" onDrop="@command('addMember', event=event)"
attributes.item="@load(member)"
visible="@load(member.role.authority eq each.authority)" />
</template>
</listbox>
</tabpanel>
</template>
</tabpanels>
</tabbox>
<!--
<vlayout children="@load(vm.workgroupRoles)">
<template name="children">
<listbox id="@load(each.authority)" model="@bind(vm.dataBean.members)" height="120px" width="200px" multiple="true"
@ -52,14 +82,14 @@
<listheader label="@load(each.description)" sort="czech(fullName)"/>
</listhead>
<template name="model" var="member">
<listitem image="@load(member.member.hasJob ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(member.member.fullName)" draggable="user" droppable="user"
<listitem image="@load(member.member.person ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(member.member.fullName)" draggable="user" droppable="user"
onDrop="@command('addMember', event=event)" attributes.item="@load(member)" visible="@load(member.role.authority eq each.authority)"/>
</template>
</listbox>
</template>
</vlayout>
-->
</hlayout>
<include src="/app/formButtons.zul" />
</vlayout>

@ -12,8 +12,9 @@
<listhead menupopup="auto">
<listheader label="${labels.code}" sort="czech(code)" width="10%" />
<listheader label="${labels.name}" sort="czech(name)" width="30%" />
<listheader label="${labels.centre}" width="8%"/>
</listhead>
<!--
<auxhead sclass="category-center" visible="@load(vm.filter)">
<auxheader>
<div sclass="find-grid-cell">
@ -38,7 +39,7 @@
<auxheader>
<div sclass="find-grid-cell">
<div sclass="find-grid-divtextbox">
<textbox value="@bind(vm.filterTemplate.description)" instant="true" onChange="@command('doFilter')" sclass="find-grid-textbox" />
<checkbox label="${labels.centre}" checked="@bind(vm.filterTemplate.centre)" onClick="@command('doFilter')"/>
</div>
<div sclass="find-grid-img">
<image src="/img/funnel.png" />
@ -46,16 +47,17 @@
</div>
</auxheader>
</auxhead>
-->
<template name="model">
<listitem>
<listcell label="@load(each.code)" />
<listcell label="@load(each.name)" />
<listcell label="@load(each.centre) @converter(vm.boolConverter)"/>
</listitem>
</template>
</listbox>
<groupbox>
<groupbox mold="3d" closable="false">
<caption label="členové"/>
<tree hflex="1" model="@load(vm.workgroupTreeModel)">
<treecols>
@ -64,47 +66,13 @@
<template name="model">
<treeitem>
<treerow>
<treecell image="@load(each.data.hasJob ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.data.fullName)"/>
<treecell image="@load(each.data.person ? '/img/user-small.png' : '/img/commission-small.png')" label="@load(each.data.fullName)"/>
</treerow>
</treeitem>
</template>
</tree>
</groupbox>
<!-- <panel hflex="1" width="70%" height="480px">
<panelchildren>
<grid model="@load(vm.dataBean.approvers)" height="90px">
<columns>
<column label="Vedoucí" sort="auto(fullName)"/>
</columns>
<rows>
<template name="model">
<row>
<cell>
<image src="/img/user-small-red.png"/><label value="@load(each.fullName)"/>
</cell>
</row>
</template>
</rows>
</grid>
<grid model="@load(vm.dataBean.members)" height="290px">
<columns>
<column label="Členové" sort="auto(fullName)"/>
</columns>
<rows>
<template name="model">
<row>
<cell>
<image src="/img/user-small.png"/><label value="@load(each.fullName)"/>
</cell>
</row>
</template>
</rows>
</grid>
</panelchildren>
</panel> -->
</hbox>
</window>
</zk>
Loading…
Cancel
Save