fixed bug with detecting whether form has emails for config panel
This commit is contained in:
parent
19880b0d07
commit
983d2ce20b
|
@ -11,7 +11,8 @@ var mongoose = require('mongoose'),
|
|||
diff = require('deep-diff'),
|
||||
_ = require('lodash'),
|
||||
nodemailer = require('nodemailer'),
|
||||
emailNotifications = require('../libs/send-email-notifications');
|
||||
emailNotifications = require('../libs/send-email-notifications'),
|
||||
constants = require('../libs/constants');
|
||||
|
||||
var smtpTransport = nodemailer.createTransport(config.mailer.options);
|
||||
|
||||
|
@ -85,7 +86,7 @@ exports.createSubmission = function(req, res) {
|
|||
|
||||
form.selfNotifications.from = formFieldDict[form.selfNotifications.fromField].fieldValue;
|
||||
|
||||
emailNotifications.send(form.selfNotifications, formFieldDict, smtpTransport, function(err){
|
||||
emailNotifications.send(form.selfNotifications, formFieldDict, smtpTransport, constants.varFormat, function(err){
|
||||
if (!err) {
|
||||
return res.status(200).send('Form submission successfully saved');
|
||||
}
|
||||
|
|
|
@ -75,5 +75,7 @@ module.exports = {
|
|||
url: /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)/,
|
||||
hexCode: /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,
|
||||
email: /^(([^<>()\[\]\\.,;:\s@']+(\.[^<>()\[\]\\.,;:\s@']+)*)|('.+'))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
||||
}
|
||||
},
|
||||
|
||||
varFormat: ['${', '}'],
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
module.exports = {
|
||||
send: function(emailSettings, emailTemplateVars, smtpTransport, cb){
|
||||
send: function(emailSettings, emailTemplateVars, smtpTransport, varFormat, cb){
|
||||
var parsedTemplate = parseTemplate(emailSettings.htmlTemplate, emailTemplateVars);
|
||||
var parsedSubject = parseTemplate(emailSettings.body, emailTemplateVars);
|
||||
var mailOptions = {
|
||||
|
@ -12,7 +12,7 @@ module.exports = {
|
|||
smtpTransport.sendMail(mailOptions, cb);
|
||||
},
|
||||
|
||||
parseTemplate: function(emailTemplate, emailAttrs){
|
||||
parseTemplate: function(emailTemplate, emailAttrs, varFormat){
|
||||
var resolvedTemplate = emailTemplate;
|
||||
Object.keys(emailAttrs).forEach(function (key) {
|
||||
resolvedTemplate = replaceTemplateVal(key, emailAttrs[key], resolvedTemplate);
|
||||
|
@ -20,7 +20,7 @@ module.exports = {
|
|||
return resolvedTemplate;
|
||||
},
|
||||
|
||||
replaceTemplateVal: function(key, val, template){
|
||||
return template.replace( new RegExp('${' + key + '}', 'g'), value )
|
||||
replaceTemplateVal: function(key, val, template, varFormat){
|
||||
return template.replace( new RegExp(varFormat[0] + key + varFormat[1], 'g'), value )
|
||||
}
|
||||
}
|
|
@ -36,7 +36,9 @@ angular.module('forms').directive('configureFormDirective', ['$rootScope', '$fil
|
|||
return field.fieldType === 'email';
|
||||
});
|
||||
|
||||
$scope.formHasEmailField = ($rootScope.emailFields > 0);
|
||||
console.log($rootScope.emailFields);
|
||||
|
||||
$scope.formHasEmailField = ($rootScope.emailFields.length > 0);
|
||||
|
||||
$scope.go = function(tab){
|
||||
tab.active = true;
|
||||
|
|
Loading…
Reference in a new issue