[Bug #928] Add a button in the template list to allow deleting templates.
Allow deleting templates if it has not any applications. FEA : ItEr72S04BugFixing
This commit is contained in:
parent
936a8c7766
commit
cf2b729f5d
4 changed files with 56 additions and 0 deletions
|
|
@ -68,4 +68,8 @@ public interface IOrderTemplatesModel {
|
|||
Map<CriterionType, List<Criterion>> getMapCriterions();
|
||||
|
||||
Scenario getCurrentScenario();
|
||||
|
||||
void confirmDelete(OrderElementTemplate template);
|
||||
|
||||
boolean hasNotApplications(OrderElementTemplate template);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,8 +55,10 @@ import org.zkoss.zk.ui.event.EventListener;
|
|||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.util.GenericForwardComposer;
|
||||
import org.zkoss.zul.Constraint;
|
||||
import org.zkoss.zul.Grid;
|
||||
import org.zkoss.zul.Image;
|
||||
import org.zkoss.zul.Label;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.Textbox;
|
||||
import org.zkoss.zul.Tree;
|
||||
|
|
@ -339,4 +341,33 @@ public class OrderTemplatesController extends GenericForwardComposer implements
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pop up confirm remove dialog
|
||||
* @param OrderTemplate
|
||||
*/
|
||||
public void confirmDelete(OrderElementTemplate template) {
|
||||
try {
|
||||
if (Messagebox.show(_("Delete order template. Are you sure?"),
|
||||
_("Confirm"),
|
||||
Messagebox.OK | Messagebox.CANCEL, Messagebox.QUESTION) == Messagebox.OK) {
|
||||
if (this.model.hasNotApplications(template)) {
|
||||
this.model.confirmDelete(template);
|
||||
Grid gridOrderTemplates = (Grid) listWindow
|
||||
.getFellowIfAny("listing");
|
||||
if (gridOrderTemplates != null) {
|
||||
Util.reloadBindings(gridOrderTemplates);
|
||||
}
|
||||
} else {
|
||||
messagesForUser
|
||||
.showMessage(
|
||||
Level.ERROR,
|
||||
_("This template can not be removed because it has applications."));
|
||||
}
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import java.util.Set;
|
|||
import org.navalplanner.business.advance.entities.AdvanceAssignmentTemplate;
|
||||
import org.navalplanner.business.common.IAdHocTransactionService;
|
||||
import org.navalplanner.business.common.IOnTransaction;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.labels.daos.ILabelDAO;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.orders.daos.IOrderDAO;
|
||||
|
|
@ -319,4 +320,20 @@ public class OrderTemplatesModel implements IOrderTemplatesModel {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void confirmDelete(OrderElementTemplate template) {
|
||||
try {
|
||||
dao.remove(template.getId());
|
||||
} catch (InstanceNotFoundException e) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public boolean hasNotApplications(OrderElementTemplate template) {
|
||||
getOrderElementsOnConversation().initialize(template);
|
||||
return getOrderElementsOnConversation().getOrderElements().isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,10 @@
|
|||
tooltiptext="${i18n:_('Edit')}"
|
||||
onClick="templatesForOrdersController.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="templatesForOrdersController.confirmDelete(self.parent.parent.value);"/>
|
||||
</hbox>
|
||||
</row>
|
||||
</rows>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue