Feature #31322 » 20191218-02-ajax-modal-form.diff
| app/controllers/issues_controller.rb | ||
|---|---|---|
|
return
|
||
|
end
|
||
|
render(
|
||
|
:partial => 'close_confirm',
|
||
|
:layout => false,
|
||
|
:locals => {}
|
||
|
)
|
||
|
return
|
||
|
end
|
||
| app/views/issues/_close_confirm.js.erb | ||
|---|---|---|
|
$('#ajax-modal').html(
|
||
|
'<%= escape_javascript(
|
||
|
render(
|
||
|
:partial => 'close_confirm_dialog',
|
||
|
:locals => {}
|
||
|
)
|
||
|
)
|
||
|
%>'
|
||
|
);
|
||
|
showModal('ajax-modal', '400px');
|
||
| app/views/issues/_close_confirm_dialog.html.erb | ||
|---|---|---|
|
<h3 class="title"> </h3>
|
||
|
<p>
|
||
|
<%= l(:text_close_parent_issue_whose_subtasks_are_open_confirmation) %>
|
||
|
</p>
|
||
|
<p class="buttons">
|
||
|
<%= button_tag l(:button_apply), :type => "button", :onclick => "run_submit();" %>
|
||
|
<%= link_to_function l(:button_cancel), "hideModal(this);" %>
|
||
|
</p>
|
||
|
<%= javascript_tag do %>
|
||
|
function run_submit() {
|
||
|
$("#issue-form").off('submit');
|
||
|
$("#issue-form").submit();
|
||
|
}
|
||
|
<% end %>
|
||
| app/views/issues/_edit.html.erb | ||
|---|---|---|
|
<%= javascript_tag do %>
|
||
|
$('#issue-form').submit(function(){
|
||
|
var status_id = 0;
|
||
|
var result = false;
|
||
|
if ($("#issue_status_id").length > 0) {
|
||
|
status_id = $("#issue_status_id").val();
|
||
|
}
|
||
|
$.ajax({
|
||
|
url: $("#issue-form").attr('action'),
|
||
|
type: 'patch',
|
||
|
async: false,
|
||
|
data: {
|
||
|
"check_go_to_close_confirm": "",
|
||
|
"status_id": status_id
|
||
| ... | ... | |
|
})
|
||
|
.then(
|
||
|
function(data){
|
||
|
result = data["result"];
|
||
|
if (data["result"]) {
|
||
|
$.ajax({
|
||
|
url: $("#issue-form").attr('action'),
|
||
|
type: 'patch',
|
||
|
data: {}
|
||
|
});
|
||
|
} else {
|
||
|
$("#issue-form").off('submit');
|
||
|
$("#issue-form").submit();
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
if (result) {
|
||
|
if (!confirm(
|
||
|
"<%= l(:text_close_parent_issue_whose_subtasks_are_open_confirmation) %>"
|
||
|
)){
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
$("#issue-form").off('submit');
|
||
|
$("#issue-form").submit();
|
||
|
return false;
|
||
|
});
|
||
|
<% end %>
|
||
| test/system/issues_test.rb | ||
|---|---|---|
|
page.find("#issue_status_id").select("Closed")
|
||
|
assert_no_difference ['Issue.count', 'child.journals.count'] do
|
||
|
assert_no_difference 'parent.journals.count' do
|
||
|
page.dismiss_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
page.first(:button, 'Submit').click
|
||
|
within('#ajax-modal') do
|
||
|
assert page.has_text?(/Are you sure/)
|
||
|
page.first(:link, 'Cancel').click
|
||
|
end
|
||
|
assert_equal 1, parent.reload.status.id
|
||
|
end
|
||
|
assert_difference 'parent.journals.count' do
|
||
|
page.accept_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
page.first(:button, 'Submit').click
|
||
|
within('#ajax-modal') do
|
||
|
assert page.has_text?(/Are you sure/)
|
||
|
page.first(:button, 'Apply').click
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, parent.reload.status.id
|
||
| ... | ... | |
|
fill_in 'Subject', :with => 'test of confirm dialog'
|
||
|
assert_no_difference ['Issue.count', 'child.journals.count'] do
|
||
|
assert_no_difference 'parent.journals.count' do
|
||
|
page.dismiss_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
page.first(:button, 'Submit').click
|
||
|
within('#ajax-modal') do
|
||
|
assert page.has_text?(/Are you sure/)
|
||
|
page.first(:link, 'Cancel').click
|
||
|
end
|
||
|
assert_equal 5, parent.reload.status.id
|
||
|
end
|
||
|
assert_difference 'parent.journals.count' do
|
||
|
page.accept_confirm /Are you sure/ do
|
||
|
page.first(:button, 'Submit').click
|
||
|
page.first(:button, 'Submit').click
|
||
|
within('#ajax-modal') do
|
||
|
assert page.has_text?(/Are you sure/)
|
||
|
page.first(:button, 'Apply').click
|
||
|
end
|
||
|
assert page.has_css?('#flash_notice')
|
||
|
assert_equal 5, parent.reload.status.id
|
||