use of io.jmix.emailtemplates.entity.ReportEmailTemplate in project jmix by jmix-framework.
the class ReportEmailTemplateEdit method onPreCommit.
@Subscribe(target = Target.DATA_CONTEXT)
protected void onPreCommit(DataContext.PreCommitEvent event) {
TemplateReport templateReport = emailBodyReportDc.getItemOrNull();
if (entityStates.isNew(getEditedEntity())) {
if (templateReport != null) {
event.getSource().merge(templateReport);
}
} else {
ReportEmailTemplate original = dataManager.load(ReportEmailTemplate.class).id(getEditedEntity().getId()).fetchPlan("emailTemplate-fetchPlan").one();
TemplateReport originalEmailBodyReport = original.getEmailBodyReport();
if (originalEmailBodyReport != null && !originalEmailBodyReport.equals(templateReport)) {
event.getSource().remove(originalEmailBodyReport);
}
}
}
Aggregations