Fix 2.4.2 upgrade notes formatting refs #19330
[arvados.git] / apps / workbench / app / views / application / report_issue_popup.js.erb
index 799a8812a06a9f0797dc382d085199612c644e75..bd11f9e1dc703a192bd6c8e766d21d5e7fbe83d8 100644 (file)
@@ -1,48 +1,16 @@
+<%# Copyright (C) The Arvados Authors. All rights reserved.
+
+SPDX-License-Identifier: AGPL-3.0 %>
+
 $("#report-issue-modal-window").html("<%= escape_javascript(render partial: 'report_issue_popup') %>");
+$("#report-issue-modal-window .modal").modal('show');
 
-// reset form input fields, for the next time around
-function reset_form() {
-  $('#report_issue_text').val("");
-  $('#additional_info').val("");
-}
+// Disable the submit button on modal loading
+$submit = $('#report-issue-submit');
+$submit.prop('disabled', true);
 
-// ajax handling for report-issue function
-$(document).
-  on('ajax:send', function() {
-    var sendButton = document.getElementById('report-issue-submit');
-    if (sendButton) {
-      var text = document.getElementById('report-issue-submit').firstChild;
-      text.data = "Sending...";
-      sendButton.disabled = true;
-    }
-    var cancelButton = document.getElementById('report-issue-cancel');
-    if (cancelButton) {
-      var text = document.getElementById('report-issue-cancel').firstChild;
-      text.data = "Close";
-    }
-    $('div').remove('.modal-footer-status');
-  }).
-  on('ajax:success', function() {
-    var sendButton = document.getElementById('report-issue-submit');
-    if (sendButton && sendButton.disabled) {
-      var text = document.getElementById('report-issue-submit').firstChild;
-      text.data = "Report sent";
-      $('div').remove('.modal-footer-status');
-      $('.modal-footer').append('<div class="modal-footer-status pull-left alert alert-success"><div><p>Thanks for reporting this issue!</p></div></div>');
-    }
-  }).
-  on('ajax:failure', function() {
-    var sendButton = document.getElementById('report-issue-submit');
-    if (sendButton && sendButton.disabled) {
-      $('div').remove('.modal-footer-status');
-      $('.modal-footer').append('<div class="modal-footer-status pull-left alert alert-danger"></br><p>We are sorry. We could not submit your report! We really want this to work, though -- please try again.</p></div>');
-      var text = document.getElementById('report-issue-submit').firstChild;
-      text.data = "Report issue";
-      sendButton.disabled = false;
-    }
-    var cancelButton = document.getElementById('report-issue-cancel');
-    if (cancelButton) {
-      var text = document.getElementById('report-issue-cancel').firstChild;
-      text.data = "Cancel";
-    }
-  });
+// capture events to enable submit button when applicable
+$('#report_issue_text').bind('input propertychange', function() {
+  var problem_desc = document.forms["report-issue-form"]["report_issue_text"].value;
+  $submit.prop('disabled', (problem_desc === null) || (problem_desc === ""));
+});