working on schedules

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

@ -1,2 +1,21 @@
module SchedulesHelper 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 end

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

@ -3,4 +3,4 @@
%h3 Create A Recipient List For This School %h3 Create A Recipient List For This School
= render 'form', recipient_list: @recipient_list = render 'form', recipient_list: @recipient_list
%br %br
%p= link_to 'Back',@school %p= link_to 'Back', @school

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

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

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

@ -1,55 +1,77 @@
%p .row
%strong Name: .col
= @school.name %p
%p %strong Name:
%strong District: = @school.name
= @school.district_id %p
%strong District:
%p= link_to "Add Recipient", new_school_recipient_path(@school) = @school.district_id
%p= link_to "Bulk Add Recipients", import_school_recipients_path(@school) %p= link_to "Add Recipient", new_school_recipient_path(@school)
%p= link_to "Create Recipient List", new_school_recipient_list_path(@school) %p= link_to "Bulk Add Recipients", import_school_recipients_path(@school)
%p= link_to "Create A Question List", new_question_list_path() %p= link_to "Create Recipient List", new_school_recipient_list_path(@school)
-#%p= link_to "Create A Schedule", new_school_schedule_path(@school) %p= link_to "Create A Question List", new_question_list_path()
= link_to 'Edit', edit_school_path(@school) %p= link_to "Create A Schedule", new_school_schedule_path(@school)
|
= link_to 'Back', root_path = link_to 'Edit', edit_school_path(@school)
|
%br = link_to 'Back', root_path
%br
%br
%h4 School Recipient Lists %br
%table{style: 'width: 100%;'} %br
%tbody %br
%thead{style: 'font-weight: bold;'} %h4 School Schedules
%th Name %table{style: 'width: 100%;'}
%th Descriptin %tbody
%th{colspan: 2} Actions %thead{style: 'font-weight: bold;'}
- @school.recipient_lists.each do |recipient_list| %th Name
%tr.recipient %th Start
%td= link_to recipient_list.name, [@school, recipient_list] %th End
%td= recipient_list.description %th{colspan: 2} Actions
%td= link_to('Edit', edit_school_recipient_list_path(@school, recipient_list)) - @school.schedules.each do |schedule|
%td= link_to('Delete', school_recipient_list_path(@school, recipient_list), method: :delete, data: {confirm: 'Are you sure you want to delete this list?'}) %tr.recipient
%td= link_to schedule.name, [@school, schedule]
%td= schedule.start_date
%br %td= schedule.end_date
%br %td= link_to('Edit', edit_school_recipient_list_path(@school, schedule))
%br %td= link_to('Delete', school_recipient_list_path(@school, schedule), method: :delete, data: {confirm: 'Are you sure you want to delete this schedule?'})
%h4 School Recipients
%table{style: 'width: 100%;'} %br
%tbody %br
%thead{style: 'font-weight: bold;'} %br
%th Name %h4 School Recipient Lists
%th Phone %table{style: 'width: 100%;'}
%th{colspan: 2} Actions %tbody
- @school.recipients.each do |recipient| %thead{style: 'font-weight: bold;'}
%tr.recipient %th Name
%td= recipient.name %th Descriptin
%td= recipient.phone %th{colspan: 2} Actions
%td= link_to('Edit', edit_school_recipient_path(@school, recipient)) - @school.recipient_lists.each do |recipient_list|
%td= link_to('Delete', school_recipient_path(@school, recipient), method: :delete, data: {confirm: 'Are you sure you want to delete this recipient?'}) %tr.recipient
%td= link_to recipient_list.name, [@school, recipient_list]
%td= recipient_list.description
%td= link_to('Edit', edit_school_recipient_list_path(@school, recipient_list))
%td= link_to('Delete', school_recipient_list_path(@school, recipient_list), method: :delete, data: {confirm: 'Are you sure you want to delete this list?'})
%br
%br
%br
%h4 School Recipients
%table{style: 'width: 100%;'}
%tbody
%thead{style: 'font-weight: bold;'}
%th Name
%th Phone
%th{colspan: 2} Actions
- @school.recipients.each do |recipient|
%tr.recipient
%td= recipient.name
%td= recipient.phone
%td= link_to('Edit', edit_school_recipient_path(@school, recipient))
%td= link_to('Delete', school_recipient_path(@school, recipient), method: :delete, data: {confirm: 'Are you sure you want to delete this recipient?'})

@ -29,17 +29,15 @@ RSpec.describe "schedules/edit", type: :view do
assert_select "textarea#schedule_description[name=?]", "schedule[description]" assert_select "textarea#schedule_description[name=?]", "schedule[description]"
assert_select "input#schedule_school_id[name=?]", "schedule[school_id]" assert_select "select[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_frequency_hours[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_active[name=?]", "schedule[active]" assert_select "input#schedule_active[name=?]", "schedule[active]"
assert_select "input#schedule_random[name=?]", "schedule[random]" 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 end
end end

@ -29,17 +29,15 @@ RSpec.describe "schedules/new", type: :view do
assert_select "textarea#schedule_description[name=?]", "schedule[description]" assert_select "textarea#schedule_description[name=?]", "schedule[description]"
assert_select "input#schedule_school_id[name=?]", "schedule[school_id]" assert_select "select[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_frequency_hours[name=?]", "schedule[frequency_hours]"
assert_select "input#schedule_active[name=?]", "schedule[active]" assert_select "input#schedule_active[name=?]", "schedule[active]"
assert_select "input#schedule_random[name=?]", "schedule[random]" 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 end
end end

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

Loading…
Cancel
Save