From 47fa0952e2bbd2d5a02602bd193c799833527f30 Mon Sep 17 00:00:00 2001 From: Stella Rouzi Date: Tue, 17 Jun 2014 10:40:57 +0300 Subject: [PATCH] States dropdown in different file --- .../events/_change_state_dropdown.html.haml | 37 +++++++++++++++++++ app/views/admin/events/_proposal.html.haml | 22 +---------- app/views/admin/events/index.html.haml | 32 +--------------- 3 files changed, 39 insertions(+), 52 deletions(-) create mode 100644 app/views/admin/events/_change_state_dropdown.html.haml diff --git a/app/views/admin/events/_change_state_dropdown.html.haml b/app/views/admin/events/_change_state_dropdown.html.haml new file mode 100644 index 00000000..dd0a96f8 --- /dev/null +++ b/app/views/admin/events/_change_state_dropdown.html.haml @@ -0,0 +1,37 @@ +- if event.transition_possible? :accept + %li= link_to 'Accept event', + accept_admin_conference_event_path(@conference.short_title, event), + method: :patch, id: "accept_event_#{event.id}" + + - if @conference.email_settings.send_on_accepted? + %li= link_to 'Accept event (without email)', + accept_admin_conference_event_path(@conference.short_title, event, send_mail: false), + method: :patch, hint: 'Accept this event without sending an automated email.', + id: "accept_event_without_mail_#{event.id}" + +- if event.transition_possible? :reject + %li= link_to 'Reject event', + reject_admin_conference_event_path(@conference.short_title, event), + method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" + + - if @conference.email_settings.send_on_rejected? + %li= link_to 'Reject event (without email)', + reject_admin_conference_event_path(@conference.short_title, event, send_mail: false), + method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}" + +- if event.transition_possible? :restart + %li= link_to 'Start review', + restart_admin_conference_event_path(@conference.short_title, event), + method: :patch, id: "restart_event_#{event.id}" + +- if event.transition_possible? :confirm + %li= link_to 'Confirm event', + confirm_admin_conference_event_path(@conference.short_title, event), + method: :patch, id: "confirm_event_#{event.id}", + hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.' + +- if event.transition_possible? :cancel + %li= link_to 'Cancel event', + cancel_admin_conference_event_path(@conference.short_title, event), + method: :patch, id: "cancel_event_#{event.id}", + hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' \ No newline at end of file diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index ef0d7354..83b1391f 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -34,27 +34,7 @@ = @event.state.humanize %ul.dropdown-menu - - if @event.transition_possible? :accept - %li= link_to "Accept event (no email)", accept_admin_conference_event_path(@conference.short_title, @event, :transition => :accept, :send_mail => false), - :method => :put, :hint => "Accept this event without sending an automated email." - %li= link_to "Accept event (WITH email)", accept_admin_conference_event_path(@conference.short_title, @event, :transition => :accept, :send_mail => true), - :method => :put, :hint => "Accept this event and send an automated email." - - if @event.transition_possible? :reject - %li= link_to "Reject event (no email)", reject_admin_conference_event_path(@conference.short_title, @event, :transition => :reject, :send_mail => false), - :method => :put, :confirm => "Are you sure?", - :hint => "Reject this event without sending an automated email." - %li= link_to "Reject event (WITH email)", reject_admin_conference_event_path(@conference.short_title, @event, :transition => :reject, :send_mail => true), - :method => :put, :confirm => "Are you sure?", - :hint => "Reject this event and send an automated email." - - if @event.transition_possible? :start_review - %li= link_to "Start review", review_admin_conference_event_path(@conference.short_title, @event, :transition => :start_review), - :method => :put - - if @event.transition_possible? :confirm - %li= link_to "Confirm event", confirm_admin_conference_event_path(@conference.short_title, @event, :transition => :confirm), - :method => :put, :hint => "Confirm that the speaker(s) will be present and that the event will actually take place." - - if @event.transition_possible? :cancel - %li= link_to "Cancel event", cancel_admin_conference_event_path(@conference.short_title, @event, :transition => :cancel), - :method => :put, :hint => "Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance." + = render 'change_state_dropdown', event: @event %tr %td %b Track diff --git a/app/views/admin/events/index.html.haml b/app/views/admin/events/index.html.haml index 2757652b..4c6ed113 100644 --- a/app/views/admin/events/index.html.haml +++ b/app/views/admin/events/index.html.haml @@ -105,37 +105,7 @@ = event.state.humanize %span.caret %ul.dropdown-menu{:role=>"menu"} - - if event.transition_possible? :accept - %li= link_to 'Accept event', - accept_admin_conference_event_path(@conference.short_title, event), - method: :patch, id: "accept_event_#{event.id}" - - if @conference.email_settings.send_on_accepted? - %li= link_to 'Accept event (without email)', - accept_admin_conference_event_path(@conference.short_title, event, send_mail: false), - method: :patch, hint: 'Accept this event without sending an automated email.', - id: "accept_event_without_mail_#{event.id}" - - if event.transition_possible? :reject - %li= link_to 'Reject event', - reject_admin_conference_event_path(@conference.short_title, event), - method: :patch, confirm: 'Are you sure?', id: "reject_event_#{event.id}" - - if @conference.email_settings.send_on_rejected? - %li= link_to 'Reject event (without email)', - reject_admin_conference_event_path(@conference.short_title, event, send_mail: false), - method: :patch, confirm: 'Are you sure?', id: "reject_event_without_mail_#{event.id}" - - if event.transition_possible? :restart - %li= link_to 'Start review', - restart_admin_conference_event_path(@conference.short_title, event), - method: :patch, id: "restart_event_#{event.id}" - - if event.transition_possible? :confirm - %li= link_to 'Confirm event', - confirm_admin_conference_event_path(@conference.short_title, event), - method: :patch, id: "confirm_event_#{event.id}", - hint: 'Confirm that the speaker(s) will be present and that the event will actually take place.' - - if event.transition_possible? :cancel - %li= link_to 'Cancel event', - cancel_admin_conference_event_path(@conference.short_title, event), - method: :patch, id: "cancel_event_#{event.id}", - hint: 'Mark this event as cancelled. Usually this means that the speakers had to cancel their appearance.' + = render 'change_state_dropdown', event: event :javascript $(document).ready(function() {