Skip to content

Commit

Permalink
Adding link to 'Class Breakdown' page on Org Dashboard
Browse files Browse the repository at this point in the history
Includes a somewhat inauspicious and strange start to the Class Breakdown page

Adds backbone (via backbone-on-rails gem), jasmine, and a bunch of crazy .js files.
  • Loading branch information
tjgrathwell committed May 13, 2013
1 parent 31e3126 commit b95f7c8
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ group :assets do
gem 'uglifier'
gem 'bootstrap-sass-rails'
gem 'jquery-ui-rails'
gem 'backbone-on-rails'
end

group :development do
Expand All @@ -37,6 +38,7 @@ group :development do
end

group :test, :development do
gem 'jasmine'
gem 'sqlite3'
gem 'rspec-rails'
gem 'awesome_print'
Expand Down
29 changes: 29 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ GEM
addressable (2.3.3)
arel (3.0.2)
awesome_print (1.1.0)
backbone-on-rails (1.0.0.0)
eco
ejs
jquery-rails
rails (>= 3.1)
bcrypt-ruby (3.0.1)
bootstrap-sass-rails (2.3.1.1)
railties (>= 3.1.0)
Expand All @@ -46,6 +51,8 @@ GEM
xpath (~> 2.0)
capybara-screenshot (0.3.4)
capybara (>= 1.0, < 3)
childprocess (0.3.9)
ffi (~> 1.0, >= 1.0.11)
coderay (1.0.9)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
Expand All @@ -63,6 +70,12 @@ GEM
railties (~> 3.1)
warden (~> 1.2.1)
diff-lcs (1.2.1)
eco (1.0.0)
coffee-script
eco-source
execjs
eco-source (1.1.0.rc.1)
ejs (1.1.1)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (1.4.0)
Expand All @@ -78,6 +91,7 @@ GEM
multipart-post (~> 1.1)
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.8.1)
gmaps4rails (1.5.6)
gravatar_image_tag (1.1.3)
guard (1.6.2)
Expand All @@ -94,6 +108,12 @@ GEM
http_parser.rb (0.5.3)
httpauth (0.2.0)
i18n (0.6.1)
jasmine (1.3.2)
jasmine-core (~> 1.3.1)
rack (~> 1.0)
rspec (>= 1.3.1)
selenium-webdriver (>= 0.1.3)
jasmine-core (1.3.1)
journey (1.0.4)
jquery-datatables-rails (1.11.2)
jquery-rails
Expand Down Expand Up @@ -192,6 +212,7 @@ GEM
rspec-core (~> 2.13.0)
rspec-expectations (~> 2.13.0)
rspec-mocks (~> 2.13.0)
rubyzip (0.9.9)
sanitize (2.0.3)
nokogiri (>= 1.4.4, < 1.6)
sass (3.2.7)
Expand All @@ -202,6 +223,11 @@ GEM
select2-rails (3.3.0)
sass-rails (~> 3.2)
thor (~> 0.14)
selenium-webdriver (2.32.1)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
sextant (0.2.3)
activesupport (>= 3.2)
rails (>= 3.2)
Expand Down Expand Up @@ -237,6 +263,7 @@ GEM
webmock (1.11.0)
addressable (>= 2.2.7)
crack (>= 0.3.2)
websocket (1.0.7)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -246,6 +273,7 @@ PLATFORMS
DEPENDENCIES
active_hash
awesome_print
backbone-on-rails
bootstrap-sass-rails
capybara (>= 2.0.1)
capybara-screenshot
Expand All @@ -257,6 +285,7 @@ DEPENDENCIES
gmaps4rails
gravatar_image_tag
guard-rspec
jasmine
jquery-datatables-rails
jquery-rails
jquery-ui-rails
Expand Down
7 changes: 7 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
//= require twitter/bootstrap/transition
//= require select2
//= require modernizr
//= require underscore
//= require backbone
//= require bridgetroll
//= require_tree ../templates
//= require_tree ./models
//= require_tree ./collections
//= require_tree ./views
//= require_tree .
//= require jquery_nested_form
//= require dataTables/jquery.dataTables
Expand Down
5 changes: 5 additions & 0 deletions app/assets/javascripts/bridgetroll.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bridgetroll = {
Models: {},
Collections: {},
Views: {}
};
3 changes: 3 additions & 0 deletions app/assets/javascripts/collections/students_collection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bridgetroll.Collections.Student = Backbone.Collection.extend({
model: Bridgetroll.Models.Student
});
3 changes: 3 additions & 0 deletions app/assets/javascripts/models/student.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bridgetroll.Models.Student = Backbone.Model.extend({

});
31 changes: 31 additions & 0 deletions app/assets/javascripts/views/section_organizer_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Bridgetroll.Views.SectionOrganizer = Backbone.View.extend({
initialize: function (options) {
this.subViews = [];
this.students = options && options.students;

this.students.each(function (student) {
this.addStudent(student);
}, this);
},

render: function () {
this.$el.empty();

_.each(this.subViews, function (view) {
view.render();
this.$el.append(view.$el);
}, this);
},

addStudent: function (student) {
var studentView = new Bridgetroll.Views.Student({model: student});
this.subViews.push(studentView);
this.render();
},

addSection: function () {
var section = new Bridgetroll.Views.Section();
this.subViews.push(section);
this.render();
}
});
8 changes: 8 additions & 0 deletions app/assets/javascripts/views/section_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bridgetroll.Views.Section = Backbone.View.extend({
className: 'bridgetroll-section',

render: function () {
this.$el.empty();
this.$el.append('i am a section');
}
});
8 changes: 8 additions & 0 deletions app/assets/javascripts/views/student_view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bridgetroll.Views.Student = Backbone.View.extend({
className: 'bridgetroll-student',

render: function () {
this.$el.empty();
this.$el.append(this.model.get('name'));
}
});
10 changes: 10 additions & 0 deletions app/assets/stylesheets/_section_organizer.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#section-organizer {
height: 500px;
border: 1px solid #ccc;
border-radius: 10px;
padding: 15px;
}

.bridgetroll-section {
border: 1px solid green;
}
1 change: 1 addition & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $tableBorder: #BFBFBF;
@import "header";
@import "footer";
@import "checkins";
@import "section_organizer";

@import "events/show";
@import "events/organize";
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class EventsController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show]
before_filter :find_event, only: [:show, :edit, :update, :destroy, :volunteer_emails, :organize]
before_filter :require_organizer, only: [:edit, :update, :destroy, :volunteer_emails, :organize]
before_filter :find_event, except: [:index, :create, :new]
before_filter :require_organizer, except: [:index, :create, :show, :new]
before_filter :assign_organizer, only: [:show, :edit, :update, :destroy]
before_filter :set_time_zone, only: [:create, :update]

Expand Down Expand Up @@ -74,6 +74,10 @@ def organize
end
end

def organize_sections

end

protected

def set_time_zone
Expand Down
3 changes: 2 additions & 1 deletion app/views/events/organize.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<%= render 'shared/actions', additional_class: 'mission-control-actions', links: [
['Manage Organizers', event_organizers_path(@event)],
['Manage Volunteers', event_volunteers_path(@event)],
['Email Volunteers', volunteer_emails_event_path(@event)]
['Email Volunteers', volunteer_emails_event_path(@event)],
['Class Breakdown', organize_sections_event_path(@event)]
] %>

<h2>Volunteer Teaching Preference Totals</h2>
Expand Down
17 changes: 17 additions & 0 deletions app/views/events/organize_sections.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<%= content_for(:header_text, @event.title) %>

<h2>Super Secret Organizer Section Organizing Tool</h2>

<div id="section-organizer"></div>

<script>
$(document).ready(function () {
var students = new Bridgetroll.Collections.Student(
<%= @event.student_rsvps.map { |rsvp| { name: rsvp.user.full_name } }.to_json.html_safe %>
);

Bridgetroll.sectionOrganizer = new Bridgetroll.Views.SectionOrganizer({students: students});
Bridgetroll.sectionOrganizer.setElement($('#section-organizer'));
Bridgetroll.sectionOrganizer.render();
});
</script>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
end
get "volunteer_emails" => "events#volunteer_emails", :on => :member
get "organize", :on => :member
get "organize_sections", :on => :member
end

get "/auth/:provider/callback" => "omniauths#callback"
Expand Down
6 changes: 6 additions & 0 deletions spec/features/event_organizer_dashboard_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
page.should have_content("Organizer Assignment")
end

it "lets the user assign students and volunteers to sections" do
visit organize_event_path(@event)
click_link "Class Breakdown"
page.should have_content("Section Organizing")
end

it "lets the user manage volunteers" do
visit organize_event_path(@event)
within('.mission-control-actions') { click_link 'Manage Volunteers' }
Expand Down
21 changes: 21 additions & 0 deletions spec/features/section_organizer_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

describe "the section organizer tool" do
before do
@organizer = create(:user)
@student = create(:user)

@event = create(:event)
@event.organizers << @organizer
create(:student_rsvp, user: @student, event: @event)

sign_in_as(@organizer)
end

it "should show the names of all students", js: true do
visit organize_sections_event_path(@event)
within '#section-organizer' do
page.should have_content(@student.full_name)
end
end
end
Empty file.
9 changes: 9 additions & 0 deletions spec/javascripts/helpers/SpecHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
beforeEach(function() {
this.addMatchers({
toBePlaying: function(expectedSong) {
var player = this.actual;
return player.currentlyPlayingSong === expectedSong
&& player.isPlaying;
}
})
});
32 changes: 32 additions & 0 deletions spec/javascripts/section_organizer/section_organizer_spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
describe("SectionOrganizer", function() {
var sectionOrganizer;
var students;
beforeEach(function() {
students = new Bridgetroll.Collections.Student([
{name: 'Lana Lang'},
{name: 'Sue Storm'},
{name: 'Ted Moesby'}
]);
sectionOrganizer = new Bridgetroll.Views.SectionOrganizer({students: students});
});

it("renders each of the students from the original collection", function () {
sectionOrganizer.render();
expect(sectionOrganizer.$el.text()).toContain('Lana Lang');
expect(sectionOrganizer.$el.text()).toContain('Sue Storm');
expect(sectionOrganizer.$el.text()).toContain('Ted Moesby');
});

describe("#addSection", function () {
it("adds a new section as a subview", function () {
sectionOrganizer.render();
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(0);

sectionOrganizer.addSection();
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(1);

sectionOrganizer.addSection();
expect(sectionOrganizer.$('.bridgetroll-section').length).toEqual(2);
});
});
});
Loading

0 comments on commit b95f7c8

Please sign in to comment.