ItEr23S08CUEdicionCalendarioLaboral: Checking not negative hours when creating an exception day.
This commit is contained in:
parent
728d6e7666
commit
d6d02b06e8
2 changed files with 21 additions and 5 deletions
|
|
@ -16,9 +16,11 @@ import org.navalplanner.web.common.MessagesForUser;
|
|||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.WrongValueException;
|
||||
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.Clients;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Button;
|
||||
import org.zkoss.zul.Checkbox;
|
||||
|
|
@ -208,11 +210,25 @@ public class BaseCalendarCRUDController extends GenericForwardComposer {
|
|||
return baseCalendarModel.getHoursOfDay();
|
||||
}
|
||||
|
||||
public void createException(Integer hours) {
|
||||
// TODO check hours parameter is >= 0
|
||||
baseCalendarModel.createException(hours);
|
||||
public void createException() {
|
||||
Component exceptionHoursIntbox;
|
||||
if (baseCalendarModel.isEditing()) {
|
||||
exceptionHoursIntbox = editWindow.getFellow("exceptionHours");
|
||||
} else {
|
||||
exceptionHoursIntbox = createWindow.getFellow("exceptionHours");
|
||||
}
|
||||
|
||||
reloadDayInformation();
|
||||
Integer hours = ((Intbox) exceptionHoursIntbox).getValue();
|
||||
|
||||
if (hours < 0) {
|
||||
throw new WrongValueException(
|
||||
exceptionHoursIntbox,
|
||||
_("Hours for an exception day should be greater or equal than zero"));
|
||||
} else {
|
||||
Clients.closeErrorBox(exceptionHoursIntbox);
|
||||
baseCalendarModel.createException(hours);
|
||||
reloadDayInformation();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Days> getHoursPerDay() {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
<hbox>
|
||||
<vbox>
|
||||
<button label="${i18n:_('Create exception')}"
|
||||
onClick="controller.createException(exceptionHours.value);" />
|
||||
onClick="controller.createException();" />
|
||||
<button disabled="@{controller.isNotExceptional}"
|
||||
label="${i18n:_('Remove exception')}"
|
||||
onClick="controller.removeException();" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue