]> source.dussan.org Git - redmine.git/commitdiff
Add "nwday" class to non-working days in calendar (#27096).
authorGo MAEDA <maeda@farend.jp>
Mon, 14 Jan 2019 05:19:31 +0000 (05:19 +0000)
committerGo MAEDA <maeda@farend.jp>
Mon, 14 Jan 2019 05:19:31 +0000 (05:19 +0000)
Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@17798 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/my_controller.rb
app/helpers/calendars_helper.rb
test/functional/calendars_controller_test.rb

index d2cc0c53c78296573572f0b3a9ad3a8b25694929..72b65e433d13a70ed643fe86008c70801bf406cb 100644 (file)
@@ -29,6 +29,7 @@ class MyController < ApplicationController
   helper :custom_fields
   helper :queries
   helper :activities
+  helper :calendars
 
   def index
     page
index a807ec426a4eb3d61073b57270f36c7c352a0010..fe3796c7f44c9e0a0e308a371a0910ba4a4d7f92 100644 (file)
@@ -18,6 +18,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
 module CalendarsHelper
+  include Redmine::Utils::DateCalculation
+
   def link_to_previous_month(year, month, options={})
     target_year, target_month = if month == 1
                                   [year - 1, 12]
@@ -59,6 +61,7 @@ module CalendarsHelper
   def calendar_day_css_classes(calendar, day)
     css = day.month==calendar.month ? 'even' : 'odd'
     css << " today" if User.current.today == day
+    css << " nwday" if non_working_week_days.include?(day.cwday)
     css
   end
 end
index 7e1cd44136d96195c1d5e4f37be6ccacd4d8b288..da9db3d64799a76f9f339f9b2d8184bcb9e1b95a 100644 (file)
@@ -130,8 +130,24 @@ class CalendarsControllerTest < Redmine::ControllerTest
     get :show, :params => {
         :query_id => 6
       }
-      
+
     assert_response :success
     assert_select 'h2', :text => 'Open issues grouped by tracker'
   end
+
+  def test_show_calendar_day_css_classes
+    get :show, :params => {
+        :month => '12',
+        :year => '2016'
+      }
+    assert_response :success
+
+    assert_select 'tr:nth-child(2)' do
+      assert_select 'td.week-number', :text => '49'
+      # non working days should have "nwday" CSS class
+      assert_select 'td.nwday', 2
+      assert_select 'td.nwday', :text => '4'
+      assert_select 'td.nwday', :text => '10'
+    end
+  end
 end