diff --git a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java index 8b8a491f..054702c5 100644 --- a/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java +++ b/src/main/java/info/bukova/isspst/services/users/UserServiceImpl.java @@ -234,7 +234,7 @@ public class UserServiceImpl extends AbstractService implements UserServic @Override @Transactional public List getUsersForCombo() { - Query q = dao.getQuery("from User u order by u.lastName"); + Query q = dao.getQuery("from User u where u.enabled = true order by u.lastName"); return q.list(); } diff --git a/src/main/java/info/bukova/isspst/ui/mail/MailForm.java b/src/main/java/info/bukova/isspst/ui/mail/MailForm.java index 8d37b12d..3b1a8363 100644 --- a/src/main/java/info/bukova/isspst/ui/mail/MailForm.java +++ b/src/main/java/info/bukova/isspst/ui/mail/MailForm.java @@ -1,9 +1,5 @@ package info.bukova.isspst.ui.mail; -import static ch.lambdaj.Lambda.filter; -import static ch.lambdaj.Lambda.having; -import static ch.lambdaj.Lambda.on; -import static org.hamcrest.Matchers.startsWith; import info.bukova.isspst.data.Address; import info.bukova.isspst.data.Member; import info.bukova.isspst.data.User; @@ -15,10 +11,6 @@ import info.bukova.isspst.reporting.ReportDefinition; import info.bukova.isspst.services.addressbook.AdbService; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.ui.DocumentViewModel; - -import java.util.ArrayList; -import java.util.List; - import org.springframework.security.access.AccessDeniedException; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; @@ -28,6 +20,14 @@ import org.zkoss.bind.annotation.NotifyChange; import org.zkoss.zk.ui.select.annotation.WireVariable; import org.zkoss.zul.Window; +import java.util.ArrayList; +import java.util.List; + +import static ch.lambdaj.Lambda.filter; +import static ch.lambdaj.Lambda.having; +import static ch.lambdaj.Lambda.on; +import static org.hamcrest.Matchers.startsWith; + public class MailForm extends DocumentViewModel { @@ -69,7 +69,7 @@ public class MailForm extends DocumentViewModel addressbook = new ArrayList
(); } - users = userService.getAll(); + users = userService.getUsersForCombo(); selectedAddresses = new ArrayList
(); selectedUsers = new ArrayList(); diff --git a/src/main/java/info/bukova/isspst/ui/renderers/JobMappingItemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/JobMappingItemRenderer.java new file mode 100644 index 00000000..3ed15e35 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/renderers/JobMappingItemRenderer.java @@ -0,0 +1,22 @@ +package info.bukova.isspst.ui.renderers; + +import info.bukova.isspst.data.JobMapping; +import info.bukova.isspst.data.User; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listitem; + +/** + * @author Pepa Rokos + */ +public class JobMappingItemRenderer extends GenericListitemRenderer { + + + @Override + protected void changeProperties(Listbox lb, Listitem li, int index, String varnm) { + JobMapping jm = getObjectOfStates(); + + if (jm.getMember() instanceof User && !((User)jm.getMember()).isEnabled()) { + li.setSclass("user-disabled"); + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/renderers/UserItemRenderer.java b/src/main/java/info/bukova/isspst/ui/renderers/UserItemRenderer.java new file mode 100644 index 00000000..85dc52e0 --- /dev/null +++ b/src/main/java/info/bukova/isspst/ui/renderers/UserItemRenderer.java @@ -0,0 +1,20 @@ +package info.bukova.isspst.ui.renderers; + +import info.bukova.isspst.data.User; +import org.zkoss.zul.Listbox; +import org.zkoss.zul.Listitem; + +/** + * @author Pepa Rokos + */ +public class UserItemRenderer extends GenericListitemRenderer { + + @Override + protected void changeProperties(Listbox lb, Listitem li, int index, String varnm) { + User u = getObjectOfStates(); + + if (!u.isEnabled()) { + li.setSclass("user-disabled"); + } + } +} diff --git a/src/main/java/info/bukova/isspst/ui/users/UsersList.java b/src/main/java/info/bukova/isspst/ui/users/UsersList.java index ac42f6f8..e07d30f1 100644 --- a/src/main/java/info/bukova/isspst/ui/users/UsersList.java +++ b/src/main/java/info/bukova/isspst/ui/users/UsersList.java @@ -9,19 +9,20 @@ import info.bukova.isspst.data.User; import info.bukova.isspst.filters.UserFilter; import info.bukova.isspst.services.users.UserService; import info.bukova.isspst.ui.ListViewModel; - -import java.util.ArrayList; -import java.util.List; - +import info.bukova.isspst.ui.renderers.UserItemRenderer; 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; +import java.util.ArrayList; +import java.util.List; + public class UsersList extends ListViewModel { @WireVariable private UserService userService; + private UserItemRenderer itemRenderer; @Init public void init() { @@ -29,6 +30,7 @@ public class UsersList extends ListViewModel { dataClass = User.class; formZul = "userForm.zul"; dataFilter = new UserFilter(getFilterTemplate()); + itemRenderer = new UserItemRenderer(); } public List getModules() { @@ -88,5 +90,7 @@ public class UsersList extends ListViewModel { return true; } - + public UserItemRenderer getItemRenderer() { + return itemRenderer; + } } diff --git a/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupForm.java b/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupForm.java index 017a1b41..505b6934 100644 --- a/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupForm.java +++ b/src/main/java/info/bukova/isspst/ui/workgroups/WorkgroupForm.java @@ -13,11 +13,8 @@ import info.bukova.isspst.services.workgroups.WorkgroupException; import info.bukova.isspst.services.workgroups.WorkgroupService; import info.bukova.isspst.ui.BigDecimalConverter; import info.bukova.isspst.ui.FormViewModel; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - +import info.bukova.isspst.ui.renderers.JobMappingItemRenderer; +import info.bukova.isspst.ui.renderers.UserItemRenderer; import org.zkoss.bind.annotation.BindingParam; import org.zkoss.bind.annotation.Command; import org.zkoss.bind.annotation.Init; @@ -27,8 +24,14 @@ 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.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import static ch.lambdaj.Lambda.filter; +import static ch.lambdaj.Lambda.having; +import static ch.lambdaj.Lambda.on; +import static org.hamcrest.Matchers.startsWith; public class WorkgroupForm extends FormViewModel { @@ -42,6 +45,8 @@ public class WorkgroupForm extends FormViewModel { private String findUser; private List selectedUsers; private BigDecimalConverter bdConverter; + private JobMappingItemRenderer itemRenderer; + private UserItemRenderer userItemRenderer; @Init(superclass = true) public void init() { @@ -49,6 +54,8 @@ public class WorkgroupForm extends FormViewModel { users.addAll(userService.getAll()); selectedUsers = new ArrayList(); bdConverter = new BigDecimalConverter(); + itemRenderer = new JobMappingItemRenderer(); + userItemRenderer = new UserItemRenderer(); } public List getUsers() { @@ -238,5 +245,12 @@ public class WorkgroupForm extends FormViewModel { public BigDecimalConverter getBdConverter() { return bdConverter; } - + + public JobMappingItemRenderer getItemRenderer() { + return itemRenderer; + } + + public UserItemRenderer getUserItemRenderer() { + return userItemRenderer; + } } diff --git a/src/main/webapp/admin/users/users.zul b/src/main/webapp/admin/users/users.zul index 09ded000..09b195ba 100644 --- a/src/main/webapp/admin/users/users.zul +++ b/src/main/webapp/admin/users/users.zul @@ -10,7 +10,8 @@ diff --git a/src/main/webapp/admin/workgroups/workgroupForm.zul b/src/main/webapp/admin/workgroups/workgroupForm.zul index 6e63a6a6..bcd98bdf 100644 --- a/src/main/webapp/admin/workgroups/workgroupForm.zul +++ b/src/main/webapp/admin/workgroups/workgroupForm.zul @@ -59,7 +59,8 @@ maxlength="@load(vm.lengthText)" width="300px" /> + droppable="true" onDrop="@command('addMember', event=event)" selectedItems="@bind(vm.selectedUsers)" + itemRenderer="@load(vm.userItemRenderer)"> @@ -82,6 +83,7 @@