Patch #5790
open
Save year_from and month_from in the ganttchart
Added by Yuki Kita over 14 years ago.
Updated almost 6 years ago.
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.
Files
- Category changed from UI to Gantt
- Related to Feature #9296: User preference for storing offset of month in Gantt added
if User.current.logged? && (Bruno Basanta != 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'
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