Zobrazovaní středisek a pracovních skupin ve stromové struktuře.

refs #97
multitenant
Josef Rokos 11 years ago
parent 6dcc93ee83
commit 9935a77bfb

@ -1,8 +1,12 @@
package info.bukova.isspst.ui.workgroups; package info.bukova.isspst.ui.workgroups;
import org.zkoss.bind.annotation.Init; import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zk.ui.select.annotation.WireVariable;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.TreeNode;
import info.bukova.isspst.data.Member;
import info.bukova.isspst.data.Workgroup; import info.bukova.isspst.data.Workgroup;
import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.services.workgroups.WorkgroupService;
import info.bukova.isspst.ui.ListViewModel; import info.bukova.isspst.ui.ListViewModel;
@ -11,12 +15,27 @@ public class WorkgroupList extends ListViewModel<Workgroup> {
@WireVariable @WireVariable
private WorkgroupService workgroupService; private WorkgroupService workgroupService;
private WorkgroupTreeFactory treeFactory;
@Init @Init
public void init() { public void init() {
service = workgroupService; service = workgroupService;
dataClass = Workgroup.class; dataClass = Workgroup.class;
formZul = "workgroupForm.zul"; formZul = "workgroupForm.zul";
treeFactory = new WorkgroupTreeFactory();
}
public TreeModel<TreeNode<Member>> getWorkgroupTreeModel() {
if (getDataBean() != null) {
return treeFactory.createTreeModel(getDataBean());
}
return null;
}
@NotifyChange({"dataBean", "workgroupTreeModel"})
public void setDataBean(Workgroup data) {
super.setDataBean(data);
} }
} }

@ -0,0 +1,38 @@
package info.bukova.isspst.ui.workgroups;
import java.util.Collection;
import java.util.LinkedList;
import info.bukova.isspst.Constants;
import info.bukova.isspst.data.JobMapping;
import info.bukova.isspst.data.Member;
import info.bukova.isspst.data.Workgroup;
import org.zkoss.zul.DefaultTreeModel;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.TreeNode;
public class WorkgroupTreeFactory {
public TreeModel<TreeNode<Member>> createTreeModel(Workgroup workgroup) {
WorkgroupTreeNode root = new WorkgroupTreeNode(null, generateChildren(workgroup));
return new DefaultTreeModel<Member>(root);
}
private Collection<WorkgroupTreeNode> generateChildren(Member member) {
Collection<WorkgroupTreeNode> children = new LinkedList<WorkgroupTreeNode>();
Workgroup workgroup = Workgroup.class.cast(member);
for (JobMapping jm : workgroup.getMembers()) {
if (jm.getRole().getAuthority().equals(Constants.ROLE_USER) && jm.getMember().isHasJob()) {
children.add(new WorkgroupTreeNode(jm.getMember()));
} else if (jm.getRole().getAuthority().equals(Constants.ROLE_USER)) {
children.add(new WorkgroupTreeNode(jm.getMember(), generateChildren(jm.getMember())));
}
}
return children;
}
}

@ -0,0 +1,25 @@
package info.bukova.isspst.ui.workgroups;
import info.bukova.isspst.data.Member;
import java.util.Collection;
import org.zkoss.zul.DefaultTreeNode;
public class WorkgroupTreeNode extends DefaultTreeNode<Member> {
/**
*
*/
private static final long serialVersionUID = 465182942358883559L;
public WorkgroupTreeNode(Member data,
Collection<WorkgroupTreeNode> children) {
super(data, children);
}
public WorkgroupTreeNode(Member data) {
super(data);
}
}

@ -55,6 +55,22 @@
</template> </template>
</listbox> </listbox>
<groupbox>
<caption label="členové"/>
<tree hflex="1" model="@load(vm.workgroupTreeModel)">
<treecols>
<treecol/>
</treecols>
<template name="model">
<treeitem>
<treerow>
<treecell image="@load(each.data.hasJob ? '/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"> <!-- <panel hflex="1" width="70%" height="480px">
<panelchildren> <panelchildren>
<grid model="@load(vm.dataBean.approvers)" height="90px"> <grid model="@load(vm.dataBean.approvers)" height="90px">

Loading…
Cancel
Save