diff --git a/app/controllers/milestones_controller.rb b/app/controllers/milestones_controller.rb index ba74846..175314f 100644 --- a/app/controllers/milestones_controller.rb +++ b/app/controllers/milestones_controller.rb @@ -2,9 +2,9 @@ class MilestonesController < ApplicationController menu_item :roadmap - before_filter :find_project, :only => [:new, :create] - before_filter :find_milestone, :only => [:show, :edit, :update, :destroy] - before_filter :authorize, :except => [:show, :total_graph] + before_action :find_project, :only => [:new, :create] + before_action :find_milestone, :only => [:show, :edit, :update, :destroy] + before_action :authorize, :except => [:show, :total_graph] helper :custom_fields helper :projects @@ -37,7 +37,7 @@ def new end def create - @milestone = @project.milestones.build(params[:milestone]) + @milestone = @project.milestones.build(milestone_params) @milestone.user_id = User.current.id if request.post? and @milestone.save if params[:versions] @@ -75,7 +75,7 @@ def update end end end - if @milestone.update_attributes(params[:milestone]) + if @milestone.update(milestone_params) versions_to_delete.each do |version| milestone_version = MilestoneVersion.where("milestone_id = #{@milestone.id} AND version_id = #{version.id}").first milestone_version.destroy @@ -100,7 +100,7 @@ def destroy end def total_graph - g = AdvancedRoadmap::Gruff::Pie.new(params[:size] || "500x400") + g = RedmineAdvancedRoadmap::Gruff::Pie.new(params[:size] || "500x400") g.hide_title = true g.theme = graph_theme g.margins = 0 @@ -149,4 +149,8 @@ def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil) end end + def milestone_params + params.require(:milestone).permit(:name, :description, :effective_date) + end + end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 2d75473..6444d6f 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -10,8 +10,6 @@ class Milestone < ActiveRecord::Base validates_length_of :name, :maximum => 60 validates :effective_date, :date => true, :allow_nil => true - attr_accessible :name, :description, :effective_date - def to_s name end diff --git a/app/views/hooks/_stylesheet.html.erb b/app/views/hooks/_stylesheet.html.erb index e0762bc..e63dbb8 100644 --- a/app/views/hooks/_stylesheet.html.erb +++ b/app/views/hooks/_stylesheet.html.erb @@ -1 +1 @@ -<%= stylesheet_link_tag("advanced_roadmap", :plugin => "advanced_roadmap_v2", :media => "all") %> +<%= stylesheet_link_tag("redmine_advanced_roadmap", :plugin => "redmine_advanced_roadmap_v2", :media => "all") %> diff --git a/app/views/settings/_advanced_roadmap_settings.html.erb b/app/views/settings/_advanced_roadmap_settings.html.erb index dda080e..88f9c23 100644 --- a/app/views/settings/_advanced_roadmap_settings.html.erb +++ b/app/views/settings/_advanced_roadmap_settings.html.erb @@ -1,4 +1,4 @@ -<%- defaults = Redmine::Plugin::registered_plugins[:advanced_roadmap_v2].settings[:default] -%> +<%- defaults = Redmine::Plugin::registered_plugins[:redmine_advanced_roadmap_v2].settings[:default] -%>

<%= label_tag 'settings[show_due_time]', l(:label_setting_show_due_time) %> diff --git a/app/views/versions/_info.html.erb b/app/views/versions/_info.html.erb index d2caae5..ddcb67b 100644 --- a/app/views/versions/_info.html.erb +++ b/app/views/versions/_info.html.erb @@ -50,7 +50,7 @@ <%- end -%> <%- if issues.present? -%> -<%- show_due_time = (Setting.plugin_advanced_roadmap_v2["show_due_time"]) -%> +<%- show_due_time = (Setting.plugin_redmine_advanced_roadmap_v2["show_due_time"]) -%>

+
diff --git a/assets/stylesheets/advanced_roadmap.css b/assets/stylesheets/redmine_advanced_roadmap.css similarity index 100% rename from assets/stylesheets/advanced_roadmap.css rename to assets/stylesheets/redmine_advanced_roadmap.css diff --git a/db/migrate/001_create_milestones.rb b/db/migrate/001_create_milestones.rb index 3e4f90d..1cdf6c5 100644 --- a/db/migrate/001_create_milestones.rb +++ b/db/migrate/001_create_milestones.rb @@ -1,4 +1,4 @@ -class CreateMilestones < ActiveRecord::Migration +class CreateMilestones < ActiveRecord::Migration[5.1] def self.up create_table :milestones, :force => true do |t| t.column :name, :string, :null => false diff --git a/db/migrate/002_create_milestone_versions.rb b/db/migrate/002_create_milestone_versions.rb index e58af02..5e7a4df 100644 --- a/db/migrate/002_create_milestone_versions.rb +++ b/db/migrate/002_create_milestone_versions.rb @@ -1,4 +1,4 @@ -class CreateMilestoneVersions < ActiveRecord::Migration +class CreateMilestoneVersions < ActiveRecord::Migration[5.1] def self.up create_table :milestone_versions, :force => true do |t| t.column :milestone_id, :integer, :null => false diff --git a/db/migrate/003_preset_permissions.rb b/db/migrate/003_preset_permissions.rb index efb9699..9d86827 100644 --- a/db/migrate/003_preset_permissions.rb +++ b/db/migrate/003_preset_permissions.rb @@ -1,4 +1,4 @@ -class PresetPermissions < ActiveRecord::Migration +class PresetPermissions < ActiveRecord::Migration[5.1] def self.up role = nil begin diff --git a/init.rb b/init.rb index 5ec5bda..b705c56 100644 --- a/init.rb +++ b/init.rb @@ -5,31 +5,25 @@ ActiveSupport::Dependencies.autoload_once_paths.reject!{|x| x =~ /^#{Regexp.escape(File.dirname(__FILE__))}/} end -require "redmine" -require "rubygems" -require "gravatar" +ApplicationHelper.send(:include, RedmineAdvancedRoadmap::ApplicationHelperPatch) +CalendarsController.send(:include, RedmineAdvancedRoadmap::CalendarsControllerPatch) +Issue.send(:include, RedmineAdvancedRoadmap::IssuePatch) +Journal.send(:include, RedmineAdvancedRoadmap::JournalPatch) +Project.send(:include, RedmineAdvancedRoadmap::ProjectPatch) +ProjectsHelper.send(:include, RedmineAdvancedRoadmap::ProjectsHelperPatch) +Query.send(:include, RedmineAdvancedRoadmap::QueryPatch) +Redmine::Helpers::Gantt.send(:include, RedmineAdvancedRoadmap::RedmineHelpersGanttPatch) +Redmine::I18n.send(:include, RedmineAdvancedRoadmap::RedmineI18nPatch) +Version.send(:include, RedmineAdvancedRoadmap::VersionPatch) +VersionsController.send(:include, RedmineAdvancedRoadmap::VersionsControllerPatch) -ApplicationHelper.send(:include, AdvancedRoadmap::ApplicationHelperPatch) -CalendarsController.send(:include, AdvancedRoadmap::CalendarsControllerPatch) -Issue.send(:include, AdvancedRoadmap::IssuePatch) -Journal.send(:include, AdvancedRoadmap::JournalPatch) -Project.send(:include, AdvancedRoadmap::ProjectPatch) -ProjectsHelper.send(:include, AdvancedRoadmap::ProjectsHelperPatch) -Query.send(:include, AdvancedRoadmap::QueryPatch) -Redmine::Helpers::Gantt.send(:include, AdvancedRoadmap::RedmineHelpersGanttPatch) -Redmine::I18n.send(:include, AdvancedRoadmap::RedmineI18nPatch) -Version.send(:include, AdvancedRoadmap::VersionPatch) -VersionsController.send(:include, AdvancedRoadmap::VersionsControllerPatch) - -require_dependency "advanced_roadmap/view_hooks" - -Redmine::Plugin.register :advanced_roadmap_v2 do +Redmine::Plugin.register :redmine_advanced_roadmap_v2 do name "Advanced roadmap & milestones plugin" url "https://github.com/ekylibre/redmine_advanced_roadmap_v2" author "Michel LOISELEUR" author_url "https://github.com/Coren" description "This is a plugin for Redmine that is used to show more information inside the Roadmap page and implements the milestones featuring." - version "2.4.3" + version "2.5.0" permission :manage_milestones, {:milestones => [:new, :create, :edit, :update, :destroy]} requires_redmine :version_or_higher => "2.1.2" diff --git a/lib/advanced_roadmap/gruff/mini/bar.rb b/lib/advanced_roadmap/gruff/mini/bar.rb deleted file mode 100644 index 5ee4124..0000000 --- a/lib/advanced_roadmap/gruff/mini/bar.rb +++ /dev/null @@ -1,37 +0,0 @@ -## -# -# Makes a small bar graph suitable for display at 200px or even smaller. -# -module Gruff - module Mini - - class Bar < Gruff::Bar - - include Gruff::Mini::Legend - - def initialize_ivars - super - - @hide_legend = true - @hide_title = true - @hide_line_numbers = true - - @marker_font_size = 50.0 - @minimum_value = 0.0 - @maximum_value = 0.0 - @legend_font_size = 60.0 - end - - def draw - expand_canvas_for_vertical_legend - - super - - draw_vertical_legend - @d.draw(@base_image) - end - - end - - end -end diff --git a/lib/advanced_roadmap/gruff/mini/legend.rb b/lib/advanced_roadmap/gruff/mini/legend.rb deleted file mode 100644 index b869cb1..0000000 --- a/lib/advanced_roadmap/gruff/mini/legend.rb +++ /dev/null @@ -1,82 +0,0 @@ -module Gruff - module Mini - module Legend - - attr_accessor :hide_mini_legend - - ## - # The canvas needs to be bigger so we can put the legend beneath it. - - def expand_canvas_for_vertical_legend - return if @hide_mini_legend - - @original_rows = @raw_rows - @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7 - render_background - end - - ## - # Draw the legend beneath the existing graph. - - def draw_vertical_legend - return if @hide_mini_legend - - @legend_labels = @data.collect {|item| item[Gruff::Base::DATA_LABEL_INDEX] } - - legend_square_width = 40.0 # small square with color of this item - legend_square_margin = 10.0 - @legend_left_margin = 100.0 - legend_top_margin = 40.0 - - # May fix legend drawing problem at small sizes - @d.font = @font if @font - @d.pointsize = @legend_font_size - - current_x_offset = @legend_left_margin - current_y_offset = @original_rows + legend_top_margin - - debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset } - - @legend_labels.each_with_index do |legend_label, index| - - # Draw label - @d.fill = @font_color - @d.font = @font if @font - @d.pointsize = scale_fontsize(@legend_font_size) - @d.stroke = 'transparent' - @d.font_weight = Magick::NormalWeight - @d.gravity = Magick::WestGravity - @d = @d.annotate_scaled( @base_image, - @raw_columns, 1.0, - current_x_offset + (legend_square_width * 1.7), current_y_offset, - truncate_legend_label(legend_label), @scale) - - # Now draw box with color of this dataset - @d = @d.stroke 'transparent' - @d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX] - @d = @d.rectangle(current_x_offset, - current_y_offset - legend_square_width / 2.0, - current_x_offset + legend_square_width, - current_y_offset + legend_square_width / 2.0) - - current_y_offset += calculate_caps_height(@legend_font_size) * 1.7 - end - @color_index = 0 - end - - ## - # Shorten long labels so they will fit on the canvas. - # - # Department of Hu... - - def truncate_legend_label(label) - truncated_label = label.to_s - while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1) - truncated_label = truncated_label[0..truncated_label.length-2] - end - truncated_label + (truncated_label.length < label.to_s.length ? "..." : '') - end - - end - end -end diff --git a/lib/advanced_roadmap/gruff/mini/pie.rb b/lib/advanced_roadmap/gruff/mini/pie.rb deleted file mode 100644 index 7822ba5..0000000 --- a/lib/advanced_roadmap/gruff/mini/pie.rb +++ /dev/null @@ -1,36 +0,0 @@ -## -# -# Makes a small pie graph suitable for display at 200px or even smaller. -# -module Gruff - module Mini - - class Pie < Gruff::Pie - - include Gruff::Mini::Legend - - def initialize_ivars - super - - @hide_legend = true - @hide_title = true - @hide_line_numbers = true - - @marker_font_size = 60.0 - @legend_font_size = 60.0 - end - - def draw - expand_canvas_for_vertical_legend - - super - - draw_vertical_legend - - @d.draw(@base_image) - end # def draw - - end # class Pie - - end -end diff --git a/lib/advanced_roadmap/gruff/mini/side_bar.rb b/lib/advanced_roadmap/gruff/mini/side_bar.rb deleted file mode 100644 index 46be4f4..0000000 --- a/lib/advanced_roadmap/gruff/mini/side_bar.rb +++ /dev/null @@ -1,35 +0,0 @@ -## -# -# Makes a small pie graph suitable for display at 200px or even smaller. -# -module Gruff - module Mini - - class SideBar < Gruff::SideBar - - include Gruff::Mini::Legend - - def initialize_ivars - super - @hide_legend = true - @hide_title = true - @hide_line_numbers = true - - @marker_font_size = 50.0 - @legend_font_size = 50.0 - end - - def draw - expand_canvas_for_vertical_legend - - super - - draw_vertical_legend - - @d.draw(@base_image) - end - - end - - end -end diff --git a/lib/advanced_roadmap/projects_helper_patch.rb b/lib/advanced_roadmap/projects_helper_patch.rb deleted file mode 100644 index 2316418..0000000 --- a/lib/advanced_roadmap/projects_helper_patch.rb +++ /dev/null @@ -1,20 +0,0 @@ -require_dependency "projects_helper" - -module AdvancedRoadmap - module ProjectsHelperPatch - def self.included(base) - base.class_eval do - def project_settings_tabs_with_more_tabs - tabs = project_settings_tabs_without_more_tabs - index = tabs.index({:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}) - if index - tabs.insert(index, {:name => "milestones", :action => :manage_milestones, :partial => "projects/settings/milestones", :label => :label_milestone_plural}) - tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} - end - return(tabs) - end - alias_method_chain :project_settings_tabs, :more_tabs - end - end - end -end diff --git a/lib/advanced_roadmap/application_helper_patch.rb b/lib/redmine_advanced_roadmap/application_helper_patch.rb similarity index 78% rename from lib/advanced_roadmap/application_helper_patch.rb rename to lib/redmine_advanced_roadmap/application_helper_patch.rb index 9a4af8e..ef93599 100644 --- a/lib/advanced_roadmap/application_helper_patch.rb +++ b/lib/redmine_advanced_roadmap/application_helper_patch.rb @@ -1,6 +1,6 @@ require_dependency "application_helper" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module ApplicationHelperPatch def self.included(base) base.class_eval do @@ -15,9 +15,9 @@ def link_to_milestone(milestone) def color_by_ratio(ratio) color = "" - color = Setting.plugin_advanced_roadmap_v2["color_good"] if ratio <= Setting.plugin_advanced_roadmap_v2["ratio_good"].to_f - color = Setting.plugin_advanced_roadmap_v2["color_bad"] if ratio >= Setting.plugin_advanced_roadmap_v2["ratio_bad"].to_f - color = Setting.plugin_advanced_roadmap_v2["color_very_bad"] if ratio >= Setting.plugin_advanced_roadmap_v2["ratio_very_bad"].to_f + color = Setting.plugin_redmine_advanced_roadmap_v2["color_good"] if ratio <= Setting.plugin_redmine_advanced_roadmap_v2["ratio_good"].to_f + color = Setting.plugin_redmine_advanced_roadmap_v2["color_bad"] if ratio >= Setting.plugin_redmine_advanced_roadmap_v2["ratio_bad"].to_f + color = Setting.plugin_redmine_advanced_roadmap_v2["color_very_bad"] if ratio >= Setting.plugin_redmine_advanced_roadmap_v2["ratio_very_bad"].to_f return(color) end diff --git a/lib/advanced_roadmap/calendars_controller_patch.rb b/lib/redmine_advanced_roadmap/calendars_controller_patch.rb similarity index 62% rename from lib/advanced_roadmap/calendars_controller_patch.rb rename to lib/redmine_advanced_roadmap/calendars_controller_patch.rb index 7b5bb8b..13d21f3 100644 --- a/lib/advanced_roadmap/calendars_controller_patch.rb +++ b/lib/redmine_advanced_roadmap/calendars_controller_patch.rb @@ -1,15 +1,16 @@ require_dependency "calendars_controller" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module CalendarsControllerPatch def self.included(base) base.class_eval do - around_filter :add_milestones, :only => [:show] + around_action :add_milestones, :only => [:show] def add_milestones yield - view = ActionView::Base.new(File.join(File.dirname(__FILE__), "..", "..", "app", "views")) + lookup_context = ActionView::LookupContext.new(ActionController::Base.view_paths) + view = ActionView::Base.with_empty_template_cache.new(lookup_context, {}, nil) view.class_eval do include ApplicationHelper end @@ -23,8 +24,8 @@ def add_milestones :id => milestone.id, :only_path => true), :day => milestone.effective_date.day} end - response.body += view.render(:partial => "hooks/calendars/milestones", - :locals => {:milestones => milestones}) + renderer = ActionView::Renderer.new(lookup_context) + response.body += renderer.render(view, { file: Rails.root.join('plugins', 'redmine_advanced_roadmap_v2', 'app', 'views', 'hooks', 'calendars', '_milestones.html.erb'), :locals => {:milestones => milestones} }) end end diff --git a/lib/advanced_roadmap/gruff.rb b/lib/redmine_advanced_roadmap/gruff.rb similarity index 100% rename from lib/advanced_roadmap/gruff.rb rename to lib/redmine_advanced_roadmap/gruff.rb diff --git a/lib/advanced_roadmap/gruff/accumulator_bar.rb b/lib/redmine_advanced_roadmap/gruff/accumulator_bar.rb similarity index 87% rename from lib/advanced_roadmap/gruff/accumulator_bar.rb rename to lib/redmine_advanced_roadmap/gruff/accumulator_bar.rb index 28b8bb6..a6c54d3 100644 --- a/lib/advanced_roadmap/gruff/accumulator_bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/accumulator_bar.rb @@ -5,7 +5,7 @@ # stacked bars. The bottom bar shows the running total and # the top bar shows the new value being added to the array. -class AdvancedRoadmap::Gruff::AccumulatorBar < AdvancedRoadmap::Gruff::StackedBar +class RedmineAdvancedRoadmap::Gruff::AccumulatorBar < RedmineAdvancedRoadmap::Gruff::StackedBar def draw raise(Gruff::IncorrectNumberOfDatasetsException) unless @data.length == 1 diff --git a/lib/advanced_roadmap/gruff/area.rb b/lib/redmine_advanced_roadmap/gruff/area.rb similarity index 94% rename from lib/advanced_roadmap/gruff/area.rb rename to lib/redmine_advanced_roadmap/gruff/area.rb index 7a57533..a2671c9 100644 --- a/lib/advanced_roadmap/gruff/area.rb +++ b/lib/redmine_advanced_roadmap/gruff/area.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/base' -class AdvancedRoadmap::Gruff::Area < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Area < RedmineAdvancedRoadmap::Gruff::Base def draw super diff --git a/lib/advanced_roadmap/gruff/bar.rb b/lib/redmine_advanced_roadmap/gruff/bar.rb similarity index 97% rename from lib/advanced_roadmap/gruff/bar.rb rename to lib/redmine_advanced_roadmap/gruff/bar.rb index c5f9fcb..e9ca50a 100644 --- a/lib/advanced_roadmap/gruff/bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/bar.rb @@ -1,7 +1,7 @@ require File.dirname(__FILE__) + '/base' require File.dirname(__FILE__) + '/bar_conversion' -class AdvancedRoadmap::Gruff::Bar < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Bar < RedmineAdvancedRoadmap::Gruff::Base # Spacing factor applied between bars attr_accessor :bar_spacing diff --git a/lib/advanced_roadmap/gruff/bar_conversion.rb b/lib/redmine_advanced_roadmap/gruff/bar_conversion.rb similarity index 96% rename from lib/advanced_roadmap/gruff/bar_conversion.rb rename to lib/redmine_advanced_roadmap/gruff/bar_conversion.rb index c97f7bd..da17a97 100644 --- a/lib/advanced_roadmap/gruff/bar_conversion.rb +++ b/lib/redmine_advanced_roadmap/gruff/bar_conversion.rb @@ -9,7 +9,7 @@ # 2. Bars all go from zero to negative direction # 3. Bars either go from zero to positive or from zero to negative # -class AdvancedRoadmap::Gruff::BarConversion +class RedmineAdvancedRoadmap::Gruff::BarConversion attr_writer :mode attr_writer :zero attr_writer :graph_top diff --git a/lib/advanced_roadmap/gruff/base.rb b/lib/redmine_advanced_roadmap/gruff/base.rb similarity index 99% rename from lib/advanced_roadmap/gruff/base.rb rename to lib/redmine_advanced_roadmap/gruff/base.rb index 4f3d502..4716b21 100644 --- a/lib/advanced_roadmap/gruff/base.rb +++ b/lib/redmine_advanced_roadmap/gruff/base.rb @@ -15,7 +15,26 @@ # Breijs, Richard Cowin, and a cast of thousands. # # See Gruff::Base#theme= for setting themes. -module AdvancedRoadmap +module Magick + + class Draw + + # Additional method to scale annotation text since Draw.scale doesn't. + def annotate_scaled(img, width, height, x, y, text, scale) + scaled_width = (width * scale) >= 1 ? (width * scale) : 1 + scaled_height = (height * scale) >= 1 ? (height * scale) : 1 + + self.annotate( img, + scaled_width, scaled_height, + x * scale, y * scale, + text) + end + + end + +end # Magick + +module RedmineAdvancedRoadmap module Gruff # This is the version of Gruff you are using. @@ -221,7 +240,7 @@ def initialize_ivars @scale = @columns / @raw_columns vera_font_path = File.expand_path('Vera.ttf', ENV['MAGICK_FONT_PATH']) - @font = File.exists?(vera_font_path) ? vera_font_path : Redmine::Configuration['rmagick_font_path'] + @font = File.exist?(vera_font_path) ? vera_font_path : Redmine::Configuration['rmagick_font_path'] @marker_font_size = 21.0 @legend_font_size = 20.0 @@ -1109,21 +1128,4 @@ class IncorrectNumberOfDatasetsException < StandardError; end end # Gruff end -module Magick - - class Draw - - # Additional method to scale annotation text since Draw.scale doesn't. - def annotate_scaled(img, width, height, x, y, text, scale) - scaled_width = (width * scale) >= 1 ? (width * scale) : 1 - scaled_height = (height * scale) >= 1 ? (height * scale) : 1 - - self.annotate( img, - scaled_width, scaled_height, - x * scale, y * scale, - text) - end - - end -end # Magick diff --git a/lib/advanced_roadmap/gruff/bullet.rb b/lib/redmine_advanced_roadmap/gruff/bullet.rb similarity index 97% rename from lib/advanced_roadmap/gruff/bullet.rb rename to lib/redmine_advanced_roadmap/gruff/bullet.rb index 3414c87..e463c05 100644 --- a/lib/advanced_roadmap/gruff/bullet.rb +++ b/lib/redmine_advanced_roadmap/gruff/bullet.rb @@ -1,6 +1,6 @@ require File.dirname(__FILE__) + '/base' -class AdvancedRoadmap::Gruff::Bullet < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Bullet < RedmineAdvancedRoadmap::Gruff::Base def initialize(target_width="400x40") if not Numeric === target_width diff --git a/lib/advanced_roadmap/gruff/deprecated.rb b/lib/redmine_advanced_roadmap/gruff/deprecated.rb similarity index 95% rename from lib/advanced_roadmap/gruff/deprecated.rb rename to lib/redmine_advanced_roadmap/gruff/deprecated.rb index 0d9d9d4..45196a6 100644 --- a/lib/advanced_roadmap/gruff/deprecated.rb +++ b/lib/redmine_advanced_roadmap/gruff/deprecated.rb @@ -3,7 +3,7 @@ # A mixin for methods that need to be deleted or have been # replaced by cleaner code. -module AdvancedRoadmap +module RedmineAdvancedRoadmap module Gruff module Deprecated diff --git a/lib/advanced_roadmap/gruff/dot.rb b/lib/redmine_advanced_roadmap/gruff/dot.rb similarity index 97% rename from lib/advanced_roadmap/gruff/dot.rb rename to lib/redmine_advanced_roadmap/gruff/dot.rb index 90639f3..20c7cb6 100644 --- a/lib/advanced_roadmap/gruff/dot.rb +++ b/lib/redmine_advanced_roadmap/gruff/dot.rb @@ -4,7 +4,7 @@ # Graph with dots and labels along a vertical access # see: 'Creating More Effective Graphs' by Robbins -class AdvancedRoadmap::Gruff::Dot < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Dot < RedmineAdvancedRoadmap::Gruff::Base def draw @has_left_labels = true diff --git a/lib/advanced_roadmap/gruff/line.rb b/lib/redmine_advanced_roadmap/gruff/line.rb similarity index 98% rename from lib/advanced_roadmap/gruff/line.rb rename to lib/redmine_advanced_roadmap/gruff/line.rb index dc7085f..fc43968 100644 --- a/lib/advanced_roadmap/gruff/line.rb +++ b/lib/redmine_advanced_roadmap/gruff/line.rb @@ -12,7 +12,7 @@ # # There are also other options described below, such as #baseline_value, #baseline_color, #hide_dots, and #hide_lines. -class AdvancedRoadmap::Gruff::Line < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Line < RedmineAdvancedRoadmap::Gruff::Base # Draw a dashed line at the given value attr_accessor :baseline_value diff --git a/lib/redmine_advanced_roadmap/gruff/mini/bar.rb b/lib/redmine_advanced_roadmap/gruff/mini/bar.rb new file mode 100644 index 0000000..b59e373 --- /dev/null +++ b/lib/redmine_advanced_roadmap/gruff/mini/bar.rb @@ -0,0 +1,38 @@ +## +# +# Makes a small bar graph suitable for display at 200px or even smaller. +# +module RedmineAdvancedRoadmap + module Gruff + module Mini + + class Bar < RedmineAdvancedRoadmap::Gruff::Bar + + include Gruff::Mini::Legend + + def initialize_ivars + super + + @hide_legend = true + @hide_title = true + @hide_line_numbers = true + + @marker_font_size = 50.0 + @minimum_value = 0.0 + @maximum_value = 0.0 + @legend_font_size = 60.0 + end + + def draw + expand_canvas_for_vertical_legend + + super + + draw_vertical_legend + @d.draw(@base_image) + end + end + + end + end +end diff --git a/lib/redmine_advanced_roadmap/gruff/mini/legend.rb b/lib/redmine_advanced_roadmap/gruff/mini/legend.rb new file mode 100644 index 0000000..1cd8881 --- /dev/null +++ b/lib/redmine_advanced_roadmap/gruff/mini/legend.rb @@ -0,0 +1,84 @@ +module RedmineAdvancedRoadmap + module Gruff + module Mini + module Legend + + attr_accessor :hide_mini_legend + + ## + # The canvas needs to be bigger so we can put the legend beneath it. + + def expand_canvas_for_vertical_legend + return if @hide_mini_legend + + @original_rows = @raw_rows + @rows += @data.length * calculate_caps_height(scale_fontsize(@legend_font_size)) * 1.7 + render_background + end + + ## + # Draw the legend beneath the existing graph. + + def draw_vertical_legend + return if @hide_mini_legend + + @legend_labels = @data.collect {|item| item[Gruff::Base::DATA_LABEL_INDEX] } + + legend_square_width = 40.0 # small square with color of this item + legend_square_margin = 10.0 + @legend_left_margin = 100.0 + legend_top_margin = 40.0 + + # May fix legend drawing problem at small sizes + @d.font = @font if @font + @d.pointsize = @legend_font_size + + current_x_offset = @legend_left_margin + current_y_offset = @original_rows + legend_top_margin + + debug { @d.line 0.0, current_y_offset, @raw_columns, current_y_offset } + + @legend_labels.each_with_index do |legend_label, index| + + # Draw label + @d.fill = @font_color + @d.font = @font if @font + @d.pointsize = scale_fontsize(@legend_font_size) + @d.stroke = 'transparent' + @d.font_weight = Magick::NormalWeight + @d.gravity = Magick::WestGravity + @d = @d.annotate_scaled( @base_image, + @raw_columns, 1.0, + current_x_offset + (legend_square_width * 1.7), current_y_offset, + truncate_legend_label(legend_label), @scale) + + # Now draw box with color of this dataset + @d = @d.stroke 'transparent' + @d = @d.fill @data[index][Gruff::Base::DATA_COLOR_INDEX] + @d = @d.rectangle(current_x_offset, + current_y_offset - legend_square_width / 2.0, + current_x_offset + legend_square_width, + current_y_offset + legend_square_width / 2.0) + + current_y_offset += calculate_caps_height(@legend_font_size) * 1.7 + end + @color_index = 0 + end + + ## + # Shorten long labels so they will fit on the canvas. + # + # Department of Hu... + + def truncate_legend_label(label) + truncated_label = label.to_s + while calculate_width(scale_fontsize(@legend_font_size), truncated_label) > (@columns - @legend_left_margin - @right_margin) && (truncated_label.length > 1) + truncated_label = truncated_label[0..truncated_label.length-2] + end + truncated_label + (truncated_label.length < label.to_s.length ? "..." : '') + end + + end + end + end +end diff --git a/lib/redmine_advanced_roadmap/gruff/mini/pie.rb b/lib/redmine_advanced_roadmap/gruff/mini/pie.rb new file mode 100644 index 0000000..284911c --- /dev/null +++ b/lib/redmine_advanced_roadmap/gruff/mini/pie.rb @@ -0,0 +1,40 @@ +## +# +# Makes a small pie graph suitable for display at 200px or even smaller. +# +require File.dirname(__FILE__) + '/legend' + +module RedmineAdvancedRoadmap + module Gruff + module Mini + + class Pie < RedmineAdvancedRoadmap::Gruff::Pie + + include RedmineAdvancedRoadmap::Gruff::Mini::Legend + + def initialize_ivars + super + + @hide_legend = true + @hide_title = true + @hide_line_numbers = true + + @marker_font_size = 60.0 + @legend_font_size = 60.0 + end + + def draw + expand_canvas_for_vertical_legend + + super + + draw_vertical_legend + + @d.draw(@base_image) + end # def draw + + end # class Pie + + end + end +end diff --git a/lib/redmine_advanced_roadmap/gruff/mini/side_bar.rb b/lib/redmine_advanced_roadmap/gruff/mini/side_bar.rb new file mode 100644 index 0000000..50d77fd --- /dev/null +++ b/lib/redmine_advanced_roadmap/gruff/mini/side_bar.rb @@ -0,0 +1,37 @@ +## +# +# Makes a small pie graph suitable for display at 200px or even smaller. +# +module RedmineAdvancedRoadmap + module Gruff + module Mini + + class SideBar < RedmineAdvancedRoadmap::Gruff::SideBar + + include RedmineAdvancedRoadmap::Gruff::Mini::Legend + + def initialize_ivars + super + @hide_legend = true + @hide_title = true + @hide_line_numbers = true + + @marker_font_size = 50.0 + @legend_font_size = 50.0 + end + + def draw + expand_canvas_for_vertical_legend + + super + + draw_vertical_legend + + @d.draw(@base_image) + end + + end + + end + end +end diff --git a/lib/advanced_roadmap/gruff/net.rb b/lib/redmine_advanced_roadmap/gruff/net.rb similarity index 98% rename from lib/advanced_roadmap/gruff/net.rb rename to lib/redmine_advanced_roadmap/gruff/net.rb index 47a8bb7..e3e299e 100644 --- a/lib/advanced_roadmap/gruff/net.rb +++ b/lib/redmine_advanced_roadmap/gruff/net.rb @@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/base' # Experimental!!! See also the Spider graph. -class AdvancedRoadmap::Gruff::Net < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Net < RedmineAdvancedRoadmap::Gruff::Base # Hide parts of the graph to fit more datapoints, or for a different appearance. attr_accessor :hide_dots diff --git a/lib/advanced_roadmap/gruff/photo_bar.rb b/lib/redmine_advanced_roadmap/gruff/photo_bar.rb similarity index 97% rename from lib/advanced_roadmap/gruff/photo_bar.rb rename to lib/redmine_advanced_roadmap/gruff/photo_bar.rb index 1581e78..2764ed4 100644 --- a/lib/advanced_roadmap/gruff/photo_bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/photo_bar.rb @@ -4,7 +4,7 @@ # # Doesn't work yet. # -class AdvancedRoadmap::Gruff::PhotoBar < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::PhotoBar < RedmineAdvancedRoadmap::Gruff::Base # TODO # diff --git a/lib/advanced_roadmap/gruff/pie.rb b/lib/redmine_advanced_roadmap/gruff/pie.rb similarity index 98% rename from lib/advanced_roadmap/gruff/pie.rb rename to lib/redmine_advanced_roadmap/gruff/pie.rb index d1181b1..9c3906b 100644 --- a/lib/advanced_roadmap/gruff/pie.rb +++ b/lib/redmine_advanced_roadmap/gruff/pie.rb @@ -11,7 +11,7 @@ # # To control where the pie chart starts creating slices, use #zero_degree. -class AdvancedRoadmap::Gruff::Pie < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Pie < RedmineAdvancedRoadmap::Gruff::Base TEXT_OFFSET_PERCENTAGE = 0.15 diff --git a/lib/advanced_roadmap/gruff/scene.rb b/lib/redmine_advanced_roadmap/gruff/scene.rb similarity index 97% rename from lib/advanced_roadmap/gruff/scene.rb rename to lib/redmine_advanced_roadmap/gruff/scene.rb index f722f07..8196737 100644 --- a/lib/advanced_roadmap/gruff/scene.rb +++ b/lib/redmine_advanced_roadmap/gruff/scene.rb @@ -39,7 +39,7 @@ # * Other named files will be used if the input matches the filename (without the filetype extension). # * If there is a file named 'default.png', it will be used unless other input values are set for the corresponding layer. -class AdvancedRoadmap::Gruff::Scene < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Scene < RedmineAdvancedRoadmap::Gruff::Base # An array listing the foldernames that will be rendered, from back to front. # @@ -106,7 +106,7 @@ def set_input(input_name, input_value) end -class Gruff::Group +class RedmineAdvancedRoadmap::Gruff::Group include Observable attr_reader :name @@ -126,7 +126,7 @@ def send_updates(value) end -class Gruff::Layer +class RedmineAdvancedRoadmap::Gruff::Layer attr_reader :name diff --git a/lib/advanced_roadmap/gruff/side_bar.rb b/lib/redmine_advanced_roadmap/gruff/side_bar.rb similarity index 97% rename from lib/advanced_roadmap/gruff/side_bar.rb rename to lib/redmine_advanced_roadmap/gruff/side_bar.rb index 49a101c..8dc9801 100644 --- a/lib/advanced_roadmap/gruff/side_bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/side_bar.rb @@ -3,7 +3,7 @@ ## # Graph with individual horizontal bars instead of vertical bars. -class AdvancedRoadmap::Gruff::SideBar < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::SideBar < RedmineAdvancedRoadmap::Gruff::Base def draw @has_left_labels = true diff --git a/lib/advanced_roadmap/gruff/side_stacked_bar.rb b/lib/redmine_advanced_roadmap/gruff/side_stacked_bar.rb similarity index 93% rename from lib/advanced_roadmap/gruff/side_stacked_bar.rb rename to lib/redmine_advanced_roadmap/gruff/side_stacked_bar.rb index 65ea77e..3a89861 100644 --- a/lib/advanced_roadmap/gruff/side_stacked_bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/side_stacked_bar.rb @@ -8,8 +8,8 @@ # # alun.eyre@googlemail.com -class AdvancedRoadmap::Gruff::SideStackedBar < AdvancedRoadmap::Gruff::SideBar - include StackedMixin +class RedmineAdvancedRoadmap::Gruff::SideStackedBar < RedmineAdvancedRoadmap::Gruff::SideBar + include RedmineAdvancedRoadmap::Gruff::StackedMixin def draw @has_left_labels = true diff --git a/lib/advanced_roadmap/gruff/spider.rb b/lib/redmine_advanced_roadmap/gruff/spider.rb similarity index 97% rename from lib/advanced_roadmap/gruff/spider.rb rename to lib/redmine_advanced_roadmap/gruff/spider.rb index eedf9b4..3e221af 100644 --- a/lib/advanced_roadmap/gruff/spider.rb +++ b/lib/redmine_advanced_roadmap/gruff/spider.rb @@ -4,7 +4,7 @@ # Experimental!!! See also the Net graph. # # Submitted by Kevin Clark http://glu.ttono.us/ -class AdvancedRoadmap::Gruff::Spider < AdvancedRoadmap::Gruff::Base +class RedmineAdvancedRoadmap::Gruff::Spider < RedmineAdvancedRoadmap::Gruff::Base # Hide all text attr_reader :hide_text diff --git a/lib/advanced_roadmap/gruff/stacked_area.rb b/lib/redmine_advanced_roadmap/gruff/stacked_area.rb similarity index 92% rename from lib/advanced_roadmap/gruff/stacked_area.rb rename to lib/redmine_advanced_roadmap/gruff/stacked_area.rb index 541c224..0b46f49 100644 --- a/lib/advanced_roadmap/gruff/stacked_area.rb +++ b/lib/redmine_advanced_roadmap/gruff/stacked_area.rb @@ -2,8 +2,8 @@ require File.dirname(__FILE__) + '/base' require File.dirname(__FILE__) + '/stacked_mixin' -class AdvancedRoadmap::Gruff::StackedArea < AdvancedRoadmap::Gruff::Base - include StackedMixin +class RedmineAdvancedRoadmap::Gruff::StackedArea < RedmineAdvancedRoadmap::Gruff::Base + include RedmineAdvancedRoadmap::Gruff::StackedMixin attr_accessor :last_series_goes_on_bottom def draw diff --git a/lib/advanced_roadmap/gruff/stacked_bar.rb b/lib/redmine_advanced_roadmap/gruff/stacked_bar.rb similarity index 92% rename from lib/advanced_roadmap/gruff/stacked_bar.rb rename to lib/redmine_advanced_roadmap/gruff/stacked_bar.rb index fb366ce..b4abf12 100644 --- a/lib/advanced_roadmap/gruff/stacked_bar.rb +++ b/lib/redmine_advanced_roadmap/gruff/stacked_bar.rb @@ -2,8 +2,8 @@ require File.dirname(__FILE__) + '/base' require File.dirname(__FILE__) + '/stacked_mixin' -class AdvancedRoadmap::Gruff::StackedBar < AdvancedRoadmap::Gruff::Base - include StackedMixin +class RedmineAdvancedRoadmap::Gruff::StackedBar < RedmineAdvancedRoadmap::Gruff::Base + include RedmineAdvancedRoadmap::Gruff::StackedMixin # Draws a bar graph, but multiple sets are stacked on top of each other. def draw diff --git a/lib/advanced_roadmap/gruff/stacked_mixin.rb b/lib/redmine_advanced_roadmap/gruff/stacked_mixin.rb similarity index 80% rename from lib/advanced_roadmap/gruff/stacked_mixin.rb rename to lib/redmine_advanced_roadmap/gruff/stacked_mixin.rb index d955d70..66cd2b2 100644 --- a/lib/advanced_roadmap/gruff/stacked_mixin.rb +++ b/lib/redmine_advanced_roadmap/gruff/stacked_mixin.rb @@ -1,9 +1,9 @@ -module AdvancedRoadmap::Gruff::Base::StackedMixin +module RedmineAdvancedRoadmap::Gruff::StackedMixin # Used by StackedBar and child classes. # # tsal: moved from Base 03 FEB 2007 - DATA_VALUES_INDEX = AdvancedRoadmap::Gruff::Base::DATA_VALUES_INDEX + DATA_VALUES_INDEX = RedmineAdvancedRoadmap::Gruff::Base::DATA_VALUES_INDEX def get_maximum_by_stack # Get sum of each stack max_hash = {} diff --git a/lib/advanced_roadmap/issue_patch.rb b/lib/redmine_advanced_roadmap/issue_patch.rb similarity index 93% rename from lib/advanced_roadmap/issue_patch.rb rename to lib/redmine_advanced_roadmap/issue_patch.rb index 753eae0..f3181c3 100644 --- a/lib/advanced_roadmap/issue_patch.rb +++ b/lib/redmine_advanced_roadmap/issue_patch.rb @@ -1,6 +1,6 @@ require_dependency "issue" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module IssuePatch def self.included(base) base.class_eval do diff --git a/lib/advanced_roadmap/journal_patch.rb b/lib/redmine_advanced_roadmap/journal_patch.rb similarity index 75% rename from lib/advanced_roadmap/journal_patch.rb rename to lib/redmine_advanced_roadmap/journal_patch.rb index d453617..c9553d3 100644 --- a/lib/advanced_roadmap/journal_patch.rb +++ b/lib/redmine_advanced_roadmap/journal_patch.rb @@ -1,4 +1,4 @@ -module AdvancedRoadmap +module RedmineAdvancedRoadmap module JournalPatch def self.included(base) base.class_eval do @@ -6,7 +6,8 @@ def self.included(base) base.send(:include, InstanceMethods) base.class_eval do - alias_method_chain :visible_details, :estimated_time_hidden + alias_method :visible_details_without_estimated_time_hidden, :visible_details + alias_method :visible_details, :visible_details_with_estimated_time_hidden end end end diff --git a/lib/advanced_roadmap/project_patch.rb b/lib/redmine_advanced_roadmap/project_patch.rb similarity index 80% rename from lib/advanced_roadmap/project_patch.rb rename to lib/redmine_advanced_roadmap/project_patch.rb index c4cc2ca..a8514a7 100644 --- a/lib/advanced_roadmap/project_patch.rb +++ b/lib/redmine_advanced_roadmap/project_patch.rb @@ -1,6 +1,6 @@ require_dependency "projects_controller" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module ProjectPatch def self.included(base) base.class_eval do diff --git a/lib/redmine_advanced_roadmap/projects_helper_patch.rb b/lib/redmine_advanced_roadmap/projects_helper_patch.rb new file mode 100644 index 0000000..1df1195 --- /dev/null +++ b/lib/redmine_advanced_roadmap/projects_helper_patch.rb @@ -0,0 +1,27 @@ +require_dependency "projects_helper" + +module RedmineAdvancedRoadmap + module ProjectsHelperPatch + def self.included(base) + base.class_eval do + alias_method :project_settings_tabs_without_more_tabs, :project_settings_tabs + def project_settings_tabs_with_more_tabs + tabs = project_settings_tabs_without_more_tabs + options = {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural} + index = tabs.index(options) + unless index # Needed for Redmine v3.4.x + options[:url] = {:tab => 'versions', :version_status => params[:version_status], :version_name => params[:version_name]} + index = tabs.index(options) + end + #index = tabs.index({:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}) + if index + tabs.insert(index, {:name => "milestones", :action => :manage_milestones, :partial => "projects/settings/milestones", :label => :label_milestone_plural}) + tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} + end + return(tabs) + end + alias_method :project_settings_tabs, :project_settings_tabs_with_more_tabs + end + end + end +end diff --git a/lib/advanced_roadmap/query_patch.rb b/lib/redmine_advanced_roadmap/query_patch.rb similarity index 96% rename from lib/advanced_roadmap/query_patch.rb rename to lib/redmine_advanced_roadmap/query_patch.rb index e399cf8..d9ae6d5 100644 --- a/lib/advanced_roadmap/query_patch.rb +++ b/lib/redmine_advanced_roadmap/query_patch.rb @@ -1,6 +1,6 @@ require_dependency "query" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module QueryPatch def self.included(base) base.class_eval do diff --git a/lib/advanced_roadmap/redmine_helpers_gantt_patch.rb b/lib/redmine_advanced_roadmap/redmine_helpers_gantt_patch.rb similarity index 76% rename from lib/advanced_roadmap/redmine_helpers_gantt_patch.rb rename to lib/redmine_advanced_roadmap/redmine_helpers_gantt_patch.rb index e58e7bc..e87a4bf 100644 --- a/lib/advanced_roadmap/redmine_helpers_gantt_patch.rb +++ b/lib/redmine_advanced_roadmap/redmine_helpers_gantt_patch.rb @@ -1,13 +1,13 @@ require_dependency "redmine/helpers/gantt" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module RedmineHelpersGanttPatch def self.included(base) base.class_eval do def render_version_with_milestones(project, version, options = {}) if @last_rendered_project != project and project.milestones.any? - subject_for_milestones_label(options) + subject_for_milestones_label(options, project) options[:top] += options[:top_increment] @number_of_rows += 1 options[:indent] += options[:indent_increment] @@ -19,23 +19,28 @@ def render_version_with_milestones(project, version, options = {}) @last_rendered_project = project render_version_without_milestones(project, version, options) end - alias_method_chain :render_version, :milestones + alias_method :render_version_without_milestones, :render_version + alias_method :render_version, :render_version_with_milestones def render_milestone(project, milestone, options = {}) # Milestone header - subject_for_milestone(milestone, options) unless options[:only] == :lines + subject_for_milestone(milestone, options, project) unless options[:only] == :lines line_for_milestone(milestone, options) unless options[:only] == :subjects options[:top] += options[:top_increment] @number_of_rows += 1 end - def subject_for_milestones_label(options) + def subject_for_milestones_label(options, prj) case options[:format] when :html html_class = 'icon icon-milestones' s = l(:label_milestone_plural) subject = view.content_tag(:span, s, :class => html_class).html_safe - html_subject(options, subject, :css => "milestones-label") + if Redmine::VERSION::MAJOR == 5 + html_subject(options, subject, nil) + else + html_subject(options, subject, :css => "milestones-label") + end when :image image_subject(options, l(:label_milestone_plural)) when :pdf @@ -44,13 +49,17 @@ def subject_for_milestones_label(options) end end - def subject_for_milestone(milestone, options) + def subject_for_milestone(milestone, options, prj) case options[:format] when :html html_class = 'icon icon-milestone' s = view.link_to_milestone(milestone).html_safe subject = view.content_tag(:span, s, :class => html_class).html_safe - html_subject(options, subject, :css => "milestone-name") + if Redmine::VERSION::MAJOR == 5 + html_subject(options, subject, milestone) + else + html_subject(options, subject, :css => "milestone-name") + end when :image image_subject(options, milestone.to_s) when :pdf @@ -70,18 +79,24 @@ def line_for_milestone(milestone, options) when :html if Redmine::VERSION::MAJOR == 2 html_task(options, coords, :css => "version task", :label => label, :markers => true) + elsif Redmine::VERSION::MAJOR == 5 + html_task(options, coords, true, label, milestone) else html_task(options, coords, true, label, Version) end when :image if Redmine::VERSION::MAJOR == 2 image_task(options, coords, :label => label, :markers => true, :height => 3) + elsif Redmine::VERSION::MAJOR == 5 + image_task(options, coords, true, label, milestone) else image_task(options, coords, true, label, Version) end when :pdf if Redmine::VERSION::MAJOR == 2 pdf_task(options, coords, :label => label, :markers => true, :height => 0.8) + elsif Redmine::VERSION::MAJOR == 5 + pdf_task(options, coords, true, label, milestone) else pdf_task(options, coords, true, label, Version) end diff --git a/lib/advanced_roadmap/redmine_i18n_patch.rb b/lib/redmine_advanced_roadmap/redmine_i18n_patch.rb similarity index 90% rename from lib/advanced_roadmap/redmine_i18n_patch.rb rename to lib/redmine_advanced_roadmap/redmine_i18n_patch.rb index e2311a5..295a897 100644 --- a/lib/advanced_roadmap/redmine_i18n_patch.rb +++ b/lib/redmine_advanced_roadmap/redmine_i18n_patch.rb @@ -1,6 +1,6 @@ require_dependency "redmine/i18n" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module RedmineI18nPatch def self.included(base) base.class_eval do diff --git a/lib/advanced_roadmap/version_patch.rb b/lib/redmine_advanced_roadmap/version_patch.rb similarity index 93% rename from lib/advanced_roadmap/version_patch.rb rename to lib/redmine_advanced_roadmap/version_patch.rb index 1becae0..f9ea368 100644 --- a/lib/advanced_roadmap/version_patch.rb +++ b/lib/redmine_advanced_roadmap/version_patch.rb @@ -1,6 +1,6 @@ require_dependency "version" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module VersionPatch def self.included(base) base.class_eval do @@ -12,13 +12,15 @@ def completed_percent_with_advanced_info calculate_advance_info unless @total_ratio @total_ratio end - alias_method_chain :completed_percent, :advanced_info + alias_method :completed_percent_without_advanced_info, :completed_percent + alias_method :completed_percent, :completed_percent_with_advanced_info def closed_percent_with_advanced_info calculate_advance_info unless @total_finished_ratio @total_finished_ratio end - alias_method_chain :closed_percent, :advanced_info + alias_method :closed_percent_without_advanced_info, :closed_percent + alias_method :closed_percent, :closed_percent_with_advanced_info def rest_hours calculate_advance_info unless @total_pending @@ -81,7 +83,7 @@ def calculate_advance_info end end end - if solved_issues < Setting.plugin_advanced_roadmap_v2["solved_issues_to_estimate"].to_i or total_solved_estimated == 0.0 + if solved_issues < Setting.plugin_redmine_advanced_roadmap_v2["solved_issues_to_estimate"].to_i or total_solved_estimated == 0.0 @progress_factor = nil else @progress_factor = total_solved_spent / total_solved_estimated diff --git a/lib/advanced_roadmap/versions_controller_patch.rb b/lib/redmine_advanced_roadmap/versions_controller_patch.rb similarity index 81% rename from lib/advanced_roadmap/versions_controller_patch.rb rename to lib/redmine_advanced_roadmap/versions_controller_patch.rb index d9428fa..cd65778 100644 --- a/lib/advanced_roadmap/versions_controller_patch.rb +++ b/lib/redmine_advanced_roadmap/versions_controller_patch.rb @@ -1,6 +1,6 @@ require_dependency "versions_controller" -module AdvancedRoadmap +module RedmineAdvancedRoadmap module VersionsControllerPatch def self.included(base) base.class_eval do @@ -15,7 +15,8 @@ def index_with_plugin end if params[:only_open] end - alias_method_chain :index, :plugin + alias_method :index_without_plugin, :index + alias_method :index, :index_with_plugin def show @issues = @version.sorted_fixed_issues diff --git a/lib/advanced_roadmap/view_hooks.rb b/lib/redmine_advanced_roadmap/view_hooks.rb similarity index 92% rename from lib/advanced_roadmap/view_hooks.rb rename to lib/redmine_advanced_roadmap/view_hooks.rb index 541ed3c..455f688 100644 --- a/lib/advanced_roadmap/view_hooks.rb +++ b/lib/redmine_advanced_roadmap/view_hooks.rb @@ -1,4 +1,4 @@ -module AdvancedRoadmap +module RedmineAdvancedRoadmap class ViewHooks < Redmine::Hook::ViewListener render_on(:view_projects_show_sidebar_bottom, :partial => "hooks/milestones")