Commit 3958330edc5aa6044ebe90382fd901834ecfa821
1 parent
5c68f4f4
Exists in
spb-stable
and in
3 other branches
Added milestone_options and assigne_options helpers
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
4 changed files
with
14 additions
and
6 deletions
Show diff stats
app/helpers/issues_helper.rb
... | ... | @@ -76,4 +76,12 @@ module IssuesHelper |
76 | 76 | def bulk_update_assignee_options |
77 | 77 | options_for_select(["None (unassigned)", nil]) + options_from_collection_for_select(@project.team.members, "id", "name", params[:assignee_id]) |
78 | 78 | end |
79 | + | |
80 | + def assignee_options object | |
81 | + options_from_collection_for_select(@project.team.members.sort_by(&:name), 'id', 'name', object.assignee_id) | |
82 | + end | |
83 | + | |
84 | + def milestone_options object | |
85 | + options_from_collection_for_select(@project.milestones.active, 'id', 'title', object.milestone_id) | |
86 | + end | |
79 | 87 | end | ... | ... |
app/views/projects/issues/_form.html.haml
... | ... | @@ -21,7 +21,7 @@ |
21 | 21 | Assign to |
22 | 22 | .controls |
23 | 23 | .pull-left |
24 | - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select a user" }, {class: 'chosen'}) | |
24 | + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Select a user" }, {class: 'chosen'}) | |
25 | 25 | .pull-right |
26 | 26 | |
27 | 27 | = link_to 'Assign to me', '#', class: 'btn btn-small assign-to-me-link' |
... | ... | @@ -29,7 +29,7 @@ |
29 | 29 | = f.label :milestone_id do |
30 | 30 | %i.icon-time |
31 | 31 | Milestone |
32 | - .controls= f.select(:milestone_id, @project.milestones.active.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) | |
32 | + .controls= f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'chosen'}) | |
33 | 33 | |
34 | 34 | .ui-box-bottom |
35 | 35 | .control-group | ... | ... |
app/views/projects/issues/_issue_context.html.haml
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | - if can?(current_user, :modify_issue, @issue) |
8 | 8 | = link_to profile_path(issue.assignee) do |
9 | 9 | = image_tag(avatar_icon(issue.assignee.email), class: 'avatar avatar-inline s16 assignee') if issue.assignee |
10 | - = f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Assign to user (none):" }, {class: 'chosen'}) | |
10 | + = f.select(:assignee_id, assignee_options(@issue), { include_blank: "Assign to user (none):" }, {class: 'chosen'}) | |
11 | 11 | - elsif issue.assignee |
12 | 12 | = link_to_member(@project, @issue.assignee) |
13 | 13 | |
... | ... | @@ -16,7 +16,7 @@ |
16 | 16 | %cite.cgray and attached to milestone |
17 | 17 | |
18 | 18 | - if can?(current_user, :modify_issue, @issue) |
19 | - = f.select(:milestone_id, @project.milestones.active.all.collect {|p| [ p.title, p.id ] }, { include_blank: "Select milestone (none):" }, {class: 'chosen'}) | |
19 | + = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone (none):" }, {class: 'chosen'}) | |
20 | 20 | |
21 | 21 | = hidden_field_tag :issue_context |
22 | 22 | = f.submit class: 'btn' | ... | ... |
app/views/projects/merge_requests/_form.html.haml
... | ... | @@ -39,12 +39,12 @@ |
39 | 39 | = f.label :assignee_id do |
40 | 40 | %i.icon-user |
41 | 41 | Assign to |
42 | - .controls= f.select(:assignee_id, @project.team.members.sort_by(&:name).map {|p| [ p.name, p.id ] }, { include_blank: "Select user" }, {class: 'chosen span3'}) | |
42 | + .controls= f.select(:assignee_id, assignee_options(@merge_request), { include_blank: "Select user" }, {class: 'chosen span3'}) | |
43 | 43 | .left |
44 | 44 | = f.label :milestone_id do |
45 | 45 | %i.icon-time |
46 | 46 | Milestone |
47 | - .controls= f.select(:milestone_id, @project.milestones.active.map {|p| [ p.title, p.id ] }, { include_blank: "Select milestone" }, {class: 'chosen'}) | |
47 | + .controls= f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'chosen'}) | |
48 | 48 | .control-group |
49 | 49 | = f.label :description, "Description" |
50 | 50 | .controls | ... | ... |