Feature #31322 » issue-31322.ver.4.diff
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
ids.size
|
||
|
end
|
||
|
def add_confirm_dialog_to_issue_submit_button_js_string
|
||
|
confirm_message = l(:text_close_parent_issue_whose_subtasks_are_open_confirmation)
|
||
|
closed_issue_status_ids = @allowed_statuses.select{|i| i.is_closed?}.pluck(:id).map(&:to_s)
|
||
|
"addConfirmDialogToIssueSubmitButton(#{closed_issue_status_ids.to_json}, '#{confirm_message}')".html_safe
|
||
|
end
|
||
|
def issues_destroy_confirmation_message(issues)
|
||
|
issues = [issues] unless issues.is_a?(Array)
|
||
|
message = l(:text_issues_destroy_confirmation)
|
||
| app/views/issues/_action_menu.html.erb | ||
|---|---|---|
|
<div class="contextual">
|
||
|
<% onclick_functions = 'showAndScrollTo("update", "issue_notes");'
|
||
|
onclick_functions << "#{add_confirm_dialog_to_issue_submit_button_js_string};"
|
||
|
onclick_functions << "return false;" %>
|
||
|
<%= link_to l(:button_edit), edit_issue_path(@issue),
|
||
|
:onclick => 'showAndScrollTo("update", "issue_notes"); return false;',
|
||
|
:onclick => onclick_functions,
|
||
|
:class => 'icon icon-edit', :accesskey => accesskey(:edit) if @issue.editable? %>
|
||
|
<%= link_to l(:button_log_time), new_issue_time_entry_path(@issue),
|
||
|
:class => 'icon icon-time-add' if User.current.allowed_to?(:log_time, @project) %>
|
||
| app/views/issues/_attributes.html.erb | ||
|---|---|---|
|
<div class="splitcontent">
|
||
|
<div class="splitcontentleft">
|
||
|
<% if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
|
||
|
<% onchange_functions = "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this);"
|
||
|
onchange_functions << "#{add_confirm_dialog_to_issue_submit_button_js_string};" %>
|
||
|
<p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), {:required => true},
|
||
|
:onchange => "updateIssueFrom('#{escape_javascript(update_issue_form_path(@project, @issue))}', this)" %></p>
|
||
|
:onchange => onchange_functions %></p>
|
||
|
<%= hidden_field_tag 'was_default_status', @issue.status_id, :id => nil if @issue.status == @issue.default_status %>
|
||
|
<% else %>
|
||
|
<p><label><%= l(:field_status) %></label> <%= @issue.status %></p>
|
||
| app/views/issues/_edit.html.erb | ||
|---|---|---|
|
<%= f.hidden_field :lock_version %>
|
||
|
<%= hidden_field_tag 'last_journal_id', params[:last_journal_id] || @issue.last_journal_id %>
|
||
|
<%= submit_tag l(:button_submit) %>
|
||
|
<%= submit_tag l(:button_submit), :id => "issue_submit_button" %>
|
||
|
<%= link_to l(:button_cancel), issue_path(id: @issue.id), :onclick => params[:action] == 'show' ? "$('#update').hide(); return false;" : '' %>
|
||
|
<%= hidden_field_tag 'prev_issue_id', @prev_issue_id if @prev_issue_id %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
text_time_logged_by_changeset: "Applied in changeset %{value}."
|
||
|
text_issues_destroy_confirmation: 'Are you sure you want to delete the selected issue(s)?'
|
||
|
text_issues_destroy_descendants_confirmation: "This will also delete %{count} subtask(s)."
|
||
|
text_close_parent_issue_whose_subtasks_are_open_confirmation: Are you sure you want to close parent issue whose subtasks are open?
|
||
|
text_time_entries_destroy_confirmation: 'Are you sure you want to delete the selected time entr(y/ies)?'
|
||
|
text_select_project_modules: 'Select modules to enable for this project:'
|
||
|
text_default_administrator_account_changed: Default administrator account changed
|
||
| public/javascripts/application.js | ||
|---|---|---|
|
return key;
|
||
|
}
|
||
|
function addConfirmDialogToIssueSubmitButton(closedIssueStatusIds, confirmMessage) {
|
||
|
var children = $("#issue_tree").find("tr.issue.child");
|
||
|
if (($.inArray($("#issue_status_id").val(), closedIssueStatusIds) > -1) &&
|
||
|
(children.length > 0) &&
|
||
|
((children.length - $("#issue_tree").find("tr.issue.child.closed").length) > 0)) {
|
||
|
$("#issue_submit_button").attr({
|
||
|
"data-confirm": confirmMessage
|
||
|
});
|
||
|
} else {
|
||
|
$("#issue_submit_button").removeAttr("data-confirm");
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
function updateIssueFrom(url, el) {
|
||
|
$('#all_attributes input, #all_attributes textarea, #all_attributes select').each(function(){
|
||
|
$(this).data('valuebeforeupdate', $(this).val());
|
||
| test/system/issues_test.rb | ||
|---|---|---|
|
assert_equal 5, issue.reload.status.id
|
||
|
end
|
||
|
test "add confirm dialog to issue submit button" do
|
||
|
parent = Issue.generate!
|
||
|
child = Issue.generate!(:parent_issue_id => parent.id)
|
||
|
with_settings :close_parent_issue_whose_subtasks_are_open => 1 do
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
visit "/issues/#{parent.id}"
|
||
|
page.first(:link, 'Edit').click
|
||
|
assert page.has_select?("issue_status_id", {:selected => "New"})
|
||
|
page.find("#issue_status_id").select("Closed")
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
page.accept_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
end
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, parent.reload.status.id
|
||
|
page.first(:link, 'Edit').click
|
||
|
assert page.has_select?("issue_status_id", {:selected => "Closed"})
|
||
|
fill_in 'Subject', :with => 'test of confirm dialog'
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
page.accept_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
end
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, parent.reload.status.id
|
||
|
assert_equal 'test of confirm dialog', parent.reload.subject
|
||
|
page.first(:link, 'Edit').click
|
||
|
assert page.has_select?("issue_status_id", {:selected => "Closed"})
|
||
|
page.find("#issue_status_id").select("New")
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
page.first(:button, 'Submit').click
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 1, parent.reload.status.id
|
||
|
visit "/issues/#{child.id}"
|
||
|
page.first(:link, 'Edit').click
|
||
|
assert page.has_select?("issue_status_id", {:selected => "New"})
|
||
|
page.find("#issue_status_id").select("Closed")
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
page.first(:button, 'Submit').click
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, child.reload.status.id
|
||
|
visit "/issues/#{parent.id}"
|
||
|
page.first(:link, 'Edit').click
|
||
|
assert page.has_select?("issue_status_id", {:selected => "New"})
|
||
|
page.find("#issue_status_id").select("Closed")
|
||
|
assert_no_difference 'Issue.count' do
|
||
|
page.first(:button, 'Submit').click
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, parent.reload.status.id
|
||
|
end
|
||
|
end
|
||
|
test "removing issue shows confirm dialog" do
|
||
|
log_user('jsmith', 'jsmith')
|
||
|
visit '/issues/1'
|
||