Feature #29285 » 29285-v2.patch
| app/views/issues/_attributes.html.erb | ||
|---|---|---|
| 15 | 15 |
<% end %> |
| 16 | 16 | |
| 17 | 17 |
<% if @issue.safe_attribute? 'assigned_to_id' %> |
| 18 |
<p><%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to), |
|
| 19 |
:include_blank => true, :required => @issue.required_attribute?('assigned_to_id') %></p>
|
|
| 18 |
<p> |
|
| 19 |
<%= f.select :assigned_to_id, principals_options_for_select(@issue.assignable_users, @issue.assigned_to), |
|
| 20 |
:include_blank => true, :required => @issue.required_attribute?('assigned_to_id') %>
|
|
| 21 |
<% if @issue.assignable_users.include?(User.current) %> |
|
| 22 |
<a class="assign-to-me-link<%= ' hidden' if @issue.assigned_to_id == User.current.id %>" href="#" data-id="<%= User.current.id %>"><%= l(:label_assign_to_me) %></a> |
|
| 23 |
<% end %> |
|
| 24 |
</p> |
|
| 20 | 25 |
<% end %> |
| 21 | 26 | |
| 22 | 27 |
<% if @issue.safe_attribute?('category_id') && @issue.project.issue_categories.any? %>
|
| app/views/issues/_form.html.erb | ||
|---|---|---|
| 60 | 60 |
$("#issue_tracker_id, #issue_status_id").each(function(){
|
| 61 | 61 |
$(this).val($(this).find("option[selected=selected]").val());
|
| 62 | 62 |
}); |
| 63 |
$(".assign-to-me-link").click(function(event){
|
|
| 64 |
event.preventDefault(); |
|
| 65 |
var element = $(event.target); |
|
| 66 |
$('#issue_assigned_to_id').val(element.data('id'));
|
|
| 67 |
element.hide(); |
|
| 68 |
}); |
|
| 69 |
$('#issue_assigned_to_id').change(function(event){
|
|
| 70 |
var assign_to_me_link = $(".assign-to-me-link");
|
|
| 71 | ||
| 72 |
if (assign_to_me_link.length > 0) {
|
|
| 73 |
var user_id = $(event.target).val(); |
|
| 74 |
var current_user_id = assign_to_me_link.data('id');
|
|
| 75 | ||
| 76 |
if (user_id == current_user_id) {
|
|
| 77 |
assign_to_me_link.hide(); |
|
| 78 |
} else {
|
|
| 79 |
assign_to_me_link.show(); |
|
| 80 |
} |
|
| 81 |
} |
|
| 82 |
}); |
|
| 63 | 83 |
}); |
| 64 | 84 |
<% end %> |
| config/locales/en.yml | ||
|---|---|---|
| 1079 | 1079 |
label_display_type_list: List |
| 1080 | 1080 |
label_display_type_board: Board |
| 1081 | 1081 |
label_my_bookmarks: My bookmarks |
| 1082 |
label_assign_to_me: Assign to me |
|
| 1082 | 1083 | |
| 1083 | 1084 |
button_login: Login |
| 1084 | 1085 |
button_submit: Submit |
| public/stylesheets/application.css | ||
|---|---|---|
| 539 | 539 |
#trackers_description dt {font-weight: bold; text-decoration: underline;}
|
| 540 | 540 |
#trackers_description dd {margin: 0; padding: 0 0 1em 0;}
|
| 541 | 541 | |
| 542 |
#issue-form .assign-to-me-link { padding-left: 5px; }
|
|
| 543 | ||
| 542 | 544 |
fieldset.collapsible {border-width: 1px 0 0 0;}
|
| 543 | 545 |
fieldset.collapsible>legend { cursor:pointer; padding-left: 18px; background-position: 4px;}
|
| 544 | 546 | |
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 2105 | 2105 |
end |
| 2106 | 2106 |
end |
| 2107 | 2107 | |
| 2108 |
def test_update_form_should_render_assign_to_me_link_when_issue_can_be_assigned_to_the_current_user |
|
| 2109 |
@request.session[:user_id] = 1 |
|
| 2110 |
get :show, :params => {
|
|
| 2111 |
:id => 10 |
|
| 2112 |
} |
|
| 2113 | ||
| 2114 |
assert_select 'form#issue-form #attributes' do |
|
| 2115 |
assert_select 'a[class=?][data-id=?]', 'assign-to-me-link', '1', 1 |
|
| 2116 |
end |
|
| 2117 |
end |
|
| 2118 | ||
| 2119 |
def test_update_form_should_not_render_assign_to_me_link_when_issue_cannot_be_assigned_to_the_current_user |
|
| 2120 |
@request.session[:user_id] = 1 |
|
| 2121 |
get :show, :params => {
|
|
| 2122 |
:id => 2 |
|
| 2123 |
} |
|
| 2124 | ||
| 2125 |
assert_select 'form#issue-form #attributes' do |
|
| 2126 |
assert_select 'a[class=?]', 'assign-to-me-link', 0 |
|
| 2127 |
end |
|
| 2128 |
end |
|
| 2129 | ||
| 2130 |
def test_update_form_should_not_show_assign_to_me_link_when_issue_is_assigned_to_the_current_user |
|
| 2131 |
issue = Issue.find(10) |
|
| 2132 |
issue.assigned_to_id = 1 |
|
| 2133 |
issue.save! |
|
| 2134 | ||
| 2135 |
@request.session[:user_id] = 1 |
|
| 2136 |
get :show, :params => {
|
|
| 2137 |
:id => 10 |
|
| 2138 |
} |
|
| 2139 | ||
| 2140 |
assert_select 'form#issue-form #attributes' do |
|
| 2141 |
assert_select 'a[class=?]', 'assign-to-me-link hidden', 1 |
|
| 2142 |
end |
|
| 2143 |
end |
|
| 2144 | ||
| 2108 | 2145 |
def test_show_should_deny_anonymous_access_without_permission |
| 2109 | 2146 |
Role.anonymous.remove_permission!(:view_issues) |
| 2110 | 2147 |
get(:show, :params => {:id => 1})
|