Merge pull request #10 from finnlabs/feature/rails3_fix_routes

Feature/rails3 fix routes
pull/6827/head
Christian Rijke 12 years ago
commit 6d3823d16f
  1. 2
      app/assets/javascripts/backlogs/app/burndown.js
  2. 4
      app/assets/javascripts/backlogs/app/impediment.js
  3. 6
      app/assets/javascripts/backlogs/app/story.js
  4. 4
      app/assets/javascripts/backlogs/app/task.js
  5. 10
      app/controllers/issue_boxes_controller.rb
  6. 12
      app/controllers/rb_application_controller.rb
  7. 2
      app/controllers/rb_master_backlogs_controller.rb
  8. 1
      app/controllers/rb_queries_controller.rb
  9. 6
      app/controllers/rb_sprints_controller.rb
  10. 2
      app/helpers/rb_common_helper.rb
  11. 4
      app/helpers/rb_master_backlogs_helper.rb
  12. 3
      app/views/rb_master_backlogs/index.html.erb
  13. 19
      app/views/rb_server_variables/show.js.erb
  14. 7
      app/views/rb_taskboards/show.html.erb
  15. 3
      app/views/shared/_view_issues_sidebar.html.erb
  16. 62
      config/routes.rb
  17. 6
      features/support/paths.rb
  18. 18
      lib/open_project/backlogs/engine.rb

@ -27,7 +27,7 @@ RB.Burndown = (function ($) {
$('<div id="charts"></div>').appendTo("body");
}
$('#charts').html("<div class='loading'>" + RB.i18n.generating_graph + "</div>");
$('#charts').load(RB.urlFor('show_burndown_chart', { id: $(this).data('this').sprintId,
$('#charts').load(RB.urlFor('show_burndown_chart', { sprint_id: $(this).data('this').sprintId,
project_id: RB.constants.project_id}));
$('#charts').dialog({
dialogClass: "rb_dialog",

@ -38,10 +38,10 @@ RB.Impediment = (function ($) {
(this.isNew() ? "" : "&id=" + j.children('.id').text());
if (this.isNew()) {
url = RB.urlFor('create_impediment');
url = RB.urlFor('create_impediment', {sprint_id: RB.constants.sprint_id});
}
else {
url = RB.urlFor('update_impediment', {id: this.getID()});
url = RB.urlFor('update_impediment', {id: this.getID(), sprint_id: RB.constants.sprint_id});
data += "&_method=put";
}

@ -84,10 +84,12 @@ RB.Story = (function ($) {
data += "&" + this.$.find('.editor').serialize();
}
//TODO: this might be unsave in case the parent of this story is not the sprint backlog, then we dont have
//a sprintId an cannot generate a valid url - one option might be to take RB.constants.sprint_id hoping it exists
if (this.isNew()) {
url = RB.urlFor('create_story');
url = RB.urlFor('create_story', {sprint_id: sprintId});
} else {
url = RB.urlFor('update_story', {id: this.getID()});
url = RB.urlFor('update_story', {id: this.getID(), sprint_id: sprintId});
data += "&_method=put";
}

@ -54,10 +54,10 @@ RB.Task = (function ($) {
(this.isNew() ? "" : "&id=" + this.$.children('.id').text());
if (this.isNew()) {
url = RB.urlFor('create_task');
url = RB.urlFor('create_task', {sprint_id: RB.constants.sprint_id});
}
else {
url = RB.urlFor('update_task', {id: this.getID()});
url = RB.urlFor('update_task', {id: this.getID(), sprint_id: RB.constants.sprint_id});
data += "&_method=put";
}

@ -19,10 +19,10 @@ class IssueBoxesController < IssuesController
format.js { render :partial => 'show' }
end
end
def edit
return redirect_to edit_issue_path(params[:id]) unless request.xhr?
update_issue_from_params
load_journals
@journal = @issue.current_journal
@ -31,10 +31,10 @@ class IssueBoxesController < IssuesController
format.js { render :partial => 'edit' }
end
end
def update
update_issue_from_params
if @issue.save_issue_with_child_records(params, @time_entry)
@issue.reload
load_journals
@ -48,7 +48,7 @@ class IssueBoxesController < IssuesController
end
end
end
private
def load_journals

@ -11,11 +11,10 @@ class RbApplicationController < ApplicationController
# Loads the project to be used by the authorize filter to
# determine if User.current has permission to invoke the method in question.
def load_project
@project = Project.find(params[:project_id]) if params[:project_id]
if params[:sprint_id]
load_sprint
@project = @sprint.project unless @project.present?
load_sprint_and_project
else
@project = Project.find(params[:project_id]) if params[:project_id]
end
end
@ -28,7 +27,8 @@ class RbApplicationController < ApplicationController
end
end
def load_sprint
@sprint = Sprint.find(params[:sprint_id])
def load_sprint_and_project(id = params[:sprint_id].to_i)
@sprint = Sprint.find(id)
@project = @sprint.project
end
end

@ -3,7 +3,7 @@ class RbMasterBacklogsController < RbApplicationController
menu_item :backlogs
def show
def index
@owner_backlogs = Backlog.owner_backlogs(@project)
@sprint_backlogs = Backlog.sprint_backlogs(@project)

@ -21,5 +21,4 @@ class RbQueriesController < RbApplicationController
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :column_names => column_names}
redirect_to :controller => 'issues', :action => 'index', :project_id => @project.id, :sort => 'position'
end
end

@ -15,4 +15,10 @@ class RbSprintsController < RbApplicationController
format.html { render :partial => "sprint", :status => status, :object => @sprint }
end
end
#overwrite load_project to load the sprint from the :id instead of :sprint_id
#which whill automatically also load the project
def load_project
load_sprint_and_project params[:id]
end
end

@ -39,7 +39,7 @@ module RbCommonHelper
end
def link_to_issue_box(title, issue, options = {})
modal_link_to(title, rb_issue_box_path(issue), options)
modal_link_to(title, backlogs_issue_box_path(issue), options)
end
def modal_link_to(title, path, options = {})

@ -65,7 +65,7 @@ module RbMasterBacklogsHelper
items[:task_board] = link_to(l(:label_task_board),
:controller => 'rb_taskboards',
:action => 'show',
:project_id => @project.id,
:project_id => @project,
:sprint_id => backlog.sprint)
if backlog.sprint.has_burndown?
@ -79,7 +79,7 @@ module RbMasterBacklogsHelper
items[:wiki] = link_to(l(:label_wiki),
:controller => 'rb_wikis',
:action => 'edit',
:project_id => @project.id,
:project_id => @project,
:sprint_id => backlog.sprint)
end

@ -13,8 +13,7 @@
<%= javascript_include_tag url_for(:controller => 'rb_server_variables',
:action => 'show',
:project_id => @project,
:format => :js) %>
:project_id => @project) %>
<%= stylesheet_link_tag 'backlogs/jqplot.css' %>
<%= stylesheet_link_tag 'backlogs/master_backlog.css', :media => 'print,screen' %>

@ -13,18 +13,18 @@ RB.i18n = {
RB.urlFor = (function () {
var routes = {
update_sprint: '<%= url_for(:controller => 'rb_sprints', :action => 'update', :sprint_id => ":id") %>',
update_sprint: '<%= backlogs_project_sprint_path(:project_id => @project.identifier, :id => ":id") %>',
create_story: '<%= url_for(:controller => 'rb_stories', :action => 'create') %>',
update_story: '<%= url_for(:controller => 'rb_stories', :action => 'update', :id => ":id") %>',
create_story: '<%= backlogs_project_sprint_stories_path(:project_id => @project.identifier, :sprint_id => ":sprint_id") %>',
update_story: '<%= backlogs_project_sprint_story_path(:project_id => @project.identifier, :sprint_id => ":sprint_id", :id => ":id") %>',
create_task: '<%= url_for(:controller => 'rb_tasks', :action => 'create') %>',
update_task: '<%= url_for(:controller => 'rb_tasks', :action => 'update', :id => ":id") %>',
create_task: '<%= backlogs_project_sprint_tasks_path(:project_id => @project.identifier, :sprint_id => ":sprint_id") %>',
update_task: '<%= backlogs_project_sprint_task_path(:project_id => @project.identifier, :sprint_id => ":sprint_id", :id => ":id") %>',
create_impediment: '<%= url_for(:controller => 'rb_impediments', :action => 'create') %>',
update_impediment: '<%= url_for(:controller => 'rb_impediments', :action => 'update', :id => ":id") %>',
create_impediment: '<%= backlogs_project_sprint_impediments_path(:project_id => @project.identifier, :sprint_id => ":sprint_id") %>',
update_impediment: '<%= backlogs_project_sprint_impediment_path(:project_id => @project.identifier, :sprint_id => ":sprint_id", :id => ":id") %>',
show_burndown_chart: '<%= url_for(:controller => 'rb_burndown_charts', :action => 'show', :sprint_id => ":id", :project_id =>":project_id") %>'
show_burndown_chart: '<%= backlogs_project_sprint_burndown_chart_path(:project_id => @project.identifier, :sprint_id => ":sprint_id") %>'
};
return function (routeName, options) {
@ -37,6 +37,9 @@ RB.urlFor = (function () {
if (options.project_id){
route = route.replace(":project_id", options.project_id);
}
if(options.sprint_id) {
route = route.replace(":sprint_id", options.sprint_id)
}
}
return route;

@ -12,8 +12,7 @@
<%= javascript_include_tag url_for(:controller => 'rb_server_variables',
:action => 'show',
:project_id => @project,
:sprint_id => @sprint,
:format => :js) %>
:sprint_id => @sprint) %>
<%= stylesheet_link_tag 'backlogs/jqplot.css' %>
<%= stylesheet_link_tag 'backlogs/taskboard.css', :media => 'print,screen' %>
@ -31,10 +30,10 @@
</span>
</div>
<% breadcrumb_paths(link_to(l(:label_backlogs), rb_master_backlog_path(@project)), link_to(@sprint.name, rb_taskboard_path(@sprint))) %>
<% breadcrumb_paths(link_to(l(:label_backlogs), backlogs_project_backlogs_path(@project)), link_to(@sprint.name, backlogs_project_backlogs_path(@sprint))) %>
<h2>
<%= link_to @sprint.name, rb_taskboard_path(@sprint) %>
<%= link_to @sprint.name, backlogs_project_backlogs_path(@sprint) %>
</h2>
<div id='rb'>

@ -49,8 +49,7 @@
<%= javascript_include_tag url_for(:controller => 'rb_server_variables',
:action => 'show',
:project_id => project,
:sprint_id => sprint,
:format => :js) %>
:sprint_id => sprint) %>
<%= link_to(l('backlogs.show_burndown_chart'),
{},

@ -2,66 +2,38 @@ OpenProject::Application.routes.draw do
# Use rb/ as a URL 'namespace.' We're using a slightly different URL pattern
# From Redmine so namespacing avoids any further problems down the line
resource :rb, :only => :none do
#scope "/rb" do
scope "", as: "backlogs" do
scope "queries/:project_id" do
resource :query,
:only => :show,
:controller => :rb_queries
end
resources :issue_boxes, :controller => :issue_boxes, :only => [:show, :edit, :update]
scope "wiki/:sprint_id" do
resource :wiki, :only => [:show, :edit], :controller => :rb_wikis
end
scope "projects/:project_id", as: 'project' do
scope "projects/:project_id/burndown_charts/:sprint_id" do
resource :burndown_chart, :only => :show, :controller => :rb_burndown_charts
end
resources :backlogs, :controller => :rb_master_backlogs, :only => :index
scope "impediment/:id" do
resource :impediment, :except => :index, :controller => :rb_impediments
end
resource :server_variables, :controller => :rb_server_variables, :only => :show, :format => :js
scope "impediments/:sprint_id" do
resources :impediments, :only => :index, :controller => :rb_impediments
end
resources :sprints, :controller => :rb_sprints, :only => :update do
scope "task/:id" do
resource :task, :except => :index, :controller => :rb_tasks
end
resource :query, :controller => :rb_queries, :only => :show
scope "tasks/:stroy_id" do
resources :tasks, :only => :index, :controller => :rb_tasks
end
resource :taskboard, :controller => :rb_taskboards, :only => :show
scope "story/:id" do
resource :story, :except => :index, :controller => :rb_stories
end
resource :wiki, :controller => :rb_wikis, :only => [:show, :edit]
scope "stories/:project_id" do
resources :stories, :only => :index, :controller => :rb_stories
end
resource :burndown_chart, :controller => :rb_burndown_charts, :only => :show
scope "sprints/:sprint_id" do
resource :sprint, :only => [:show, :update], :controller => :rb_sprints
end
resources :impediments, :controller => :rb_impediments, :only => [:create, :update]
scope "server_variables/:project_id" do
resource :server_variables, :only => :show, :controller => :rb_server_variables
end
resources :tasks, :controller => :rb_tasks, :only => [:create, :update]
scope "taskboard/:sprint_id" do
resource :taskboard, :only => :show, :controller => :rb_taskboards
end
resources :stories, :controller => :rb_stories, :only => [:index, :create, :update]
scope "master_backlogs/:project_id" do
resource :master_backlog, :only => :show, :controller => :rb_master_backlogs
end
end
resources :issue_boxes, :only => [:show, :edit, :update]
end
get 'projects/:project_id/versions/:id/edit' => 'version_settings#edit'
get 'projects/:id/project_issue_statuses' => 'projects#project_issue_statuses'
get 'projects/:project_id/versions/:id/edit' => 'version_settings#edit'
post 'projects/:id/project_issue_statuses' => 'projects#project_issue_statuses'
post 'projects/:id/rebuild_positions' => 'projects#rebuild_positions'
end

@ -9,7 +9,7 @@ module BacklogsNavigationHelpers
case page_name
when /^the master backlog(?: of the [pP]roject "(.+?)")?$/
project = get_project($1)
"/rb/master_backlogs/#{project.identifier}"
"/projects/#{project.identifier}/backlogs"
when /^the (:?overview ?)?page (?:for|of) the [pP]roject$/
project = get_project
@ -23,7 +23,7 @@ module BacklogsNavigationHelpers
project = get_project($2)
sprint = Sprint.find_by_name_and_project_id($1, project)
"/rb/projects/#{project.id}/burndown_charts/#{sprint.id}"
"/projects/#{project.identifier}/sprints/#{sprint.id}/burndown_chart"
when /^the task ?board for "(.+?)"(?: (?:in|of) the [pP]roject "(.+?)")?$/
project = get_project($2)
@ -33,7 +33,7 @@ module BacklogsNavigationHelpers
# do not depend on @sprint being set in new step definitions
@sprint = sprint
"/rb/taskboards/#{sprint.id}"
"/projects/#{project.identifier}/sprints/#{sprint.id}/taskboard"
else
super

@ -18,6 +18,20 @@ module OpenProject::Backlogs
Rails.application.config.assets.precompile += %w( backlogs.css backlogs.js )
end
config.before_configuration do |app|
# This is required for the routes to be loaded first
# as the routes should be prepended so they take precedence over the core.
app.config.paths['config/routes'].unshift File.join(File.dirname(__FILE__), "..", "..", "..", "config", "routes.rb")
end
initializer "remove_duplicate_backlogs_routes", :after => "add_routing_paths" do |app|
# removes duplicate entry from app.routes_reloader
# As we prepend the plugin's routes to the load_path up front and rails
# adds all engines' config/routes.rb later, we have double loaded the routes
# This is not harmful as such but leads to duplicate routes which decreases performance
app.routes_reloader.paths.uniq!
end
initializer 'backlogs.register_test_paths' do |app|
app.config.plugins_to_test_paths << self.root
end
@ -90,7 +104,7 @@ module OpenProject::Backlogs
# Master backlog permissions
permission :view_master_backlog, {
:rb_master_backlogs => :show,
:rb_master_backlogs => :index,
:rb_sprints => [:index, :show],
:rb_wikis => :show,
:rb_stories => [:index, :show],
@ -139,7 +153,7 @@ module OpenProject::Backlogs
menu :project_menu,
:backlogs,
{:controller => :rb_master_backlogs, :action => :show},
{:controller => :rb_master_backlogs, :action => :index},
:caption => :project_module_backlogs,
:before => :calendar,
:param => :project_id,

Loading…
Cancel
Save