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

Using entry points to do the redirection.

FEA: ItEr76S27ResourceBinding
This commit is contained in:
Manuel Rego Casasnovas 2012-05-09 11:20:00 +02:00
parent cfb85fe2b1
commit a751b266b4
4 changed files with 42 additions and 8 deletions

View file

@ -137,11 +137,13 @@ public class CriterionsController extends GenericForwardComposer {
public void forceSortGridSatisfaction() {
Column column = (Column) listingCriterions.getColumns().getFirstChild();
ListModelExt model = (ListModelExt) listingCriterions.getModel();
if ("ascending".equals(column.getSortDirection())) {
model.sort(column.getSortAscending(), true);
}
if ("descending".equals(column.getSortDirection())) {
model.sort(column.getSortDescending(), false);
if (model != null) {
if ("ascending".equals(column.getSortDirection())) {
model.sort(column.getSortAscending(), true);
}
if ("descending".equals(column.getSortDirection())) {
model.sort(column.getSortDescending(), false);
}
}
}

View file

@ -457,14 +457,15 @@ public class WorkerCRUDController extends GenericForwardComposer implements
messages = new MessagesForUser(messagesContainer);
setupResourcesCostCategoryAssignmentController(comp);
final EntryPointsHandler<IWorkerCRUDControllerEntryPoints> handler = URLHandlerRegistry
.getRedirectorFor(IWorkerCRUDControllerEntryPoints.class);
handler.register(this, page);
getVisibility().showOnly(listWindow);
initFilterComponent();
setupFilterLimitingResourceListbox();
initializeTabs();
initUserBindingComponents();
final EntryPointsHandler<IWorkerCRUDControllerEntryPoints> handler = URLHandlerRegistry
.getRedirectorFor(IWorkerCRUDControllerEntryPoints.class);
handler.register(this, page);
}
private void initUserBindingComponents() {

View file

@ -25,9 +25,12 @@ import static org.libreplan.web.I18nHelper._;
import java.util.List;
import javax.annotation.Resource;
import org.apache.commons.logging.LogFactory;
import org.libreplan.business.common.exceptions.InstanceNotFoundException;
import org.libreplan.business.common.exceptions.ValidationException;
import org.libreplan.business.resources.entities.Worker;
import org.libreplan.business.users.entities.Profile;
import org.libreplan.business.users.entities.User;
import org.libreplan.business.users.entities.UserRole;
@ -36,6 +39,7 @@ import org.libreplan.web.common.Util;
import org.libreplan.web.common.components.Autocomplete;
import org.libreplan.web.common.entrypoints.EntryPointsHandler;
import org.libreplan.web.common.entrypoints.IURLHandlerRegistry;
import org.libreplan.web.resources.worker.IWorkerCRUDControllerEntryPoints;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
@ -45,6 +49,7 @@ import org.zkoss.zul.Combobox;
import org.zkoss.zul.Comboitem;
import org.zkoss.zul.Constraint;
import org.zkoss.zul.Label;
import org.zkoss.zul.Messagebox;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.Textbox;
@ -61,6 +66,9 @@ public class UserCRUDController extends BaseCRUDController<User> implements
private static final org.apache.commons.logging.Log LOG = LogFactory.getLog(UserCRUDController.class);
@Resource
private IWorkerCRUDControllerEntryPoints workerCRUD;
private IUserModel userModel;
private Textbox passwordBox;
@ -331,4 +339,24 @@ public class UserCRUDController extends BaseCRUDController<User> implements
return false;
}
public void goToWorkerEdition() {
Worker worker = getUser().getWorker();
if (worker != null) {
if (showConfirmWorkerEditionDialog() == Messagebox.OK) {
workerCRUD.goToEditForm(worker);
}
}
}
private int showConfirmWorkerEditionDialog() {
try {
return Messagebox
.show(_("Unsaved changes will be lost. Would you like to continue?"),
_("Confirm worker edition"), Messagebox.OK
| Messagebox.CANCEL, Messagebox.QUESTION);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}

View file

@ -111,6 +111,9 @@
</row>
</rows>
</grid>
<button label="${i18n:_('Go to worker edition window')}"
onClick="controller.goToWorkerEdition();"
visible="@{controller.bound}" />
</groupbox>
<!-- Associated UserRoles -->