add bootstrap-switch for is_highlight
This commit is contained in:
parent
2dd326c8b9
commit
a845dd5d7d
9 changed files with 45 additions and 12 deletions
3
Gemfile
3
Gemfile
|
|
@ -121,6 +121,9 @@ gem 'money-rails'
|
||||||
# for lists
|
# for lists
|
||||||
gem 'acts_as_list'
|
gem 'acts_as_list'
|
||||||
|
|
||||||
|
# for switch checkboxes
|
||||||
|
gem 'bootstrap-switch-rails', '~> 3.0.0'
|
||||||
|
|
||||||
# Use guard and spring for testing in development
|
# Use guard and spring for testing in development
|
||||||
group :development do
|
group :development do
|
||||||
# rspec Guard rules
|
# rspec Guard rules
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ GEM
|
||||||
bcrypt (3.1.7)
|
bcrypt (3.1.7)
|
||||||
bootstrap-sass (3.3.1.0)
|
bootstrap-sass (3.3.1.0)
|
||||||
sass (~> 3.2)
|
sass (~> 3.2)
|
||||||
|
bootstrap-switch-rails (3.0.2)
|
||||||
bootstrap3-datetimepicker-rails (3.0.3)
|
bootstrap3-datetimepicker-rails (3.0.3)
|
||||||
momentjs-rails (>= 2.8.1)
|
momentjs-rails (>= 2.8.1)
|
||||||
browser (0.6.0)
|
browser (0.6.0)
|
||||||
|
|
@ -438,6 +439,7 @@ DEPENDENCIES
|
||||||
awesome_nested_set (~> 3.0.0.rc.5)
|
awesome_nested_set (~> 3.0.0.rc.5)
|
||||||
axlsx_rails
|
axlsx_rails
|
||||||
bootstrap-sass
|
bootstrap-sass
|
||||||
|
bootstrap-switch-rails (~> 3.0.0)
|
||||||
bootstrap3-datetimepicker-rails (~> 3.0.2)
|
bootstrap3-datetimepicker-rails (~> 3.0.2)
|
||||||
byebug
|
byebug
|
||||||
cancancan
|
cancancan
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
//= require osem-datepickers
|
//= require osem-datepickers
|
||||||
//= require osem-datatables
|
//= require osem-datatables
|
||||||
//= require osem-tickets
|
//= require osem-tickets
|
||||||
|
//= require bootstrap-switch
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('a[disabled=disabled]').click(function(event){
|
$('a[disabled=disabled]').click(function(event){
|
||||||
|
|
|
||||||
|
|
@ -13,4 +13,5 @@
|
||||||
*= require bootstrap-markdown.min
|
*= require bootstrap-markdown.min
|
||||||
*= require bootstrap-datetimepicker
|
*= require bootstrap-datetimepicker
|
||||||
*= require leaflet
|
*= require leaflet
|
||||||
|
*= require bootstrap3-switch
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,14 @@ module Admin
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if @event.submitter.update_attributes(params[:user]) &&
|
if @event.submitter.update_attributes(params[:user]) &&
|
||||||
@event.update_attributes(params[:event])
|
@event.update_attributes(params[:event])
|
||||||
|
|
||||||
|
if request.xhr?
|
||||||
|
render js: 'index'
|
||||||
|
else
|
||||||
flash[:notice] = "Successfully updated event with ID #{@event.id}."
|
flash[:notice] = "Successfully updated event with ID #{@event.id}."
|
||||||
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
redirect_back_or_to(admin_conference_event_path(@conference.short_title, @event))
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@url = admin_conference_event_path(@conference.short_title, @event)
|
@url = admin_conference_event_path(@conference.short_title, @event)
|
||||||
flash[:notice] = 'Update not successful. ' + @event.errors.full_messages.to_sentence
|
flash[:notice] = 'Update not successful. ' + @event.errors.full_messages.to_sentence
|
||||||
|
|
|
||||||
|
|
@ -32,15 +32,9 @@
|
||||||
%td
|
%td
|
||||||
%b Highlight
|
%b Highlight
|
||||||
%td
|
%td
|
||||||
= link_to "#{@event.is_highlight}".capitalize,
|
= check_box_tag @conference.short_title, @event.id, @event.is_highlight, class: 'switch-checkbox',
|
||||||
admin_conference_event_path(@conference.short_title,
|
data: { size: "small" }
|
||||||
@event,
|
|
||||||
event: { is_highlight: !@event.is_highlight }),
|
|
||||||
method: :patch
|
|
||||||
- if @event.is_highlight
|
|
||||||
(the event is as a highlight and will appear in the splashpage)
|
|
||||||
- else
|
|
||||||
(mark as true to make the event a highlight that appears in the splashpage)
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b State
|
%b State
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
%b Submitter
|
%b Submitter
|
||||||
%th
|
%th
|
||||||
%b Speaker
|
%b Speaker
|
||||||
|
%th
|
||||||
|
%b Highlight
|
||||||
%th
|
%th
|
||||||
%b Type
|
%b Type
|
||||||
%th
|
%th
|
||||||
|
|
@ -70,6 +72,10 @@
|
||||||
= link_to speaker.name, admin_user_path(speaker)
|
= link_to speaker.name, admin_user_path(speaker)
|
||||||
- else
|
- else
|
||||||
Unknown speaker
|
Unknown speaker
|
||||||
|
%td
|
||||||
|
= check_box_tag @conference.short_title, event.id, event.is_highlight, class: 'switch-checkbox',
|
||||||
|
data: { size: "small" }
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
|
%button{:type=>"button", :class=>"btn btn-link dropdown-toggle", "data-toggle"=>"dropdown"}
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,23 @@
|
||||||
detectlang: true,
|
detectlang: true,
|
||||||
autocollect: true
|
autocollect: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$("[class='switch-checkbox']").bootstrapSwitch();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('input[class="switch-checkbox"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||||
|
url = "/admin/conference/" + this.name + "/events/" + this.value
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'PATCH',
|
||||||
|
data: { event: { is_highlight: state } },
|
||||||
|
dataType: "script"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
= content_for(:script_head)
|
= content_for(:script_head)
|
||||||
=# javascript_include_tag "//cdn.transifex.com/live.js"
|
=# javascript_include_tag "//cdn.transifex.com/live.js"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,12 @@
|
||||||
include_blank: false, label: 'Session Type'
|
include_blank: false, label: 'Session Type'
|
||||||
- else
|
- else
|
||||||
Event type: #{@event.event_type.title}
|
Event type: #{@event.event_type.title}
|
||||||
%br
|
|
||||||
%br
|
%br
|
||||||
|
= f.label :is_highlight
|
||||||
|
= f.check_box :is_highlight, class: 'switch-checkbox', data: { size: "small" }
|
||||||
|
|
||||||
|
%br
|
||||||
= f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.difficulty_levels.any?
|
= f.input :difficulty_level, :as => :select, :collection => @conference.difficulty_levels, :include_blank => "(Please select)" if @conference.difficulty_levels.any?
|
||||||
= f.input :require_registration
|
= f.input :require_registration
|
||||||
= f.input :abstract, :input_html => {:rows => 5, :class => "span11"},
|
= f.input :abstract, :input_html => {:rows => 5, :class => "span11"},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue