Commit d6b7b0ae authored by Chrysanthi Lagodimou's avatar Chrysanthi Lagodimou
Browse files

schedule as schedulable in views and controller

parent aff62930
......@@ -9,6 +9,7 @@ class VolunteersController < ApplicationController
def new
@volunteer = Volunteer.new
@volunteer.schedules << Schedule.build
end
def edit; end
......@@ -52,6 +53,9 @@ class VolunteersController < ApplicationController
],
relatives_attributes: [
:id, :first_name, :last_name, :date_of_birth, :relation, :_destroy
],
schedules_attributes: [
:id, :day, :time, :available
])
end
end
......@@ -132,6 +132,28 @@
.col-xs-12
= f.input :region, collection: Volunteer.region_collection, as: :radio_buttons, label: false
.row
.col-xs-12
h3= t('schedule')
.row
.col-xs-12
table.table.table-striped
thead
tr
th= t('when')
- Schedule.days.each do |day|
th.days= t("weekdays.#{day}")
tbody
- @volunteer.schedules.group_by(&:time).each do |time, schedules|
tr
td
= t("times.#{time}")
= f.simple_fields_for :schedules, schedules do |schedule|
td
= schedule.input :day, as: :hidden
= schedule.input :time, as: :hidden
= schedule.input :available, as: :boolean, label: false
.row
.col-xs-12
= f.button :submit, class: 'btn btn-success'
......@@ -113,6 +113,30 @@
- else
i.glyphicon.glyphicon-remove.text-danger
.row
.col-xs-12
h3= t('schedule')
.row
.col-xs-12
table.table.table-striped
thead
tr
th= t('when')
- Schedule.days.each do |day|
th.text-center
= t("weekdays.#{day}")
tbody
- @client.schedules.group_by(&:time).each do |time, schedules|
tr
td
= t("times.#{time}")
- schedules.each do |schedule|
td.text-center
- if schedule.available
i.glyphicon.glyphicon-ok.text-success
- else
i.glyphicon.glyphicon-remove.text-danger
.row
.col-xs-12
= link_to t_action(:edit), edit_volunteer_path(@volunteer), class: 'btn btn-default'
......
FactoryGirl.define do
factory :schedule do
client
day ' '
time ' '
end
......
......@@ -43,6 +43,7 @@ class VolunteersTest < ApplicationSystemTestCase
page.check('volunteer_training')
page.check('volunteer_adults')
page.choose('volunteer_region_canton')
page.check('volunteer_schedules_attributes_17_available')
click_button 'Create Volunteer'
assert page.has_text? 'Volunteer was successfully created.'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment