Big refactoring of registration
- Added datatable gem - Addaed datatable to events, users (#422), registrations
This commit is contained in:
parent
0f1051d24e
commit
d21e19b977
34 changed files with 435 additions and 12988 deletions
|
|
@ -7,70 +7,63 @@
|
|||
= "(#{@registrations.length})"
|
||||
= " - Attended (#{@attended})"
|
||||
.btn-group.pull-right
|
||||
- if can? :create, Registration
|
||||
= link_to "New", new_admin_conference_registration_path(@conference.short_title), :class => "btn btn-default"
|
||||
- if can? :read, Registration
|
||||
= link_to "Export PDF", admin_conference_registrations_path(@conference.short_title, :format => :pdf), :class => "btn btn-default"
|
||||
= link_to "Export XLS", {:format => :xlsx}, :class => "btn btn-default"
|
||||
%table.table.table-bordered.table-striped.table-hover#registrations
|
||||
%table.table.table-bordered.table-striped.table-hover#registrations-datatable
|
||||
%thead
|
||||
%th
|
||||
No
|
||||
- @headers.each do |h|
|
||||
- h = h.gsub("_", " ")
|
||||
%th
|
||||
= h.capitalize
|
||||
%th
|
||||
%th
|
||||
%th
|
||||
- counter = 0
|
||||
- @registrations.each do |registration|
|
||||
%tr
|
||||
%td
|
||||
= counter +=1
|
||||
- @headers.each do |field|
|
||||
%th #
|
||||
%th Name
|
||||
%th E-Mail
|
||||
%th Ticket
|
||||
%th Arrival
|
||||
%th Departure
|
||||
%th Attended
|
||||
%th Questions
|
||||
%th Edit
|
||||
%th Delete
|
||||
%tbody
|
||||
- @registrations.each_with_index do |registration, index|
|
||||
%tr
|
||||
%td
|
||||
- if field == "name"
|
||||
#{registration.name} #{registration.nickname} #{registration.affiliation}
|
||||
- if registration.supporter_level && registration.supporter_level.title != 'Free'
|
||||
%p{:style => "color:red"}
|
||||
= registration.supporter_level.title
|
||||
|
||||
-elsif field == 'attended'
|
||||
= link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym), :class => "btn btn-success"
|
||||
|
||||
-elsif (registration.send(field.to_sym).class == TrueClass || registration.send(field.to_sym).class == FalseClass)
|
||||
= link_to "#{registration.send(field.to_sym)}", admin_conference_registrations_change_field_path(@conference.short_title, :id => registration.id, :view_field => "#{field}"), :method => :patch, ":#{field}" => registration.send(field.to_sym)
|
||||
|
||||
- elsif field == 'arrival' || field == 'departure'
|
||||
= registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym)
|
||||
|
||||
= index + 1
|
||||
%td
|
||||
= registration.name
|
||||
%td
|
||||
= registration.email
|
||||
%td
|
||||
- if registration.supporter_level
|
||||
= registration.supporter_level.title
|
||||
%td
|
||||
- if registration.arrival
|
||||
= registration.arrival.strftime("%d %b %H:%M")
|
||||
- else
|
||||
= registration.send(field.to_sym)
|
||||
%td
|
||||
= link_to "Questions", "javascript: void(0)", :class => "questions btn btn-success", :id => counter, :onclick => "toggle('row#{counter}')"
|
||||
n/a
|
||||
%td
|
||||
- if registration.departure
|
||||
= registration.departure.strftime("%d %b %H:%M")
|
||||
- else
|
||||
n/a
|
||||
%td
|
||||
= link_to "#{registration.attended}", admin_conference_registrations_toogle_attended_path(@conference.short_title, id: registration.id),
|
||||
method: :patch, class: 'btn btn-success'
|
||||
%td
|
||||
= link_to 'Questions','#', class: 'btn btn-success question-btn', 'data-id' => index, 'data-name' => registration.name
|
||||
%td
|
||||
= link_to 'Edit', edit_admin_conference_registration_path(@conference.short_title, id: registration),
|
||||
method: :get, class: 'btn btn-primary'
|
||||
%td
|
||||
= link_to 'Delete', admin_conference_registration_path(@conference.short_title, registration),
|
||||
method: :delete, class: 'btn btn-danger', data: { confirm: "Do you really want to delete the Registration for #{registration.name}?" }
|
||||
- @registrations.each_with_index do |registration, index|
|
||||
.questions{class: "question#{index}", style: 'display:none;'}
|
||||
= render partial: 'questions', locals: { registration: registration }
|
||||
|
||||
%td
|
||||
= link_to "Edit", edit_admin_conference_registration_path(@conference.short_title, :id => registration), :method => :get, :class => "btn btn-primary"
|
||||
|
||||
%td
|
||||
= link_to "Delete", admin_conference_registration_path(@conference.short_title, registration), :method => :delete, :class => "btn btn-danger", data: {confirm: "Really delete registration for #{registration.name} #{registration.email}?"}
|
||||
%tr{:id => "row#{counter}", :style=>"display:none;"}
|
||||
%td{:colspan=>13}
|
||||
= render :partial => "questions", :locals => {:registration => registration}
|
||||
|
||||
:javascript
|
||||
$(document).ready(function() {
|
||||
$('#registrations').dataTable( {
|
||||
"bPaginate": false,
|
||||
"bLengthChange": false
|
||||
} );
|
||||
} );
|
||||
|
||||
function toggle(rowid) {
|
||||
if( document.getElementById(rowid).style.display=='none' ){
|
||||
document.getElementById(rowid).style.display = '';
|
||||
}else{
|
||||
document.getElementById(rowid).style.display = 'none';
|
||||
}
|
||||
};
|
||||
.modal.fade{ id: "questions", 'role' => 'dialog', 'aria-hidden' => 'true' }
|
||||
.modal-dialog
|
||||
.modal-content
|
||||
.modal-header
|
||||
%h3{id: 'question-modal-header'}
|
||||
Questions for Foobar
|
||||
.modal-body#question-modal-body
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue