working on schedules

pull/1/head
Jared Cosulich 9 years ago
parent df369cc985
commit 260b1dd2c3

@ -1,2 +1,21 @@
module SchedulesHelper
def options_for_frequency_hours
[
['Once A Week', 24 * 7],
['Every Other Week', 2 * 24 * 7],
['Once A Month', 4 * 24 * 7]
]
end
def frequency_description(hours)
case hours
when (24 * 7)
'Once A Week'
when (2 * 24 * 7)
'Every Other Week'
when (4 * 24 * 7)
'Once A Month'
end
end
end

@ -9,6 +9,8 @@
= javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
%body
.container
.row
.col
= render partial: 'layouts/header'
- if notice.present?

@ -7,45 +7,41 @@
%ul
- @schedule.errors.full_messages.each do |msg|
%li= msg
.field
.form-group
= f.label :name
%br/
= f.text_field :name
.field
= f.text_field :name, class: 'form-control'
.form-group
= f.label :description
%br/
= f.text_area :description
.field
= f.label :school_id
= f.text_area :description, class: 'form-control'
.form-group
= f.label :frequency_hours, 'How often should be people be surveyed?'
%br/
= f.number_field :school_id
.field
= f.label :frequency_hours
%br/
= f.number_field :frequency_hours
.field
= f.select :frequency_hours, options_for_frequency_hours, class: 'form-control'
.form-group
= f.label :start_date
%br/
= f.date_select :start_date
.field
= f.date_select :start_date, class: 'form-control'
.form-group
= f.label :end_date
%br/
= f.date_select :end_date
.field
= f.date_select :end_date, class: 'form-control'
.form-group
= f.label :active
%br/
= f.check_box :active
.field
= f.check_box :active, class: 'form-control'
.form-group
= f.label :random
%br/
= f.check_box :random
.field
= f.check_box :random, class: 'form-control'
.form-group
= f.label :recipient_list_id
%br/
= f.number_field :recipient_list_id
.field
= f.collection_select :recipient_list_id, @school.recipient_lists.all, :id, :name, class: 'form-control'
.form-group
= f.label :question_list_id
%br/
= f.number_field :question_list_id
.actions
= f.submit
= f.collection_select :question_list_id, QuestionList.all, :id, :name, class: 'form-control'
.form-group
= f.submit 'Save Schedule', class: 'btn btn-primary'

@ -1,3 +1,6 @@
%h1 New schedule
= render 'form'
= link_to 'Back', school_schedules_path(@schedule.school)
.row
.offset-2.col-8
%h3 Create A New Schedule For This School
= render 'form', schedule: @schedule
%br
%p= link_to 'Back', @school

@ -7,10 +7,10 @@
= @schedule.description
%p
%b School:
= @schedule.school.name
= link_to(@school.name, @school)
%p
%b Frequency hours:
= @schedule.frequency_hours
= frequency_description(@schedule.frequency_hours)
%p
%b Start date:
= @schedule.start_date
@ -25,10 +25,11 @@
= @schedule.random
%p
%b Recipient list:
= @schedule.recipient_list.name
= link_to(@schedule.recipient_list.name, [@school, @schedule.recipient_list])
%p
%b Question list:
= @schedule.question_list.name
= link_to(@schedule.question_list.name, @schedule.question_list)
= link_to 'Edit', edit_school_schedule_path(@schedule.school, @schedule)
|
= link_to 'Back', school_schedules_path(@schedule.school)

@ -1,3 +1,5 @@
.row
.col
%p
%strong Name:
= @school.name
@ -13,12 +15,32 @@
%p= link_to "Create A Question List", new_question_list_path()
-#%p= link_to "Create A Schedule", new_school_schedule_path(@school)
%p= link_to "Create A Schedule", new_school_schedule_path(@school)
= link_to 'Edit', edit_school_path(@school)
|
= link_to 'Back', root_path
%br
%br
%br
%h4 School Schedules
%table{style: 'width: 100%;'}
%tbody
%thead{style: 'font-weight: bold;'}
%th Name
%th Start
%th End
%th{colspan: 2} Actions
- @school.schedules.each do |schedule|
%tr.recipient
%td= link_to schedule.name, [@school, schedule]
%td= schedule.start_date
%td= schedule.end_date
%td= link_to('Edit', edit_school_recipient_list_path(@school, schedule))
%td= link_to('Delete', school_recipient_list_path(@school, schedule), method: :delete, data: {confirm: 'Are you sure you want to delete this schedule?'})
%br
%br
%br

@ -29,17 +29,15 @@ RSpec.describe "schedules/edit", type: :view do
assert_select "textarea#schedule_description[name=?]", "schedule[description]"
assert_select "input#schedule_school_id[name=?]", "schedule[school_id]"
assert_select "input#schedule_frequency_hours[name=?]", "schedule[frequency_hours]"
assert_select "select[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_active[name=?]", "schedule[active]"
assert_select "input#schedule_random[name=?]", "schedule[random]"
assert_select "input#schedule_recipient_list_id[name=?]", "schedule[recipient_list_id]"
assert_select "select[name=?]", "schedule[recipient_list_id]"
assert_select "input#schedule_question_list_id[name=?]", "schedule[question_list_id]"
assert_select "select[name=?]", "schedule[question_list_id]"
end
end
end

@ -29,17 +29,15 @@ RSpec.describe "schedules/new", type: :view do
assert_select "textarea#schedule_description[name=?]", "schedule[description]"
assert_select "input#schedule_school_id[name=?]", "schedule[school_id]"
assert_select "input#schedule_frequency_hours[name=?]", "schedule[frequency_hours]"
assert_select "select[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_active[name=?]", "schedule[active]"
assert_select "input#schedule_random[name=?]", "schedule[random]"
assert_select "input#schedule_recipient_list_id[name=?]", "schedule[recipient_list_id]"
assert_select "select[name=?]", "schedule[recipient_list_id]"
assert_select "input#schedule_question_list_id[name=?]", "schedule[question_list_id]"
assert_select "select[name=?]", "schedule[question_list_id]"
end
end
end

@ -12,7 +12,7 @@ RSpec.describe "schedules/show", type: :view do
:name => "Name",
:description => "MyText",
:school => @school,
:frequency_hours => 3,
:frequency_hours => 2 * 24 * 7,
:active => false,
:random => false,
:recipient_list => @recipient_list,
@ -25,7 +25,7 @@ RSpec.describe "schedules/show", type: :view do
expect(rendered).to match(/Name/)
expect(rendered).to match(/MyText/)
expect(rendered).to match(/#{@school.name}/)
expect(rendered).to match(/3/)
expect(rendered).to match(/Every Other Week/)
expect(rendered).to match(/false/)
expect(rendered).to match(/false/)
expect(rendered).to match(/#{@recipient_list.name}/)

Loading…
Cancel
Save