|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package info.bukova.isspst.ui.workgroups;
|
|
|
|
|
|
|
|
|
|
import info.bukova.isspst.Constants;
|
|
|
|
|
import info.bukova.isspst.StringUtils;
|
|
|
|
|
import info.bukova.isspst.data.JobMapping;
|
|
|
|
|
import info.bukova.isspst.data.Member;
|
|
|
|
|
import info.bukova.isspst.data.Role;
|
|
|
|
@ -8,6 +9,7 @@ import info.bukova.isspst.data.User;
|
|
|
|
|
import info.bukova.isspst.data.Workgroup;
|
|
|
|
|
import info.bukova.isspst.services.users.RoleService;
|
|
|
|
|
import info.bukova.isspst.services.users.UserService;
|
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupException;
|
|
|
|
|
import info.bukova.isspst.services.workgroups.WorkgroupService;
|
|
|
|
|
import info.bukova.isspst.ui.FormViewModel;
|
|
|
|
|
|
|
|
|
@ -22,6 +24,10 @@ import org.zkoss.bind.annotation.NotifyChange;
|
|
|
|
|
import org.zkoss.zk.ui.event.DropEvent;
|
|
|
|
|
import org.zkoss.zk.ui.select.annotation.WireVariable;
|
|
|
|
|
import org.zkoss.zul.Listitem;
|
|
|
|
|
import org.zkoss.zul.Messagebox;
|
|
|
|
|
|
|
|
|
|
import static ch.lambdaj.Lambda.*;
|
|
|
|
|
import static org.hamcrest.Matchers.*;
|
|
|
|
|
|
|
|
|
|
public class WorkgroupForm extends FormViewModel<Workgroup> {
|
|
|
|
|
|
|
|
|
@ -32,11 +38,14 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
|
|
|
|
|
@WireVariable
|
|
|
|
|
private WorkgroupService workgroupService;
|
|
|
|
|
private List<Member> users;
|
|
|
|
|
private String findUser;
|
|
|
|
|
private List<Member> selectedUsers;
|
|
|
|
|
|
|
|
|
|
@Init(superclass = true)
|
|
|
|
|
public void init() {
|
|
|
|
|
users = new ArrayList<Member>();
|
|
|
|
|
users.addAll(userService.getAll());
|
|
|
|
|
selectedUsers = new ArrayList<Member>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Member> getUsers() {
|
|
|
|
@ -147,13 +156,31 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
|
|
|
|
|
|
|
|
|
|
if (!u.isPerson()) {
|
|
|
|
|
workgroupService.loadMembers((Workgroup) u);
|
|
|
|
|
} else if (!getDataBean().isCentre()) {
|
|
|
|
|
workgroupService.loadParentsMembers(getDataBean());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
workgroupService.addMember(getDataBean(), u, roleService.getRoleByAuthority(target));
|
|
|
|
|
|
|
|
|
|
if (!u.isPerson()) {
|
|
|
|
|
users.remove(u);
|
|
|
|
|
try {
|
|
|
|
|
workgroupService.addMember(getDataBean(), u, roleService.getRoleByAuthority(target));
|
|
|
|
|
|
|
|
|
|
if (!u.isPerson()) {
|
|
|
|
|
users.remove(u);
|
|
|
|
|
}
|
|
|
|
|
} catch (WorkgroupException e) {
|
|
|
|
|
String message;
|
|
|
|
|
String title;
|
|
|
|
|
|
|
|
|
|
if (!getDataBean().isCentre()) {
|
|
|
|
|
message = StringUtils.localize("WorkgroupFormUserIsCenterMember");
|
|
|
|
|
title = StringUtils.localize("WorkgroupFormCannotAddUser");
|
|
|
|
|
} else {
|
|
|
|
|
message = StringUtils.localize("WorkgroupFormMemberIsCenterMember");
|
|
|
|
|
title = StringUtils.localize("WorkgroupFormCannotAddWorkgroup");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Messagebox.show(message, title, Messagebox.OK, Messagebox.ERROR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getSource(DropEvent event) {
|
|
|
|
@ -171,5 +198,36 @@ public class WorkgroupForm extends FormViewModel<Workgroup> {
|
|
|
|
|
|
|
|
|
|
return target;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFindUser() {
|
|
|
|
|
return findUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setFindUser(String findUser) {
|
|
|
|
|
this.findUser = findUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Member> getSelectedUsers() {
|
|
|
|
|
return selectedUsers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setSelectedUsers(List<Member> selectedUser) {
|
|
|
|
|
this.selectedUsers = selectedUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Command
|
|
|
|
|
@NotifyChange("selectedUsers")
|
|
|
|
|
public void find() {
|
|
|
|
|
List<Member> found = filter(having(on(Member.class).getFullName(), startsWith(findUser)), users);
|
|
|
|
|
|
|
|
|
|
if (!found.isEmpty()) {
|
|
|
|
|
if (selectedUsers == null) {
|
|
|
|
|
selectedUsers = new ArrayList<Member>();
|
|
|
|
|
} else {
|
|
|
|
|
selectedUsers.clear();
|
|
|
|
|
selectedUsers.add(found.get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|