diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 4723dc1a25..d9c3825f8a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -67,6 +67,7 @@ //= require autocomplete_textareas //= require_tree ./pages //= require openproject_plugins +//= require versions //source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse if (typeof []._reverse == 'undefined') { diff --git a/app/assets/javascripts/versions.js b/app/assets/javascripts/versions.js new file mode 100644 index 0000000000..334a4ac32b --- /dev/null +++ b/app/assets/javascripts/versions.js @@ -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); diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index cc1b41f92a..f75d1485d4 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -35,6 +35,7 @@ class VersionsController < ApplicationController before_filter :find_project, :only => [:index, :new, :create, :close_completed] before_filter :authorize + include VersionsHelper def index @types = @project.types.find(:all, :order => 'position') @@ -148,7 +149,7 @@ class VersionsController < ApplicationController def status_by respond_to do |format| 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 diff --git a/app/helpers/versions_helper.rb b/app/helpers/versions_helper.rb index 2cd51046a0..14ef0fc439 100644 --- a/app/helpers/versions_helper.rb +++ b/app/helpers/versions_helper.rb @@ -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])}} 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 def status_by_options_for_select(value) diff --git a/app/views/versions/_issue_counts.html.erb b/app/views/versions/_issue_counts.html.erb deleted file mode 100644 index 2a2395b440..0000000000 --- a/app/views/versions/_issue_counts.html.erb +++ /dev/null @@ -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. - -++#%> - -
diff --git a/app/views/versions/_work_package_counts.html.erb b/app/views/versions/_work_package_counts.html.erb new file mode 100644 index 0000000000..4706049475 --- /dev/null +++ b/app/views/versions/_work_package_counts.html.erb @@ -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 %> + + +<% end %> diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 3ee96b71ff..a72691849d 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -29,8 +29,9 @@ See doc/COPYRIGHT.rdoc for more details. # 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 * update will paginate diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb index b14c92fec4..1515f0e692 100644 --- a/spec/controllers/versions_controller_spec.rb +++ b/spec/controllers/versions_controller_spec.rb @@ -252,8 +252,6 @@ describe VersionsController do end describe "#status_by" do - render_views - before do User.stub(:current).and_return(user) end @@ -264,7 +262,7 @@ describe VersionsController do end it { response.should be_success } - it { response.should render_template("issue_counts") } + it { response.should render_template("work_package_counts") } end context "status by version with status_by" do @@ -273,7 +271,7 @@ describe VersionsController do end it { response.should be_success } - it { response.should render_template("issue_counts") } + it { response.should render_template("work_package_counts") } end end end