diff options
| author | cedricnjanga | 2017-12-15 11:54:12 +0100 |
|---|---|---|
| committer | Luc Donnet | 2017-12-21 13:54:07 +0100 |
| commit | 70e46cba80443fb615e1f7182422c8de6d96e7c3 (patch) | |
| tree | 080d965835b3fcb1cbba8612da4dfbe8354a53be /app | |
| parent | 0cf1d52d1dfc83fe304c7f3b7f7e1114ade28c11 (diff) | |
| download | chouette-core-70e46cba80443fb615e1f7182422c8de6d96e7c3.tar.bz2 | |
Handle page title error display
attempt to add select tag for model color
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/business_calendar_helper.rb | 5 | ||||
| -rw-r--r-- | app/models/business_calendar.rb | 2 | ||||
| -rw-r--r-- | app/views/business_calendars/_form.html.slim | 2 | ||||
| -rw-r--r-- | app/views/business_calendars/index.html.slim | 2 |
4 files changed, 9 insertions, 2 deletions
diff --git a/app/helpers/business_calendar_helper.rb b/app/helpers/business_calendar_helper.rb new file mode 100644 index 000000000..d99fe3bc4 --- /dev/null +++ b/app/helpers/business_calendar_helper.rb @@ -0,0 +1,5 @@ +module BusinessCalendarHelper + def color_diplsay(color) + content_tag(:span, '', class: 'fa fa-circle', style: "color:#{color}") + end +end
\ No newline at end of file diff --git a/app/models/business_calendar.rb b/app/models/business_calendar.rb index 0064b4537..45fbdb6ac 100644 --- a/app/models/business_calendar.rb +++ b/app/models/business_calendar.rb @@ -4,6 +4,8 @@ require_relative 'calendar/period' class BusinessCalendar < ActiveRecord::Base include CalendarSupport + extend Enumerize + enumerize :color, in: %w(#9B9B9B #FFA070 #C67300 #7F551B #41CCE3 #09B09C #3655D7 #6321A0 #E796C6 #DD2DAA) scope :overlapping, -> (period_range) do where("(periods.begin <= :end AND periods.end >= :begin) OR (dates BETWEEN :begin AND :end)", {begin: period_range.begin, end: period_range.end}) diff --git a/app/views/business_calendars/_form.html.slim b/app/views/business_calendars/_form.html.slim index a7c0d8c4a..0fd504e51 100644 --- a/app/views/business_calendars/_form.html.slim +++ b/app/views/business_calendars/_form.html.slim @@ -3,7 +3,7 @@ .col-lg-12 = f.input :name = f.input :short_name - = f.input :color + = f.input :color, as: :select, collection: BusinessCalendar.color.values, label_method: lambda { |c| color_diplsay(c) } .separator diff --git a/app/views/business_calendars/index.html.slim b/app/views/business_calendars/index.html.slim index ce7f2343b..0cb81f0ac 100644 --- a/app/views/business_calendars/index.html.slim +++ b/app/views/business_calendars/index.html.slim @@ -24,7 +24,7 @@ ), \ TableBuilderHelper::Column.new( \ key: :color, \ - attribute: 'color'\ + attribute: Proc.new { |tt| tt.color ? content_tag(:span, '', class: 'fa fa-circle', style: "color:#{tt.color}") : '-' }\ ), \ TableBuilderHelper::Column.new( \ key: :created_at, \ |
