Add link from worker edition to user edition if the worker is bound to a user

Using entry points to do the redirection.

FEA: ItEr76S27ResourceBinding
This commit is contained in:
Manuel Rego Casasnovas 2012-05-09 08:19:39 +02:00
parent 372f4d1650
commit c607ba4584
3 changed files with 35 additions and 5 deletions

View file

@ -29,6 +29,8 @@ import java.util.EnumSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.lang.StringUtils;
import org.joda.time.LocalDate;
import org.libreplan.business.calendars.entities.BaseCalendar;
@ -55,6 +57,7 @@ import org.libreplan.web.common.entrypoints.EntryPointsHandler;
import org.libreplan.web.common.entrypoints.IURLHandlerRegistry;
import org.libreplan.web.costcategories.ResourcesCostCategoryAssignmentController;
import org.libreplan.web.resources.search.ResourcePredicate;
import org.libreplan.web.users.IUserCRUDController;
import org.libreplan.web.users.services.IDBPasswordEncoderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.zkoss.zk.ui.Component;
@ -100,6 +103,9 @@ public class WorkerCRUDController extends GenericForwardComposer implements
@Autowired
private IDBPasswordEncoderService dbPasswordEncoderService;
@Resource
private IUserCRUDController userCRUD;
private Window listWindow;
private Window editWindow;
@ -1092,4 +1098,24 @@ public class WorkerCRUDController extends GenericForwardComposer implements
return false;
}
public void goToUserEdition() {
User user = getWorker().getUser();
if (user != null) {
if (showConfirmUserEditionDialog() == Messagebox.OK) {
userCRUD.goToEditForm(user);
}
}
}
private int showConfirmUserEditionDialog() {
try {
return Messagebox
.show(_("Unsaved changes will be lost. Would you like to continue?"),
_("Confirm user edition"), Messagebox.OK
| Messagebox.CANCEL, Messagebox.QUESTION);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -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
@ -53,6 +53,7 @@ import org.zkoss.zul.Textbox;
* Controller for CRUD actions over a {@link User}
*
* @author Jacobo Aragunde Perez <jaragunde@igalia.com>
* @author Manuel Rego Casasnovas <rego@igalia.com>
*/
@SuppressWarnings("serial")
public class UserCRUDController extends BaseCRUDController<User> implements
@ -76,15 +77,15 @@ public class UserCRUDController extends BaseCRUDController<User> implements
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
final EntryPointsHandler<IUserCRUDController> handler = URLHandlerRegistry
.getRedirectorFor(IUserCRUDController.class);
handler.register(this, page);
passwordBox = (Textbox) editWindow.getFellowIfAny("password");
passwordConfirmationBox = (Textbox) editWindow.getFellowIfAny("passwordConfirmation");
profileAutocomplete = (Autocomplete) editWindow.getFellowIfAny("profileAutocomplete");
userRolesCombo = (Combobox) editWindow.getFellowIfAny("userRolesCombo");
appendAllUserRoles(userRolesCombo);
final EntryPointsHandler<IUserCRUDController> handler = URLHandlerRegistry
.getRedirectorFor(IUserCRUDController.class);
handler.register(this, page);
}
/**

View file

@ -122,6 +122,9 @@
</row>
</rows>
</grid>
<button label="${i18n:_('Go to user edition window')}"
onClick="controller.goToUserEdition();"
visible="@{controller.userSelected}" />
</panelchildren>
</panel>
<panel title="${i18n:_('New user')}" border="normal"