ItEr43S18CUMarcarUnidadeTraballoExportableItEr42S25: Merged task properties and subcontract commands in a window with tabs.
This commit is contained in:
parent
a693e1f42b
commit
9877ba1b3f
16 changed files with 456 additions and 242 deletions
|
|
@ -27,7 +27,6 @@ import org.zkoss.zk.ui.Component;
|
|||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Datebox;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.api.Window;
|
||||
|
||||
public class TaskEditFormComposer extends GenericForwardComposer {
|
||||
|
||||
|
|
@ -35,8 +34,6 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
|
||||
}
|
||||
|
||||
private Window window;
|
||||
|
||||
private Task currentTask;
|
||||
private TaskDTO taskDTO;
|
||||
|
||||
|
|
@ -51,17 +48,11 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
}
|
||||
|
||||
public void showEditFormFor(Component openRelativeTo, Task task) {
|
||||
this.currentTask = task;
|
||||
this.taskDTO = toDTO(task);
|
||||
try {
|
||||
window.setMode("modal");
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
updateComponentValuesForTask(taskDTO);
|
||||
}
|
||||
|
||||
|
|
@ -75,11 +66,9 @@ public class TaskEditFormComposer extends GenericForwardComposer {
|
|||
|
||||
public void accept() {
|
||||
copyFromDTO(taskDTO, currentTask);
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
window.setVisible(false);
|
||||
currentTask = null;
|
||||
taskDTO = null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -420,4 +420,8 @@ public class Task extends TaskElement {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isSubcontracted() {
|
||||
return (subcontractedTaskData != null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -354,4 +354,9 @@ public abstract class TaskElement extends BaseEntity {
|
|||
return dayAssignments;
|
||||
}
|
||||
|
||||
public boolean isSubcontracted() {
|
||||
// Just Task could be subcontracted
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.planner.order;
|
||||
|
||||
import org.navalplanner.business.planner.daos.ITaskElementDAO;
|
||||
import org.navalplanner.business.planner.daos.ITaskSourceDAO;
|
||||
import org.navalplanner.business.planner.entities.SubcontractedTaskData;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* Common functions to make needed reattachments for edit a {@link TaskElement}.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
@Component
|
||||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class EditTaskUtilities implements IEditTaskUtilities {
|
||||
|
||||
@Autowired
|
||||
private ITaskSourceDAO taskSourceDAO;
|
||||
|
||||
@Autowired
|
||||
private ITaskElementDAO taskElementDAO;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void reattach(TaskElement taskElement) {
|
||||
if (taskElement.getTaskSource() != null) {
|
||||
taskSourceDAO.reattach(taskElement.getTaskSource());
|
||||
}
|
||||
|
||||
taskElementDAO.reattach(taskElement);
|
||||
if (taskElement instanceof Task) {
|
||||
forceLoadHoursGroup((Task) taskElement);
|
||||
if (taskElement.isSubcontracted()) {
|
||||
forceLoadExternalCompany(((Task) taskElement)
|
||||
.getSubcontractedTaskData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void forceLoadHoursGroup(Task task) {
|
||||
task.getHoursGroup();
|
||||
}
|
||||
|
||||
private void forceLoadExternalCompany(
|
||||
SubcontractedTaskData subcontractedTaskData) {
|
||||
subcontractedTaskData.getExternalCompany().getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.planner.order;
|
||||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
||||
/**
|
||||
* Contract for {@link EditTaskUtilities}.
|
||||
*
|
||||
* @author Manuel Rego Casasnovas <mrego@igalia.com>
|
||||
*/
|
||||
public interface IEditTaskUtilities {
|
||||
|
||||
void reattach(TaskElement taskElement);
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
package org.navalplanner.web.planner.order;
|
||||
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.zkoss.ganttz.extensions.ICommandOnTask;
|
||||
|
||||
/**
|
||||
|
|
@ -30,6 +31,6 @@ import org.zkoss.ganttz.extensions.ICommandOnTask;
|
|||
*/
|
||||
public interface ISubcontractCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void setSubcontractController(SubcontractController subcontractController);
|
||||
void setEditTaskController(EditTaskController editTaskController);
|
||||
|
||||
}
|
||||
|
|
@ -56,6 +56,7 @@ public interface ISubcontractModel {
|
|||
|
||||
Date getEndDate();
|
||||
void setEndDate(Date endDate);
|
||||
void removeSubcontractedTaskData();
|
||||
|
||||
/*
|
||||
* Final conversation steps
|
||||
|
|
|
|||
|
|
@ -80,7 +80,6 @@ import org.navalplanner.web.planner.milestone.IDeleteMilestoneCommand;
|
|||
import org.navalplanner.web.planner.order.ISaveCommand.IAfterSaveListener;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.navalplanner.web.planner.taskedition.ITaskPropertiesCommand;
|
||||
import org.navalplanner.web.planner.taskedition.TaskPropertiesController;
|
||||
import org.navalplanner.web.print.CutyPrint;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
|
|
@ -210,11 +209,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
configuration
|
||||
.addCommandOnTask(buildCalendarAllocationCommand(calendarAllocationController));
|
||||
configuration
|
||||
.addCommandOnTask(buildTaskPropertiesCommand(editTaskController
|
||||
.getTaskPropertiesController()));
|
||||
.addCommandOnTask(buildTaskPropertiesCommand(editTaskController));
|
||||
configuration
|
||||
.addCommandOnTask(buildSubcontractCommand(editTaskController
|
||||
.getSubcontractController()));
|
||||
.addCommandOnTask(buildSubcontractCommand(editTaskController));
|
||||
configuration.setDoubleClickCommand(resourceAllocationCommand);
|
||||
addPrintSupport(configuration, order);
|
||||
Tabbox chartComponent = new Tabbox();
|
||||
|
|
@ -550,10 +547,10 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
|
||||
private ITaskPropertiesCommand buildTaskPropertiesCommand(
|
||||
TaskPropertiesController taskPropertiesController) {
|
||||
EditTaskController editTaskController) {
|
||||
ITaskPropertiesCommand taskPropertiesCommand = getTaskPropertiesCommand();
|
||||
taskPropertiesCommand
|
||||
.setTaskPropertiesController(taskPropertiesController);
|
||||
.setEditTaskController(editTaskController);
|
||||
return taskPropertiesCommand;
|
||||
}
|
||||
|
||||
|
|
@ -1031,9 +1028,9 @@ public abstract class OrderPlanningModel implements IOrderPlanningModel {
|
|||
}
|
||||
|
||||
private ISubcontractCommand buildSubcontractCommand(
|
||||
SubcontractController subcontractController) {
|
||||
EditTaskController editTaskController) {
|
||||
ISubcontractCommand subcontractCommand = getSubcontractCommand();
|
||||
subcontractCommand.setSubcontractController(subcontractController);
|
||||
subcontractCommand.setEditTaskController(editTaskController);
|
||||
return subcontractCommand;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import static org.navalplanner.web.I18nHelper._;
|
|||
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.taskedition.EditTaskController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
@ -39,7 +41,10 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class SubcontractCommand implements ISubcontractCommand {
|
||||
|
||||
private SubcontractController subcontractController;
|
||||
private EditTaskController editTaskController;
|
||||
|
||||
@Autowired
|
||||
private IEditTaskUtilities editTaskUtilities;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
|
@ -60,16 +65,16 @@ public class SubcontractCommand implements ISubcontractCommand {
|
|||
@Transactional(readOnly = true)
|
||||
public void doAction(IContextWithPlannerTask<TaskElement> context,
|
||||
final TaskElement task) {
|
||||
editTaskUtilities.reattach(task);
|
||||
|
||||
if (isApplicableTo(task)) {
|
||||
subcontractController.showWindow(context, (Task) task, context
|
||||
.getTask());
|
||||
editTaskController.showEditFormSubcontract(context, task);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubcontractController(
|
||||
SubcontractController subcontractController) {
|
||||
this.subcontractController = subcontractController;
|
||||
public void setEditTaskController(EditTaskController editTaskController) {
|
||||
this.editTaskController = editTaskController;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,18 +30,15 @@ import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
|||
import org.navalplanner.business.planner.entities.SubcontractedTaskData;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Window;
|
||||
import org.zkoss.zul.api.Tabpanel;
|
||||
|
||||
/**
|
||||
* Controller for subcontract a task.
|
||||
|
|
@ -52,68 +49,50 @@ import org.zkoss.zul.Window;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class SubcontractController extends GenericForwardComposer {
|
||||
|
||||
private Window window;
|
||||
private Tabpanel tabpanel;
|
||||
|
||||
private ISubcontractModel subcontractModel;
|
||||
|
||||
private Component messagesContainer;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private IContextWithPlannerTask<TaskElement> context;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
tabpanel = (Tabpanel) comp;
|
||||
}
|
||||
|
||||
public void showWindow(IContextWithPlannerTask<TaskElement> context,
|
||||
Task task, org.zkoss.ganttz.data.Task ganttTask) {
|
||||
public void showWindow(Task task,
|
||||
IContextWithPlannerTask<TaskElement> context) {
|
||||
this.context = context;
|
||||
|
||||
try {
|
||||
subcontractModel.init(task, ganttTask);
|
||||
Util.reloadBindings(window);
|
||||
window.doModal();
|
||||
} catch (SuspendNotAllowedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
subcontractModel.init(task, context.getTask());
|
||||
Util.reloadBindings(tabpanel);
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
try {
|
||||
int status = Messagebox.YES;
|
||||
if (subcontractModel.hasResourceAllocations()) {
|
||||
try {
|
||||
status = Messagebox
|
||||
.show(
|
||||
_("As you are subcontracting this task, all the resource allocations related with this task will be removed.")
|
||||
+ _("Are you sure?"),
|
||||
_("Confirm"), Messagebox.YES
|
||||
| Messagebox.NO,
|
||||
Messagebox.QUESTION);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
public void accept() throws ValidationException {
|
||||
int status = Messagebox.YES;
|
||||
if (subcontractModel.hasResourceAllocations()) {
|
||||
try {
|
||||
status = Messagebox
|
||||
.show(
|
||||
_("As you are subcontracting this task, all the resource allocations related with this task will be removed.")
|
||||
+ _("Are you sure?"), _("Confirm"),
|
||||
Messagebox.YES | Messagebox.NO,
|
||||
Messagebox.QUESTION);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (status == Messagebox.YES) {
|
||||
subcontractModel.confirm();
|
||||
if (status == Messagebox.YES) {
|
||||
subcontractModel.confirm();
|
||||
if (context != null) {
|
||||
context.reloadCharts();
|
||||
window.setVisible(false);
|
||||
}
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showInvalidValues(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
subcontractModel.cancel();
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
public List<ExternalCompany> getSubcontractorExternalCompanies() {
|
||||
|
|
@ -142,4 +121,8 @@ public class SubcontractController extends GenericForwardComposer {
|
|||
subcontractModel.setEndDate(endDate);
|
||||
}
|
||||
|
||||
public void removeSubcontractedTaskData() {
|
||||
subcontractModel.removeSubcontractedTaskData();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -23,7 +23,6 @@ package org.navalplanner.web.planner.order;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.common.daos.IConfigurationDAO;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.daos.IExternalCompanyDAO;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
|
|
@ -63,9 +62,6 @@ public class SubcontractModel implements ISubcontractModel {
|
|||
@Autowired
|
||||
private ISubcontractedTaskDataDAO subcontractedTaskDataDAO;
|
||||
|
||||
@Autowired
|
||||
private IConfigurationDAO configurationDAO;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void init(Task task, org.zkoss.ganttz.data.Task ganttTask) {
|
||||
|
|
@ -77,8 +73,6 @@ public class SubcontractModel implements ISubcontractModel {
|
|||
|
||||
SubcontractedTaskData subcontractedTaskData = task
|
||||
.getSubcontractedTaskData();
|
||||
forceLoadSubcontractedTaskData(subcontractedTaskData);
|
||||
|
||||
this.currentSubcontractedTaskData = subcontractedTaskData;
|
||||
|
||||
if (subcontractedTaskData == null) {
|
||||
|
|
@ -89,14 +83,6 @@ public class SubcontractModel implements ISubcontractModel {
|
|||
}
|
||||
}
|
||||
|
||||
private void forceLoadSubcontractedTaskData(
|
||||
SubcontractedTaskData subcontractedTaskData) {
|
||||
if (subcontractedTaskData != null) {
|
||||
subcontractedTaskDataDAO.reattach(subcontractedTaskData);
|
||||
subcontractedTaskData.getWorkDescription();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubcontractedTaskData getSubcontractedTaskData() {
|
||||
return subcontractedTaskData;
|
||||
|
|
@ -105,16 +91,24 @@ public class SubcontractModel implements ISubcontractModel {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void confirm() throws ValidationException {
|
||||
subcontractedTaskDataDAO.save(subcontractedTaskData);
|
||||
if (task != null) {
|
||||
if (subcontractedTaskData == null) {
|
||||
task.setSubcontractedTaskData(null);
|
||||
} else {
|
||||
subcontractedTaskDataDAO.save(subcontractedTaskData);
|
||||
|
||||
if (currentSubcontractedTaskData == null) {
|
||||
task.setSubcontractedTaskData(subcontractedTaskData);
|
||||
} else {
|
||||
currentSubcontractedTaskData.applyChanges(subcontractedTaskData);
|
||||
if (currentSubcontractedTaskData == null) {
|
||||
task.setSubcontractedTaskData(subcontractedTaskData);
|
||||
} else {
|
||||
currentSubcontractedTaskData
|
||||
.applyChanges(subcontractedTaskData);
|
||||
}
|
||||
|
||||
task.removeAllResourceAllocations();
|
||||
}
|
||||
|
||||
recalculateTaskLength();
|
||||
}
|
||||
|
||||
task.removeAllResourceAllocations();
|
||||
recalculateTaskLength();
|
||||
}
|
||||
|
||||
private void recalculateTaskLength() {
|
||||
|
|
@ -168,4 +162,9 @@ public class SubcontractModel implements ISubcontractModel {
|
|||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void removeSubcontractedTaskData() {
|
||||
subcontractedTaskData = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,25 @@
|
|||
*/
|
||||
|
||||
package org.navalplanner.web.planner.taskedition;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.MessagesForUser;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.planner.allocation.ResourceAllocationController;
|
||||
import org.navalplanner.web.planner.order.SubcontractController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.api.Tab;
|
||||
import org.zkoss.zul.api.Tabbox;
|
||||
import org.zkoss.zul.api.Tabpanel;
|
||||
import org.zkoss.zul.api.Window;
|
||||
|
||||
/**
|
||||
* Controller for edit a {@link Task}.
|
||||
|
|
@ -45,6 +57,30 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
@Autowired
|
||||
private SubcontractController subcontractController;
|
||||
|
||||
private Window window;
|
||||
|
||||
private Tabbox editTaskTabbox;
|
||||
private Tab resourceAllocationTab;
|
||||
private Tab subcontractTab;
|
||||
private Tabpanel taskPropertiesTabpanel;
|
||||
private Tabpanel subcontractTabpanel;
|
||||
private Component messagesContainer;
|
||||
|
||||
private IMessagesForUser messagesForUser;
|
||||
|
||||
private TaskElement taskElement;
|
||||
|
||||
private IContextWithPlannerTask<TaskElement> context;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
taskPropertiesController.doAfterCompose(taskPropertiesTabpanel);
|
||||
subcontractController.doAfterCompose(subcontractTabpanel);
|
||||
messagesForUser = new MessagesForUser(messagesContainer);
|
||||
}
|
||||
|
||||
public TaskPropertiesController getTaskPropertiesController() {
|
||||
return taskPropertiesController;
|
||||
}
|
||||
|
|
@ -57,4 +93,87 @@ public class EditTaskController extends GenericForwardComposer {
|
|||
return subcontractController;
|
||||
}
|
||||
|
||||
private void showEditForm(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
this.taskElement = taskElement;
|
||||
this.context = context;
|
||||
|
||||
taskPropertiesController.showEditFormFor(context, taskElement);
|
||||
if (taskElement.isSubcontracted()) {
|
||||
subcontractController.showWindow((Task) taskElement, context);
|
||||
}
|
||||
|
||||
try {
|
||||
Util.reloadBindings(window);
|
||||
window.setMode("modal");
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void showEditFormTaskProperties(
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
editTaskTabbox.setSelectedPanelApi(taskPropertiesTabpanel);
|
||||
showEditForm(context, taskElement);
|
||||
}
|
||||
|
||||
public void showEditFormSubcontract(
|
||||
IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
if (taskElement.isSubcontracted()) {
|
||||
editTaskTabbox.setSelectedPanelApi(subcontractTabpanel);
|
||||
}
|
||||
showEditForm(context, taskElement);
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
try {
|
||||
taskPropertiesController.accept();
|
||||
subcontractController.accept();
|
||||
|
||||
taskElement = null;
|
||||
context = null;
|
||||
|
||||
window.setVisible(false);
|
||||
} catch (ValidationException e) {
|
||||
messagesForUser.showInvalidValues(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
taskPropertiesController.cancel();
|
||||
subcontractController.cancel();
|
||||
|
||||
taskElement = null;
|
||||
context = null;
|
||||
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
public void subcontract(boolean subcontract) {
|
||||
if (taskElement instanceof Task) {
|
||||
if (subcontract) {
|
||||
resourceAllocationTab.setVisible(false);
|
||||
subcontractTab.setVisible(true);
|
||||
subcontractController.showWindow((Task) taskElement, context);
|
||||
} else {
|
||||
subcontractTab.setVisible(false);
|
||||
resourceAllocationTab.setVisible(true);
|
||||
subcontractController.removeSubcontractedTaskData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSubcontracted() {
|
||||
if (taskElement == null) {
|
||||
return false;
|
||||
}
|
||||
return taskElement.isSubcontracted();
|
||||
}
|
||||
|
||||
public boolean isNotSubcontracted() {
|
||||
return !isSubcontracted();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,7 +30,6 @@ import org.zkoss.ganttz.extensions.ICommandOnTask;
|
|||
*/
|
||||
public interface ITaskPropertiesCommand extends ICommandOnTask<TaskElement> {
|
||||
|
||||
void setTaskPropertiesController(
|
||||
TaskPropertiesController taskPropertiesController);
|
||||
void setEditTaskController(EditTaskController editTaskController);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,15 +22,12 @@ package org.navalplanner.web.planner.taskedition;
|
|||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import org.navalplanner.business.planner.daos.ITaskElementDAO;
|
||||
import org.navalplanner.business.planner.daos.ITaskSourceDAO;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
import org.navalplanner.web.planner.order.IEditTaskUtilities;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
||||
|
||||
/**
|
||||
|
|
@ -42,31 +39,17 @@ import org.zkoss.ganttz.extensions.IContextWithPlannerTask;
|
|||
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
|
||||
public class TaskPropertiesCommand implements ITaskPropertiesCommand {
|
||||
|
||||
@Autowired
|
||||
private ITaskElementDAO taskElementDAO;
|
||||
private EditTaskController editTaskController;
|
||||
|
||||
@Autowired
|
||||
private ITaskSourceDAO taskSourceDAO;
|
||||
|
||||
private TaskPropertiesController taskPropertiesController;
|
||||
private IEditTaskUtilities editTaskUtilities;
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public void doAction(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
if (taskElement.getTaskSource() != null) {
|
||||
taskSourceDAO.reattach(taskElement.getTaskSource());
|
||||
}
|
||||
taskElementDAO.reattach(taskElement);
|
||||
if (taskElement instanceof Task) {
|
||||
forceLoadHoursGroup((Task) taskElement);
|
||||
}
|
||||
editTaskUtilities.reattach(taskElement);
|
||||
|
||||
taskPropertiesController.showEditFormFor(context, taskElement);
|
||||
}
|
||||
|
||||
private void forceLoadHoursGroup(Task task) {
|
||||
task.getHoursGroup();
|
||||
editTaskController.showEditFormTaskProperties(context, taskElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -75,9 +58,9 @@ public class TaskPropertiesCommand implements ITaskPropertiesCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setTaskPropertiesController(
|
||||
TaskPropertiesController taskPropertiesController) {
|
||||
this.taskPropertiesController = taskPropertiesController;
|
||||
public void setEditTaskController(
|
||||
EditTaskController editTaskController) {
|
||||
this.editTaskController = editTaskController;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -40,10 +40,11 @@ import org.zkoss.zk.ui.event.Events;
|
|||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Comboitem;
|
||||
import org.zkoss.zul.Intbox;
|
||||
import org.zkoss.zul.api.Checkbox;
|
||||
import org.zkoss.zul.api.Combobox;
|
||||
import org.zkoss.zul.api.Datebox;
|
||||
import org.zkoss.zul.api.Row;
|
||||
import org.zkoss.zul.api.Window;
|
||||
import org.zkoss.zul.api.Tabpanel;
|
||||
|
||||
/**
|
||||
* Controller for edit {@link Task} popup.
|
||||
|
|
@ -143,7 +144,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
|
||||
private TaskElement currentTaskElement;
|
||||
|
||||
private Window window;
|
||||
private Tabpanel tabpanel;
|
||||
|
||||
private Intbox hours;
|
||||
|
||||
|
|
@ -157,6 +158,10 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
|
||||
private IContextWithPlannerTask<TaskElement> currentContext;
|
||||
|
||||
private Row subcontract;
|
||||
|
||||
private Checkbox subcontractCheckbox;
|
||||
|
||||
public void showEditFormFor(IContextWithPlannerTask<TaskElement> context,
|
||||
TaskElement taskElement) {
|
||||
this.currentContext = context;
|
||||
|
|
@ -170,12 +175,23 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
Task task = (Task) currentTaskElement;
|
||||
showDurationRow(task);
|
||||
showStartConstraintRow(task);
|
||||
showSubcontractRow(task);
|
||||
} else {
|
||||
hideDurationRow();
|
||||
hideStartConstraintRow();
|
||||
hideSubcontractRow();
|
||||
}
|
||||
hours.setValue(currentTaskElement.getWorkHours());
|
||||
Util.reloadBindings(window);
|
||||
Util.reloadBindings(tabpanel);
|
||||
}
|
||||
|
||||
private void hideSubcontractRow() {
|
||||
subcontract.setVisible(false);
|
||||
}
|
||||
|
||||
private void showSubcontractRow(Task task) {
|
||||
subcontractCheckbox.setChecked(task.getSubcontractedTaskData() != null);
|
||||
subcontract.setVisible(true);
|
||||
}
|
||||
|
||||
private void hideStartConstraintRow() {
|
||||
|
|
@ -247,7 +263,7 @@ public class TaskPropertiesController extends GenericForwardComposer {
|
|||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
tabpanel = (Tabpanel) comp;
|
||||
taskEditFormComposer.doAfterCompose(comp);
|
||||
WebStartConstraintType.appendItems(startConstraintTypes);
|
||||
startConstraintTypes.addEventListener(Events.ON_SELECT,
|
||||
|
|
|
|||
|
|
@ -43,54 +43,131 @@
|
|||
</planner>
|
||||
</div>
|
||||
|
||||
<window id="taskPropertiesWindow"
|
||||
apply="${propertiesController}" closable="true"
|
||||
title="${i18n:_('Task properties')}" width="650px" visible="false"
|
||||
border="normal">
|
||||
<window id="editTaskWindow" apply="${editController}" border="normal"
|
||||
title="${i18n:_('Task properties')}" width="650px" visible="false">
|
||||
|
||||
<grid>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox id="name" value="@{propertiesController.ganttTaskDTO.name}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Start')}" />
|
||||
<datebox id="startDateBox" disabled="true"
|
||||
value="@{propertiesController.ganttTaskDTO.beginDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End')}" />
|
||||
<datebox id="endDateBox" disabled="true"
|
||||
value="@{propertiesController.ganttTaskDTO.endDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Notes')}" />
|
||||
<textbox id="notes" value="@{propertiesController.ganttTaskDTO.notes}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Hours')}" />
|
||||
<intbox id="hours" disabled="true" />
|
||||
</row>
|
||||
<row id="durationRow">
|
||||
<label value="${i18n:_('Duration (days)')}" />
|
||||
<intbox id="duration" disabled="true"/>
|
||||
</row>
|
||||
<row id="startConstraint">
|
||||
<label value="${i18n:_('Constraint')}" />
|
||||
<vbox>
|
||||
<combobox id="startConstraintTypes">
|
||||
</combobox>
|
||||
<datebox id="startConstraintDate" constraint ="no empty"/>
|
||||
</vbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<vbox id="messagesContainer" />
|
||||
|
||||
<tabbox id="editTaskTabbox">
|
||||
<tabs>
|
||||
<tab id="taskPropertiesTab" label="${i18n:_('Task properties')}" />
|
||||
<tab id="resourceAllocationTab" label="${i18n:_('Resource allocation')}"
|
||||
visible="@{editController.isNotSubcontracted}" />
|
||||
<tab id="subcontractTab" label="${i18n:_('Subcontract')}"
|
||||
visible="@{editController.isSubcontracted}" />
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel id="taskPropertiesTabpanel">
|
||||
<grid>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox id="name" value="@{propertiesController.ganttTaskDTO.name}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Start')}" />
|
||||
<datebox id="startDateBox" disabled="true"
|
||||
value="@{propertiesController.ganttTaskDTO.beginDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End')}" />
|
||||
<datebox id="endDateBox" disabled="true"
|
||||
value="@{propertiesController.ganttTaskDTO.endDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Notes')}" />
|
||||
<textbox id="notes" value="@{propertiesController.ganttTaskDTO.notes}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Hours')}" />
|
||||
<intbox id="hours" disabled="true" />
|
||||
</row>
|
||||
<row id="durationRow">
|
||||
<label value="${i18n:_('Duration (days)')}" />
|
||||
<intbox id="duration" disabled="true"/>
|
||||
</row>
|
||||
<row id="startConstraint">
|
||||
<label value="${i18n:_('Constraint')}" />
|
||||
<vbox>
|
||||
<combobox id="startConstraintTypes">
|
||||
</combobox>
|
||||
<datebox id="startConstraintDate" constraint ="no empty"/>
|
||||
</vbox>
|
||||
</row>
|
||||
<row id="subcontract">
|
||||
<label value="${i18n:_('Subcontract')}" />
|
||||
<checkbox id="subcontractCheckbox" label="${i18n:_('Is subcontracted')}"
|
||||
onCheck="editController.subcontract(self.checked);" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</tabpanel>
|
||||
<tabpanel id="resourceAllocationTabpanel">TODO</tabpanel>
|
||||
<tabpanel id="subcontractTabpanel">
|
||||
<grid>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('External company')}" />
|
||||
|
||||
<combobox model="@{subController.subcontractorExternalCompanies}"
|
||||
value="@{subController.subcontractedTaskData.externalCompany.name}"
|
||||
onSelect="subController.setExternalCompany(self.selectedItem);">
|
||||
<comboitem self="@{each='externalCompany'}"
|
||||
value="@{externalCompany}"
|
||||
label="@{externalCompany.name}" />
|
||||
</combobox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontratation date')}" />
|
||||
<datebox value="@{subController.subcontractedTaskData.subcontratationDate}"
|
||||
disabled="true" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontract communication date')}" />
|
||||
<datebox value="@{subController.subcontractedTaskData.subcontractCommunicationDate}"
|
||||
disabled="true" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Work description')}" />
|
||||
<textbox value="@{subController.subcontractedTaskData.workDescription}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontract price')}" />
|
||||
<decimalbox value="@{subController.subcontractedTaskData.subcontractPrice}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontracted code')}" />
|
||||
<textbox value="@{subController.subcontractedTaskData.subcontractedCode}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End date')}" />
|
||||
<datebox value="@{subController.endDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Exportation options')}" />
|
||||
<vbox>
|
||||
<checkbox label="${i18n:_('Node without children')}"
|
||||
checked="@{subController.subcontractedTaskData.nodeWithoutChildrenExported}" />
|
||||
<checkbox label="${i18n:_('Labels')}"
|
||||
checked="@{subController.subcontractedTaskData.labelsExported}" />
|
||||
<checkbox label="${i18n:_('Material assignments')}"
|
||||
checked="@{subController.subcontractedTaskData.materialAssignmentsExported}" />
|
||||
<checkbox label="${i18n:_('Hours groups')}"
|
||||
checked="@{subController.subcontractedTaskData.hoursGroupsExported}" />
|
||||
<checkbox label="${i18n:_('Criterion requirements')}"
|
||||
checked="@{subController.subcontractedTaskData.criterionRequirementsExported}" />
|
||||
</vbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
<hbox>
|
||||
<button id="ok" label="${i18n:_('Accept')}"
|
||||
onClick="propertiesController.accept();" />
|
||||
onClick="editController.accept();" />
|
||||
<button id="cancel" label="${i18n:_('Cancel')}"
|
||||
onClick="propertiesController.cancel();" />
|
||||
onClick="editController.cancel();" />
|
||||
</hbox>
|
||||
</window>
|
||||
|
||||
|
|
@ -235,78 +312,5 @@
|
|||
|
||||
</window>
|
||||
|
||||
<window id="subcontractWindow"
|
||||
apply="${subController}"
|
||||
title="${i18n:_('Subcontract')}" width="600px"
|
||||
closable="true" visible="false">
|
||||
|
||||
<vbox id="messagesContainer" />
|
||||
|
||||
<grid>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('External company')}" />
|
||||
|
||||
<combobox model="@{subController.subcontractorExternalCompanies}"
|
||||
value="@{subController.subcontractedTaskData.externalCompany.name}"
|
||||
onSelect="subController.setExternalCompany(self.selectedItem);">
|
||||
<comboitem self="@{each='externalCompany'}"
|
||||
value="@{externalCompany}"
|
||||
label="@{externalCompany.name}" />
|
||||
</combobox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontratation date')}" />
|
||||
<datebox value="@{subController.subcontractedTaskData.subcontratationDate}"
|
||||
disabled="true" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontract communication date')}" />
|
||||
<datebox value="@{subController.subcontractedTaskData.subcontractCommunicationDate}"
|
||||
disabled="true" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Work description')}" />
|
||||
<textbox value="@{subController.subcontractedTaskData.workDescription}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontract price')}" />
|
||||
<decimalbox value="@{subController.subcontractedTaskData.subcontractPrice}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Subcontracted code')}" />
|
||||
<textbox value="@{subController.subcontractedTaskData.subcontractedCode}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('End date')}" />
|
||||
<datebox value="@{subController.endDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Exportation options')}" />
|
||||
<vbox>
|
||||
<checkbox label="${i18n:_('Node without children')}"
|
||||
checked="@{subController.subcontractedTaskData.nodeWithoutChildrenExported}" />
|
||||
<checkbox label="${i18n:_('Labels')}"
|
||||
checked="@{subController.subcontractedTaskData.labelsExported}" />
|
||||
<checkbox label="${i18n:_('Material assignments')}"
|
||||
checked="@{subController.subcontractedTaskData.materialAssignmentsExported}" />
|
||||
<checkbox label="${i18n:_('Hours groups')}"
|
||||
checked="@{subController.subcontractedTaskData.hoursGroupsExported}" />
|
||||
<checkbox label="${i18n:_('Criterion requirements')}"
|
||||
checked="@{subController.subcontractedTaskData.criterionRequirementsExported}" />
|
||||
</vbox>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<hbox>
|
||||
<button label="${i18n:_('Accept')}"
|
||||
onClick="subController.accept();" />
|
||||
<button label="${i18n:_('Cancel')}"
|
||||
onClick="subController.cancel();" />
|
||||
</hbox>
|
||||
|
||||
</window>
|
||||
|
||||
</div>
|
||||
</zk>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue