Merge pull request #760 from opf/fix/grouped_work_packges_on_version_show

Fix/grouped work packges on version show
pull/762/head
Johannes Wollert 11 years ago
commit df5caf1261
  1. 1
      app/assets/javascripts/application.js
  2. 71
      app/assets/javascripts/versions.js
  3. 3
      app/controllers/versions_controller.rb
  4. 2
      app/helpers/versions_helper.rb
  5. 67
      app/views/versions/_issue_counts.html.erb
  6. 76
      app/views/versions/_work_package_counts.html.erb
  7. 3
      doc/CHANGELOG.md
  8. 6
      spec/controllers/versions_controller_spec.rb

@ -67,6 +67,7 @@
//= require autocomplete_textareas //= require autocomplete_textareas
//= require_tree ./pages //= require_tree ./pages
//= require openproject_plugins //= require openproject_plugins
//= require versions
//source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse //source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse
if (typeof []._reverse == 'undefined') { if (typeof []._reverse == 'undefined') {

@ -0,0 +1,71 @@
//-- copyright
// OpenProject is a project management system.
// Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License version 3.
//
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
// Copyright (C) 2006-2013 Jean-Philippe Lang
// Copyright (C) 2010-2013 the ChiliProject Team
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// See doc/COPYRIGHT.rdoc for more details.
//++
(function ($) {
var applicable,
register_change_wp_by_status,
handle_change_wp_by_status,
init;
applicable = function () {
return $('body.controller-versions.action-show').length === 1;
};
init = function () {
register_change_wp_by_status();
};
register_change_wp_by_status = function () {
$('#status_by_select').change(function () {
handle_change_wp_by_status();
return false;
});
};
handle_change_wp_by_status = function () {
var form = $('#status_by_form'),
url = form.attr('action'),
data = form.serialize();
$.ajax({ url: url,
headers: { Accept: 'text/javascript' },
data: data,
complete: function (jqXHR) {
form.replaceWith(jqXHR.responseText);
register_change_wp_by_status();
}
});
};
$('document').ready(function () {
if (applicable()) {
init();
}
});
})(jQuery);

@ -35,6 +35,7 @@ class VersionsController < ApplicationController
before_filter :find_project, :only => [:index, :new, :create, :close_completed] before_filter :find_project, :only => [:index, :new, :create, :close_completed]
before_filter :authorize before_filter :authorize
include VersionsHelper
def index def index
@types = @project.types.find(:all, :order => 'position') @types = @project.types.find(:all, :order => 'position')
@ -148,7 +149,7 @@ class VersionsController < ApplicationController
def status_by def status_by
respond_to do |format| respond_to do |format|
format.html { render :action => 'show' } format.html { render :action => 'show' }
format.js { render(:update) {|page| page.replace_html 'status_by', render_status_by(@version, params[:status_by])} } format.js { render_status_by @version, params[:status_by] }
end end
end end

@ -49,7 +49,7 @@ module VersionsHelper
counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}} counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
max = counts.collect {|c| c[:total]}.max max = counts.collect {|c| c[:total]}.max
render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max} render :partial => 'work_package_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
end end
def status_by_options_for_select(value) def status_by_options_for_select(value)

@ -1,67 +0,0 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See doc/COPYRIGHT.rdoc for more details.
++#%>
<form id="status_by_form">
<fieldset>
<legend>
<% update_form = remote_function(:url => status_by_version_path(version),
:with => "Form.serialize('status_by_form')",
:method => :get) %>
<%= l(:label_issues_by,
select_tag('status_by',
status_by_options_for_select(criteria),
:id => 'status_by_select',
:onchange => update_form)).html_safe %>
</legend>
<% if counts.empty? %>
<p><em><%= l(:label_no_data) %></em></p>
<% else %>
<table>
<% counts.each do |count| %>
<tr>
<td width="130px" align="right" >
<%= link_to h(count[:group]), {controller: :work_packages,
action: :index,
project_id: version.project,
set_filter: 1,
status_id: '*',
fixed_version_id: version}.merge("#{criteria}_id".to_sym => count[:group]) %>
</td>
<td width="240px">
<%= progress_bar((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}",
:width => "#{(count[:total].to_f / max * 200).floor}px;") %>
</td>
</tr>
<% end %>
</table>
<% end %>
</fieldset>
</form>

@ -0,0 +1,76 @@
<%#-- copyright
OpenProject is a project management system.
Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License version 3.
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
Copyright (C) 2006-2013 Jean-Philippe Lang
Copyright (C) 2010-2013 the ChiliProject Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
See doc/COPYRIGHT.rdoc for more details.
++#%>
<% tag_for_selection = select_tag('status_by',
status_by_options_for_select(criteria),
:id => 'status_by_select') %>
<%= form_tag status_by_version_path(version),
:id => "status_by_form" do %>
<fieldset>
<legend>
<%= l(:label_work_packages_by, tag_for_selection).html_safe %>
</legend>
<% if counts.empty? %>
<p>
<em><%= l(:label_no_data) %></em>
</p>
<% else %>
<table>
<% counts.each do |count| %>
<tr>
<td width="130px" align="right" >
<%= link_to h(count[:group]), {controller: :work_packages,
action: :index,
project_id: version.project,
set_filter: 1,
status_id: '*',
fixed_version_id: version}.merge("#{criteria}_id".to_sym => count[:group]) %>
</td>
<td width="240px">
<%= progress_bar((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}",
:width => "#{(count[:total].to_f / max * 200).floor}px;") %>
</td>
</tr>
<% end %>
</table>
<% end %>
</fieldset>
<% end %>

@ -29,8 +29,9 @@ See doc/COPYRIGHT.rdoc for more details.
# Changelog # Changelog
## 3.0.0pre40 * `#3407` Fix: [Roadmap] Missing dropdown menu for displaying work packages by different criteria
## 3.0.0pre40
* `#3066` [Work package tracking] Bulk edit causes page not found * `#3066` [Work package tracking] Bulk edit causes page not found
* update will paginate * update will paginate

@ -252,8 +252,6 @@ describe VersionsController do
end end
describe "#status_by" do describe "#status_by" do
render_views
before do before do
User.stub(:current).and_return(user) User.stub(:current).and_return(user)
end end
@ -264,7 +262,7 @@ describe VersionsController do
end end
it { response.should be_success } it { response.should be_success }
it { response.should render_template("issue_counts") } it { response.should render_template("work_package_counts") }
end end
context "status by version with status_by" do context "status by version with status_by" do
@ -273,7 +271,7 @@ describe VersionsController do
end end
it { response.should be_success } it { response.should be_success }
it { response.should render_template("issue_counts") } it { response.should render_template("work_package_counts") }
end end
end end
end end

Loading…
Cancel
Save