it changes the way of creating a project.
Show a pop-up from order list view to create a new order with the main properties. FEA : ItEr65S09CreateProject
This commit is contained in:
parent
4d72cca820
commit
808eb1a3c1
3 changed files with 239 additions and 4 deletions
|
|
@ -223,6 +223,8 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
private OrderElementTreeController orderElementTreeController;
|
||||
|
||||
private ProjectDetailsController projectDetailsController;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
|
@ -1011,16 +1013,33 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
public void goToCreateForm() {
|
||||
try {
|
||||
showOrderElementFilter();
|
||||
hideCreateButtons();
|
||||
orderModel.prepareForCreate();
|
||||
prepareEditWindow();
|
||||
showEditWindow(_("Create order"));
|
||||
showCreationPopup();
|
||||
} catch (ConcurrentModificationException e) {
|
||||
messagesForUser.showMessage(Level.ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void editNewCreatedOrder() {
|
||||
showOrderElementFilter();
|
||||
hideCreateButtons();
|
||||
prepareEditWindow();
|
||||
showEditWindow(_("Create order"));
|
||||
}
|
||||
|
||||
private void showCreationPopup() {
|
||||
Window window = (Window) Executions.createComponents(
|
||||
"/orders/_projectDetails.zul", null,
|
||||
new HashMap<String, String>());
|
||||
projectDetailsController = new ProjectDetailsController();
|
||||
try {
|
||||
projectDetailsController.doAfterCompose(window);
|
||||
projectDetailsController.showWindow(this);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideCreateButtons() {
|
||||
showCreateButtons(false);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,145 @@
|
|||
/*
|
||||
* This file is part of NavalPlan
|
||||
*
|
||||
* Copyright (C) 2010 Wireless Galicia 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
|
||||
* 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.orders;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.planner.consolidations.AdvanceConsolidationController;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.SuspendNotAllowedException;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.ComboitemRenderer;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Window;
|
||||
|
||||
/**
|
||||
* Controller for the creation of an {@link order} with its principal
|
||||
* properties.
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgailicia.com>
|
||||
*/
|
||||
|
||||
public class ProjectDetailsController extends GenericForwardComposer {
|
||||
|
||||
private static final Log LOG = LogFactory
|
||||
.getLog(AdvanceConsolidationController.class);
|
||||
|
||||
private OrderCRUDController orderController;
|
||||
|
||||
private Grid gridProjectDetails;
|
||||
|
||||
private BaseCalendar defaultCalendar;
|
||||
|
||||
private String oldCode;
|
||||
|
||||
private boolean isCodeAutogeneratedInit;
|
||||
private Window window;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
window = (Window) comp;
|
||||
window.setVariable("projectController", this, true);
|
||||
}
|
||||
|
||||
public void showWindow(OrderCRUDController orderController) {
|
||||
this.orderController = orderController;
|
||||
this.defaultCalendar = orderController.getOrder().getCalendar();
|
||||
this.isCodeAutogeneratedInit = orderController.getOrder()
|
||||
.isCodeAutogenerated();
|
||||
|
||||
try {
|
||||
Util.reloadBindings(window);
|
||||
Util.createBindingsFor(gridProjectDetails);
|
||||
Util.reloadBindings(gridProjectDetails);
|
||||
window.doModal();
|
||||
} catch (SuspendNotAllowedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
clearProperties();
|
||||
close();
|
||||
}
|
||||
|
||||
public void accept() {
|
||||
orderController.editNewCreatedOrder();
|
||||
close();
|
||||
}
|
||||
|
||||
private void close() {
|
||||
window.setVisible(false);
|
||||
}
|
||||
|
||||
public Order getOrder() {
|
||||
return orderController.getOrder();
|
||||
}
|
||||
|
||||
public boolean isCodeAutogenerated() {
|
||||
return orderController.isCodeAutogenerated();
|
||||
}
|
||||
|
||||
public void setCodeAutogenerated(boolean codeAutogenerated) {
|
||||
orderController.setCodeAutogenerated(codeAutogenerated);
|
||||
Util.reloadBindings(gridProjectDetails);
|
||||
}
|
||||
|
||||
public List<ExternalCompany> getExternalCompaniesAreClient() {
|
||||
return orderController.getExternalCompaniesAreClient();
|
||||
}
|
||||
|
||||
public List<BaseCalendar> getBaseCalendars() {
|
||||
return orderController.getBaseCalendars();
|
||||
}
|
||||
|
||||
public ComboitemRenderer getBaseCalendarsComboitemRenderer() {
|
||||
return orderController.getBaseCalendarsComboitemRenderer();
|
||||
}
|
||||
|
||||
public void setBaseCalendar(BaseCalendar calendar) {
|
||||
orderController.setBaseCalendar(calendar);
|
||||
}
|
||||
|
||||
private void clearProperties() {
|
||||
Order order = orderController.getOrder();
|
||||
order.setName(null);
|
||||
// reset the code autogenerated property
|
||||
if (isCodeAutogeneratedInit) {
|
||||
order.setCodeAutogenerated(true);
|
||||
|
||||
} else {
|
||||
order.setCodeAutogenerated(false);
|
||||
order.setCode("");
|
||||
}
|
||||
order.setCustomer(null);
|
||||
order.setDeadline(null);
|
||||
order.setInitDate(new Date());
|
||||
order.setCalendar(defaultCalendar);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
<!--
|
||||
This file is part of NavalPlan
|
||||
|
||||
Copyright (C) 2010 Wireless Galicia 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
|
||||
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/>.
|
||||
-->
|
||||
|
||||
<window id="projectCreationWindow" title="${i18n:_('Create project')}" width="650px">
|
||||
<grid id="gridProjectDetails">
|
||||
<columns>
|
||||
<column width="130px" />
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${i18n:_('Name')}" />
|
||||
<textbox value="@{projectController.order.name}" width="500px"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Code')}" />
|
||||
<hbox>
|
||||
<textbox id="txtCode" value="@{projectController.order.code}" width="250px"
|
||||
disabled="@{projectController.codeAutogenerated}" />
|
||||
<checkbox label="${i18n:_('Autogenerated')}"
|
||||
checked="@{projectController.codeAutogenerated}"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Starting date')}" />
|
||||
<datebox id="initDate"
|
||||
value="@{projectController.order.initDate}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Deadline')}" />
|
||||
<datebox id="deadline" value="@{projectController.order.deadline}" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Customer')}" />
|
||||
<bandboxSearch id="bdExternalCompanies" widthBandbox="485px" widthListbox="500px"
|
||||
finder="ExternalCompanyBandboxFinder"
|
||||
model="@{projectController.externalCompaniesAreClient}"
|
||||
selectedElement="@{projectController.order.customer}"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Calendar')}" />
|
||||
<combobox id="calendarCombobox" width="200px"
|
||||
model="@{projectController.baseCalendars}"
|
||||
itemRenderer="@{projectController.baseCalendarsComboitemRenderer}"
|
||||
onSelect="projectController.setBaseCalendar(self.selectedItem.value);" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<button label="${i18n:_('Accept')}"
|
||||
onClick="projectController.accept();" />
|
||||
<button label="${i18n:_('Cancel')}"
|
||||
onClick="projectController.cancel();" />
|
||||
</hbox>
|
||||
</window>
|
||||
Loading…
Add table
Reference in a new issue