Search in sources :

Example 1 with EmailTemplate

use of io.jmix.emailtemplates.entity.EmailTemplate in project jmix by jmix-framework.

the class EmailTemplateBuilderImpl method cloneTemplate.

protected EmailTemplate cloneTemplate(EmailTemplate emailTemplate) {
    EmailTemplate clonedTemplate = metadataTools.deepCopy(emailTemplate);
    if (clonedTemplate instanceof JsonEmailTemplate) {
        clonedTemplate.setEmailBodyReport(emailTemplate.getEmailBodyReport());
        ((JsonEmailTemplate) clonedTemplate).setReport(emailTemplate.getReport());
    }
    List<TemplateReport> attachedTemplateReports = new ArrayList<>();
    List<TemplateReport> templateAttachedTemplateReports = emailTemplate.getAttachedTemplateReports();
    if (templateAttachedTemplateReports != null) {
        for (TemplateReport templateReport : templateAttachedTemplateReports) {
            TemplateReport newTemplateReport = metadataTools.deepCopy(templateReport);
            attachedTemplateReports.add(newTemplateReport);
        }
    }
    clonedTemplate.setAttachedTemplateReports(attachedTemplateReports);
    return clonedTemplate;
}
Also used : JsonEmailTemplate(io.jmix.emailtemplates.entity.JsonEmailTemplate) ArrayList(java.util.ArrayList) JsonEmailTemplate(io.jmix.emailtemplates.entity.JsonEmailTemplate) EmailTemplate(io.jmix.emailtemplates.entity.EmailTemplate) TemplateReport(io.jmix.emailtemplates.entity.TemplateReport)

Example 2 with EmailTemplate

use of io.jmix.emailtemplates.entity.EmailTemplate in project jmix by jmix-framework.

the class EmailTemplateBrowse method onSendEmailClick.

protected void onSendEmailClick() {
    EmailTemplate template = emailTemplatesTable.getSingleSelected();
    if (template != null) {
        template = dataManager.load(EmailTemplate.class).id(template.getId()).fetchPlan("emailTemplate-fetchPlan").optional().orElse(null);
        screens.create(EmailTemplateSendScreen.class, OpenMode.DIALOG, new MapScreenOptions(ParamsMap.of("emailTemplate", template))).show();
    }
}
Also used : EmailTemplateSendScreen(io.jmix.emailtemplatesui.screen.emailtemplate.send.EmailTemplateSendScreen) JsonEmailTemplate(io.jmix.emailtemplates.entity.JsonEmailTemplate) ReportEmailTemplate(io.jmix.emailtemplates.entity.ReportEmailTemplate) EmailTemplate(io.jmix.emailtemplates.entity.EmailTemplate)

Aggregations

EmailTemplate (io.jmix.emailtemplates.entity.EmailTemplate)2 JsonEmailTemplate (io.jmix.emailtemplates.entity.JsonEmailTemplate)2 ReportEmailTemplate (io.jmix.emailtemplates.entity.ReportEmailTemplate)1 TemplateReport (io.jmix.emailtemplates.entity.TemplateReport)1 EmailTemplateSendScreen (io.jmix.emailtemplatesui.screen.emailtemplate.send.EmailTemplateSendScreen)1 ArrayList (java.util.ArrayList)1