Feature #31322 » issue-31322-ver.3.diff
app/helpers/issues_helper.rb | ||
---|---|---|
315 | 315 |
ids.size |
316 | 316 |
end |
317 | 317 | |
318 |
def add_confirm_dialog_to_issue_submit_button_js_string |
|
319 |
# TODO: use i18n |
|
320 |
confirm_message = "POC" |
|
321 |
closed_issue_status_ids = @allowed_statuses.select{|i| i.is_closed?}.pluck(:id).map(&:to_s) |
|
322 |
"add_confirm_dialog_to_issue_submit_button(#{closed_issue_status_ids.to_json}, '#{confirm_message}')".html_safe |
|
323 |
end |
|
324 | ||
318 | 325 |
def issues_destroy_confirmation_message(issues) |
319 | 326 |
issues = [issues] unless issues.is_a?(Array) |
320 | 327 |
message = l(:text_issues_destroy_confirmation) |
app/views/issues/_action_menu.html.erb | ||
---|---|---|
1 | 1 |
<div class="contextual"> |
2 |
<% onclick_functions = 'showAndScrollTo("update", "issue_notes");' |
|
3 |
onclick_functions << "#{add_confirm_dialog_to_issue_submit_button_js_string};" |
|
4 |
onclick_functions << "return false;" %> |
|
2 | 5 |
<%= link_to l(:button_edit), edit_issue_path(@issue), |
3 |
:onclick => 'showAndScrollTo("update", "issue_notes"); return false;',
|
|
6 |
:onclick => onclick_functions,
|
|
4 | 7 |
:class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %> |
5 | 8 |
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue), |
6 | 9 |
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %> |
app/views/issues/_attributes.html.erb | ||
---|---|---|
3 | 3 |
<div class="splitcontent"> |
4 | 4 |
<div class="splitcontentleft"> |
5 | 5 |
<% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %> |
6 |
<% onchange_functions = "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this);" |
|
7 |
onchange_functions << "#{add_confirm_dialog_to_issue_submit_button_js_string};" %> |
|
6 | 8 |
<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true}, |
7 |
:onchange => "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this)" %></p>
|
|
9 |
:onchange => onchange_functions %></p>
|
|
8 | 10 |
<%= hidden_field_tag 'was_default_status', @issue.status_id, :id => nil if @issue.status == @issue.default_status %> |
9 | 11 |
<% else %> |
10 | 12 |
<p><label><%= l(:field_status) %></label> <%= @issue.status %></p> |
app/views/issues/_edit.html.erb | ||
---|---|---|
72 | 72 | |
73 | 73 |
<%= f.hidden_field :lock_version %> |
74 | 74 |
<%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %> |
75 |
<%= submit_tag l(:button_submit) %> |
|
75 |
<%= submit_tag l(:button_submit), :id => "issue_submit_button" %>
|
|
76 | 76 |
<%= link_to l(:button_cancel), issue_path(id: @issue.id), :onclick => params[:action] == 'show' ? "$('#update').hide(); return false;" : '' %> |
77 | 77 | |
78 | 78 |
<%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %> |
public/javascripts/application.js | ||
---|---|---|
570 | 570 |
return key; |
571 | 571 |
} |
572 | 572 | |
573 |
function add_confirm_dialog_to_issue_submit_button(closed_issue_status_ids, confirm_message) { |
|
574 |
var children = $("#issue_tree").find("tr.issue.child"); |
|
575 |
if (($.inArray($("#issue_status_id").val(), closed_issue_status_ids) > -1) && |
|
576 |
(children.length > 0) && |
|
577 |
((children.length - $("#issue_tree").find("tr.issue.child.closed").length) > 0)) { |
|
578 |
$("#issue_submit_button").attr({ |
|
579 |
"data-confirm": confirm_message |
|
580 |
}); |
|
581 |
} else { |
|
582 |
$("#issue_submit_button").removeAttr("data-confirm"); |
|
583 |
} |
|
584 |
return true; |
|
585 |
} |
|
586 | ||
573 | 587 |
function updateIssueFrom(url, el) { |
574 | 588 |
$('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){ |
575 | 589 |
$(this).data('valuebeforeupdate', $(this).val()); |