ItEr38S05ValidacionEProbasFuncionaisItEr37S06 : fix the remove operation to a work report type.

This commit is contained in:
Susana Montes Pedreira 2009-12-09 20:19:45 +01:00 committed by Javier Moran Rua
parent 0fcc2568d0
commit a8e8a9be02
3 changed files with 17 additions and 9 deletions

View file

@ -94,14 +94,18 @@ public interface IWorkReportTypeModel {
/**
* Check if it's or not editing a {@link WorkReportType}
*
* @return true if it's editing a {@link WorkReportType}
*/
boolean isEditing();
/**
* Set if it's or not shows {@link WorkReportType} list
* @return true if it's shows the list.
*/
void setListing(boolean listing);
/**
* Check if there is any {@link WorkReport} bound to {@link WorkReportType}
*
* @param workReportType
* @return
*/

View file

@ -157,6 +157,7 @@ public class WorkReportTypeCRUDController extends GenericForwardComposer
}
public void goToList() {
this.workReportTypeModel.setListing(true);
Util.reloadBindings(listWindow);
getVisibility().showOnly(listWindow);
}
@ -217,12 +218,6 @@ public class WorkReportTypeCRUDController extends GenericForwardComposer
public boolean isEditable() {
return (!thereAreWorkReportsFor(getWorkReportType()));
}
public void remove(WorkReportType workReportType) {
workReportTypeModel.confirmRemove(workReportType);
Util.reloadBindings(listWindow);
messagesForUser.showMessage(
Level.INFO, _("Removed {0}", workReportType.getName()));
}
public void goToEditForm() {
getVisibility().showOnly(editWindow);

View file

@ -75,6 +75,8 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
private boolean editing = false;
private boolean listing = true;
private static final Map<LabelType, List<Label>> mapLabels = new HashMap<LabelType, List<Label>>();
@Override
@ -97,7 +99,7 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
@Override
@Transactional(readOnly = true)
public boolean thereAreWorkReportsFor(WorkReportType workReportType) {
if (isEditing()) {
if ((listing) || (isEditing())) {
final List<WorkReport> workReports = workReportDAO
.getAllByWorkReportType(workReportType);
return (workReports != null && !workReports.isEmpty());
@ -115,6 +117,7 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
@Transactional(readOnly = true)
public void prepareForCreate() {
loadLabels();
setListing(false);
editing = false;
this.workReportType = WorkReportType.create();
}
@ -122,6 +125,7 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
@Override
@Transactional(readOnly = true)
public void initEdit(WorkReportType workReportType) {
setListing(false);
editing = true;
Validate.notNull(workReportType);
loadLabels();
@ -197,6 +201,11 @@ public class WorkReportTypeModel implements IWorkReportTypeModel {
return this.editing;
}
@Override
public void setListing(boolean listing) {
this.listing = listing;
}
/* Operations to manage the Description field */
public List<DescriptionField> getDescriptionFields() {