Patch #5790

Save year_from and month_from in the ganttchart

Added by Yuki Kita about 11 years ago. Updated over 2 years ago.

Status:NewStart date:2010-06-30
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Gantt
Target version:-

Description

It would be nice to save year_from and month_from in the ganttchart so that it is not necessary for users to reset them every time.
Now zoom and months are saved but year_from and month_from are not saved.This behavior is not user friendly.

gantt.rb.diff Magnifier (1.45 KB) Yuki Kita, 2010-06-30 23:06


Related issues

Related to Redmine - Feature #9296: User preference for storing offset of month in Gantt New 2011-09-21

History

#1 Updated by Mischa The Evil almost 11 years ago

  • Category changed from UI to Gantt

#2 Updated by Toshi MARUYAMA over 7 years ago

  • Related to Feature #9296: User preference for storing offset of month in Gantt added

#3 Updated by roy yeh over 4 years ago

if User.current.logged? && (@zoom != pref[:gantt_zoom] || @months != pref[:gantt_months] || @month_from != pref[:gantt_month] || @year_from != pref[:year_from])

typo 'year_from' should be replaced by 'gantt_year'

#4 Updated by Sunding Wei over 2 years ago

Thanks to Yuki Kita, I fixed the path which applies to Redmine v3.4.4.stable

--- gantt.rb.old    2018-11-06 13:38:56.680046209 +0800
+++ gantt.rb    2018-12-05 16:13:20.565366565 +0800
@@ -59,18 +59,18 @@
             @month_from = 1
           end
         else
-          @month_from ||= User.current.today.month
-          @year_from ||= User.current.today.year
+          @month_from ||= (User.current.pref[:gantt_month] || Date.today.month)
+          @year_from ||= (User.current.pref[:gantt_year] || Date.today.year)
         end
         zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
         @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
         months = (options[:months] || User.current.pref[:gantt_months]).to_i
         @months = (months > 0 && months < 25) ? months : 6
         # Save gantt parameters as user preference (zoom and months count)
-        if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] ||
-              @months != User.current.pref[:gantt_months]))
-          User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
-          User.current.preference.save
+        pref = User.current.pref
+        if User.current.logged? && (@zoom != pref[:gantt_zoom] || @months != pref[:gantt_months] || @month_from != pref[:gantt_month] || @year_from != pref[:year_from])
+          pref[:gantt_zoom], pref[:gantt_months], pref[:gantt_month], pref[:year_from] = @zoom, @months, @month_from, @year_from
+          pref.save
         end
         @date_from = Date.civil(@year_from, @month_from, 1)
         @date_to = (@date_from >> @months) - 1

Also available in: Atom PDF