From 1578b1737959119ade261e04c4ff0bc58b456425 Mon Sep 17 00:00:00 2001 From: Daniel Munn Date: Wed, 30 May 2012 18:19:29 +0100 Subject: [PATCH 01/18] Updating codebase to work with redmine 2.0 (Untested) --- .../{projects.rhtml => projects.html.erb} | 2 +- .../projects/{index.rhtml => index.html.erb} | 201 +++++++++--------- init.rb | 3 +- lib/projectstreeview_projects_helper_patch.rb | 56 +++-- 4 files changed, 142 insertions(+), 120 deletions(-) rename app/views/admin/{projects.rhtml => projects.html.erb} (97%) rename app/views/projects/{index.rhtml => index.html.erb} (69%) diff --git a/app/views/admin/projects.rhtml b/app/views/admin/projects.html.erb similarity index 97% rename from app/views/admin/projects.rhtml rename to app/views/admin/projects.html.erb index 38a9f3b..ac04918 100644 --- a/app/views/admin/projects.rhtml +++ b/app/views/admin/projects.html.erb @@ -83,7 +83,7 @@ <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %> <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %> <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> - <%= link_to(l(:button_delete), project_destroy_confirm_path(project), :class => 'icon icon-del') %> + <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %> <% end %> diff --git a/app/views/projects/index.rhtml b/app/views/projects/index.html.erb similarity index 69% rename from app/views/projects/index.rhtml rename to app/views/projects/index.html.erb index b3ebaea..5ae74e3 100644 --- a/app/views/projects/index.rhtml +++ b/app/views/projects/index.html.erb @@ -1,101 +1,100 @@ -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> -<% end %> -
- <% if authorize_global_implemented %> - <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> - <% else %> - <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.admin? %> - <% end %> - <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> - <%= link_to(l(:label_overall_spent_time), { :controller => 'time_entries' }) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> - <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index' }%> -
- -

<%=l(:label_project_plural)%>

- - - - - - - - - - - - - <% ancestors = [] %> - <% for project in @projects %> - <% rowid = "" %> - <% classes = "" %> - <% spanicon = "" %> - <% openonclick = "" %> - <% showchildren = false %> - <% project_id_lsd = "%04d" % project.id %> - <% project.children.each do |child| %> - <% if @projects.include?(child) %> - <% showchildren = true %> - <% break %> - <% end %> - <% end %> - <% if(!project.children.empty? && showchildren) %> - <% classes += " closed parent " + cycle("odd", "even") %> - <% rowid = "id=\""+project_id_lsd+"span\"" %> - <% openonclick = "onclick=\"showHide('"+project_id_lsd+"','"+project_id_lsd+"span')\""%> - <% spanicon = "  " %> - <% else %> - <% classes += " child" %> - <% end %> - <% if(project.parent_id == nil) %> - <% ancestors.clear %> - <% ancestors << project.id %> - <% else %> - <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> - <% ancestors.pop %> - <% end %> - <% classes += " hide" %> - <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> - <% prvclasses = "closed show parent " + cycle("odd", "even") %> - <% ancestors.each do |pid| %> - <% prvclasses += " " + "%04d" % pid %> - <% end %> - <% project_parent_id_lsd = "%04d" % project.parent.id %> - <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> - " > - - - - - <% ancestors << project.parent_id %> - <% end %> - <% ancestors.each do |pid| %> - <% classes += " " + "%04d" % pid %> - <% end %> - <% ancestors << project.id %> - <% end %> - > - - - - - - - <% end %> - -
<%=l(:label_project)%><%=l(:field_description)%><%=l(:field_go_to)%><%=l(:field_versions)%><%=l(:field_created_on)%>
<%= "" %><%="  " %><%= h("") %> class="empty">  >Project is private.
<%= "" %><%= spanicon %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> class="empty <%=User.current.member_of?(project) ? 'my-project' : nil%>">  ><%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %><%= favorite_project_modules_links(project) %><%= format_date(project.created_on) %>
- -<%=l(:expand_all)%> - - -<% if User.current.logged? %> -

-<%= l(:label_my_projects) %> -

-<% end %> - -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> -<% end %> - -<% html_title(l(:label_project_plural)) -%> +<% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> +<% end %> + +
+ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> + <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> + <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> + <%= link_to l(:label_overall_activity), + { :controller => 'activities', :action => 'index', + :id => nil } %> +
+ +

<%=l(:label_project_plural)%>

+ + + + + + + + + + + + + <% ancestors = [] %> + <% for project in @projects %> + <% rowid = "" %> + <% classes = "" %> + <% spanicon = "" %> + <% openonclick = "" %> + <% showchildren = false %> + <% project_id_lsd = "%04d" % project.id %> + <% project.children.each do |child| %> + <% if @projects.include?(child) %> + <% showchildren = true %> + <% break %> + <% end %> + <% end %> + <% if(!project.children.empty? && showchildren) %> + <% classes += " closed parent " + cycle("odd", "even").html_safe %> + <% rowid = "id=\"".html_safe+project_id_lsd.html_safe+"span\"".html_safe %> + <% openonclick = "onclick=\"showHide('"+project_id_lsd+"','"+project_id_lsd+"span')\"".html_safe %> + <% spanicon = "  ".html_safe %> + <% else %> + <% classes += " child" %> + <% end %> + <% if(project.parent_id == nil) %> + <% ancestors.clear %> + <% ancestors << project.id %> + <% else %> + <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> + <% ancestors.pop %> + <% end %> + <% classes += " hide".html_safe %> + <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> + <% prvclasses = "closed show parent " + cycle("odd", "even") %> + <% ancestors.each do |pid| %> + <% prvclasses += " " + "%04d" % pid %> + <% end %> + <% project_parent_id_lsd = "%04d" % project.parent.id %> + <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> + " > + + + + + <% ancestors << project.parent_id %> + <% end %> + <% ancestors.each do |pid| %> + <% classes += " " + "%04d" % pid %> + <% end %> + <% ancestors << project.id %> + <% end %> + > + + + + + + + <% end %> + +
<%=l(:label_project)%><%=l(:field_description)%><%=l(:field_go_to)%><%=l(:field_versions)%><%=l(:field_created_on)%>
<%= "" %><%="  " %><%= h("") %> class="empty">  >Project is private.
<%= "".html_safe %><%= spanicon.html_safe %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> class="empty <%=User.current.member_of?(project) ? 'my-project' : nil%>">  ><%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %><%= favorite_project_modules_links(project) %><%= render_project_progress(project) %><%= format_date(project.created_on) %>
+ +<%=l(:expand_all)%> + + +<% if User.current.logged? %> +

+<%= l(:label_my_projects) %> +

+<% end %> + +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> +<% end %> + +<% html_title(l(:label_project_plural)) -%> diff --git a/init.rb b/init.rb index eee09a0..d9adaf3 100644 --- a/init.rb +++ b/init.rb @@ -1,14 +1,13 @@ require 'redmine' # Patches to the Redmine core. -require 'dispatcher' require 'projectstreeview_projects_helper_patch' Redmine::Plugin.register :projects_tree_view do name 'Projects Tree View plugin' author 'Chris Peterson' description 'This is a Redmine plugin which will turn the projects page into a tree view' - version '0.0.4' + version '0.0.5' end class ProjectsTreeViewListener < Redmine::Hook::ViewListener diff --git a/lib/projectstreeview_projects_helper_patch.rb b/lib/projectstreeview_projects_helper_patch.rb index 14e96d4..8bb8549 100644 --- a/lib/projectstreeview_projects_helper_patch.rb +++ b/lib/projectstreeview_projects_helper_patch.rb @@ -29,27 +29,33 @@ def authorize_global_implemented end def render_project_progress(project) - s = '' - if project.issues.open.count > 0 - issues_closed_pourcent = (1 - project.issues.open.count.to_f/project.issues.count) * 100 - s << "
Issues: " + - link_to("#{project.issues.open.count} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + - " / #{project.issues.count} total
" + + s = ''.html_safe + cond = project.project_condition(false) + + open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) + + if open_issues > 0 + issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 + s << "
Issues: ".html_safe + + link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + + " / #{project.issues.count} total
".html_safe + progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) end - unless project.versions.open.empty? - s << "
" - project.versions.open.reverse_each do |version| + project_versions = project_open(project) + + unless project_versions.empty? + s << "
".html_safe + project_versions.reverse_each do |version| unless version.completed? - s << link_to_version(version) + ": " + - link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + - " / " + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + "" + ". " + s << "
".html_safe + link_to_version(version) + ": ".html_safe + + link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + + " / ".html_safe + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". ".html_safe s << due_date_distance_in_words(version.effective_date) if version.effective_date - s << "
" + - progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) + s << "

".html_safe + + progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) end end - s << "
" + s << "
".html_safe end end @@ -58,10 +64,28 @@ def favorite_project_modules_links(project) menu_items_for(:project_menu, project) do |node| links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview end - links.join(", ") + links.join(", ").html_safe + end + + def project_open(project) + trackers = project.trackers.find(:all, :order => 'position') + #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) + with_subprojects = Setting.display_subprojects_issues? + project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] + + versions = project.shared_versions || [] + versions += project.rolled_up_versions.visible if with_subprojects + versions = versions.uniq.sort + completed_versions = versions.select {|version| version.closed? || version.completed? } + versions -= completed_versions + + issues_by_version = {} + versions.reject! {|version| !project_ids.include?(version.project_id) && issues_by_version[version].blank?} + return versions end end # Close the module ProjectstreeviewProjectsHelperPatch::InstanceMethods end # Close the module ProjectstreeviewProjectsHelperPatch + ProjectsHelper.send(:include, ProjectstreeviewProjectsHelperPatch) From b2e28bca6f7dabb76e0d5dc9d441b9a000de8182 Mon Sep 17 00:00:00 2001 From: Daniel Munn Date: Wed, 30 May 2012 18:26:04 +0100 Subject: [PATCH 02/18] Version 0.0.5 --- CHANGELOG | 3 +++ README.rdoc | 3 ++- init.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ef98fc8..c058237 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +0.0.6 (2012-05-30): + * patched to work with redmine 2.0 + * UI updated to enforce breakline properly utilised 0.0.5 (2011-01-23): * added js exapnd all button * Fixed missing spent time link diff --git a/README.rdoc b/README.rdoc index 23f893f..6b206ce 100644 --- a/README.rdoc +++ b/README.rdoc @@ -11,13 +11,14 @@ propagates the tree view to the project show page's subprojects list. * Anton-zaytsev * Shadowbq * cforce +* danmunn ==Changelog For the complete changelog see the CHANGELOG-file in the Projects Tree View plugin directory. ==Latest stable release -The currently available, latest stable release of the plugin is version 0.0.3. +The currently available, latest stable release of the plugin is version 0.0.6. ==Compatibility diff --git a/init.rb b/init.rb index d9adaf3..b889460 100644 --- a/init.rb +++ b/init.rb @@ -5,9 +5,9 @@ Redmine::Plugin.register :projects_tree_view do name 'Projects Tree View plugin' - author 'Chris Peterson' + author 'Chris Peterson and Github community' description 'This is a Redmine plugin which will turn the projects page into a tree view' - version '0.0.5' + version '0.0.6' end class ProjectsTreeViewListener < Redmine::Hook::ViewListener From 3e155e2a683c05ca8654d15cf23e94b21c94aea5 Mon Sep 17 00:00:00 2001 From: Daniel Munn Date: Wed, 30 May 2012 18:26:04 +0100 Subject: [PATCH 03/18] Version 0.0.6 --- CHANGELOG | 3 +++ README.rdoc | 3 ++- init.rb | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index ef98fc8..c058237 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,6 @@ +0.0.6 (2012-05-30): + * patched to work with redmine 2.0 + * UI updated to enforce breakline properly utilised 0.0.5 (2011-01-23): * added js exapnd all button * Fixed missing spent time link diff --git a/README.rdoc b/README.rdoc index 23f893f..6b206ce 100644 --- a/README.rdoc +++ b/README.rdoc @@ -11,13 +11,14 @@ propagates the tree view to the project show page's subprojects list. * Anton-zaytsev * Shadowbq * cforce +* danmunn ==Changelog For the complete changelog see the CHANGELOG-file in the Projects Tree View plugin directory. ==Latest stable release -The currently available, latest stable release of the plugin is version 0.0.3. +The currently available, latest stable release of the plugin is version 0.0.6. ==Compatibility diff --git a/init.rb b/init.rb index d9adaf3..b889460 100644 --- a/init.rb +++ b/init.rb @@ -5,9 +5,9 @@ Redmine::Plugin.register :projects_tree_view do name 'Projects Tree View plugin' - author 'Chris Peterson' + author 'Chris Peterson and Github community' description 'This is a Redmine plugin which will turn the projects page into a tree view' - version '0.0.5' + version '0.0.6' end class ProjectsTreeViewListener < Redmine::Hook::ViewListener From 7d2d708f9316748d0d9944cdcfc514fa2794b1dc Mon Sep 17 00:00:00 2001 From: ichizok Date: Thu, 14 Jun 2012 16:25:15 +0900 Subject: [PATCH 04/18] expand all projects by default --- app/views/admin/projects.html.erb | 97 --------- app/views/projects/index.html.erb | 151 +++++++------- assets/javascripts/projects_tree_view.js | 191 +++++++++--------- assets/stylesheets/projects_tree_view.css | 12 +- init.rb | 17 +- lib/projectstreeview_projects_helper_patch.rb | 123 +++++------ 6 files changed, 232 insertions(+), 359 deletions(-) delete mode 100644 app/views/admin/projects.html.erb diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb deleted file mode 100644 index ac04918..0000000 --- a/app/views/admin/projects.html.erb +++ /dev/null @@ -1,97 +0,0 @@ -
-<%= link_to l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add' %> -
- -

<%=l(:label_project_plural)%>

- -<% form_tag({}, :method => :get) do %> -
<%= l(:label_filter_plural) %> - -<%= select_tag 'status', project_status_options_for_select(@status), :class => "small", :onchange => "this.form.submit(); return false;" %> - -<%= text_field_tag 'name', params[:name], :size => 30 %> -<%= submit_tag l(:button_apply), :class => "small", :name => nil %> -
-<% end %> -  - -
- - - - - - - - - -<% ancestors = [] %> -<% for project in @projects %> - <% rowid = "" %> - <% classes = "" %> - <% spanicon = "" %> - <% openonclick = "" %> - <% showchildren = false %> - <% project_id_lsd = "%04d" % project.id %> - <% project.children.each do |child| %> - <% if @projects.include?(child) %> - <% showchildren = true %> - <% break %> - <% end %> - <% end %> - <% if(!project.children.empty? && showchildren) %> - <% classes += " closed parent " + cycle("odd", "even") %> - <% rowid = "id=\""+project_id_lsd+"span\"" %> - <% openonclick = "onclick=\"showHide('"+project_id_lsd+"','"+project_id_lsd+"span')\""%> - <% spanicon = "  " %> - <% else %> - <% classes += " child" %> - <% end %> - <% if(project.parent_id == nil) %> - <% ancestors.clear %> - <% ancestors << project.id %> - <% else %> - <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> - <% ancestors.pop %> - <% end %> - <% classes += " hide" %> - <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> - <% prvclasses = "closed show parent " + cycle("odd", "even") %> - <% ancestors.each do |pid| %> - <% prvclasses += " " + "%04d" % pid %> - <% end %> - <% project_parent_id_lsd = "%04d" % project.parent.id %> - <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> - " > - - - - - <% ancestors << project.parent_id %> - <% end %> - <% ancestors.each do |pid| %> - <% classes += " " + "%04d" % pid %> - <% end %> - <% ancestors << project.id %> - <% end %> - > - - - - - - -<% end %> - -
<%=l(:label_project)%><%=l(:field_description)%><%=l(:field_is_public)%><%=l(:field_created_on)%>
<%= "" %><%="  " %><%= h("") %> class="empty">  >Project is private.
<%= "" %><%= spanicon %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> ><%= textilizable project.short_description, :project => project %><%= image_tag 'true.png' if project.is_public? %><%= format_date(project.created_on) %> - <%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project, :status => params[:status] }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %> - <%= link_to(l(:button_unarchive), { :controller => 'projects', :action => 'unarchive', :id => project, :status => params[:status] }, :method => :post, :class => 'icon icon-unlock') if !project.active? && (project.parent.nil? || project.parent.active?) %> - <%= link_to(l(:button_copy), { :controller => 'projects', :action => 'copy', :id => project }, :class => 'icon icon-copy') %> - <%= link_to(l(:button_delete), project_path(project), :method => :delete, :class => 'icon icon-del') %> -
- -<%=l(:expand_all)%> - -
- -<% html_title(l(:label_project_plural)) -%> diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 5ae74e3..b330343 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,91 +1,90 @@ <% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> + <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %>
- <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> - <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> - <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> - <%= link_to l(:label_overall_activity), - { :controller => 'activities', :action => 'index', - :id => nil } %> + <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> + <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> + <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> + <%= link_to l(:label_overall_activity), + { :controller => 'activities', :action => 'index', + :id => nil } %>
-

<%=l(:label_project_plural)%>

+

<%= l(:label_project_plural)%>

- - - - - - - - - - - <% ancestors = [] %> - <% for project in @projects %> - <% rowid = "" %> - <% classes = "" %> - <% spanicon = "" %> - <% openonclick = "" %> - <% showchildren = false %> - <% project_id_lsd = "%04d" % project.id %> - <% project.children.each do |child| %> - <% if @projects.include?(child) %> - <% showchildren = true %> - <% break %> - <% end %> - <% end %> - <% if(!project.children.empty? && showchildren) %> - <% classes += " closed parent " + cycle("odd", "even").html_safe %> + + + + + + + + + + + <% ancestors = [] %> + <% for project in @projects %> + <% rowid = "" %> + <% classes = "" %> + <% spanicon = "" %> + <% openonclick = "" %> + <% showchildren = false %> + <% project_id_lsd = "%04d" % project.id %> + <% project.children.each do |child| %> + <% if @projects.include?(child) %> + <% showchildren = true %> + <% break %> + <% end %> + <% end %> + <% if(!project.children.empty? && showchildren) %> + <% classes += " open parent " + cycle("odd", "even").html_safe %> <% rowid = "id=\"".html_safe+project_id_lsd.html_safe+"span\"".html_safe %> <% openonclick = "onclick=\"showHide('"+project_id_lsd+"','"+project_id_lsd+"span')\"".html_safe %> - <% spanicon = "  ".html_safe %> - <% else %> - <% classes += " child" %> - <% end %> - <% if(project.parent_id == nil) %> - <% ancestors.clear %> - <% ancestors << project.id %> - <% else %> - <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> - <% ancestors.pop %> - <% end %> - <% classes += " hide".html_safe %> - <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> - <% prvclasses = "closed show parent " + cycle("odd", "even") %> - <% ancestors.each do |pid| %> - <% prvclasses += " " + "%04d" % pid %> - <% end %> - <% project_parent_id_lsd = "%04d" % project.parent.id %> - <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> - " > - - - - - <% ancestors << project.parent_id %> - <% end %> - <% ancestors.each do |pid| %> + <% spanicon = "  ".html_safe %> + <% else %> + <% classes += " child" %> + <% end %> + <% if(project.parent_id == nil) %> + <% ancestors.clear %> + <% ancestors << project.id %> + <% else %> + <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> + <% ancestors.pop %> + <% end %> + <% # classes += " hide".html_safe %> + <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> + <% prvclasses = "open show parent " + cycle("odd", "even") %> + <% ancestors.each do |pid| %> + <% prvclasses += " " + "%04d" % pid %> + <% end %> + <% project_parent_id_lsd = "%04d" % project.parent.id %> + <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> + " > + + + + + <% ancestors << project.parent_id %> + <% end %> + <% ancestors.each do |pid| %> <% classes += " " + "%04d" % pid %> - <% end %> - <% ancestors << project.id %> - <% end %> - > - - - - - - - <% end %> - + <% end %> + <% ancestors << project.id %> + <% end %> + > + + + + + + + <% end %> +
<%=l(:label_project)%><%=l(:field_description)%><%=l(:field_go_to)%><%=l(:field_versions)%><%=l(:field_created_on)%>
<%= l(:label_project)%><%= l(:field_description)%><%= l(:field_go_to)%><%= l(:field_versions)%><%= l(:field_created_on)%>
<%= "" %><%="  " %><%= h("") %> class="empty">  >Project is private.
<%= "" %><%= "  " %><%= h("") %> class="empty">  >Project is private.
<%= "".html_safe %><%= spanicon.html_safe %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> class="empty <%=User.current.member_of?(project) ? 'my-project' : nil%>">  ><%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %><%= favorite_project_modules_links(project) %><%= render_project_progress(project) %><%= format_date(project.created_on) %>
<%= "".html_safe %><%= spanicon.html_safe %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> class="empty <%= User.current.member_of?(project) ? 'my-project' : nil%>">  ><%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %><%= favorite_project_modules_links(project) %><%= render_project_progress(project) %><%= format_date(project.created_on) %>
-<%=l(:expand_all)%> - +<%= link_to l(:expand_all), "#", :onclick => 'expandAll()' %> <% if User.current.logged? %>

@@ -94,7 +93,7 @@ <% end %> <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> + <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> <% end %> <% html_title(l(:label_project_plural)) -%> diff --git a/assets/javascripts/projects_tree_view.js b/assets/javascripts/projects_tree_view.js index 5f11259..786f671 100644 --- a/assets/javascripts/projects_tree_view.js +++ b/assets/javascripts/projects_tree_view.js @@ -1,104 +1,101 @@ /* Function to allow the projects to show up as a tree */ - Event.observe(window, 'load', function() { - if ($('expand_all')) { - $('expand_all').observe('click', function() { - $$('table.list tr').each(function(e) { e.addClassName('open'); e.removeClassName('hide'); }); - }); - } - }); +function showHide(EL,PM) +{ + var els = document.getElementsByTagName('tr'); + var elsLen = els.length; + var pattern = new RegExp("(^|\\s)"+EL+"(\\s|$)"); + var cpattern = new RegExp("span"); + var expand = new RegExp("open"); + var collapse = new RegExp("closed"); + var hide = new RegExp("hide"); + var spanid = PM; + var classid = new RegExp("junk"); + var oddeventoggle = 0; + for (i = 0; i < elsLen; i++) + { + if(cpattern.test(els[i].id)) + { + var tmpspanid = spanid; + var tmpclassid = classid; + spanid = els[i].id; + classid = spanid; + classid = classid.match(/(\w+)span/)[1]; + classid = new RegExp(classid); + if(tmpclassid.test(els[i].className) && (tmpspanid.toString() != PM.toString())) + { + if(collapse.test(document.getElementById(tmpspanid).className)) + { + spanid = tmpspanid; + classid = tmpclassid; + } + } + } -function showHide(EL,PM) -{ - var els = document.getElementsByTagName('tr'); - var elsLen = els.length; - var pattern = new RegExp("(^|\\s)"+EL+"(\\s|$)"); - var cpattern = new RegExp("span"); - var expand = new RegExp("open"); - var collapse = new RegExp("closed"); - var hide = new RegExp("hide"); - var spanid = PM; - var classid = new RegExp("junk"); - var oddeventoggle = 0; - for (i = 0; i < elsLen; i++) - { - - if(cpattern.test(els[i].id)) - { - var tmpspanid = spanid; - var tmpclassid = classid; - spanid = els[i].id; - classid = spanid; - classid = classid.match(/(\w+)span/)[1]; - classid = new RegExp(classid); - if(tmpclassid.test(els[i].className) && (tmpspanid.toString() != PM.toString())) - { - if(collapse.test(document.getElementById(tmpspanid).className)) - { - spanid = tmpspanid; - classid = tmpclassid; - } - } - } - - if ( pattern.test(els[i].className) ) { + if ( pattern.test(els[i].className) ) { + + var cnames = els[i].className; + + cnames = cnames.replace(/hide/g,''); + + if (expand.test(document.getElementById(PM).className)) + { + cnames += ' hide'; + } + else + { + /* classid test function is buggy and matches incorrect ids 5 matches 50. */ + if((spanid.toString() != PM.toString()) && + (classid.test(els[i].className))) + { + if(collapse.test(document.getElementById(spanid).className)) + { + cnames += ' hide'; + } + } + } + + els[i].className = cnames; - var cnames = els[i].className; - - cnames = cnames.replace(/hide/g,''); - - if (expand.test(document.getElementById(PM).className)) - { - cnames += ' hide'; - } - else - { - /* classid test function is buggy and matches incorrect ids 5 matches 50. */ - if((spanid.toString() != PM.toString()) && - (classid.test(els[i].className))) - { - if(collapse.test(document.getElementById(spanid).className)) - { - cnames += ' hide'; - } - } - } - - els[i].className = cnames; - - } - - if(!(hide.test(els[i].className))) - { - var cnames = els[i].className; - cnames = cnames.replace(/odd/g,''); - cnames = cnames.replace(/even/g,''); - - if(oddeventoggle == 0) - { - cnames += ' odd'; - } - else - { - cnames += ' even'; - } - - oddeventoggle ^= 1; - els[i].className = cnames; - } - } - if (collapse.test(document.getElementById(PM).className)) - { - var cnames = document.getElementById(PM).className; - cnames = cnames.replace(/closed/,'open'); - document.getElementById(PM).className = cnames; - } - else - { - var cnames = document.getElementById(PM).className; - cnames = cnames.replace(/open/,'closed'); - document.getElementById(PM).className = cnames; - } + } + + if(!(hide.test(els[i].className))) + { + var cnames = els[i].className; + cnames = cnames.replace(/odd/g,''); + cnames = cnames.replace(/even/g,''); + + if(oddeventoggle == 0) + { + cnames += ' odd'; + } + else + { + cnames += ' even'; + } + + oddeventoggle ^= 1; + els[i].className = cnames; + } + } + if (collapse.test(document.getElementById(PM).className)) + { + var cnames = document.getElementById(PM).className; + cnames = cnames.replace(/closed/,'open'); + document.getElementById(PM).className = cnames; + } + else + { + var cnames = document.getElementById(PM).className; + cnames = cnames.replace(/open/,'closed'); + document.getElementById(PM).className = cnames; + } } +function expandAll() +{ + $$('table.list tr').each(function(e) { + e.addClassName('open'); e.removeClassName('closed'); e.removeClassName('hide'); + }); +} diff --git a/assets/stylesheets/projects_tree_view.css b/assets/stylesheets/projects_tree_view.css index 6bf1e9a..a7c88b6 100644 --- a/assets/stylesheets/projects_tree_view.css +++ b/assets/stylesheets/projects_tree_view.css @@ -2,10 +2,8 @@ tr.parent { border: 1px solid #f8f8f8; } tr.parent td.name { white-space: nowrap; width: 300px; } tr.child { border: 1px solid #f8f8f8; } tr.child td.name { white-space: nowrap; width: 300px; } -tr.parent span.expander {background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer;} -span.empty { text-align:right; width: 100%; cursor: pointer;} -tr.parent.open span.expander {background-image: url(../images/bullet_toggle_minus.png); cursor: pointer;} -tr.parent.open {background-color:#ffffbb;} -tr.hide { - display:none; - } +tr.parent span.expander { background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer; } +span.empty { text-align:right; width: 100%; cursor: pointer; } +tr.parent.open span.expander { background-image: url(../images/bullet_toggle_minus.png); cursor: pointer; } +/* tr.parent.open { background-color:#ffffbb; } */ +tr.hide { display:none; } diff --git a/init.rb b/init.rb index b889460..1cd7835 100644 --- a/init.rb +++ b/init.rb @@ -1,21 +1,24 @@ require 'redmine' # Patches to the Redmine core. -require 'projectstreeview_projects_helper_patch' +Rails.configuration.to_prepare do + require_dependency 'projects_helper' + ProjectsHelper.send(:include, ProjectstreeviewProjectsHelperPatch) +end Redmine::Plugin.register :projects_tree_view do name 'Projects Tree View plugin' author 'Chris Peterson and Github community' description 'This is a Redmine plugin which will turn the projects page into a tree view' + url 'https://github.com/cforce/projects_tree_view' version '0.0.6' + requires_redmine :version_or_higher => '2.0.0' end class ProjectsTreeViewListener < Redmine::Hook::ViewListener - # Adds javascript and stylesheet tags - def view_layouts_base_html_head(context) - javascript_include_tag('projects_tree_view', :plugin => :projects_tree_view) + - stylesheet_link_tag('projects_tree_view', :plugin => :projects_tree_view) - end - + render_on :view_layouts_base_html_head, :inline => <<-EOT + <%= javascript_include_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> + <%= stylesheet_link_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> + EOT end diff --git a/lib/projectstreeview_projects_helper_patch.rb b/lib/projectstreeview_projects_helper_patch.rb index 8bb8549..f931cbd 100644 --- a/lib/projectstreeview_projects_helper_patch.rb +++ b/lib/projectstreeview_projects_helper_patch.rb @@ -1,91 +1,64 @@ -require_dependency 'projects_helper' - module ProjectstreeviewProjectsHelperPatch - def self.included(base) # :nodoc: - base.extend(ClassMethods) + extend ActiveSupport::Concern - base.send(:include, InstanceMethods) - end - module ClassMethods end - - module InstanceMethods - - ### - # Compatibility helpers - ### - - # Redmine Core trunk@r2734 (0.9-devel) - # Returns true if the method is defined, else it returns false - def users_by_role_implemented - return ProjectsController.method_defined?("users_by_role") - end - # Redmine Core trunk@r2750 (0.9-devel) - # Returns true if the method is defined, else it returns false - def authorize_global_implemented - return ApplicationController.method_defined?("authorize_global") - end - - def render_project_progress(project) - s = ''.html_safe - cond = project.project_condition(false) + def render_project_progress(project) + s = '' + cond = project.project_condition(false) - open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) + open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) - if open_issues > 0 - issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 - s << "

Issues: ".html_safe + - link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + - " / #{project.issues.count} total
".html_safe + - progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) - end - project_versions = project_open(project) + if open_issues > 0 + issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 + s << "
Issues: " + + link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + + " / #{project.issues.count} total
" + + progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) + end + project_versions = project_open(project) - unless project_versions.empty? - s << "
".html_safe - project_versions.reverse_each do |version| - unless version.completed? - s << "
".html_safe + link_to_version(version) + ": ".html_safe + - link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + - " / ".html_safe + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". ".html_safe - s << due_date_distance_in_words(version.effective_date) if version.effective_date - s << "

".html_safe + - progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) - end + unless project_versions.empty? + s << "
" + project_versions.reverse_each do |version| + unless version.completed? + s << "
" + link_to_version(version) + ": " + + link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + + " / " + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". " + s << due_date_distance_in_words(version.effective_date) if version.effective_date + s << "

" + + progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) end - s << "
".html_safe - end - end - - def favorite_project_modules_links(project) - links = [] - menu_items_for(:project_menu, project) do |node| - links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview end - links.join(", ").html_safe + s << "
" end + s.html_safe + end - def project_open(project) - trackers = project.trackers.find(:all, :order => 'position') - #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) - with_subprojects = Setting.display_subprojects_issues? - project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] - - versions = project.shared_versions || [] - versions += project.rolled_up_versions.visible if with_subprojects - versions = versions.uniq.sort - completed_versions = versions.select {|version| version.closed? || version.completed? } - versions -= completed_versions - - issues_by_version = {} - versions.reject! {|version| !project_ids.include?(version.project_id) && issues_by_version[version].blank?} - return versions + def favorite_project_modules_links(project) + links = [] + menu_items_for(:project_menu, project) do |node| + links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview end + links.join(", ").html_safe + end + + def project_open(project) + trackers = project.trackers.find(:all, :order => 'position') + #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) + with_subprojects = Setting.display_subprojects_issues? + project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] + versions = project.shared_versions || [] + versions += project.rolled_up_versions.visible if with_subprojects + versions = versions.uniq.sort + completed_versions = versions.select {|version| version.closed? || version.completed? } + versions -= completed_versions - end # Close the module ProjectstreeviewProjectsHelperPatch::InstanceMethods -end # Close the module ProjectstreeviewProjectsHelperPatch + issues_by_version = {} + versions.reject! {|version| !project_ids.include?(version.project_id) && issues_by_version[version].blank?} + versions + end -ProjectsHelper.send(:include, ProjectstreeviewProjectsHelperPatch) +end From 65fe8d2905010c07464ab6a81b5512ab27df1a35 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 15 Jun 2012 15:32:36 +0900 Subject: [PATCH 05/18] refactoring --- app/views/projects/index.html.erb | 67 ++++++------------------------- 1 file changed, 13 insertions(+), 54 deletions(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index b330343..60d6630 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -6,9 +6,7 @@ <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> <%= link_to(l(:label_issue_view_all), { :controller => 'issues' }) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> - <%= link_to l(:label_overall_activity), - { :controller => 'activities', :action => 'index', - :id => nil } %> + <%= link_to l(:label_overall_activity), { :controller => 'activities', :action => 'index', :id => nil } %>

<%= l(:label_project_plural)%>

@@ -25,61 +23,22 @@ <% ancestors = [] %> - <% for project in @projects %> - <% rowid = "" %> - <% classes = "" %> - <% spanicon = "" %> - <% openonclick = "" %> - <% showchildren = false %> - <% project_id_lsd = "%04d" % project.id %> - <% project.children.each do |child| %> - <% if @projects.include?(child) %> - <% showchildren = true %> - <% break %> - <% end %> - <% end %> - <% if(!project.children.empty? && showchildren) %> - <% classes += " open parent " + cycle("odd", "even").html_safe %> - <% rowid = "id=\"".html_safe+project_id_lsd.html_safe+"span\"".html_safe %> - <% openonclick = "onclick=\"showHide('"+project_id_lsd+"','"+project_id_lsd+"span')\"".html_safe %> - <% spanicon = "  ".html_safe %> - <% else %> - <% classes += " child" %> - <% end %> - <% if(project.parent_id == nil) %> - <% ancestors.clear %> - <% ancestors << project.id %> - <% else %> - <% while (ancestors.any? && !(project.parent_id == ancestors.last)) %> - <% ancestors.pop %> - <% end %> - <% # classes += " hide".html_safe %> - <% if( !(ancestors.detect {|pid| pid == project.parent_id })) %> - <% prvclasses = "open show parent " + cycle("odd", "even") %> - <% ancestors.each do |pid| %> - <% prvclasses += " " + "%04d" % pid %> - <% end %> - <% project_parent_id_lsd = "%04d" % project.parent.id %> - <% openonclick = "onclick=\"showHide('"+project_parent_id_lsd+"','"+project_parent_id_lsd+"span')\"" %> - " > - <%= "" %><%= "  " %><%= h("") %> class="empty">  - >Project is private. - - - <% ancestors << project.parent_id %> - <% end %> - <% ancestors.each do |pid| %> - <% classes += " " + "%04d" % pid %> - <% end %> - <% ancestors << project.id %> - <% end %> - > - <%= "".html_safe %><%= spanicon.html_safe %><%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %> class="empty <%= User.current.member_of?(project) ? 'my-project' : nil%>">  - ><%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> + <% plevel = 0 %> + <% project_tree(@projects) do |project, level| %> + <% project_id = "%04d" % project.id %> + <% (plevel - level).times { ancestors.pop } if (level < plevel) %> + <% has_children = !project.children.empty? %> + " id="<%= project_id + "span" if has_children %>"> + <%= " ".html_safe if has_children %> + <%= project.active? ? link_to_project(project, {:action => 'show'}) : h(project.name) %> + ">  + <%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> <%= favorite_project_modules_links(project) %> <%= render_project_progress(project) %> <%= format_date(project.created_on) %> + <% ancestors << project_id if has_children %> + <% plevel = level %> <% end %> From 3cda18412fa8e46c593447f4f2461c53f74d63cd Mon Sep 17 00:00:00 2001 From: ichizok Date: Tue, 10 Jul 2012 20:00:54 +0900 Subject: [PATCH 06/18] added collapse_all (children) --- app/views/projects/index.html.erb | 13 ++++++++++--- assets/javascripts/projects_tree_view.js | 13 ++++++++++++- config/locales/en.yml | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 60d6630..b6df67b 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -28,8 +28,13 @@ <% project_id = "%04d" % project.id %> <% (plevel - level).times { ancestors.pop } if (level < plevel) %> <% has_children = !project.children.empty? %> - " id="<%= project_id + "span" if has_children %>"> - <%= " ".html_safe if has_children %> + " id="<%= project_id + "span" if has_children %>"> + + <% if has_children %> + )" class="expander">  + <% else %> +   + <% end %> <%= project.active? ? link_to_project(project, {:action => 'show'}) : h(project.name) %> ">  <%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> @@ -43,7 +48,9 @@ -<%= link_to l(:expand_all), "#", :onclick => 'expandAll()' %> +

+<%= link_to(l(:expand_all), "#", :onclick => 'expandAll()')%> / <%= link_to l(:collapse_all), "#", :onclick => 'collapseAll()' %> +

<% if User.current.logged? %>

diff --git a/assets/javascripts/projects_tree_view.js b/assets/javascripts/projects_tree_view.js index 786f671..35eae44 100644 --- a/assets/javascripts/projects_tree_view.js +++ b/assets/javascripts/projects_tree_view.js @@ -95,7 +95,18 @@ function showHide(EL,PM) function expandAll() { - $$('table.list tr').each(function(e) { + $$('table.list tr.project').each(function(e) { e.addClassName('open'); e.removeClassName('closed'); e.removeClassName('hide'); }); } + +function collapseAll() +{ + $$('table.list tr.project').each(function(e) { + e.removeClassName('open'); e.addClassName('closed'); + if (!e.hasClassName('root')) + { + e.addClassName('hide'); + } + }); +} diff --git a/config/locales/en.yml b/config/locales/en.yml index 04710ce..18cbda4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,3 +5,4 @@ en: field_go_to: Go to module subprojects: sub projects expand_all: "Expand All" + collapse_all: "Collapse All" From fa2ebed919fb81e2b893cc3637f1ec7f1316bfed Mon Sep 17 00:00:00 2001 From: ichizok Date: Tue, 10 Jul 2012 23:53:12 +0900 Subject: [PATCH 07/18] refactoring, fixed toggle odd/even --- app/views/projects/index.html.erb | 12 +-- assets/javascripts/projects_tree_view.js | 121 ++++++---------------- assets/stylesheets/projects_tree_view.css | 6 +- init.rb | 8 -- 4 files changed, 43 insertions(+), 104 deletions(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index b6df67b..fd5c2b8 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -1,4 +1,6 @@ <% content_for :header_tags do %> + <%= javascript_include_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> + <%= stylesheet_link_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> <% end %> @@ -28,14 +30,12 @@ <% project_id = "%04d" % project.id %> <% (plevel - level).times { ancestors.pop } if (level < plevel) %> <% has_children = !project.children.empty? %> - " id="<%= project_id + "span" if has_children %>"> - + " class="<%= project.css_classes %> closed <%= level > 0 ? "hide #{ancestors.last}" : cycle("odd", "even") %>"> + <% if has_children %> - )" class="expander">  - <% else %> -   + )">  <% end %> - <%= project.active? ? link_to_project(project, {:action => 'show'}) : h(project.name) %> + <%= project.active? ? link_to_project(project, {:action => 'show'}) : h(project.name) %> ">  <%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> <%= favorite_project_modules_links(project) %> diff --git a/assets/javascripts/projects_tree_view.js b/assets/javascripts/projects_tree_view.js index 35eae44..c1f3eb2 100644 --- a/assets/javascripts/projects_tree_view.js +++ b/assets/javascripts/projects_tree_view.js @@ -1,112 +1,59 @@ /* Function to allow the projects to show up as a tree */ -function showHide(EL,PM) +function toggleOddEven() { - var els = document.getElementsByTagName('tr'); - var elsLen = els.length; - var pattern = new RegExp("(^|\\s)"+EL+"(\\s|$)"); - var cpattern = new RegExp("span"); - var expand = new RegExp("open"); - var collapse = new RegExp("closed"); - var hide = new RegExp("hide"); - var spanid = PM; - var classid = new RegExp("junk"); - var oddeventoggle = 0; - for (i = 0; i < elsLen; i++) - { + var isEven = false; - if(cpattern.test(els[i].id)) - { - var tmpspanid = spanid; - var tmpclassid = classid; - spanid = els[i].id; - classid = spanid; - classid = classid.match(/(\w+)span/)[1]; - classid = new RegExp(classid); - if(tmpclassid.test(els[i].className) && (tmpspanid.toString() != PM.toString())) - { - if(collapse.test(document.getElementById(tmpspanid).className)) - { - spanid = tmpspanid; - classid = tmpclassid; - } - } + $$('table.list tr.project').each(function(e) { + if (!e.hasClassName('hide')) { + e.removeClassName('odd'); + e.removeClassName('even'); + e.addClassName(isEven ? 'even' : 'odd'); + isEven = !isEven; } + }) +} - if ( pattern.test(els[i].className) ) { - - var cnames = els[i].className; - - cnames = cnames.replace(/hide/g,''); - - if (expand.test(document.getElementById(PM).className)) - { - cnames += ' hide'; - } - else - { - /* classid test function is buggy and matches incorrect ids 5 matches 50. */ - if((spanid.toString() != PM.toString()) && - (classid.test(els[i].className))) - { - if(collapse.test(document.getElementById(spanid).className)) - { - cnames += ' hide'; - } - } - } - - els[i].className = cnames; +function toggleShowHide(projectId) +{ + var project = $('project' + projectId); + var isClosed = project.className.include('closed'); + $$('table.list tr.' + projectId).each(function(e) { + if (isClosed) { + e.removeClassName('hide'); + } else { + e.addClassName('hide'); } + }) - if(!(hide.test(els[i].className))) - { - var cnames = els[i].className; - cnames = cnames.replace(/odd/g,''); - cnames = cnames.replace(/even/g,''); - - if(oddeventoggle == 0) - { - cnames += ' odd'; - } - else - { - cnames += ' even'; - } + project.removeClassName('closed'); + project.removeClassName('open'); + project.addClassName(isClosed ? 'open' : 'closed'); - oddeventoggle ^= 1; - els[i].className = cnames; - } - } - if (collapse.test(document.getElementById(PM).className)) - { - var cnames = document.getElementById(PM).className; - cnames = cnames.replace(/closed/,'open'); - document.getElementById(PM).className = cnames; - } - else - { - var cnames = document.getElementById(PM).className; - cnames = cnames.replace(/open/,'closed'); - document.getElementById(PM).className = cnames; - } + toggleOddEven(); } function expandAll() { $$('table.list tr.project').each(function(e) { - e.addClassName('open'); e.removeClassName('closed'); e.removeClassName('hide'); + e.removeClassName('closed'); + e.removeClassName('hide'); + e.addClassName('open'); }); + + toggleOddEven(); } function collapseAll() { $$('table.list tr.project').each(function(e) { - e.removeClassName('open'); e.addClassName('closed'); - if (!e.hasClassName('root')) - { + e.removeClassName('open'); + e.addClassName('closed'); + if (!e.hasClassName('root')) { e.addClassName('hide'); } }); + + toggleOddEven(); } diff --git a/assets/stylesheets/projects_tree_view.css b/assets/stylesheets/projects_tree_view.css index a7c88b6..44ade45 100644 --- a/assets/stylesheets/projects_tree_view.css +++ b/assets/stylesheets/projects_tree_view.css @@ -1,9 +1,9 @@ tr.parent { border: 1px solid #f8f8f8; } tr.parent td.name { white-space: nowrap; width: 300px; } -tr.child { border: 1px solid #f8f8f8; } -tr.child td.name { white-space: nowrap; width: 300px; } +tr.child { border: 1px solid #f8f8f8; } +tr.child td.name { white-space: nowrap; width: 300px; } +tr.leaf td.name a { margin-left: 16px; } tr.parent span.expander { background-image: url(../images/bullet_toggle_plus.png); padding-left: 8px; margin-left: 0; cursor: pointer; } span.empty { text-align:right; width: 100%; cursor: pointer; } tr.parent.open span.expander { background-image: url(../images/bullet_toggle_minus.png); cursor: pointer; } -/* tr.parent.open { background-color:#ffffbb; } */ tr.hide { display:none; } diff --git a/init.rb b/init.rb index 1cd7835..fbb778f 100644 --- a/init.rb +++ b/init.rb @@ -14,11 +14,3 @@ version '0.0.6' requires_redmine :version_or_higher => '2.0.0' end - -class ProjectsTreeViewListener < Redmine::Hook::ViewListener - # Adds javascript and stylesheet tags - render_on :view_layouts_base_html_head, :inline => <<-EOT - <%= javascript_include_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> - <%= stylesheet_link_tag 'projects_tree_view', :plugin => 'projects_tree_view' %> - EOT -end From 616c108b8ff435019a209f09a2dc1f24df745f4d Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 11 Jul 2012 14:21:25 +0900 Subject: [PATCH 08/18] fixed expand/collapse tree --- app/views/projects/index.html.erb | 2 +- assets/javascripts/projects_tree_view.js | 65 ++++++++++++++---------- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index fd5c2b8..8f0c3e6 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -30,7 +30,7 @@ <% project_id = "%04d" % project.id %> <% (plevel - level).times { ancestors.pop } if (level < plevel) %> <% has_children = !project.children.empty? %> - " class="<%= project.css_classes %> closed <%= level > 0 ? "hide #{ancestors.last}" : cycle("odd", "even") %>"> + "> <% if has_children %> )">  diff --git a/assets/javascripts/projects_tree_view.js b/assets/javascripts/projects_tree_view.js index c1f3eb2..2381ea8 100644 --- a/assets/javascripts/projects_tree_view.js +++ b/assets/javascripts/projects_tree_view.js @@ -1,55 +1,64 @@ /* Function to allow the projects to show up as a tree */ -function toggleOddEven() -{ +function toggleOddEven() { var isEven = false; - $$('table.list tr.project').each(function(e) { - if (!e.hasClassName('hide')) { - e.removeClassName('odd'); - e.removeClassName('even'); - e.addClassName(isEven ? 'even' : 'odd'); - isEven = !isEven; + $$('table.list tr.project:not(.hide)').each(function(e) { + e.removeClassName('odd'); + e.removeClassName('even'); + e.addClassName(isEven ? 'even' : 'odd'); + isEven = !isEven; + }) +} + +function expandProjectTree(id) { + $$('table.list tr.child.' + id).each(function(e) { + e.removeClassName('hide'); + if (e.hasClassName('open')) { + expandProjectTree(e.identify()); } }) } -function toggleShowHide(projectId) -{ - var project = $('project' + projectId); - var isClosed = project.className.include('closed'); +function collapseProjectTree(id) { + $$('table.list tr.child.' + id).each(function(e) { + e.addClassName('hide'); + collapseProjectTree(e.identify()); + }) +} - $$('table.list tr.' + projectId).each(function(e) { - if (isClosed) { - e.removeClassName('hide'); +function toggleShowHide(id) { + with($(id)) { + if (hasClassName('open')) { + collapseProjectTree(id); + removeClassName('open'); + addClassName('collapsed'); } else { - e.addClassName('hide'); + expandProjectTree(id); + removeClassName('collapsed'); + addClassName('open'); } - }) - - project.removeClassName('closed'); - project.removeClassName('open'); - project.addClassName(isClosed ? 'open' : 'closed'); + } toggleOddEven(); } -function expandAll() -{ +function expandAll() { $$('table.list tr.project').each(function(e) { - e.removeClassName('closed'); e.removeClassName('hide'); - e.addClassName('open'); + if (!e.hasClassName('leaf')) { + e.removeClassName('collapsed'); + e.addClassName('open'); + } }); toggleOddEven(); } -function collapseAll() -{ +function collapseAll() { $$('table.list tr.project').each(function(e) { e.removeClassName('open'); - e.addClassName('closed'); + e.addClassName('collapsed'); if (!e.hasClassName('root')) { e.addClassName('hide'); } From 662aea7cedf082756deeabb8a5f245fd7dba4a31 Mon Sep 17 00:00:00 2001 From: ichizok Date: Tue, 18 Sep 2012 20:00:06 +0900 Subject: [PATCH 09/18] compatible with Redmine 2.1 use jquery(in Redmine) instead of prototype.js --- app/views/projects/index.html.erb | 2 +- assets/javascripts/projects_tree_view.js | 63 +++++++++--------- init.rb | 8 ++- ...rojects_tree_view_projects_helper_patch.rb | 65 +++++++++++++++++++ lib/projectstreeview_projects_helper_patch.rb | 64 ------------------ 5 files changed, 103 insertions(+), 99 deletions(-) create mode 100644 lib/projects_tree_view_projects_helper_patch.rb delete mode 100644 lib/projectstreeview_projects_helper_patch.rb diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 8f0c3e6..e8f1257 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -30,7 +30,7 @@ <% project_id = "%04d" % project.id %> <% (plevel - level).times { ancestors.pop } if (level < plevel) %> <% has_children = !project.children.empty? %> - "> + "> <% if has_children %> )">  diff --git a/assets/javascripts/projects_tree_view.js b/assets/javascripts/projects_tree_view.js index 2381ea8..3ff6fbc 100644 --- a/assets/javascripts/projects_tree_view.js +++ b/assets/javascripts/projects_tree_view.js @@ -3,52 +3,53 @@ function toggleOddEven() { var isEven = false; - $$('table.list tr.project:not(.hide)').each(function(e) { - e.removeClassName('odd'); - e.removeClassName('even'); - e.addClassName(isEven ? 'even' : 'odd'); + $('table.list tr.project:not(.hide)').each(function() { + var e = $(this); + e.removeClass('odd'); + e.removeClass('even'); + e.addClass(isEven ? 'even' : 'odd'); isEven = !isEven; }) } function expandProjectTree(id) { - $$('table.list tr.child.' + id).each(function(e) { - e.removeClassName('hide'); - if (e.hasClassName('open')) { - expandProjectTree(e.identify()); + $('table.list tr.child.' + id).each(function() { + var e = $(this); + e.removeClass('hide'); + if (e.hasClass('open')) { + expandProjectTree(e.context.id); } }) } function collapseProjectTree(id) { - $$('table.list tr.child.' + id).each(function(e) { - e.addClassName('hide'); - collapseProjectTree(e.identify()); + $('table.list tr.child.' + id).each(function() { + var e = $(this); + e.addClass('hide'); + collapseProjectTree(e.context.id); }) } function toggleShowHide(id) { - with($(id)) { - if (hasClassName('open')) { - collapseProjectTree(id); - removeClassName('open'); - addClassName('collapsed'); - } else { - expandProjectTree(id); - removeClassName('collapsed'); - addClassName('open'); - } + var e = $('#' + id); + + if (e.hasClass('open')) { + collapseProjectTree(id); + e.removeClass('open'); + } else { + expandProjectTree(id); + e.addClass('open'); } toggleOddEven(); } function expandAll() { - $$('table.list tr.project').each(function(e) { - e.removeClassName('hide'); - if (!e.hasClassName('leaf')) { - e.removeClassName('collapsed'); - e.addClassName('open'); + $('table.list tr.project').each(function() { + var e = $(this); + e.removeClass('hide'); + if (!e.hasClass('leaf')) { + e.addClass('open'); } }); @@ -56,11 +57,11 @@ function expandAll() { } function collapseAll() { - $$('table.list tr.project').each(function(e) { - e.removeClassName('open'); - e.addClassName('collapsed'); - if (!e.hasClassName('root')) { - e.addClassName('hide'); + $('table.list tr.project').each(function() { + var e = $(this); + e.removeClass('open'); + if (!e.hasClass('root')) { + e.addClass('hide'); } }); diff --git a/init.rb b/init.rb index fbb778f..44ac671 100644 --- a/init.rb +++ b/init.rb @@ -1,9 +1,11 @@ require 'redmine' +require 'projects_tree_view_projects_helper_patch' + # Patches to the Redmine core. Rails.configuration.to_prepare do require_dependency 'projects_helper' - ProjectsHelper.send(:include, ProjectstreeviewProjectsHelperPatch) + ProjectsHelper.send(:include, ProjectsTreeView::ProjectsHelperPatch) end Redmine::Plugin.register :projects_tree_view do @@ -11,6 +13,6 @@ author 'Chris Peterson and Github community' description 'This is a Redmine plugin which will turn the projects page into a tree view' url 'https://github.com/cforce/projects_tree_view' - version '0.0.6' - requires_redmine :version_or_higher => '2.0.0' + version '0.0.8' + requires_redmine :version_or_higher => '2.1.0' end diff --git a/lib/projects_tree_view_projects_helper_patch.rb b/lib/projects_tree_view_projects_helper_patch.rb new file mode 100644 index 0000000..b154e54 --- /dev/null +++ b/lib/projects_tree_view_projects_helper_patch.rb @@ -0,0 +1,65 @@ +module ProjectsTreeView + module ProjectsHelperPatch + extend ActiveSupport::Concern + + module ClassMethods + end + + def render_project_progress(project) + s = '' + cond = project.project_condition(false) + + open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) + + if open_issues > 0 + issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 + s << "

Issues: " + + link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + + " / #{project.issues.count} total
" + + progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) + end + project_versions = project_open(project) + + unless project_versions.empty? + s << "
" + project_versions.reverse_each do |version| + unless version.completed? + s << "
" + link_to_version(version) + ": " + + link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + + " / " + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". " + s << due_date_distance_in_words(version.effective_date) if version.effective_date + s << "

" + + progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) + end + end + s << "
" + end + s.html_safe + end + + def favorite_project_modules_links(project) + links = [] + menu_items_for(:project_menu, project) do |node| + links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview + end + links.join(", ").html_safe + end + + def project_open(project) + trackers = project.trackers.find(:all, :order => 'position') + #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) + with_subprojects = Setting.display_subprojects_issues? + project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] + + versions = project.shared_versions || [] + versions += project.rolled_up_versions.visible if with_subprojects + versions = versions.uniq.sort + completed_versions = versions.select {|version| version.closed? || version.completed? } + versions -= completed_versions + + issues_by_version = {} + versions.reject! {|version| !project_ids.include?(version.project_id) && issues_by_version[version].blank?} + versions + end + end +end diff --git a/lib/projectstreeview_projects_helper_patch.rb b/lib/projectstreeview_projects_helper_patch.rb deleted file mode 100644 index f931cbd..0000000 --- a/lib/projectstreeview_projects_helper_patch.rb +++ /dev/null @@ -1,64 +0,0 @@ -module ProjectstreeviewProjectsHelperPatch - extend ActiveSupport::Concern - - module ClassMethods - end - - def render_project_progress(project) - s = '' - cond = project.project_condition(false) - - open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) - - if open_issues > 0 - issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 - s << "
Issues: " + - link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + - " / #{project.issues.count} total
" + - progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) - end - project_versions = project_open(project) - - unless project_versions.empty? - s << "
" - project_versions.reverse_each do |version| - unless version.completed? - s << "
" + link_to_version(version) + ": " + - link_to_if(version.open_issues_count > 0, l(:label_x_open_issues_abbr, :count => version.open_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'o', :fixed_version_id => version, :set_filter => 1) + - " / " + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". " - s << due_date_distance_in_words(version.effective_date) if version.effective_date - s << "

" + - progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) - end - end - s << "
" - end - s.html_safe - end - - def favorite_project_modules_links(project) - links = [] - menu_items_for(:project_menu, project) do |node| - links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview - end - links.join(", ").html_safe - end - - def project_open(project) - trackers = project.trackers.find(:all, :order => 'position') - #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) - with_subprojects = Setting.display_subprojects_issues? - project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] - - versions = project.shared_versions || [] - versions += project.rolled_up_versions.visible if with_subprojects - versions = versions.uniq.sort - completed_versions = versions.select {|version| version.closed? || version.completed? } - versions -= completed_versions - - issues_by_version = {} - versions.reject! {|version| !project_ids.include?(version.project_id) && issues_by_version[version].blank?} - versions - end - -end From 79291b0ee999cbc77978c34f007412c811e38238 Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 3 Oct 2012 03:12:35 +0900 Subject: [PATCH 10/18] grafted from chiastolite/setting_show_project_progress: add setting 'show project progress' --- app/views/projects/index.html.erb | 9 +++++++-- app/views/settings/_project_tree_settings.html.erb | 8 ++++++++ config/locales/en.yml | 1 + init.rb | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/views/settings/_project_tree_settings.html.erb diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index e8f1257..e06ef30 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -14,12 +14,15 @@

<%= l(:label_project_plural)%>

+ <% show_project_progress = Setting.plugin_projects_tree_view['show_project_progress'] %> - + <% if show_project_progress %> + + <% end %> @@ -39,7 +42,9 @@ ">  - + <% if show_project_progress %> + + <% end %> <% ancestors << project_id if has_children %> diff --git a/app/views/settings/_project_tree_settings.html.erb b/app/views/settings/_project_tree_settings.html.erb new file mode 100644 index 0000000..d41cf79 --- /dev/null +++ b/app/views/settings/_project_tree_settings.html.erb @@ -0,0 +1,8 @@ +

+

<%= l(:label_project)%> <%= l(:field_description)%> <%= l(:field_go_to)%><%= l(:field_versions)%><%= l(:field_versions)%><%= l(:field_created_on)%>
<%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> <%= favorite_project_modules_links(project) %><%= render_project_progress(project) %><%= render_project_progress(project) %><%= format_date(project.created_on) %>
+ + + + +
<%= l(:show_progress) %><%= check_box_tag('settings[show_project_progress]', true, @settings['show_project_progress'])%>
+

diff --git a/config/locales/en.yml b/config/locales/en.yml index 18cbda4..a9d3ada 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -6,3 +6,4 @@ en: subprojects: sub projects expand_all: "Expand All" collapse_all: "Collapse All" + show_progress: "Show project progress" diff --git a/init.rb b/init.rb index 44ac671..a917d14 100644 --- a/init.rb +++ b/init.rb @@ -15,4 +15,8 @@ url 'https://github.com/cforce/projects_tree_view' version '0.0.8' requires_redmine :version_or_higher => '2.1.0' + + settings :default => { + 'show_project_progress' => true + }, :partial => 'settings/project_tree_settings' end From 33287d452d0e355868e2928c143ab4c12317932b Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 29 Mar 2013 11:24:44 +0900 Subject: [PATCH 11/18] grafted from jwalkerbg/simplelist: Added 'Expand All/Collapse All' links at the top of projects' tree. --- app/views/projects/index.html.erb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index e06ef30..c6b0799 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -13,6 +13,10 @@

<%= l(:label_project_plural)%>

+

+<%= link_to(l(:expand_all), "#", :onclick => 'expandAll()')%> / <%= link_to l(:collapse_all), "#", :onclick => 'collapseAll()' %> +

+ <% show_project_progress = Setting.plugin_projects_tree_view['show_project_progress'] %> From ae6b39d24ad286c07b776f0196374f74a9f1e134 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 29 Mar 2013 11:28:54 +0900 Subject: [PATCH 12/18] added japanese localization --- config/locales/ja.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 config/locales/ja.yml diff --git a/config/locales/ja.yml b/config/locales/ja.yml new file mode 100644 index 0000000..a2f9ffa --- /dev/null +++ b/config/locales/ja.yml @@ -0,0 +1,8 @@ +ja: + + field_versions: "バージョン" + field_go_to: "モジュール" + subprojects: "サブプロジェクト" + expand_all: "すべて表示する" + collapse_all: "サブプロジェクトを隠す" + show_progress: "プロジェクトの進捗を表示する" From e6fbb40b6c129c6e24e0f5d57cebb4a03bbae310 Mon Sep 17 00:00:00 2001 From: ichizok Date: Fri, 29 Mar 2013 11:53:22 +0900 Subject: [PATCH 13/18] formatted setting view --- app/views/settings/_project_tree_settings.html.erb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/settings/_project_tree_settings.html.erb b/app/views/settings/_project_tree_settings.html.erb index d41cf79..fb7087e 100644 --- a/app/views/settings/_project_tree_settings.html.erb +++ b/app/views/settings/_project_tree_settings.html.erb @@ -1,8 +1,4 @@

-

- - - - -
<%= l(:show_progress) %><%= check_box_tag('settings[show_project_progress]', true, @settings['show_project_progress'])%>
+ <%= content_tag(:label, l(:show_progress)) %> + <%= check_box_tag('settings[show_project_progress]', true, @settings['show_project_progress'])%>

From 81d3e6fb629d1b5cc502f2d671a7f09e8bd623ca Mon Sep 17 00:00:00 2001 From: ichizok Date: Tue, 26 Nov 2013 16:36:37 +0900 Subject: [PATCH 14/18] inhibit warning about deprecated method --- app/views/projects/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index c6b0799..9f22882 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -42,7 +42,7 @@ <% if has_children %> )">  <% end %> - <%= project.active? ? link_to_project(project, {:action => 'show'}) : h(project.name) %> + <%= project.active? ? link_to_project(project) : h(project.name) %> ">  <%= textilizable project.short_description.gsub(/\!.+\!/,""), :project => project %> <%= favorite_project_modules_links(project) %> From 5c318d5e6642f645373c17f344ac2f223dc5ec8a Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 4 Mar 2015 14:00:15 +0900 Subject: [PATCH 15/18] remove unnecassary 'to_s' calling --- app/views/projects/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 9f22882..1de0572 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -38,7 +38,7 @@ <% (plevel - level).times { ancestors.pop } if (level < plevel) %> <% has_children = !project.children.empty? %> "> - + <% if has_children %> )">  <% end %> From df7f6006a7500dddb8cfb7c53478c0af96955b69 Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 4 Mar 2015 14:29:49 +0900 Subject: [PATCH 16/18] compatible with Redmine 3.0 --- init.rb | 2 +- lib/projects_tree_view_projects_helper_patch.rb | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/init.rb b/init.rb index a917d14..1c568b4 100644 --- a/init.rb +++ b/init.rb @@ -14,7 +14,7 @@ description 'This is a Redmine plugin which will turn the projects page into a tree view' url 'https://github.com/cforce/projects_tree_view' version '0.0.8' - requires_redmine :version_or_higher => '2.1.0' + requires_redmine :version_or_higher => '3.0.0' settings :default => { 'show_project_progress' => true diff --git a/lib/projects_tree_view_projects_helper_patch.rb b/lib/projects_tree_view_projects_helper_patch.rb index b154e54..c61b4ec 100644 --- a/lib/projects_tree_view_projects_helper_patch.rb +++ b/lib/projects_tree_view_projects_helper_patch.rb @@ -9,14 +9,14 @@ def render_project_progress(project) s = '' cond = project.project_condition(false) - open_issues = Issue.visible.count(:include => [:project, :status, :tracker], :conditions => ["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]) + open_issues = Issue.visible.includes(:project, :status).where(["(#{cond}) AND #{IssueStatus.table_name}.is_closed=?", false]).references(:project, :status).count if open_issues > 0 - issues_closed_pourcent = (1 - open_issues.to_f/project.issues.count) * 100 + issues_closed_percent = (1 - open_issues.to_f/project.issues.count) * 100 s << "
Issues: " + link_to("#{open_issues} open", :controller => 'issues', :action => 'index', :project_id => project, :set_filter => 1) + " / #{project.issues.count} total
" + - progress_bar(issues_closed_pourcent, :width => '30em', :legend => '%0.0f%' % issues_closed_pourcent) + progress_bar(issues_closed_percent, :width => '30em', :legend => '%0.0f%' % issues_closed_percent) end project_versions = project_open(project) @@ -29,7 +29,7 @@ def render_project_progress(project) " / " + link_to_if(version.closed_issues_count > 0, l(:label_x_closed_issues_abbr, :count => version.closed_issues_count), :controller => 'issues', :action => 'index', :project_id => version.project, :status_id => 'c', :fixed_version_id => version, :set_filter => 1) + ". " s << due_date_distance_in_words(version.effective_date) if version.effective_date s << "
" + - progress_bar([version.closed_pourcent, version.completed_pourcent], :width => '30em', :legend => ('%0.0f%' % version.completed_pourcent)) + progress_bar([version.closed_percent, version.completed_percent], :width => '30em', :legend => ('%0.0f%' % version.completed_percent)) end end s << "" @@ -46,7 +46,7 @@ def favorite_project_modules_links(project) end def project_open(project) - trackers = project.trackers.find(:all, :order => 'position') + #trackers = project.trackers.order(:position) #retrieve_selected_tracker_ids(trackers, trackers.select {|t| t.is_in_roadmap?}) with_subprojects = Setting.display_subprojects_issues? project_ids = with_subprojects ? project.self_and_descendants.collect(&:id) : [project.id] From c0997ac080991f943814a50fc90b89c79ff901a9 Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 4 Mar 2015 14:30:28 +0900 Subject: [PATCH 17/18] bump version to 0.0.9 --- init.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.rb b/init.rb index 1c568b4..1cfa38d 100644 --- a/init.rb +++ b/init.rb @@ -13,7 +13,7 @@ author 'Chris Peterson and Github community' description 'This is a Redmine plugin which will turn the projects page into a tree view' url 'https://github.com/cforce/projects_tree_view' - version '0.0.8' + version '0.0.9' requires_redmine :version_or_higher => '3.0.0' settings :default => { From f21cd2ee86de79d498fe1b9e517392906a10ef8b Mon Sep 17 00:00:00 2001 From: ichizok Date: Wed, 18 Jan 2017 19:31:25 +0900 Subject: [PATCH 18/18] don't show 'new-object' ("+") menu --- lib/projects_tree_view_projects_helper_patch.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/projects_tree_view_projects_helper_patch.rb b/lib/projects_tree_view_projects_helper_patch.rb index c61b4ec..bb404d8 100644 --- a/lib/projects_tree_view_projects_helper_patch.rb +++ b/lib/projects_tree_view_projects_helper_patch.rb @@ -40,7 +40,10 @@ def render_project_progress(project) def favorite_project_modules_links(project) links = [] menu_items_for(:project_menu, project) do |node| - links << link_to(extract_node_details(node, project)[0], extract_node_details(node, project)[1]) unless node.name == :overview + if node.name != :new_object && node.name != :overview + details = extract_node_details(node, project) + links << link_to(details[0], details[1]) + end end links.join(", ").html_safe end