ItEr42S18CUProcuraPartesTraballoDadosAltaNoSistemaItEr41S21 : Improved the work report editing and creation.
This commit is contained in:
parent
e49fa7038a
commit
9e8809fafb
5 changed files with 93 additions and 12 deletions
|
|
@ -84,8 +84,14 @@ public interface IWorkReportModel {
|
|||
WorkReport getWorkReport();
|
||||
|
||||
/**
|
||||
* Return all {@link WorkReportLine} associated with current {@link WorkReport}
|
||||
*
|
||||
* Gets the current {@link WorkReportType}.
|
||||
* @return A {@link WorkReportType}
|
||||
*/
|
||||
WorkReportType getWorkReportType();
|
||||
|
||||
/**
|
||||
* Return all {@link WorkReportLine} associated with current
|
||||
* {@link WorkReport}
|
||||
* @return
|
||||
*/
|
||||
List<WorkReportLine> getWorkReportLines();
|
||||
|
|
|
|||
|
|
@ -93,6 +93,8 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
|
||||
private static final org.apache.commons.logging.Log LOG = LogFactory.getLog(WorkReportCRUDController.class);
|
||||
|
||||
private boolean cameBackList = false;
|
||||
|
||||
private Window createWindow;
|
||||
|
||||
private Window listWindow;
|
||||
|
|
@ -135,6 +137,8 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
|
||||
private Listbox listType;
|
||||
|
||||
private Listbox listTypeToAssign;
|
||||
|
||||
private Datebox filterStartDate;
|
||||
|
||||
private Datebox filterFinishDate;
|
||||
|
|
@ -515,7 +519,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
}
|
||||
|
||||
public void cancel() {
|
||||
if (workReportModel.isEditing()) {
|
||||
if (cameBackList || workReportModel.isEditing()) {
|
||||
goToList();
|
||||
} else {
|
||||
workReportTypeCRUD.goToList();
|
||||
|
|
@ -523,6 +527,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
}
|
||||
|
||||
public void goToCreateForm(WorkReportType workReportType) {
|
||||
cameBackList = false;
|
||||
workReportModel.initCreate(workReportType);
|
||||
prepareWorkReportList();
|
||||
getVisibility().showOnly(createWindow);
|
||||
|
|
@ -557,6 +562,7 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
// components work report list
|
||||
listing = (Grid) window.getFellow("listing");
|
||||
listType = (Listbox) window.getFellow("listType");
|
||||
listTypeToAssign = (Listbox) window.getFellow("listTypeToAssign");
|
||||
filterStartDate = (Datebox) window.getFellow("filterStartDate");
|
||||
filterFinishDate = (Datebox) window.getFellow("filterFinishDate");
|
||||
clearFilterDates();
|
||||
|
|
@ -1366,8 +1372,22 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
|
||||
private final String FILTER = _("Filter work reports");
|
||||
|
||||
public List<WorkReportType> getFilterWorkReportTypes() {
|
||||
List<WorkReportType> result = workReportModel.getWorkReportTypes();
|
||||
if (result.isEmpty()) {
|
||||
result.add(getDefaultWorkReportType());
|
||||
} else {
|
||||
result.add(0, getDefaultWorkReportType());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<WorkReportType> getWorkReportTypes() {
|
||||
return workReportModel.getWorkReportTypes();
|
||||
List<WorkReportType> result = workReportModel.getWorkReportTypes();
|
||||
if (!result.isEmpty()) {
|
||||
this.firstType = result.get(0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public WorkReportType getDefaultWorkReportType() {
|
||||
|
|
@ -1582,4 +1602,45 @@ public class WorkReportCRUDController extends GenericForwardComposer implements
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods improved the work report edition and creation.Executed on
|
||||
* pressing New work report button Creates a new work report for a type, and
|
||||
* added it to the work report list
|
||||
*/
|
||||
|
||||
public void onCreateNewWorkReport() {
|
||||
Listitem selectedItem = listTypeToAssign.getSelectedItem();
|
||||
if (selectedItem == null) {
|
||||
throw new WrongValueException(listTypeToAssign,
|
||||
_("please, select a work report type"));
|
||||
}
|
||||
|
||||
WorkReportType type = (WorkReportType) selectedItem.getValue();
|
||||
if (type == null) {
|
||||
throw new WrongValueException(listTypeToAssign,
|
||||
_("please, select a work report type"));
|
||||
}
|
||||
|
||||
goToCreateForm(type);
|
||||
listTypeToAssign.clearSelection();
|
||||
cameBackList = true;
|
||||
}
|
||||
|
||||
private WorkReportType firstType;
|
||||
|
||||
public WorkReportType getFirstType() {
|
||||
return firstType;
|
||||
}
|
||||
|
||||
public void setFirstType(WorkReportType firstType) {
|
||||
this.firstType = firstType;
|
||||
}
|
||||
|
||||
public void newWorkReportWithSameType() {
|
||||
if (save()) {
|
||||
goToCreateForm(workReportModel.getWorkReportType());
|
||||
cameBackList = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,8 @@ public class WorkReportModel implements IWorkReportModel {
|
|||
return workReport;
|
||||
}
|
||||
|
||||
private WorkReportType getWorkReportType() {
|
||||
@Override
|
||||
public WorkReportType getWorkReportType() {
|
||||
return this.workReportType;
|
||||
}
|
||||
|
||||
|
|
@ -508,11 +509,6 @@ public class WorkReportModel implements IWorkReportModel {
|
|||
public List<WorkReportType> getWorkReportTypes() {
|
||||
List<WorkReportType> result = workReportTypeDAO
|
||||
.list(WorkReportType.class);
|
||||
if (result.isEmpty()) {
|
||||
result.add(getDefaultType());
|
||||
} else {
|
||||
result.add(0, getDefaultType());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,6 +92,8 @@
|
|||
label="${arg.save_button_label}" sclass="save-button global-action"/>
|
||||
<button onClick="controller.saveAndContinue();"
|
||||
label="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="${arg.cancel_button_label}" sclass="cancel-button global-action"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@
|
|||
|
||||
<window id="${arg.top_id}" title="${i18n:_('Work report listing')}">
|
||||
<div align="right">
|
||||
<hbox id="hboxFilter" align="end">
|
||||
<hbox id="hboxFilter" align="center">
|
||||
<!-- Filter by type, start date and finish date -->
|
||||
<label value="${i18n:_('Filter work report by :')}"/>
|
||||
<label value="${i18n:_('Type')}"/>
|
||||
<listbox id="listType" mold="select" rows="1"
|
||||
model="@{controller.workReportTypes}" width="150px"
|
||||
model="@{controller.filterWorkReportTypes}" width="150px"
|
||||
selectedItem="@{controller.defaultWorkReportType}">
|
||||
<listitem self="@{each='workReportType'}" value="@{workReportType}">
|
||||
<listcell label="@{workReportType.name}" />
|
||||
|
|
@ -71,4 +71,20 @@
|
|||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<separator bar="false" spacing="20px" orient="horizontal"/>
|
||||
<div align="left">
|
||||
<hbox align="center">
|
||||
<!-- Create new Work Report -->
|
||||
<label value="${i18n:_('Select type :')}"/>
|
||||
<listbox id="listTypeToAssign" mold="select" rows="1"
|
||||
model="@{controller.workReportTypes}" width="150px"
|
||||
selectedItem="@{controller.firstType}">
|
||||
<listitem self="@{each='workReportType'}" value="@{workReportType}">
|
||||
<listcell label="@{workReportType.name}" />
|
||||
</listitem>
|
||||
</listbox>
|
||||
<button label="${i18n:_('New work report')}" style="margin-top: -4px"
|
||||
onClick="controller.onCreateNewWorkReport()"/>
|
||||
</hbox>
|
||||
</div>
|
||||
</window>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue