Add option to unbound resource from user edition
FEA: ItEr76S27ResourceBinding
This commit is contained in:
parent
9d7b1754b4
commit
cc92ce809d
4 changed files with 33 additions and 2 deletions
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* Copyright (C) 2009-2010 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
* Copyright (C) 2010-2011 Igalia, S.L.
|
||||
* Copyright (C) 2010-2012 Igalia, S.L.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
|
|
@ -33,6 +33,7 @@ import org.libreplan.business.users.entities.UserRole;
|
|||
* Model for UI operations related to {@link User}
|
||||
*
|
||||
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
|
||||
* @author Manuel Rego Casasnovas <rego@igalia.com>
|
||||
*/
|
||||
public interface IUserModel {
|
||||
|
||||
|
|
@ -129,4 +130,6 @@ public interface IUserModel {
|
|||
|
||||
boolean isLDAPRolesBeingUsed();
|
||||
|
||||
void unboundResource();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ import org.zkoss.zul.Messagebox;
|
|||
import org.zkoss.zul.Row;
|
||||
import org.zkoss.zul.RowRenderer;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.api.Groupbox;
|
||||
|
||||
/**
|
||||
* Controller for CRUD actions over a {@link User}
|
||||
|
|
@ -77,6 +78,8 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
|
||||
private Combobox userRolesCombo;
|
||||
|
||||
private Groupbox boundResourceGroupbox;
|
||||
|
||||
private Autocomplete profileAutocomplete;
|
||||
|
||||
private IURLHandlerRegistry URLHandlerRegistry;
|
||||
|
|
@ -118,6 +121,8 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
profileAutocomplete = (Autocomplete) editWindow.getFellowIfAny("profileAutocomplete");
|
||||
userRolesCombo = (Combobox) editWindow.getFellowIfAny("userRolesCombo");
|
||||
appendAllUserRoles(userRolesCombo);
|
||||
boundResourceGroupbox = (Groupbox) editWindow
|
||||
.getFellowIfAny("boundResourceGroupbox");
|
||||
|
||||
final EntryPointsHandler<IUserCRUDController> handler = URLHandlerRegistry
|
||||
.getRedirectorFor(IUserCRUDController.class);
|
||||
|
|
@ -376,4 +381,9 @@ public class UserCRUDController extends BaseCRUDController<User> implements
|
|||
}
|
||||
}
|
||||
|
||||
public void unboundResource() {
|
||||
userModel.unboundResource();
|
||||
Util.reloadBindings(boundResourceGroupbox);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,6 +71,8 @@ public class UserModel implements IUserModel {
|
|||
|
||||
private String clearNewPassword;
|
||||
|
||||
private Worker unboundWorker;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<User> getUsers() {
|
||||
|
|
@ -116,6 +118,11 @@ public class UserModel implements IUserModel {
|
|||
|
||||
user.validate();
|
||||
userDAO.save(user);
|
||||
|
||||
if (unboundWorker != null) {
|
||||
unboundWorker.setUser(null);
|
||||
workerDAO.save(unboundWorker);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -126,6 +133,7 @@ public class UserModel implements IUserModel {
|
|||
@Override
|
||||
public void initCreate() {
|
||||
this.user = User.create();
|
||||
this.unboundWorker = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -134,6 +142,7 @@ public class UserModel implements IUserModel {
|
|||
Validate.notNull(user);
|
||||
this.user = getFromDB(user);
|
||||
this.setClearNewPassword(null);
|
||||
this.unboundWorker = null;
|
||||
}
|
||||
|
||||
@Transactional(readOnly = true)
|
||||
|
|
@ -250,4 +259,10 @@ public class UserModel implements IUserModel {
|
|||
.getLdapSaveRolesDB();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unboundResource() {
|
||||
unboundWorker = user.getWorker();
|
||||
user.setWorker(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
</grid>
|
||||
</groupbox>
|
||||
|
||||
<groupbox closable="false">
|
||||
<groupbox closable="false" id="boundResourceGroupbox">
|
||||
<caption label="${i18n:_('Bound resource')}" />
|
||||
<grid fixedLayout="false" span="true">
|
||||
<columns>
|
||||
|
|
@ -114,6 +114,9 @@
|
|||
<button label="${i18n:_('Go to worker edition window')}"
|
||||
onClick="controller.goToWorkerEdition();"
|
||||
visible="@{controller.bound}" />
|
||||
<button label="${i18n:_('Unbound resource')}"
|
||||
onClick="controller.unboundResource();"
|
||||
visible="@{controller.bound}" />
|
||||
</groupbox>
|
||||
|
||||
<!-- Associated UserRoles -->
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue