Search in sources :

Example 1 with ReportEmailTemplate

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);
        }
    }
}
Also used : ReportEmailTemplate(io.jmix.emailtemplates.entity.ReportEmailTemplate) TemplateReport(io.jmix.emailtemplates.entity.TemplateReport)

Aggregations

ReportEmailTemplate (io.jmix.emailtemplates.entity.ReportEmailTemplate)1 TemplateReport (io.jmix.emailtemplates.entity.TemplateReport)1