Uploaded image for project: 'InvoicePlane'
  1. InvoicePlane
  2. IP-627

eMail tempalte won't import if there is a <style> (fix apported)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: v1.5.5
    • Fix Version/s: None
    • Component/s: Email, Templates
    • Labels:
      None

      Description

      I've noticed email templates will not be imported any time a style element was present, I searached the forum for a solution but none was found so I started debuging by myself and fixed it.

      The problem was in file:

      /assets/core/js/scripts.js

      /assets/core/js/scripts.min.js

       

      In the next function was used the jquery ".html" instead of ".text". The first one parses html code the second just insert it and that's what is needed in this case.

       

      function inject_email_template(template_fields, email_template) {
          $.each(email_template, function (key, val) {
              // remove prefix from key
              key = key.replace("email_template_", "");
              // if key is in template_fields, apply value to form field
              if (val && template_fields.indexOf(key) > -1) {
                  if (key === 'body') {
                      $("#" + key).html(val);
                  } else {
                      $("#" + key).val(val);
                  }
              }
          });
      }

      The solution is as simple as changing it

      function inject_email_template(template_fields, email_template) {
          $.each(email_template, function (key, val) {
              // remove prefix from key
              key = key.replace("email_template_", "");
              // if key is in template_fields, apply value to form field
              if (val && template_fields.indexOf(key) > -1) {
                  if (key === 'body') {
                      $("#" + key).text(val);
                  } else {
                      $("#" + key).val(val);
                  }
              }
          });
      }

      PD: First post ever using this platform, hope did notthing wrong.

        Gliffy Diagrams

          Attachments

            Issue Links

              Structure

                Activity

                  People

                  • Assignee:
                    Unassigned
                    Reporter:
                    skilpadden Skilpadden
                  • Votes:
                    0 Vote for this issue
                    Watchers:
                    3 Start watching this issue

                    Dates

                    • Created:
                      Updated:
                      Resolved:

                      Structure Helper Panel