ItEr48S04ValidacionEProbasFuncionaisItEr47S04 : [Bug #347] Fixing bug.
Shows correctly the page work report query. Refactoring the TimeConverter class to work with LocalTime. Fix the method checkConstraintHoursCalculatedByClock() in the WorkReportLine entity. If an exception is detected on the hours of the workReportLine will be shown a error message.
This commit is contained in:
parent
9fce2a020b
commit
38c183a9b0
4 changed files with 184 additions and 19 deletions
|
|
@ -378,7 +378,7 @@ public class WorkReportLine extends IntegrationEntity implements Comparable {
|
|||
|
||||
if (workReport.getWorkReportType().getHoursManagement().equals(
|
||||
HoursManagementEnum.HOURS_CALCULATED_BY_CLOCK)) {
|
||||
if (getDiferenceBetweenTimeStartAndFinish() != numHours) {
|
||||
if (getDiferenceBetweenTimeStartAndFinish().compareTo(numHours) != 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
package org.navalplanner.web.common.typeconverters;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.joda.time.LocalTime;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zkplus.databind.TypeConverter;
|
||||
|
||||
|
|
@ -41,8 +41,8 @@ public class TimeConverter implements TypeConverter {
|
|||
|
||||
@Override
|
||||
public Object coerceToUi(Object object, Component component) {
|
||||
Date date = ((Date)object);
|
||||
return object != null ? (new SimpleDateFormat("h:mm a"))
|
||||
.format((Date) object) : new String("");
|
||||
LocalTime date = ((LocalTime) object);
|
||||
DateTimeFormatter fmt = DateTimeFormat.forPattern("h:mm a");
|
||||
return object != null ? fmt.print((LocalTime) object) : new String("");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,7 +251,6 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
private void showInvalidValues(ValidationException e) {
|
||||
for (InvalidValue invalidValue : e.getInvalidValues()) {
|
||||
Object value = invalidValue.getBean();
|
||||
|
||||
if (value instanceof WorkReport) {
|
||||
validateWorkReport();
|
||||
}
|
||||
|
|
@ -313,8 +312,8 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
// Find which row contains workReportLine inside listBox
|
||||
Row row = findWorkReportLine(listWorkReportLines.getRows().getChildren(),
|
||||
workReportLine);
|
||||
workReportLine = (WorkReportLine) row.getValue();
|
||||
|
||||
workReportLine = (WorkReportLine) row.getValue();
|
||||
if (row != null) {
|
||||
if (getWorkReportType().getDateIsSharedByLines()) {
|
||||
if (!validateWorkReport()) {
|
||||
|
|
@ -374,6 +373,14 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!workReportLine.checkConstraintHoursCalculatedByClock()) {
|
||||
// Locate TextboxOrder
|
||||
Intbox txtHours = getIntboxHours(row);
|
||||
String message = _("number of hours is not properly calculated based on clock");
|
||||
showInvalidMessage(txtHours, message);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (workReportLine.getTypeOfWorkHours() == null) {
|
||||
// Locate TextboxOrder
|
||||
Autocomplete autoTypeOfHours = getTypeOfHours(row);
|
||||
|
|
@ -381,7 +388,6 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
showInvalidMessage(autoTypeOfHours,message);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
@ -615,7 +621,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
listWorkReportLines.setMold(MOLD);
|
||||
listWorkReportLines.setPageSize(PAGING);
|
||||
|
||||
appendColumns(listWorkReportLines);
|
||||
appendColumns(listWorkReportLines);
|
||||
listWorkReportLines
|
||||
.setSortedColumn((NewDataSortableColumn) listWorkReportLines
|
||||
.getColumns().getFirstChild());
|
||||
|
|
@ -924,7 +930,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
timeStart.addEventListener(Events.ON_CHANGE, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
reloadWorkReportLines();
|
||||
reloadWorkReportLines();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -972,7 +978,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
timeFinish.addEventListener(Events.ON_CHANGE, new EventListener() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
reloadWorkReportLines();
|
||||
reloadWorkReportLines();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,21 +19,180 @@
|
|||
-->
|
||||
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
|
||||
<?page id="work_report_admin"?>
|
||||
<?page id="work_report_admin_query"?>
|
||||
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_v01.css"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/common/css/navalpro_zk.css"?>
|
||||
<?link rel="stylesheet" type="text/css" href="/resources/css/resources.css"?>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<?component name="listQuery" inline="true" macroURI="_listWorkReportQuery.zul"?>
|
||||
<?component name="edition" inline="true" macroURI="_editWorkReport.zul"?>
|
||||
<zk>
|
||||
<window self="@{define(content)}"
|
||||
apply="org.navalplanner.web.workreports.WorkReportCRUDController">
|
||||
<vbox id="messagesContainer"></vbox>
|
||||
|
||||
<listQuery top_id="listQueryWindow" />
|
||||
<edition top_id="createWindow" title="${i18n:_('Edit work report')}"
|
||||
save_button_label="${i18n:_('Save')}" cancel_button_label="${i18n:_('Cancel')}" />
|
||||
<window id="listQueryWindow" title="${i18n:_('Work report lines listing')}">
|
||||
<panel title="${i18n:_('Filter work report by :')}" border="normal"
|
||||
style="overflow:auto">
|
||||
<panelchildren>
|
||||
<separator bar="false" spacing="5px" orient="horizontal"/>
|
||||
<div align="center">
|
||||
<hbox id="hboxFilter" align="end">
|
||||
<!-- Filter work report lines -->
|
||||
<label value="${i18n:_('Resource :')}"/>
|
||||
<autocomplete id="filterResource" buttonVisible="true"
|
||||
finder="ResourceFinder"/>
|
||||
<label value="${i18n:_('order element :')}"/>
|
||||
<bandbox id="bandboxFilterOrderElement">
|
||||
<bandpopup>
|
||||
<listbox id="filterOrderElement" width="750px" fixedLayout="true"
|
||||
model="@{controller.orderElements}"
|
||||
onSelect="controller.setFilterOrderElement(event)">
|
||||
<listhead>
|
||||
<listheader label="${i18n:_('Order')}"/>
|
||||
<listheader label="${i18n:_('Order code')}"/>
|
||||
<listheader label="${i18n:_('Order element')}"/>
|
||||
<listheader label="${i18n:_('Order element code')}"/>
|
||||
</listhead>
|
||||
<listitem self="@{each='orderElement'}" value="@{orderElement}">
|
||||
<listcell label="@{orderElement.order.name}"/>
|
||||
<listcell label="@{orderElement.order.code}"/>
|
||||
<listcell label="@{orderElement.name}"/>
|
||||
<listcell label="@{orderElement.code}"/>
|
||||
</listitem>
|
||||
</listbox>
|
||||
</bandpopup>
|
||||
</bandbox>
|
||||
<label value="${i18n:_('from')}"/>
|
||||
<datebox id="filterStartDateLine" constraint = "@{controller.checkConstraintStartDateLine}"/>
|
||||
<label value="${i18n:_('to')}"/>
|
||||
<datebox id="filterFinishDateLine" constraint = "@{controller.checkConstraintFinishDateLine}"/>
|
||||
<label value="${i18n:_('hours type :')}"/>
|
||||
<autocomplete id="filterHoursType" buttonVisible="true"
|
||||
finder="TypeOfWorkHoursFinder" width="100px"/>
|
||||
<button label="${i18n:_('Filter')}" style="margin-top: -4px"
|
||||
onClick="controller.onApplyFilterWorkReportLines(event)"/>
|
||||
</hbox>
|
||||
</div>
|
||||
|
||||
<separator bar="false" spacing="5px" orient="horizontal"/>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
<separator bar="false" spacing="20px" orient="horizontal"/>
|
||||
<grid id="gridListQuery" mold="paging" pageSize="10"
|
||||
model="@{controller.queryWorkReportLines}"
|
||||
onInitRender ="controller.sortQueryWorkReportLines();">
|
||||
<columns sizable="true">
|
||||
<column id="date" label="${i18n:_('Date')}" width="200px" align="center"
|
||||
sort="auto(date)" sortDirection="ascending"/>
|
||||
<column label="${i18n:_('Resource')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Order Element Code')}" width="200px" align="center"/>
|
||||
<column label="${i18n:_('Start hour')}" width="80px" align="center"/>
|
||||
<column label="${i18n:_('Finish hour')}" width="80px" align="center"/>
|
||||
<column label="${i18n:_('Hours')}" width="80px" align="center"/>
|
||||
<column label="${i18n:_('Hours type')}" width="150px" align="center"/>
|
||||
<column label="${i18n:_('Work Report')}" width="80px" align="center"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row self="@{each='queryWorkReportLine'}" value="@{queryWorkReportLine}">
|
||||
<label value="@{queryWorkReportLine.date, converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
<label value="@{queryWorkReportLine.resource.shortDescription}"/>
|
||||
<label value="@{queryWorkReportLine.orderElement.code}" />
|
||||
<label value="@{queryWorkReportLine.clockStart, converter='org.navalplanner.web.common.typeconverters.TimeConverter'}" />
|
||||
<label value="@{queryWorkReportLine.clockFinish, converter='org.navalplanner.web.common.typeconverters.TimeConverter'}" />
|
||||
<label value="@{queryWorkReportLine.numHours}" />
|
||||
<label value="@{queryWorkReportLine.typeOfWorkHours.name}" />
|
||||
<button sclass="icono" image="/common/img/ico_editar1.png"
|
||||
hoverImage="/common/img/ico_editar.png"
|
||||
tooltiptext="${i18n:_('Edit')}"
|
||||
onClick="controller.goToEditFormQuery(self.parent.value);">
|
||||
</button>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</window>
|
||||
|
||||
<window id="createWindow" title="${i18n:_('Edit work report')}">
|
||||
<tabbox>
|
||||
<tabs>
|
||||
<tab label="${i18n:_('Report data')}"></tab>
|
||||
</tabs>
|
||||
<tabpanels>
|
||||
<tabpanel>
|
||||
<vbox>
|
||||
|
||||
<panel title="${i18n:_('Heading Fields')}" border="normal"
|
||||
style="overflow:auto">
|
||||
<panelchildren>
|
||||
<grid id="HeadingRequirementsFields" mold="paging" pageSize="4" fixedLayout="true">
|
||||
<columns>
|
||||
<column width="200px"/>
|
||||
<column />
|
||||
</columns>
|
||||
<rows>
|
||||
<row visible = "@{controller.workReport.workReportType.dateIsSharedByLines}">
|
||||
<label value="${i18n:_('Date')}:" />
|
||||
<datebox id="date" value="@{controller.workReport.date}" />
|
||||
</row>
|
||||
<row visible = "@{controller.workReport.workReportType.resourceIsSharedInLines}">
|
||||
<label value="${i18n:_('Resource')}:" />
|
||||
<autocomplete id="autocompleteResource" buttonVisible="true"
|
||||
onChange ="controller.changeResource(self.selectedItem);"
|
||||
finder="ResourceFinder"
|
||||
selectedItem="@{controller.workReport.resource}"/>
|
||||
</row>
|
||||
<row visible = "@{controller.workReport.workReportType.orderElementIsSharedInLines}">
|
||||
<label value="${i18n:_('OrderElement Code')}:" />
|
||||
<bandboxSearch id="bandboxSelectOrderElementInHead"
|
||||
finder="OrderElementBandboxFinder"
|
||||
model="@{controller.orderElements}"
|
||||
selectedElement="@{controller.workReport.orderElement}"
|
||||
onSelect="controller.setOrderElementInComponent(event)" />
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<grid id="headingFieldsAndLabels" mold="paging" pageSize="4"
|
||||
fixedLayout="true"
|
||||
model="@{controller.fieldsAndLabelsHeading}"
|
||||
rowRenderer= "@{controller.orderedFieldsAndLabelsRowRenderer}">
|
||||
<columns>
|
||||
<column width="200px"/>
|
||||
<column />
|
||||
</columns>
|
||||
</grid>
|
||||
</panelchildren>
|
||||
</panel>
|
||||
|
||||
<separator bar="false" spacing="80px" orient="vertical"/>
|
||||
|
||||
<!-- Work report lines -->
|
||||
<panel title="${i18n:_('Work report lines')}"
|
||||
border="normal">
|
||||
<panelchildren>
|
||||
<hbox>
|
||||
<button label="${i18n:_('Add new row')}"
|
||||
onClick="controller.addWorkReportLine()" />
|
||||
</hbox>
|
||||
|
||||
<newdatasortablegrid id="listWorkReportLines" fixedLayout="true"
|
||||
rowRenderer="@{controller.renderer}" />
|
||||
</panelchildren>
|
||||
</panel>
|
||||
</vbox>
|
||||
</tabpanel>
|
||||
</tabpanels>
|
||||
</tabbox>
|
||||
|
||||
<button onClick="controller.saveAndExit();"
|
||||
label="${i18n:_('Save')}" sclass="save-button global-action"/>
|
||||
<button onClick="controller.saveAndContinue();"
|
||||
label="${i18n:_('Save & Continue')}" sclass="saveandcontinue-button global-action"/>
|
||||
<button onClick="controller.newWorkReportWithSameType();"
|
||||
label="Save & New work report" sclass="saveandcontinue-button global-action"/>
|
||||
<button onClick="controller.cancel();"
|
||||
label="${i18n:_('Cancel')}" sclass="cancel-button global-action"/>
|
||||
|
||||
</window>
|
||||
|
||||
</window>
|
||||
</zk>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue