Merge ff6f53aec2 into 124d275a09
This commit is contained in:
commit
4edc189d66
4 changed files with 36 additions and 43 deletions
|
|
@ -2,6 +2,8 @@ $(function () {
|
||||||
$("[class='switch-checkbox']").bootstrapSwitch();
|
$("[class='switch-checkbox']").bootstrapSwitch();
|
||||||
|
|
||||||
$('input[class="switch-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
$('input[class="switch-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||||
|
console.log(event);
|
||||||
|
console.log(state);
|
||||||
var url = $(this).attr('url') + state;
|
var url = $(this).attr('url') + state;
|
||||||
var method = $(this).attr('method');
|
var method = $(this).attr('method');
|
||||||
|
|
||||||
|
|
@ -11,4 +13,7 @@ $(function () {
|
||||||
dataType: 'script'
|
dataType: 'script'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,8 @@ module Admin
|
||||||
@attended = @conference.registrations.where('attended = ?', true).count
|
@attended = @conference.registrations.where('attended = ?', true).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit; end
|
def edit;
|
||||||
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@registration.update_attributes(registration_params)
|
@registration.update_attributes(registration_params)
|
||||||
|
|
@ -36,27 +37,21 @@ module Admin
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def present
|
def toggle_attendance
|
||||||
@registration.attended = true
|
case params[:attended]
|
||||||
if @registration.save
|
when "true"
|
||||||
flash[:notice] = "#{@user.email} has attended"
|
@registration.attended = true
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
when "false"
|
||||||
else
|
@registration.attended = false
|
||||||
flash[:notice] = "Update Attended for #{@user.email} failed!" \
|
else
|
||||||
"#{@registration.errors.full_messages.join('. ')}"
|
# redirect_to action: :index,
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
# error: 'Wrong url path.')
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def absent
|
|
||||||
@registration.attended = false
|
|
||||||
if @registration.save
|
if @registration.save
|
||||||
flash[:notice] = "#{@user.email} has not attended"
|
head :ok
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
|
||||||
else
|
else
|
||||||
flash[:notice] = "Update Attended for #{@user.email} failed!" \
|
head :unprocessable_entity
|
||||||
"#{@registration.errors.full_messages.join('. ')}"
|
|
||||||
redirect_to admin_conference_registrations_path(@conference.short_title)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -69,13 +64,14 @@ module Admin
|
||||||
def registration_params
|
def registration_params
|
||||||
params.require(:registration).
|
params.require(:registration).
|
||||||
permit(
|
permit(
|
||||||
:conference_id, :arrival, :departure,
|
:conference_id, :arrival, :departure,
|
||||||
:volunteer,
|
:volunteer,
|
||||||
vchoice_ids: [], qanswer_ids: [],
|
vchoice_ids: [], qanswer_ids: [],
|
||||||
qanswers_attributes: [],
|
qanswers_attributes: [],
|
||||||
user_attributes: [
|
user_attributes: [
|
||||||
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
:id, :name, :tshirt, :mobile, :volunteer_experience, :languages,
|
||||||
:nickname, :affiliation ])
|
:nickname, :affiliation])
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -43,25 +43,18 @@
|
||||||
-if @conference.questions.any?
|
-if @conference.questions.any?
|
||||||
%td
|
%td
|
||||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||||
|
%td{'data-order' => "#{registration.attended}"}
|
||||||
|
= check_box_tag "#{@conference.short_title}_#{registration.id}", registration.id, registration.attended,
|
||||||
|
class: 'switch-checkbox', method: :patch,
|
||||||
|
url: toggle_attendance_admin_conference_registration_path(@conference.short_title, id: registration.id)+"?attended=",
|
||||||
|
data: { size: "large",
|
||||||
|
on_color: 'success',
|
||||||
|
off_color: 'warning',
|
||||||
|
on_text: 'Present',
|
||||||
|
off_text: 'Absent' }
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
.btn-group
|
.btn-group
|
||||||
- if registration.attended
|
|
||||||
- btnclass = 'btn-success'
|
|
||||||
- else
|
|
||||||
- btnclass = 'btn-warning'
|
|
||||||
%button{type: "button", class: "btn #{btnclass} dropdown-toggle", "data-toggle" => "dropdown", "aria-expanded" => "false"}
|
|
||||||
- if registration.attended
|
|
||||||
Present
|
|
||||||
- else
|
|
||||||
Absent
|
|
||||||
%span.caret
|
|
||||||
%ul.dropdown-menu{role: "menu"}
|
|
||||||
%li
|
|
||||||
= link_to "Present", present_admin_conference_registration_path(@conference.short_title, id: registration.id),
|
|
||||||
method: :patch
|
|
||||||
= link_to "Absent" , absent_admin_conference_registration_path(@conference.short_title, id: registration.id),
|
|
||||||
method: :patch
|
|
||||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||||
method: :get, class: 'btn btn-primary'
|
method: :get, class: 'btn btn-primary'
|
||||||
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,7 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
resources :registrations, except: [:create, :new] do
|
resources :registrations, except: [:create, :new] do
|
||||||
member do
|
member do
|
||||||
patch :present
|
patch :toggle_attendance
|
||||||
patch :absent
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue