Big refactoring of registration

- Added datatable gem
- Addaed datatable to events, users (#422), registrations
This commit is contained in:
Chrisbr 2014-08-22 15:08:54 +02:00
parent 0f1051d24e
commit d21e19b977
34 changed files with 435 additions and 12988 deletions

View file

@ -6,110 +6,102 @@
Events
- if @events
= "(#{@events.length})"
.well
%table.table.table-striped.table-bordered.table-hover#events
%thead
%table.table.table-striped.table-bordered.table-hover#events-datatable
%thead
%th
%b ID
%th
%b Title
- if @conference.call_for_papers && @conference.call_for_papers.rating && @conference.call_for_papers.rating > 0
%th
%b ID
%th
%b Title
%b Rating
%th
%b Submitter
%th
%b Speaker
%th
%b Type
%th
%b Track
%th
%b Difficulty
%th
%b State
- @events.each do |event|
%tr
%td
= event.id
%td
=link_to event.title, admin_conference_event_path(@conference.short_title, event)
- if @conference.call_for_papers && @conference.call_for_papers.rating && @conference.call_for_papers.rating > 0
%th
%b Rating
%th
%b Submitter
%th
%b Speaker
%th
%b Type
%th
%b Track
%th
%b Difficulty
%th
%b State
- @events.each do |event|
%tr
%td
= event.id
%td
=link_to event.title, admin_conference_event_path(@conference.short_title, event)
- if @conference.call_for_papers && @conference.call_for_papers.rating && @conference.call_for_papers.rating > 0
%td{:style => "width:96px"}
- if event.average_rating.to_f > 0
#{event.average_rating}/#{@conference.call_for_papers.rating}
%br
#{pluralize(event.voters.length, 'voter')}
%br
- @conference.call_for_papers.rating.times do |counter|
- if event.average_rating.to_f.round == counter+1
= label_tag "label_rating", "", :class => "avgrating", :avgrate => true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label_rating", "", :class => "avgrating"
- else
0/#{@conference.call_for_papers.rating}
%td{:style => "width:96px"}
- if event.average_rating.to_f > 0
#{event.average_rating}/#{@conference.call_for_papers.rating}
%br
#{pluralize(event.voters.length, 'voter')}
%br
- @conference.call_for_papers.rating.times do |counter|
- if event.average_rating.to_f.round == counter+1
= label_tag "label_rating", "", :class => "avgrating", :avgrate => true
= javascript_tag "$('label[avgrate=true]').prevAll().andSelf().addClass('bright');"
- else
= label_tag "label_rating", "", :class => "avgrating"
- else
0/#{@conference.call_for_papers.rating}
%br
- if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1
- bgcolor="#F7819F"
- if event.submitter && event.submitter.registrations && event.submitter.registrations.count < 1
- bgcolor="#F7819F"
- else
- bgcolor=""
%td{:style=>"background-color: #{bgcolor}"}
- if !event.submitter.nil?
=link_to event.submitter.name, admin_user_path(event.submitter)
- if event.submitter.registrations.count < 1
(Unregistered!)
- else
Unknown submitter
%td
- if speaker = event.speakers.first
= link_to speaker.name, admin_user_path(speaker)
- else
Unknown speaker
- l = link_to "Change", edit_admin_conference_event_speaker_path(@conference.short_title, event), :remote => true
= "(#{l})".html_safe
%td
.btn-group
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
- if event.event_type.nil?
Event Type
- else
= event.event_type.title
%span.caret
%ul.dropdown-menu
- @event_types.each do |type|
%li= link_to type.title, admin_conference_event_path(@conference.short_title, event, :event_type_id => type.id) ,
:method => :put, :event_type_id => type.id
%td
.btn-group
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
- if event.track.nil?
Track
- else
= event.track.name
%span.caret
%ul.dropdown-menu
- @tracks.each do |track|
%li= link_to track.name, admin_conference_event_path(@conference.short_title, event, :track_id => track.id) ,
:method => :put, :track_id => track.id
%td
= event.difficulty_level.title if @conference.use_difficulty_levels && event.difficulty_level
%td
- if event.state == "withdrawn"
Withdrawn
- else
- bgcolor=""
%td{:style=>"background-color: #{bgcolor}"}
- if !event.submitter.nil?
=link_to event.submitter.name, admin_user_path(event.submitter)
- if event.submitter.registrations.count < 1
(Unregistered!)
- else
Unknown submitter
%td
- if speaker = event.speakers.first
= link_to speaker.name, admin_user_path(speaker)
- else
Unknown speaker
- l = link_to "Change", edit_admin_conference_event_speaker_path(@conference.short_title, event), :remote => true
= "(#{l})".html_safe
%td
.btn-group
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
- if event.event_type.nil?
Event Type
- else
= event.event_type.title
= event.state.humanize
%span.caret
%ul.dropdown-menu
- @event_types.each do |type|
%li= link_to type.title, admin_conference_event_path(@conference.short_title, event, :event_type_id => type.id) ,
:method => :put, :event_type_id => type.id
%td
.btn-group
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
- if event.track.nil?
Track
- else
= event.track.name
%span.caret
%ul.dropdown-menu
- @tracks.each do |track|
%li= link_to track.name, admin_conference_event_path(@conference.short_title, event, :track_id => track.id) ,
:method => :put, :track_id => track.id
%td
= event.difficulty_level.title if @conference.use_difficulty_levels && event.difficulty_level
%td
- if event.state == "withdrawn"
Withdrawn
- else
.btn-group
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
= event.state.humanize
%span.caret
%ul.dropdown-menu{:role=>"menu"}
= render 'change_state_dropdown', event: event
:javascript
$(document).ready(function() {
$('#events').dataTable( {
"bPaginate": false
} );
} );
%ul.dropdown-menu{:role=>"menu"}
= render 'change_state_dropdown', event: event

View file

@ -4,28 +4,35 @@
Edit registration of #{@user.name} (#{@user.email}) for #{@conference.title}
%br
.row
.col-md-12
.col-md-8
= semantic_form_for(@registration, :url => admin_conference_registration_path(@conference.short_title, @registration)) do |f|
= f.inputs "Personal Information" do
= f.inputs 'Personal Information' do
= f.fields_for :user do |u|
= u.input :nickname, :as => :string
= u.input :affiliation, :placeholder => "Company/User Group/nothing", :as => :string
= f.inputs "Registration Information" do
= u.input :name, as: :string
= u.input :nickname, as: :string
= u.input :affiliation, placeholder: 'Company/User Group/nothing', as: :string
= f.inputs 'Registration Information' do
- if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0
= f.semantic_fields_for :supporter_registration do |reg|
= reg.input :supporter_level, :as => :select, :collection => @conference.supporter_levels
= reg.input :code, :label => "Confirmation or registration code (if applicable)"
= reg.input :supporter_level, as: :select, collection: @conference.supporter_levels
%span#supporter-link.help-block
= f.input :attending_with_partner, :label => false
= f.input :using_affiliated_lodging, :label => false
= f.input :handicapped_access_required, :label => false
= f.input :other_special_needs, :label => "Any other special needs?", :input_html => {:rows => 2, :class => "span6"}
- @conference.questions.each do |q|
%h5
= "Q: #{q.title}"
- if q.question_type.id == 1 || q.question_type.id == 2 # yes/no or single choice
= f.input :qanswers, :collection => q.qanswers, :as => :select, :input_html => { :multiple => false }, :label => false, :include_blank => "Please make your choice",
:member_label => Proc.new {|a| a.answer.title}
- if q.question_type.id == 3 # multiple choice
= f.input :qanswers, :collection => q.qanswers, :as => :check_boxes, :label => false,
:member_label => Proc.new {|a| a.answer.title}
-# Not necessary
- if @conference.social_events.count > 0
= f.inputs "Are you planning to attend any of the parties?" do
= f.inputs 'Are you planning to attend any of the parties?' do
%br Yes, I'll be attending...
%br
= f.input :social_events, :as => :check_boxes, :label => false, :collection => @conference.social_events
= f.action :submit, :button_html => { :value => "Edit Registration", :class => "btn btn-primary" }
= f.input :social_events, as: :check_boxes, label: false, collection: @conference.social_events
= f.action :submit, button_html: { value: 'Edit Registration', class: 'btn btn-primary' }
:javascript
$("#registration_supporter_registration_attributes_supporter_level_id").change(function () {
var str = "";
@ -33,25 +40,3 @@
$("#supporter-link").html(str);
})
.trigger('change');
$("#registration-arrival-datepicker").datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
showSecond: false,
numberOfMonths: 1,
defaultDate: '#{@conference.start_date.yesterday.strftime('%Y-%m-%d')}',
onSelect: function(selected) {
$("#registration-departure-datepicker").datepicker("option","minDate", selected)
}
});
$("#registration-departure-datepicker").datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
showSecond: false,
numberOfMonths: 1,
defaultDate: '#{@conference.end_date.tomorrow.strftime('%Y-%m-%d')}',
onSelect: function(selected) {
$("#registration-arrival-datepicker").datepicker("option","maxDate", selected)
}
});

View file

@ -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

View file

@ -1,64 +0,0 @@
.row
.col-md-12
%h3
Create new account and registration
.row
.col-md-12
= semantic_form_for(@registration, :url => admin_conference_registrations_path(@conference.short_title)) do |f|
= f.inputs "Your details" do
= f.fields_for @user do |u|
= u.input :email, :as => :string, :hint => "Please enter a valid email address. You will need it to log in to OSEM later."
= u.input :name, as: :string
= u.input :nickname, :as => :string
= u.input :affiliation, :placeholder => "Company/User Group/nothing", :as => :string
= f.inputs "Registration Information" do
- if @conference.use_supporter_levels? and @conference.supporter_levels.length > 0
= f.semantic_fields_for @supporter_registration do |reg|
= reg.input :supporter_level, :as => :select, :collection => @conference.supporter_levels
= reg.input :code, :label => "Confirmation or registration code (if applicable)"
%span#supporter-link.help-block
= f.input :attending_with_partner, :label => false
= f.input :using_affiliated_lodging, :label => false
= f.input :handicapped_access_required, :label => false
= f.input :other_special_needs, :label => "Any other special needs?", :input_html => {:rows => 2, :class => "span6"}
- if @conference.social_events.count > 0
= f.inputs "Are you planning to attend any of the parties?" do
%br Yes, I'll be attending...
%br
= f.input :social_events, :as => :check_boxes, :label => false, :collection => @conference.social_events
= f.action :submit, :button_html => { :value => "Create", :class => "btn btn-primary"}
:javascript
$("#registration_supporter_registration_attributes_supporter_level_id").change(function () {
var str = "";
#{generate_supporter_level_js @conference}
$("#supporter-link").html(str);
})
.trigger('change');
$("#registration-arrival-datepicker").datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
showSecond: false,
numberOfMonths: 1,
defaultDate: '#{@conference.start_date.yesterday.strftime('%Y-%m-%d')}',
onSelect: function(selected) {
$("#registration-departure-datepicker").datepicker("option","minDate", selected)
}
});
$("#registration-departure-datepicker").datetimepicker({
dateFormat: "yy-mm-dd",
timeFormat: "HH:mm",
showSecond: false,
numberOfMonths: 1,
defaultDate: '#{@conference.end_date.tomorrow.strftime('%Y-%m-%d')}',
onSelect: function(selected) {
$("#registration-arrival-datepicker").datepicker("option","maxDate", selected)
}
});

View file

@ -5,25 +5,19 @@
- if @users
= "(#{@users.length})"
= link_to "New User", new_admin_user_path, class: 'btn btn-success pull-right'
.well
%table.table.table-striped.table-bordered.table-hover#users
%thead
%th
%b ID
%th
%b State
%th
%b Email
%th
%b Name
%th
%b Attended Conferences
%th
%b Roles
%th
%th
%th
= link_to 'New User', new_admin_user_path, class: 'btn btn-success pull-right'
%table.table.table-striped.table-bordered.table-hover#users-datatable
%thead
%th ID
%th State
%th Email
%th Name
%th Attended Conferences
%th Roles
%th View
%th Edit
%th Delete
%tbody
- @users.each do |user|
%tr
%td
@ -44,24 +38,19 @@
= show_roles(user.get_roles.first(2))
- if user.get_roles.count > 2
= '...'
- else
None
- if can? :show, user
%td
= link_to "View", admin_user_path(user), class: 'btn btn-success'
= link_to 'View', admin_user_path(user), class: 'btn btn-success'
- if can? :update, user
%td
= link_to "Edit", edit_admin_user_path(user), class: 'btn btn-primary'
= link_to 'Edit', edit_admin_user_path(user), class: 'btn btn-primary'
- if can? :destroy, user
%td
- if current_user.id == user.id or user.role_ids.include? 3
=link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button"
= link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'},
disabled: true, class: 'btn btn-primary disabled btn-danger', role: 'button'
- else
=link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger"
:javascript
$(document).ready(function() {
$('#users').dataTable( {
"bPaginate": false,
"bLengthChange": false
} );
} );
= link_to 'Delete',admin_user_path(user), method: :delete,
data: { confirm: 'Are you sure ?' }, class: 'btn btn-primary btn-danger'