Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added message and disabled the dropdown in email view when no participants are present #65

Merged
merged 4 commits into from Jul 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js.coffee
Expand Up @@ -15,6 +15,7 @@
#= require bootstrap
#= require cocoon
#= require additional
#= require event_emails
#

window.init_page = ->
Expand Down
11 changes: 11 additions & 0 deletions app/assets/javascripts/event_emails.js.coffee
@@ -0,0 +1,11 @@
if $('#select_recp').data('users')
$('#select_recp').prop("disabled", true)

fill_email_to = (state) ->
$('#state'+state).click ->
users = $('#state'+state).data('users')
$('#event_email_to').val(users)
if users.length == 0
$('#event_email_to').attr('placeholder', 'No recipients present for ' + state + ' state')

fill_email_to state for state in ['All', 'Accepted', 'Incomplete', 'Submitted', 'Approved', 'Cancel']
25 changes: 5 additions & 20 deletions app/views/event_emails/new.html.haml
@@ -1,35 +1,20 @@
.col-md-10
%h2 Email the participants of #{@event.name}
.dropdown.pull-right
%button#select_recp.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button"}
%button#select_recp.btn.btn-default.dropdown-toggle{"aria-expanded" => "true", "aria-haspopup" => "true", "data-toggle" => "dropdown", :type => "button", "data-users" => "#{users_for_event('all').empty?}"}
Select recipients
%span.caret
%ul.dropdown-menu{"aria-labelledby" => "select_recp"}
%li
%a{:onclick => "user_email(#{users_for_event('all')})"} All
%li
%a{:onclick => "user_email(#{users_for_event('accepted')})"} Accepted
%li
%a{:onclick => "user_email(#{users_for_event('incomplete')})"} Incomplete
%li
%a{:onclick => "user_email(#{users_for_event('submitted')})"} Submitted
%li
%a{:onclick => "user_email(#{users_for_event('approved')})"} Approved
%li
%a{:onclick => "user_email(#{users_for_event('canceled')})"} Cancel
- %w[All Accepted Incomplete Submitted Approved Cancel].each do |s|
%li
%a{id: 'state' + s, "data-users" => users_for_event(s.downcase) } #{s}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that you cleaned that up 👍

%br
= simple_form_for(resource, url: event_event_emails_path) do |f|
= f.input :to, as: :text,readonly: true, input_html: {rows: 1}
= f.input :to, as: :text,readonly: true,placeholder: 'Select the recipients', input_html: {rows: 1}
= f.input :subject
= f.input :body, as: :text, hint: 'This field supports markdown', input_html: {rows: 12}
%a{:href => "https://daringfireball.net/projects/markdown/syntax"}
View Markdown Syntax
.pull-right
= f.button :submit, 'Send', class: 'btn btn-primary', data: { disable_with: "Please wait..." }
= link_to 'Cancel', event_event_emails_path(@event) , class: 'btn btn-default'

:javascript
function user_email(users){
var recip = document.getElementById('event_email_to');
recip.value = users
}
8 changes: 8 additions & 0 deletions spec/features/event_email.spec.rb
Expand Up @@ -3,6 +3,14 @@
feature 'Email Events', '' do
fixtures :all

scenario 'When there are no participants present', js: true do
sign_in_as_user(users(:tspmember))
visit event_event_emails_path(events(:hoth_hackaton))
click_link 'Compose'

page.should have_button('Select recipients', disabled: true)
end

scenario 'Email the event participants', js: true do
sign_in_as_user(users(:tspmember))
visit event_event_emails_path(events(:party))
Expand Down