Merge pull request #1402 from AlexDenisov/preselected_milestone_while_create_new_issue

Preselected milestone and assignee while create new issue
This commit is contained in:
Dmitriy Zaporozhets 2012-09-07 11:10:27 -07:00
commit 7b50a7c99d
5 changed files with 63 additions and 2 deletions

View file

@ -80,6 +80,10 @@ function issuesPage(){
$(this).closest("form").submit(); $(this).closest("form").submit();
}); });
$("#new_issue_link").click(function(){
updateNewIssueURL();
});
$('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){ $('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){
var t = $(this), var t = $(this),
totalIssues, totalIssues,
@ -126,3 +130,20 @@ function issuesCheckChanged() {
$('.issues_filters').show(); $('.issues_filters').show();
} }
} }
function updateNewIssueURL(){
var new_issue_link = $("#new_issue_link");
var milestone_id = $("#milestone_id").val();
var assignee_id = $("#assignee_id").val();
var new_href = "";
if(milestone_id){
new_href = "issue[milestone_id]=" + milestone_id + "&";
}
if(assignee_id){
new_href = new_href + "issue[assignee_id]=" + assignee_id;
}
if(new_href.length){
new_href = new_issue_link.attr("href") + "?" + new_href;
new_issue_link.attr("href", new_href);
}
};

View file

@ -37,7 +37,7 @@ class IssuesController < ApplicationController
end end
def new def new
@issue = @project.issues.new @issue = @project.issues.new(params[:issue])
respond_with(@issue) respond_with(@issue)
end end

View file

@ -6,7 +6,7 @@
.right .right
.span5 .span5
- if can? current_user, :write_issue, @project - if can? current_user, :write_issue, @project
= link_to new_project_issue_path(@project), class: "right btn", title: "New Issue", remote: true do = link_to new_project_issue_path(@project), class: "right btn", title: "New Issue", remote: true, id: "new_issue_link" do
%i.icon-plus %i.icon-plus
New Issue New Issue
= form_tag search_project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: :right do = form_tag search_project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: :right do

View file

@ -64,3 +64,19 @@ Feature: Issues
And I fill in issue search with "" And I fill in issue search with ""
Then I should see "Release 0.4" in issues Then I should see "Release 0.4" in issues
And I should see "Release 0.3" in issues And I should see "Release 0.3" in issues
@javascript
Scenario: I create Issue with pre-selected milestone
Given project "Shop" has milestone "v2.2"
And project "Shop" has milestone "v3.0"
And I visit project "Shop" issues page
When I select milestone "v3.0"
And I click link "New Issue"
Then I should see selected milestone with title "v3.0"
@javascript
Scenario: I create Issue with pre-selected assignee
When I select first assignee from "Shop" project
And I click link "New Issue"
Then I should see first assignee from "Shop" as selected assignee

View file

@ -55,3 +55,27 @@ Given /^I fill in issue search with "(.*?)"$/ do |arg1|
end end
fill_in 'issue_search', with: arg1 fill_in 'issue_search', with: arg1
end end
When /^I select milestone "(.*?)"$/ do |milestone_title|
select milestone_title, from: "milestone_id"
end
Then /^I should see selected milestone with title "(.*?)"$/ do |milestone_title|
issues_milestone_selector = "#issue_milestone_id_chzn/a"
wait_until{ page.has_content?("Details") }
page.find(issues_milestone_selector).should have_content(milestone_title)
end
When /^I select first assignee from "(.*?)" project$/ do |project_name|
project = Project.find_by_name project_name
first_assignee = project.users.first
select first_assignee.name, from: "assignee_id"
end
Then /^I should see first assignee from "(.*?)" as selected assignee$/ do |project_name|
issues_assignee_selector = "#issue_assignee_id_chzn/a"
wait_until{ page.has_content?("Details") }
project = Project.find_by_name project_name
assignee_name = project.users.first.name
page.find(issues_assignee_selector).should have_content(assignee_name)
end