Commit 7b50a7c99dbab132bfc2fbabfc3309f13359fd60
Exists in
master
and in
4 other branches
Merge pull request #1402 from AlexDenisov/preselected_milestone_while_create_new_issue
Preselected milestone and assignee while create new issue
Showing
5 changed files
with
63 additions
and
2 deletions
Show diff stats
app/assets/javascripts/issues.js
| ... | ... | @@ -80,6 +80,10 @@ function issuesPage(){ |
| 80 | 80 | $(this).closest("form").submit(); |
| 81 | 81 | }); |
| 82 | 82 | |
| 83 | + $("#new_issue_link").click(function(){ | |
| 84 | + updateNewIssueURL(); | |
| 85 | + }); | |
| 86 | + | |
| 83 | 87 | $('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){ |
| 84 | 88 | var t = $(this), |
| 85 | 89 | totalIssues, |
| ... | ... | @@ -126,3 +130,20 @@ function issuesCheckChanged() { |
| 126 | 130 | $('.issues_filters').show(); |
| 127 | 131 | } |
| 128 | 132 | } |
| 133 | + | |
| 134 | +function updateNewIssueURL(){ | |
| 135 | + var new_issue_link = $("#new_issue_link"); | |
| 136 | + var milestone_id = $("#milestone_id").val(); | |
| 137 | + var assignee_id = $("#assignee_id").val(); | |
| 138 | + var new_href = ""; | |
| 139 | + if(milestone_id){ | |
| 140 | + new_href = "issue[milestone_id]=" + milestone_id + "&"; | |
| 141 | + } | |
| 142 | + if(assignee_id){ | |
| 143 | + new_href = new_href + "issue[assignee_id]=" + assignee_id; | |
| 144 | + } | |
| 145 | + if(new_href.length){ | |
| 146 | + new_href = new_issue_link.attr("href") + "?" + new_href; | |
| 147 | + new_issue_link.attr("href", new_href); | |
| 148 | + } | |
| 149 | +}; | ... | ... |
app/controllers/issues_controller.rb
app/views/issues/index.html.haml
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | .right |
| 7 | 7 | .span5 |
| 8 | 8 | - if can? current_user, :write_issue, @project |
| 9 | - = link_to new_project_issue_path(@project), class: "right btn", title: "New Issue", remote: true do | |
| 9 | + = link_to new_project_issue_path(@project), class: "right btn", title: "New Issue", remote: true, id: "new_issue_link" do | |
| 10 | 10 | %i.icon-plus |
| 11 | 11 | New Issue |
| 12 | 12 | = form_tag search_project_issues_path(@project), method: :get, remote: true, id: "issue_search_form", class: :right do | ... | ... |
features/projects/issues/issues.feature
| ... | ... | @@ -64,3 +64,19 @@ Feature: Issues |
| 64 | 64 | And I fill in issue search with "" |
| 65 | 65 | Then I should see "Release 0.4" in issues |
| 66 | 66 | And I should see "Release 0.3" in issues |
| 67 | + | |
| 68 | + @javascript | |
| 69 | + Scenario: I create Issue with pre-selected milestone | |
| 70 | + Given project "Shop" has milestone "v2.2" | |
| 71 | + And project "Shop" has milestone "v3.0" | |
| 72 | + And I visit project "Shop" issues page | |
| 73 | + When I select milestone "v3.0" | |
| 74 | + And I click link "New Issue" | |
| 75 | + Then I should see selected milestone with title "v3.0" | |
| 76 | + | |
| 77 | + @javascript | |
| 78 | + Scenario: I create Issue with pre-selected assignee | |
| 79 | + When I select first assignee from "Shop" project | |
| 80 | + And I click link "New Issue" | |
| 81 | + Then I should see first assignee from "Shop" as selected assignee | |
| 82 | + | ... | ... |
features/step_definitions/project/project_issues_steps.rb
| ... | ... | @@ -55,3 +55,27 @@ Given /^I fill in issue search with "(.*?)"$/ do |arg1| |
| 55 | 55 | end |
| 56 | 56 | fill_in 'issue_search', with: arg1 |
| 57 | 57 | end |
| 58 | + | |
| 59 | +When /^I select milestone "(.*?)"$/ do |milestone_title| | |
| 60 | + select milestone_title, from: "milestone_id" | |
| 61 | +end | |
| 62 | + | |
| 63 | +Then /^I should see selected milestone with title "(.*?)"$/ do |milestone_title| | |
| 64 | + issues_milestone_selector = "#issue_milestone_id_chzn/a" | |
| 65 | + wait_until{ page.has_content?("Details") } | |
| 66 | + page.find(issues_milestone_selector).should have_content(milestone_title) | |
| 67 | +end | |
| 68 | + | |
| 69 | +When /^I select first assignee from "(.*?)" project$/ do |project_name| | |
| 70 | + project = Project.find_by_name project_name | |
| 71 | + first_assignee = project.users.first | |
| 72 | + select first_assignee.name, from: "assignee_id" | |
| 73 | +end | |
| 74 | + | |
| 75 | +Then /^I should see first assignee from "(.*?)" as selected assignee$/ do |project_name| | |
| 76 | + issues_assignee_selector = "#issue_assignee_id_chzn/a" | |
| 77 | + wait_until{ page.has_content?("Details") } | |
| 78 | + project = Project.find_by_name project_name | |
| 79 | + assignee_name = project.users.first.name | |
| 80 | + page.find(issues_assignee_selector).should have_content(assignee_name) | |
| 81 | +end | ... | ... |