Rework bootstrapSwitch
This commit is contained in:
parent
a35f98b1a3
commit
53f0606ac1
4 changed files with 89 additions and 32 deletions
|
|
@ -1,16 +1,14 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
$(document).ready(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) {
|
||||||
url = "/admin/conference/" + this.name + "/events/" + this.value
|
var url = $(this).attr('url') + state;
|
||||||
|
var method = $(this).attr('method');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
type: 'PATCH',
|
type: method,
|
||||||
data: { event: { is_highlight: state } },
|
dataType: 'script'
|
||||||
dataType: 'script'
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
%br
|
%br
|
||||||
%small
|
%small
|
||||||
= @event.subtitle
|
= @event.subtitle
|
||||||
= link_to "Edit", edit_admin_conference_event_path(@conference.short_title, @event), :class => "btn btn-mini btn-default pull-right"
|
= link_to 'Edit', edit_admin_conference_event_path(@conference.short_title, @event), class: 'btn btn-mini btn-primary pull-right'
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-md-12
|
.col-md-12
|
||||||
|
|
@ -15,12 +15,12 @@
|
||||||
%b Type
|
%b Type
|
||||||
%td
|
%td
|
||||||
.dropdown
|
.dropdown
|
||||||
= link_to "#", :class => "dropdown-toggle", :id => "type-dropdown" do
|
= link_to '#', class: 'dropdown-toggle', id: 'type-dropdown' do
|
||||||
- if @event.event_type.nil?
|
- if @event.event_type.nil?
|
||||||
Event Type
|
Event Type
|
||||||
- else
|
- else
|
||||||
= @event.event_type.title
|
= @event.event_type.title
|
||||||
<b class="caret"></b>
|
<b class='caret'></b>
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
- @event_types.each do |type|
|
- @event_types.each do |type|
|
||||||
%li= link_to type.title,
|
%li= link_to type.title,
|
||||||
|
|
@ -32,20 +32,21 @@
|
||||||
%td
|
%td
|
||||||
%b Highlight
|
%b Highlight
|
||||||
%td
|
%td
|
||||||
= check_box_tag @conference.short_title, @event.id, @event.is_highlight, class: 'switch-checkbox',
|
= check_box_tag @conference.short_title, @event.id, @event.is_highlight,
|
||||||
data: { size: "small",
|
method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[is_highlight]=",
|
||||||
off_color: 'warning',
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
on_text: 'Yes',
|
off_color: 'warning',
|
||||||
off_text: 'No' }
|
on_text: 'Yes',
|
||||||
|
off_text: 'No' }
|
||||||
|
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
%b State
|
%b State
|
||||||
%td
|
%td
|
||||||
.dropdown
|
.dropdown
|
||||||
= link_to "#", :class => "dropdown-toggle" do
|
= link_to '#', class: 'dropdown-toggle' do
|
||||||
= @event.state.humanize
|
= @event.state.humanize
|
||||||
<b class="caret"></b>
|
<b class='caret'></b>
|
||||||
%ul.dropdown-menu
|
%ul.dropdown-menu
|
||||||
= render 'change_state_dropdown', event: @event
|
= render 'change_state_dropdown', event: @event
|
||||||
%tr
|
%tr
|
||||||
|
|
@ -53,7 +54,7 @@
|
||||||
%b Track
|
%b Track
|
||||||
%td
|
%td
|
||||||
.dropdown
|
.dropdown
|
||||||
= link_to "#", :class => "dropdown-toggle", :id => "track-dropdown" do
|
= link_to '#', class: 'dropdown-toggle', id: 'track-dropdown' do
|
||||||
- if @event.track.nil?
|
- if @event.track.nil?
|
||||||
Track
|
Track
|
||||||
- else
|
- else
|
||||||
|
|
@ -71,7 +72,7 @@
|
||||||
%b Difficulty
|
%b Difficulty
|
||||||
%td
|
%td
|
||||||
.dropdown
|
.dropdown
|
||||||
= link_to "#", :class => "dropdown-toggle", :id => "difficulty-dropdown" do
|
= link_to '#', class: 'dropdown-toggle', id: 'difficulty-dropdown' do
|
||||||
- if @event.difficulty_level.nil?
|
- if @event.difficulty_level.nil?
|
||||||
Difficulty Level
|
Difficulty Level
|
||||||
- else
|
- else
|
||||||
|
|
@ -83,6 +84,17 @@
|
||||||
@event,
|
@event,
|
||||||
event: { difficulty_level_id: difficulty.id }),
|
event: { difficulty_level_id: difficulty.id }),
|
||||||
method: :patch
|
method: :patch
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%b Requires Registration
|
||||||
|
%td
|
||||||
|
= check_box_tag @conference.short_title, @event.id, @event.require_registration,
|
||||||
|
method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{@event.id}?event[require_registration]=",
|
||||||
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
|
off_color: 'warning',
|
||||||
|
on_text: 'Yes',
|
||||||
|
off_text: 'No' }
|
||||||
|
|
||||||
- if !@event.room.nil?
|
- if !@event.room.nil?
|
||||||
%tr
|
%tr
|
||||||
%td
|
%td
|
||||||
|
|
@ -126,18 +138,18 @@
|
||||||
%td= simple_format(@event.description)
|
%td= simple_format(@event.description)
|
||||||
|
|
||||||
- if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0
|
- if @conference.call_for_paper && @conference.call_for_paper.rating && @conference.call_for_paper.rating > 0
|
||||||
= render :partial => "voting"
|
= render partial: 'voting'
|
||||||
|
|
||||||
.row
|
.row
|
||||||
= link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link"
|
= link_to "Comments (#{@comment_count})", '#', id: 'event-comment-link'
|
||||||
#comments-div
|
#comments-div
|
||||||
%hr
|
%hr
|
||||||
%ul.media
|
%ul.media
|
||||||
%div
|
%div
|
||||||
.row-fluid
|
.row-fluid
|
||||||
= form_tag(comment_admin_conference_event_path(@conference.short_title, @event.id), :method => :post) do
|
= form_tag(comment_admin_conference_event_path(@conference.short_title, @event.id), method: :post) do
|
||||||
= text_area_tag(:comment, "")
|
= text_area_tag(:comment, '')
|
||||||
= submit_tag "Add Comment", :class => "btn btn-primary pull-right"
|
= submit_tag 'Add Comment', class: 'btn btn-primary pull-right'
|
||||||
%br
|
%br
|
||||||
- @comments.each do |comment|
|
- @comments.each do |comment|
|
||||||
%div
|
%div
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@
|
||||||
%b Submitter
|
%b Submitter
|
||||||
%th
|
%th
|
||||||
%b Speaker
|
%b Speaker
|
||||||
|
%th
|
||||||
|
%b Pre-registration
|
||||||
%th
|
%th
|
||||||
%b Highlight
|
%b Highlight
|
||||||
%th
|
%th
|
||||||
|
|
@ -72,12 +74,22 @@
|
||||||
= link_to speaker.name, admin_user_path(speaker)
|
= link_to speaker.name, admin_user_path(speaker)
|
||||||
- else
|
- else
|
||||||
Unknown speaker
|
Unknown speaker
|
||||||
|
|
||||||
|
%td{'data-order' => "#{event.require_registration}"}
|
||||||
|
= check_box_tag @conference.short_title, event.id, event.require_registration,
|
||||||
|
method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[require_registration]=",
|
||||||
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
|
off_color: 'warning',
|
||||||
|
on_text: 'Yes',
|
||||||
|
off_text: 'No' }
|
||||||
|
|
||||||
%td{'data-order' => "#{event.is_highlight}"}
|
%td{'data-order' => "#{event.is_highlight}"}
|
||||||
= check_box_tag @conference.short_title, event.id, event.is_highlight, class: 'switch-checkbox',
|
= check_box_tag @conference.short_title, event.id, event.is_highlight,
|
||||||
data: { size: "small",
|
method: :patch, url: "/admin/conference/#{@conference.short_title}/events/#{event.id}?event[is_highlight]=",
|
||||||
off_color: 'warning',
|
class: 'switch-checkbox', data: { size: 'small',
|
||||||
on_text: 'Yes',
|
off_color: 'warning',
|
||||||
off_text: 'No' }
|
on_text: 'Yes',
|
||||||
|
off_text: 'No' }
|
||||||
|
|
||||||
%td
|
%td
|
||||||
.btn-group
|
.btn-group
|
||||||
|
|
|
||||||
35
spec/views/admin/events/index.html.haml_spec.rb
Normal file
35
spec/views/admin/events/index.html.haml_spec.rb
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'admin/events/index' do
|
||||||
|
let!(:conference) { create(:conference) }
|
||||||
|
let!(:event1) { create(:event, conference: conference, title: 'event1') }
|
||||||
|
let!(:event2) { create(:event, conference: conference, title: 'event2') }
|
||||||
|
|
||||||
|
it 'renders all conference events' do
|
||||||
|
assign(:conference, conference)
|
||||||
|
assign(:events, [ event1, event2 ])
|
||||||
|
assign(:event_types, [ create(:event_type, conference: conference), create(:event_type, conference: conference) ])
|
||||||
|
assign(:tracks, [ create(:track, conference: conference), create(:track, conference: conference) ])
|
||||||
|
assign(:difficulty_levels, [ create(:difficulty_level, conference: conference), create(:difficulty_level, conference: conference) ])
|
||||||
|
|
||||||
|
render
|
||||||
|
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(1)', text: 'ID')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(2)', text: 'Title')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(3)', text: 'Submitter')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(4)', text: 'Speaker')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(5)', text: 'Pre-registration')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(6)', text: 'Highlight')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(7)', text: 'Type')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(8)', text: 'Track')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(9)', text: 'Difficulty')
|
||||||
|
expect(rendered).to have_selector('table thead th:nth-of-type(10)', text: 'State')
|
||||||
|
|
||||||
|
expect(conference.events.count).to eq 2
|
||||||
|
expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(1)', text: event1.id)
|
||||||
|
expect(rendered).to have_selector('table tr:nth-of-type(1) td:nth-of-type(2)', text: 'event1')
|
||||||
|
|
||||||
|
expect(rendered).to have_selector('table tr:nth-of-type(2) td:nth-of-type(1)', text: event2.id)
|
||||||
|
expect(rendered).to have_selector('table tr:nth-of-type(2) td:nth-of-type(2)', text: 'event2')
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue