Skip to content

Commit

Permalink
Section titles now edited by button rather than double-click
Browse files Browse the repository at this point in the history
Changed seed_event to accept a range of students to create
so that we only create 5 students during test rather than 65
  • Loading branch information
tjgrathwell committed Jun 30, 2013
1 parent 725a8d4 commit 33a58be
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 18 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ group :production do
end

group :assets do
gem 'turbo-sprockets-rails3'
gem 'handlebars_assets'
gem 'jquery-datatables-rails'
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
gem 'bootstrap-sass-rails'
gem 'font-awesome-rails'
gem 'jquery-ui-rails'
gem 'backbone-on-rails'
end
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ GEM
faye-websocket (0.4.7)
eventmachine (>= 0.12.0)
ffi (1.8.1)
font-awesome-rails (3.2.1.1)
railties (>= 3.2, < 5.0)
gmaps4rails (1.5.6)
gravatar_image_tag (1.1.3)
guard (1.6.2)
Expand Down Expand Up @@ -259,6 +261,9 @@ GEM
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
turbo-sprockets-rails3 (0.3.6)
railties (> 3.2.8, < 4.0.0)
sprockets (>= 2.0.0)
tzinfo (0.3.37)
uglifier (1.3.0)
execjs (>= 0.3.0)
Expand Down Expand Up @@ -287,6 +292,7 @@ DEPENDENCIES
devise (~> 2.2.3)
factory_girl_rails
faker
font-awesome-rails
gmaps4rails
gravatar_image_tag
guard-rspec
Expand Down Expand Up @@ -315,5 +321,6 @@ DEPENDENCIES
sqlite3
terminal-notifier-guard
thin
turbo-sprockets-rails3
uglifier
webmock
6 changes: 3 additions & 3 deletions app/assets/javascripts/views/section_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Bridgetroll.Views.Section = Bridgetroll.Views.Base.extend({
},

events: {
'dblclick .bridgetroll-section-title': 'onTitleDoubleClick',
'click .edit': 'onEditClick',
'click .destroy': 'onDestroyClick'
},

Expand Down Expand Up @@ -110,12 +110,12 @@ Bridgetroll.Views.Section = Bridgetroll.Views.Base.extend({
}, this));
},

onTitleDoubleClick: function () {
onEditClick: function () {
if (this.section.isUnassigned()) {
return;
}

var newName = window.prompt('Enter the new name for ' + this.section.get('name'));
var newName = window.prompt('Enter the new name for ' + this.section.get('name'), this.section.get('name') || '');
if (newName) {
this.section
.save({name: newName})
Expand Down
29 changes: 23 additions & 6 deletions app/assets/stylesheets/_section_organizer.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $bridgetroll-section-border-color: #BBB;

.bridgetroll-section-title {
margin: -5px 0 5px 0;
padding: 5px 10px;
padding: 5px 5px 5px 10px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
color: white;
Expand Down Expand Up @@ -51,13 +51,30 @@ $bridgetroll-section-border-color: #BBB;
width: 175px;
vertical-align: top;

.destroy {
font-size: 2em;
.actions {
display: inline-block;
float: right;

&:hover {
cursor: pointer;
color: #ff6167;
span {
font-size: 2em;
}

i {
font-size: 1.5em;
}

i, span {
&:hover {
cursor: pointer;
}

&.destroy:hover {
color: #ff6167;
}

&.edit:hover {
color: rgb(71, 213, 156);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ $tableBorder: #BFBFBF;
@import 'twitter/bootstrap/responsive';
@import "select2";

@import "font-awesome";

@import "fonts";
@import "style_guide";
@import "base";
Expand Down
9 changes: 8 additions & 1 deletion app/assets/templates/section_organizer/section.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
<div class='bridgetroll-section-title {{#unless destructable}}special{{/unless}}'>{{title}} {{#if destructable}}<span class='destroy'>&times;</span>{{/if}}</div>
<div class='bridgetroll-section-title {{#unless destructable}}special{{/unless}}'>
{{title}}
<div class='actions'>
{{#if destructable}}
<i class="icon-edit edit"></i> <span class='destroy'>&times;</span>
{{/if}}
</div>
</div>
<ul class='volunteers'>
{{#each volunteers}}
<li class="attendee {{#unless this.checkins_count}}no-show{{/unless}}" data-id="{{this.id}}"><div class="bridgetroll-badge volunteer">V</div>{{this.full_name}}</li>
Expand Down
5 changes: 3 additions & 2 deletions db/seeds/seed_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def self.destroy_event event
event.destroy
end

def self.seed_event
def self.seed_event(options={})
students_per_level_range = options[:students_per_level_range] || (3..15)
old_event = Event.where(title: 'Seeded Test Event').first
destroy_event(old_event) if old_event.present?

Expand Down Expand Up @@ -119,7 +120,7 @@ def self.seed_event
create_volunteer_rsvp(event: event, user: ta, assignment: VolunteerAssignment::TA, class_level: 3)

(1..5).each do |level|
students_in_level = (3..15).to_a.sample
students_in_level = students_per_level_range.to_a.sample
(1..students_in_level).each do |index|
student = create_user("student#{level}-#{index}@example.com")
create_student_rsvp(event: event, user: student, class_level: level)
Expand Down
4 changes: 2 additions & 2 deletions spec/javascripts/section_organizer/section_view_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ describe("Section", function () {
});
});

describe("onTitleDoubleClick", function () {
describe("onEditClick", function () {
beforeEach(function () {
spyOn(window, 'prompt').andReturn("Pirate's Bay");
view.onTitleDoubleClick();
view.onEditClick();
});

it("makes a request to update the name with the prompted value", function () {
Expand Down
8 changes: 4 additions & 4 deletions spec/seeds/seeds_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ def assert_no_rows_present

describe "#seed_event" do
it "creates an event which can cleanly destroy itself" do
Seeder::seed_event
Seeder::seed_event(students_per_level_range: (1..1))
event = Event.last
event.title.should == 'Seeded Test Event'
Seeder::destroy_event(event)
assert_no_rows_present
end

it "destroys itself when asked to create itself twice" do
Seeder::seed_event
Seeder::seed_event
Seeder::seed_event(students_per_level_range: (1..1))
Seeder::seed_event(students_per_level_range: (1..1))
Event.count.should == 1
end

Expand All @@ -38,7 +38,7 @@ def assert_no_rows_present
innocent_user = create(:user)
other_event.organizers << innocent_user

event = Seeder::seed_event
event = Seeder::seed_event(students_per_level_range: (1..1))
event.organizers << innocent_user

Seeder::destroy_event(event)
Expand Down

0 comments on commit 33a58be

Please sign in to comment.