Bug #1369: Improved behaviour of project creation popup when using templates
* If a template is selected, the 'generate code' checkbox is automatically set and disabled * When selecting a project, start project date is calculated with the current day plus template start delay * Deadline is calculated as start project date plus template duration till deadline FEA: ItEr76S04BugFixing
This commit is contained in:
parent
b6a622c7ae
commit
183977850e
3 changed files with 29 additions and 12 deletions
|
|
@ -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
|
||||
|
|
@ -294,6 +294,10 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
}
|
||||
|
||||
|
||||
public void setBandboxEventListener(String event, EventListener listener) {
|
||||
bandbox.addEventListener(event, listener);
|
||||
}
|
||||
|
||||
public void foucusOnInput() {
|
||||
bandbox.setFocus(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* This file is part of LibrePlan
|
||||
*
|
||||
* Copyright (C) 2010-2011 Wireless Galicia, S.L.
|
||||
* Copyright (C) 2011 Igalia, S.L.
|
||||
* Copyright (C) 2011-2012 Igalia, S.L.
|
||||
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
|
@ -49,6 +49,7 @@ import org.zkoss.zk.ui.event.Event;
|
|||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
import org.zkoss.zul.ComboitemRenderer;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Datebox;
|
||||
|
|
@ -91,6 +92,8 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
|
||||
private Datebox deadline;
|
||||
|
||||
private Checkbox generateCode;
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
|
|
@ -277,23 +280,32 @@ public class ProjectDetailsController extends GenericForwardComposer {
|
|||
bdExternalCompanies.close();
|
||||
}
|
||||
});
|
||||
bdProjectTemplate.setListboxEventListener(Events.ON_SELECT,
|
||||
bdProjectTemplate.setBandboxEventListener(Events.ON_BLUR,
|
||||
new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) {
|
||||
calculateDeadlineDate();
|
||||
if (bdProjectTemplate.getSelectedElement() == null) {
|
||||
generateCode.setDisabled(false);
|
||||
} else {
|
||||
setCodeAutogenerated(true);
|
||||
generateCode.setDisabled(true);
|
||||
generateCode.setChecked(true);
|
||||
calculateProjectDates();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void calculateDeadlineDate() {
|
||||
if ((bdProjectTemplate.getSelectedElement() == null)
|
||||
|| (((OrderTemplate) bdProjectTemplate.getSelectedElement())
|
||||
.getDeadlineAsDaysFromBeginning() == null)
|
||||
|| (initDate.getValue() == null)) {
|
||||
public void calculateProjectDates() {
|
||||
OrderTemplate template = (OrderTemplate) bdProjectTemplate.getSelectedElement();
|
||||
if (template == null) {
|
||||
return;
|
||||
}
|
||||
int days = ((OrderTemplate) bdProjectTemplate.getSelectedElement()).getDeadlineAsDaysFromBeginning();
|
||||
deadline.setValue( new LocalDate(initDate.getValue()).plusDays(days).toDateTimeAtStartOfDay().toDate());
|
||||
initDate.setValue(new LocalDate().plusDays(template.getStartAsDaysFromBeginning()).toDateTimeAtStartOfDay().toDate());
|
||||
if (template.getDeadlineAsDaysFromBeginning() != null ) {
|
||||
deadline.setValue( new LocalDate(initDate.getValue()).plusDays(template.getDeadlineAsDaysFromBeginning()).toDateTimeAtStartOfDay().toDate());
|
||||
} else {
|
||||
deadline.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
This file is part of LibrePlan
|
||||
|
||||
Copyright (C) 2010-2011 Wireless Galicia, S.L.
|
||||
Copyright (C) 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
|
||||
|
|
@ -43,7 +44,7 @@
|
|||
<textbox id="txtCode" value="@{projectController.order.code}" width="250px"
|
||||
disabled="@{projectController.codeAutogenerated}"
|
||||
constraint="no empty:${i18n:_('cannot be null or empty')}"/>
|
||||
<checkbox label="${i18n:_('Generate code')}"
|
||||
<checkbox id="generateCode" label="${i18n:_('Generate code')}"
|
||||
checked="@{projectController.codeAutogenerated}"/>
|
||||
</hbox>
|
||||
</row>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue