got basic email templating to work

This commit is contained in:
David Baldwynn 2017-11-01 16:44:05 -07:00
parent 9faa514ce9
commit 33368f016c
14 changed files with 82 additions and 87 deletions

View file

@ -82,8 +82,7 @@ exports.createSubmission = function(req, res) {
async.waterfall([
function(callback) {
if (form.selfNotifications && form.selfNotifications.enabled && form.selfNotifications.fromField) {
form.selfNotifications.fromEmails = formFieldDict[form.selfNotifications.fromField].fieldValue;
form.selfNotifications.fromEmails = formFieldDict[form.selfNotifications.fromField];
emailNotifications.send(form.selfNotifications, formFieldDict, smtpTransport, constants.varFormat, function(err){
if(err){
@ -101,7 +100,7 @@ exports.createSubmission = function(req, res) {
function(callback) {
if (form.respondentNotifications && form.respondentNotifications.enabled && form.respondentNotifications.toField) {
form.selfNotifications.toEmails = formFieldDict[form.selfNotifications.toField].fieldValue;
form.selfNotifications.toEmails = formFieldDict[form.selfNotifications.toField];
emailNotifications.send(form.selfNotifications, formFieldDict, smtpTransport, constants.varFormat, function(err){
if(err){

View file

@ -4,10 +4,11 @@ const constants = require('./constants');
module.exports = {
send: function(emailSettings, emailTemplateVars, smtpTransport, varFormat, cb){
var parsedTemplate = this.parseTemplate(emailSettings.htmlTemplate, emailTemplateVars);
var parsedSubject = this.parseTemplate(emailSettings.body, emailTemplateVars);
var parsedTemplate = this.parseTemplate(emailSettings.htmlTemplate, emailTemplateVars, varFormat);
var parsedSubject = this.parseTemplate(emailSettings.subject, emailTemplateVars, varFormat);
var mailOptions = {
from: emailSettings.fromEmails,
replyTo: emailSettings.fromEmails,
from: 'noreply@tellform.com',
cc: emailSettings.toEmails,
subject: parsedSubject,
html: parsedTemplate
@ -32,8 +33,8 @@ module.exports = {
createFieldDict: function(form_fields){
var formFieldDict = {};
form_fields.forEach(function(field){
if(field.hasOwnProperty('_id') && field.hasOwnProperty('fieldValue')){
formFieldDict[field._id] = field.fieldValue;
if(field.hasOwnProperty('globalId') && field.hasOwnProperty('fieldValue')){
formFieldDict[field.globalId] = field.fieldValue;
}
});
return formFieldDict;

View file

@ -158,7 +158,7 @@ var FormSchema = new Schema({
selfNotifications: {
fromField: {
type: Schema.Types.ObjectId,
type: String
},
toEmails: {
type: String
@ -177,7 +177,7 @@ var FormSchema = new Schema({
respondentNotifications: {
toField: {
type: Schema.Types.ObjectId,
type: String
},
fromEmails: {
type: String,
@ -250,10 +250,6 @@ FormSchema.virtual('analytics.views').get(function () {
}
});
FormSchema.virtual('analytics.submissions').get(function () {
return this.submissions.length;
});
FormSchema.virtual('analytics.conversionRate').get(function () {
if(this.analytics && this.analytics.visitors && this.analytics.visitors.length > 0){
return this.submissions.length/this.analytics.visitors.length*100;

View file

@ -985,17 +985,6 @@ angular.module('view-form').directive('submitFormDirective', ["$http", "TimeCoun
if($scope.myform.form_fields[i].fieldType === 'dropdown' && !$scope.myform.form_fields[i].deletePreserved){
$scope.myform.form_fields[i].fieldValue = $scope.myform.form_fields[i].fieldValue.option_value;
}
//Get rid of unnessecary attributes for each form field
delete form.form_fields[i].submissionId;
delete form.form_fields[i].disabled;
delete form.form_fields[i].ratingOptions;
delete form.form_fields[i].fieldOptions;
delete form.form_fields[i].logicJump;
delete form.form_fields[i].description;
delete form.form_fields[i].validFieldTypes;
delete form.form_fields[i].fieldType;
}
setTimeout(function () {

File diff suppressed because one or more lines are too long

View file

@ -16,13 +16,19 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
CANCEL: 'Cancel',
DISPLAY_START_PAGE: 'Display Start Page?',
DISPLAY_END_PAGE: 'Display Custom End Page?',
ENABLE_EMAIL_NOTIFICATIONS: 'Enable Email Notifications',
EMAIL_NOTIFICATION_RECIPIENTS: 'Email Notification Recipients',
GENERAL_TAB: 'General',
SELF_NOTIFICATIONS_TAB: 'Self notifications',
RESPONDENT_NOTIFICATIONS_TAB: 'Respondent notifications',
//Self Notifications Tab
SEND_NOTIFICATION_TO: 'Send to',
NO_EMAIL_FIELD_WARNING: 'Error: You need an email field in your form to send the email to your form respondent',
REPLY_TO: 'Reply to',
EMAIL_SUBJECT: 'Subject',
EMAIL_MESSAGE: 'Message',
ENABLE_RESPONDENT_NOTIFICATIONS: 'Respondent Notifications are currently',
ENABLE_SELF_NOTIFICATIONS: 'Respondent Notifications are currently',
TOGGLE_ENABLED: 'Enabled',
TOGGLE_DISABLED: 'Disabled',
ADD_VARIABLE_BUTTON: 'Add variable',
//List Forms View

View file

@ -15,12 +15,22 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
CANCEL: 'Annuler',
DISPLAY_START_PAGE: "Afficher la page de démarrage?",
DISPLAY_END_PAGE: "Afficher la page de fin personnalisée?",
ENABLE_EMAIL_NOTIFICATIONS: 'Enable Email Notifications',
EMAIL_NOTIFICATION_RECIPIENTS: 'Email Notification Recipients',
GENERAL_TAB: 'General',
SELF_NOTIFICATIONS_TAB: 'Self notifications',
RESPONDANT_NOTIFICATIONS_TAB: 'Respondent notifications',
SEND_NOTIFICATION_TO: 'Envoyer à',
NO_EMAIL_FIELD_WARNING: 'Erreur: Vous avez besoin d\'un champ e-mail dans votre formulaire pour envoyer l\'e-mail au répondant de votre formulaire',
REPLY_TO: "Répondre à",
EMAIL_SUBJECT: 'Sujet',
EMAIL_MESSAGE: "Message",
ENABLE_RESPONDENT_NOTIFICATIONS: 'Les notifications des répondants sont actuellement',
ENABLE_SELF_NOTIFICATIONS: "Les notifications des répondants sont actuellement",
TOGGLE_ENABLED: 'Activé',
TOGGLE_DISABLED: 'Désactivé',
ADD_VARIABLE_BUTTON: "Ajouter une variable",
// Afficher les formulaires
CREATE_A_NEW_FORM: "Créer un nouveau formulaire",
CREATE_FORM: "Créer un formulaire",

View file

@ -15,12 +15,22 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
CANCEL: 'Abbrechen',
DISPLAY_START_PAGE: 'Startseite anzeigen?',
DISPLAY_END_PAGE: 'Benutzerdefinierte Endseite anzeigen?',
ENABLE_EMAIL_NOTIFICATIONS: 'E-Mail-Benachrichtigungen aktivieren',
EMAIL_NOTIFICATION_RECIPIENTS: 'E-Mail-Benachrichtigungsempfänger',
GENERAL_TAB: 'Allgemein',
SELF_NOTIFICATIONS_TAB: 'Selbstbenachrichtigungen',
RESPONDANT_NOTIFICATIONS_TAB: 'Beantwortungsbenachrichtigungen',
SEND_NOTIFICATION_TO: 'Senden an',
NO_EMAIL_FIELD_WARNING: 'Fehler: Sie benötigen ein E-Mail-Feld in Ihrem Formular, um die E-Mail an Ihr Formular zu senden.',
REPLY_TO: 'Antworten auf',
EMAIL_SUBJECT: "Betreff",
EMAIL_MESSAGE: 'Nachricht',
ENABLE_RESPONDENT_NOTIFICATIONS: 'Antwortbenachrichtigungen sind derzeit',
ENABLE_SELF_NOTIFICATIONS: 'Antwortbenachrichtigungen sind derzeit',
TOGGLE_ENABLED: 'Aktiviert',
TOGGLE_DISABLED: 'Deaktiviert',
ADD_VARIABLE_BUTTON: 'Variable hinzufügen',
// Listenformularansicht
CREATE_A_NEW_FORM: 'Erstelle ein neues Formular',
CREATE_FORM: 'Formular erstellen',

View file

@ -15,12 +15,22 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
CANCEL: 'Annulla',
DISPLAY_START_PAGE: 'Visualizza pagina iniziale?',
DISPLAY_END_PAGE: 'Mostra pagina finale personalizzata?',
ENABLE_EMAIL_NOTIFICATIONS: 'Attiva notifiche e-mail',
EMAIL_NOTIFICATION_RECIPIENTS: 'Destinatari di notifica e-mail',
GENERAL_TAB: 'Generale',
SELF_NOTIFICATIONS_TAB: 'Autodiagnosi',
RESPONDANT_NOTIFICATIONS_TAB: 'Notifiche rispondenti',
SEND_NOTIFICATION_TO: 'Invia a',
NO_EMAIL_FIELD_WARNING: 'Errore: Hai bisogno di un campo e-mail nel tuo modulo per inviare l\'email al tuo interlocutore',
REPLY_TO: 'Rispondi a',
EMAIL_SUBJECT: 'Oggetto',
EMAIL_MESSAGE: 'Messaggio',
ENABLE_RESPONDENT_NOTIFICATIONS: 'Notifiche rispondenti sono attualmente',
ENABLE_SELF_NOTIFICATIONS: 'Notifiche rispondenti sono attualmente',
TOGGLE_ENABLED: 'Abilitato',
TOGGLE_DISABLED: 'disabilitato',
ADD_VARIABLE_BUTTON: 'Aggiungi variabile',
// Visualizzazione dei moduli di elenco
CREATE_A_NEW_FORM: 'Crea un nuovo modulo',
CREATE_FORM: 'Crea modulo',

View file

@ -16,11 +16,21 @@ angular.module('forms').config(['$translateProvider', function ($translateProvid
CANCEL: 'Cancelar',
DISPLAY_START_PAGE: '¿Mostrar página de inicio?',
DISPLAY_END_PAGE: '¿Mostrar paǵina de fin?',
ENABLE_EMAIL_NOTIFICATIONS: 'Habilitar notificaciones por correo electrónico',
EMAIL_NOTIFICATION_RECIPIENTS: 'Destinatarios de notificación de correo electrónico',
GENERAL_TAB: 'General',
SELF_NOTIFICATIONS_TAB: 'Auto notificaciones',
RESPONDANT_NOTIFICATIONS_TAB: 'Notificaciones de los demandados',
GENERAL_TAB: 'Général',
SEND_NOTIFICATION_TO: 'Enviar a',
NO_EMAIL_FIELD_WARNING: 'Error: necesita un campo de correo electrónico en su formulario para enviar el correo electrónico a su encuestado',
REPLY_TO: 'Responder a',
EMAIL_SUBJECT: 'Asunto',
EMAIL_MESSAGE: 'Mensaje',
ENABLE_RESPONDENT_NOTIFICATIONS: 'Las notificaciones de los demandados son actualmente',
ENABLE_SELF_NOTIFICATIONS: 'Las notificaciones de los demandados son actualmente',
TOGGLE_ENABLED: 'Habilitado',
TOGGLE_DISABLED: 'Desactivado',
ADD_VARIABLE_BUTTON: 'Agregar variable',
//List Forms View
CREATE_A_NEW_FORM: 'Crear formulario',

View file

@ -37,42 +37,6 @@
</div>
</div>
<div class="row field">
<div class="field-title col-sm-12">
<h5>{{ 'ENABLE_EMAIL_NOTIFICATIONS' | translate }}</h5>
</div>
<div class="field-input col-sm-12">
<label style="display: inline-block;">
<input type="radio" data-ng-value="true" ng-model="myform.emailNotifications.enabled" ng-required="true" style="background-color:#33CC00;"/>
&nbsp;<span>{{ 'YES' | translate }}</span>
</label>
<label style="display: inline-block;">
<input type="radio" data-ng-value="false" ng-model="myform.emailNotifications.enabled" ng-required="true" />
&nbsp;<span>{{ 'NO' | translate }}</span>
</label>
</div>
</div>
<div class="row field" ng-if="myform.emailNotifications.enabled">
<div class="field-title col-sm-12">
<h5>{{ 'EMAIL_NOTIFICATION_RECIPIENTS' | translate }}</h5>
</div>
<div class="col-sm-12">
<input class="form-control"
type="text"
ng-model="myform.emailNotifications.recipients"
value="{{myform.emailNotifications.recipients}}"
style="width: 100%;"
placeholder="email@domain.com,email2@domain2.com,etc">
</div>
</div>
<div class="row field">
<div class="col-sm-12 field-title">{{ 'LANGUAGE' | translate }}</div>
<div class="col-sm-12 field-input">

View file

@ -2,7 +2,7 @@
<div class="col-sm-offset-2">
<div class="row field" ng-if="formHasEmailField">
<div class="field-title col-sm-12">
<h5>{{ 'SEND_NOTIFICATION_TO' | translate }}</h5>
<h5>{{ 'SEND_NOTIFICATION_TO' | translate }}:</h5>
</div>
<div class="col-xs-12 field-input">
@ -14,7 +14,7 @@
ng-required="true">
<ui-select-match placeholder="{{ 'OPTION_PLACEHOLDER' | translate }}">
</ui-select-match>
<ui-select-choices repeat="field in emailFields | filter: $select.search" ng-class="{'active': field._id === myform.respondentNotifications.toField }">
<ui-select-choices repeat="field.globalId as field in emailFields | filter: $select.search">
<span ng-bind-html="field.title | highlight: $select.search">
</span>
</ui-select-choices>
@ -28,7 +28,7 @@
<div class="row field">
<div class="field-title col-xs-12">
<h5>{{ 'REPLY_TO' | translate }}</h5>
<h5>{{ 'REPLY_TO' | translate }}:</h5>
</div>
<div class="col-xs-12 field-input">
@ -41,7 +41,7 @@
<div class="row field">
<div class="field-title col-sm-12">
<h5>{{ 'EMAIL_SUBJECT' | translate }}</h5>
<h5>{{ 'EMAIL_SUBJECT' | translate }}:</h5>
</div>
<div class="col-sm-12">
<text-angular class="email-subject" ng-model="myform.respondentNotifications.subject" ta-toolbar="[['insertField']]" ta-default-wrap="n"></text-angular>
@ -60,19 +60,19 @@
<div class="row field">
<div class="field-title col-sm-12">
<h5>{{ 'ENABLE_RESPONDENT_NOTIFICATIONS' | translate }}</h5>
<h5>{{ 'ENABLE_RESPONDENT_NOTIFICATIONS' | translate }}:</h5>
</div>
<div class="field-input col-sm-12">
<label style="display: inline-block;">
<input type="radio" data-ng-value="true" ng-model="myform.respondentNotifications.enabled" ng-required="true" style="background-color:#33CC00;"/>
&nbsp;<span>{{ 'YES' | translate }}</span>
&nbsp;<span>{{ 'ENABLED' | translate }}</span>
</label>
<label style="display: inline-block;">
<input type="radio" data-ng-value="false" ng-model="myform.respondentNotifications.enabled" ng-required="true" />
&nbsp;<span>{{ 'NO' | translate }}</span>
&nbsp;<span>{{ 'DISABLED' | translate }}</span>
</label>
</div>

View file

@ -26,8 +26,9 @@
set-search-to-answer="true"
ng-required="true">
<ui-select-match placeholder="{{ 'OPTION_PLACEHOLDER' | translate }}">
{{$select.selected.title}}
</ui-select-match>
<ui-select-choices repeat="field in emailFields | filter: $select.search" ng-class="{'active': field._id === myform.selfNotifications.fromField }">
<ui-select-choices repeat="field.globalId as field in $root.emailFields | filter: { title: $select.search }">
<span ng-bind-html="field.title | highlight: $select.search">
</span>
</ui-select-choices>
@ -42,7 +43,6 @@
<div class="col-sm-12">
<text-angular class="email-subject" ng-model="myform.selfNotifications.subject" ta-toolbar="[['insertField']]" ta-default-wrap="n"></text-angular>
<div ng-bind="myform.selfNotifications.subject"></div>
</div>
</div>
@ -65,12 +65,12 @@
<label style="display: inline-block;">
<input type="radio" data-ng-value="true" ng-model="myform.selfNotifications.enabled" ng-required="true" style="background-color:#33CC00;"/>
&nbsp;<span>{{ 'YES' | translate }}</span>
&nbsp;<span>{{ 'ENABLED' | translate }}</span>
</label>
<label style="display: inline-block;">
<input type="radio" data-ng-value="false" ng-model="myform.selfNotifications.enabled" ng-required="true" />
&nbsp;<span>{{ 'NO' | translate }}</span>
&nbsp;<span>{{ 'DISABLED' | translate }}</span>
</label>
</div>

View file

@ -51,11 +51,11 @@ angular.module('forms').run(['Menus',
taRegisterTool('insertField', {
display: '<div class="dropdown" uib-dropdown is-open="isopen">\
<div class="dropdown-toggle" ng-disabled="isDisabled()" uib-dropdown-toggle>\
<span>{{ "ADD_A_VARIABLE" | translate }}</span>\
<span>{{ "ADD_VARIABLE_BUTTON" | translate }}</span>\
<b class="caret"></b>\
</div>\
<ul class="dropdown-menu">\
<li ng-repeat="field in $root.myform.form_fields" ng-click="onClickField(field._id, field.title)">\
<li ng-repeat="field in $root.myform.form_fields" ng-click="onClickField(field.globalId, field.title)">\
{{field.title}}\
</li>\
</ul>\