From c607ba4584ad2c9ee0853d3f3a7a64389dd6ac53 Mon Sep 17 00:00:00 2001 From: Manuel Rego Casasnovas Date: Wed, 9 May 2012 08:19:39 +0200 Subject: [PATCH] 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 --- .../worker/WorkerCRUDController.java | 26 +++++++++++++++++++ .../web/users/UserCRUDController.java | 11 ++++---- .../main/webapp/resources/worker/_edition.zul | 3 +++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java index 8d27d58c1..59898d478 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/resources/worker/WorkerCRUDController.java @@ -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); + } + } + } diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java index 53cfc1a42..017c4b211 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/users/UserCRUDController.java @@ -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 + * @author Manuel Rego Casasnovas */ @SuppressWarnings("serial") public class UserCRUDController extends BaseCRUDController implements @@ -76,15 +77,15 @@ public class UserCRUDController extends BaseCRUDController implements public void doAfterCompose(Component comp) throws Exception { super.doAfterCompose(comp); - final EntryPointsHandler 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 handler = URLHandlerRegistry + .getRedirectorFor(IUserCRUDController.class); + handler.register(this, page); } /** diff --git a/libreplan-webapp/src/main/webapp/resources/worker/_edition.zul b/libreplan-webapp/src/main/webapp/resources/worker/_edition.zul index ca5a57953..5f62c6eb2 100644 --- a/libreplan-webapp/src/main/webapp/resources/worker/_edition.zul +++ b/libreplan-webapp/src/main/webapp/resources/worker/_edition.zul @@ -122,6 +122,9 @@ +