ItEr53S04ValidacionEProbasFuncionaisItEr52S04: [Bug #389] Added delete button to Cost Category listing.
This commit is contained in:
parent
bd50d1dd1b
commit
5dfb91b16c
4 changed files with 41 additions and 1 deletions
|
|
@ -30,6 +30,7 @@ import java.util.Set;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.validator.InvalidValue;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.HourCost;
|
||||
|
|
@ -393,6 +394,20 @@ public class CostCategoryCRUDController extends GenericForwardComposer
|
|||
}
|
||||
}
|
||||
|
||||
public void confirmRemove(CostCategory category) {
|
||||
try {
|
||||
int status = Messagebox.show(_("Confirm deleting this cost category. Are you sure?"), _("Delete"),
|
||||
Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION);
|
||||
if (Messagebox.OK == status) {
|
||||
removeCostCategory(category);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
messagesForUser.showMessage(
|
||||
Level.ERROR, e.getMessage());
|
||||
LOG.error(_("Error on showing removing element: ", category.getId()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public HourCostListRenderer getRenderer() {
|
||||
return hourCostListRenderer;
|
||||
}
|
||||
|
|
@ -412,6 +427,17 @@ public class CostCategoryCRUDController extends GenericForwardComposer
|
|||
Util.reloadBindings(listHourCosts);
|
||||
}
|
||||
|
||||
public void removeCostCategory(CostCategory category) {
|
||||
try {
|
||||
costCategoryModel.confirmRemoveCostCategory(category);
|
||||
}
|
||||
catch(InstanceNotFoundException e) {
|
||||
messagesForUser.showMessage(
|
||||
Level.ERROR, _("The cost category had already been removed."));
|
||||
}
|
||||
Util.reloadBindings(listWindow.getFellowIfAny("listing"));
|
||||
}
|
||||
|
||||
/**
|
||||
* RowRenderer for a @{HourCost} element
|
||||
*
|
||||
|
|
|
|||
|
|
@ -128,4 +128,11 @@ public class CostCategoryModel implements ICostCategoryModel {
|
|||
public void removeHourCost(HourCost hourCost) {
|
||||
costCategory.removeHourCost(hourCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmRemoveCostCategory(CostCategory category)
|
||||
throws InstanceNotFoundException {
|
||||
costCategoryDAO.remove(category.getId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ package org.navalplanner.web.costcategories;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.costcategories.entities.CostCategory;
|
||||
import org.navalplanner.business.costcategories.entities.HourCost;
|
||||
|
|
@ -54,4 +55,7 @@ public interface ICostCategoryModel {
|
|||
void addHourCost();
|
||||
|
||||
void removeHourCost(HourCost hourCost);
|
||||
|
||||
void confirmRemoveCostCategory(CostCategory category)
|
||||
throws InstanceNotFoundException;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,10 @@
|
|||
tooltiptext="${i18n:_('Edit')}"
|
||||
onClick="controller.goToEditForm(self.parent.parent.value);">
|
||||
</button>
|
||||
|
||||
<button sclass="icono" image="/common/img/ico_borrar1.png"
|
||||
hoverImage="/common/img/ico_borrar.png"
|
||||
tooltiptext="${i18n:_('Delete')}"
|
||||
onClick="controller.confirmRemove(self.parent.parent.value);"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue