From b2eafd07c33c52b73f026f8efaed97083ae349fd Mon Sep 17 00:00:00 2001 From: William Woodson Date: Sun, 21 Feb 2016 11:13:28 -0600 Subject: [PATCH] Updated new campaigns modal, send test email modal, and js to use sending profile --- static/js/app/campaigns.js | 53 +++++++++++++++++++++++++++++++------- templates/campaigns.html | 35 +++++-------------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/static/js/app/campaigns.js b/static/js/app/campaigns.js index d12d4736..0ac1e4ed 100644 --- a/static/js/app/campaigns.js +++ b/static/js/app/campaigns.js @@ -31,11 +31,7 @@ function launch() { name: $("#page").val() }, smtp: { - from_address: $("input[name=from]").val(), - host: $("input[name=host]").val(), - username: $("input[name=username]").val(), - password: $("input[name=password]").val(), - ignore_cert_errors: $("#ignore_cert_errors").prop("checked") + name: $("#profile").val() }, groups: groups } @@ -70,11 +66,7 @@ function sendTestEmail() { name: $("#page").val() }, smtp: { - from_address: $("input[name=from]").val(), - host: $("input[name=host]").val(), - username: $("input[name=username]").val(), - password: $("input[name=password]").val(), - ignore_cert_errors: $("#ignore_cert_errors").prop("checked") + name: $("#profile").val() } } btnHtml = $("#sendTestModalSubmit").html() @@ -114,6 +106,7 @@ function edit(campaign) { group_bh.clear(); template_bh.clear(); page_bh.clear(); + profile_bh.clear(); if (campaign == "new") { api.groups.get() .success(function(groups) { @@ -142,6 +135,15 @@ function edit(campaign) { page_bh.add(pages) } }) + api.SMTP.get() + .success(function(profiles) { + if (profiles.length == 0){ + modalError("No profiles found!") + return false + } else { + profile_bh.add(profiles) + } + }) } } @@ -330,4 +332,35 @@ $(document).ready(function() { .bind('typeahead:autocomplete', function(ev, page) { $("#page").typeahead('val', page.name) }); + // Create the sending profile typeahead objects + profile_bh = new Bloodhound({ + datumTokenizer: function(s) { + return Bloodhound.tokenizers.whitespace(s.name) + }, + queryTokenizer: Bloodhound.tokenizers.whitespace, + local: [] + }) + profile_bh.initialize() + $("#profile.typeahead.form-control").typeahead({ + hint: true, + highlight: true, + minLength: 1 + }, { + name: "profiles", + source: profile_bh, + templates: { + empty: function(data) { + return '
No profiles matched that query
' + }, + suggestion: function(data) { + return '
' + data.name + '
' + } + } + }) + .bind('typeahead:select', function(ev, profile) { + $("#profile").typeahead('val', profile.name) + }) + .bind('typeahead:autocomplete', function(ev, profile) { + $("#profile").typeahead('val', profile.name) + }); }) diff --git a/templates/campaigns.html b/templates/campaigns.html index 4d4bfecc..6e65dbba 100644 --- a/templates/campaigns.html +++ b/templates/campaigns.html @@ -81,34 +81,13 @@
-
-
- -
-
- - -
- - -
- - -
- - -
- - -
- -
-
-
+ +
+ + + + +