Created
March 9, 2012 17:28
-
-
Save ka8725/2007659 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/app/admin/pages.rb b/app/admin/pages.rb | |
| index d857bab..fe5c3bb 100644 | |
| --- a/app/admin/pages.rb | |
| +++ b/app/admin/pages.rb | |
| @@ -48,18 +48,17 @@ ActiveAdmin.register Page do | |
| end | |
| f.inputs 'Working days' do | |
| - f.input :monday, :as => :boolean | |
| - f.semantic_fields_for :working_date_times, f.object.working_date_times.where(:working_day => 1).first || f.object.working_date_times.new(:working_day => 1) do |cw| | |
| - cw.input :from_time | |
| - cw.input :to_time | |
| + working_days = '' | |
| + Page::WORKING_DAYS.each_pair do |k, v| | |
| + working_days << %Q{ | |
| + f.input :#{v}, :as => :boolean | |
| + f.inputs nil, :for => [:working_date_times, f.object.working_date_times.where(:working_day => #{k}).first || f.object.working_date_times.new(:working_day => #{k})] do |ff| | |
| + ff.input :from_time, :as => :select, :collection => #{0.upto(24).map {|i| ["#{i}:00", "#{i}:30"]}.flatten} | |
| + ff.input :to_time, :as => :select, :collection => #{0.upto(24).map {|i| ["#{i}:00", "#{i}:30"]}.flatten} | |
| + ff.input :working_day, :as => :hidden | |
| + end} | |
| end | |
| - f.input :tuesday, :as => :boolean | |
| - f.input :wednesday, :as => :boolean | |
| - f.input :thursday, :as => :boolean | |
| - f.input :friday, :as => :boolean | |
| - f.input :saturday, :as => :boolean | |
| - f.input :sunday, :as => :boolean | |
| - | |
| + eval(working_days) | |
| end | |
| f.inputs 'Custom fields' do | |
| diff --git a/app/models/page.rb b/app/models/page.rb | |
| index 5cfc754..c6f54e6 100644 | |
| --- a/app/models/page.rb | |
| +++ b/app/models/page.rb | |
| @@ -1,16 +1,16 @@ | |
| # -*- encoding : utf-8 -*- | |
| class Page < ActiveRecord::Base | |
| - | |
| include FlagShihTzu | |
| - has_flags 1 => :monday, | |
| - 2 => :tuesday, | |
| - 3 => :wednesday, | |
| - 4 => :thursday, | |
| - 5 => :friday, | |
| - 6 => :saturday, | |
| - 7 => :sunday, | |
| - :column => 'working_days' | |
| + WORKING_DAYS = {1 => :monday, | |
| + 2 => :tuesday, | |
| + 3 => :wednesday, | |
| + 4 => :thursday, | |
| + 5 => :friday, | |
| + 6 => :saturday, | |
| + 7 => :sunday} | |
| + | |
| + has_flags WORKING_DAYS.merge(:column => 'working_days') | |
| default_scope where(:active => true).order('show_first DESC, created_at DESC') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment