Skip to content

Commit

Permalink
Add personal message to sent email as taken from UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
tremulaes committed Apr 27, 2015
1 parent 51ce356 commit e3fce0e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/application/routers/users.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class App.Routers.Users extends App.Router
emailHistory = new App.Models.EmailHistory id: username
user.fetch().done ->
emailHistory.fetch().done ->
console.log(emailHistory)
view = new App.Views.Users.Edit(model: user, emailHistory: emailHistory)
$('.main-container').html(view.el)
view.render()
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</fieldset>
<fieldset>
<label for="email-personal-message" class="col-xs-12">Include a personal message!</label>
<textarea class="col-xs-12" name="email-personal-message" id='send-email-message' rows="3"></textarea>
<textarea class="col-xs-12" name="email-personal-message" id='send-email-personal-message' rows="3"></textarea>
</fieldset>
<fieldset>
<input type="submit" id="send_email" value="Send Link">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class App.Views.Users.Edit extends App.View
form = @$el.find "#mailer_form"
username = $('body').attr('id')
address = $('#send-email-address').val();
window.sendEmail(address, username)
message = $('#send-email-personal-message').val();
window.sendEmail(address, username, message)
error = ->
$(form + ' .message').html("<span class='error'>There was an issue and no email was sent.</span>")
success = ->
Expand Down
6 changes: 4 additions & 2 deletions app/assets/javascripts/email.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
function sendEmail(address, username) {
function sendEmail(address, username, message) {
$.ajax({
url: 'email',
data: {email: address, username: username},
data: {email: address, username: username, message: message},
type: 'POST'
}).done(function(data){
$('#send_email').attr('disabled', false)
$('#send_email').val('Submit')
$("#send-email-address").val("")
$("#send-email-personal-message").val("")
$('#send-email-message').html("Your email has been successfully sent!")
$('.email-history-list').append("<li>" + data.email + " on " + data.date + ".</li>")
}).fail(function(data){
$('#send_email').attr('disabled', false)
$('#send_email').val('Submit')
$("#send-email-address").val("")
$("#send-email-personal-message").val("")
$('#send-email-message').html("There was an error and your email was not able to be sent. Please try again shortly.")
})
}
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/githubAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ var getGitHubData = function(username){
}
reposData.allLang = allLang;
reposData.allStars = allStars;
console.log(reposData)
return reposData
}

Expand Down
1 change: 1 addition & 0 deletions app/mailers/user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class UserMailer < ApplicationMailer

def share_email(params)
@user = User.find_by(username: params[:username])
@message = params[:message]
@url = "https://devolio.herokuapp.com/#{@user.username}"
mail(to: params[:email], subject: "#{@user.name} would like to share their Devolio!")
@user.email_histories.create(recipient: params[:email], date: DateTime.now)
Expand Down
3 changes: 3 additions & 0 deletions app/views/user_mailer/share_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
<body>
<h3>Hello!</h3>
<p><%= @user.name %> would like to share their Devolio with you!</p>
<% if @message %>
<p><%= @message %></p>
<% end %>
<p>DEVOLIO merges personal resume information with a user's GitHub account activity to quickly and easily produce an attractive, informative job search profile. Additionally, the dev community is centralized around Twitter, so a user can also show their Twitter stream on the same profile page.</p>
<p>Simply <a href='<%= @url %>'>follow this link</a> to check it out!</p>
<p>Sincerely,</p>
Expand Down

0 comments on commit e3fce0e

Please sign in to comment.