Skip to content
This repository has been archived by the owner on Oct 20, 2023. It is now read-only.

Commit

Permalink
Activity: Display day of week checkboxes in form.
Browse files Browse the repository at this point in the history
Refrences #52.
  • Loading branch information
ybakos committed Sep 8, 2020
1 parent 711b025 commit e82d80a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/helpers/activities_helper.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
module ActivitiesHelper

DAYS_OF_WEEK = ['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday']

def day_checkboxes(form)
''.tap do |result|
DAYS_OF_WEEK.each do |day|
result << form.check_box('days', {multiple: true, class: 'form-check-input'}, day.capitalize, '')
result << form.label(:"days_#{day}", day.capitalize, class: 'form-check-label mr-3')
end
end.html_safe
end

end
4 changes: 4 additions & 0 deletions app/views/activities/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
.form-group
= form.label :location
= form.text_field :location, class: 'form-control'
.form-group
%label.d-block Days
.form-check.form-check-inline
= day_checkboxes(form)
.form-group
= form.label :start_date
= form.date_select :start_date, order: [:month, :day, :year]
Expand Down
9 changes: 9 additions & 0 deletions spec/helpers/activities_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'rails_helper'

RSpec.describe ActivitiesHelper, type: :helper do

describe '#day_checkboxes' do
pending
end

end

0 comments on commit e82d80a

Please sign in to comment.