Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract partials for publishing buttons on unpublished_events#index a…
…nd event#show Also moves the generation of the 'Publish' confirm text from a "data: confirm" to a bespoke AJAX request. This allows the controller to not care about fetching the # of users in each region just to show a confirm dialog. To facilitate this, added a /regions/:id.json which can provide the name and # of users to be emailed for a specific region.
- Loading branch information
1 parent
b6936d3
commit 94f4797
Showing
11 changed files
with
69 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
app/views/events/unpublished_events/_mark_as_spam_button.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<%= button_to 'Flag as Spam', unpublished_event_flag_path(event), class: 'btn btn-danger', method: :post, | ||
data: { | ||
confirm: "Are you sure? This will remove this event from the approval page, and flag #{event.organizers.first.full_name} as a spammer so that all subsequent events they create will immediately be flagged as spam." | ||
} %> |
24 changes: 24 additions & 0 deletions
24
app/views/events/unpublished_events/_publish_event_button.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<% if event.location %> | ||
<%= button_to 'Publish', unpublished_event_publish_path(event), class: 'btn', id: "publish-event-#{event.id}", method: :post %> | ||
<script> | ||
window.whenReady(function () { | ||
$("#publish-event-<%= event.id %>").on('click', function (e) { | ||
e.preventDefault(); | ||
$.get('/regions/<%= event.region.id %>.json', function (region) { | ||
var confirmText; | ||
<% if event.email_on_approval %> | ||
confirmText = "Are you sure? This will email " + region.users_subscribed_to_email_count + " members of " + region.name; | ||
<% else %> | ||
confirmText = "Are you sure? The event will start showing for all users, and no one will be emailed since the event organizers have chosen to manually send the announcement email."; | ||
<% end %> | ||
var answer = confirm(confirmText); | ||
if (answer) { | ||
$(e.target).closest('form').submit(); | ||
} | ||
}); | ||
}); | ||
}); | ||
</script> | ||
<% else %> | ||
<button class="btn" disabled>No Location - Can't Publish!</button> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters