setapproval.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. $(function()
  2. {
  3. $('input[name=approval]').change(function()
  4. {
  5. var approval = $(this).val();
  6. $('.approval-select').toggle(approval == 'enabled');
  7. $('.submit-box').toggle(approval != 'enabled' || window.approvalCount != 0);
  8. })
  9. $('input[name=approval][checked=checked]').change();
  10. $('#approvalFlow').change(function()
  11. {
  12. const flowID = $(this).val();
  13. if(flowID > 0)
  14. {
  15. const url = createLink('approvalflow', 'design', 'flowID=' + flowID);
  16. $('.designBtn').attr('href', url);
  17. }
  18. });
  19. $.setAjaxForm('#setForm', function(response)
  20. {
  21. if(response.result == 'fail')
  22. {
  23. if(response.coverMessage)
  24. {
  25. $('#coverContent').html(response.coverMessage);
  26. $('#coverModal').modal();
  27. $('#coverButton').click(function()
  28. {
  29. $('#setForm').append("<input value='1' name='cover' class='hide'>");
  30. $('#setForm #submit').click();
  31. })
  32. }
  33. else
  34. {
  35. setTimeout(function(){location.reload();}, 1200);
  36. }
  37. }
  38. else
  39. {
  40. if(response.locate == 'reload')
  41. {
  42. setTimeout(function(){location.reload();}, 1200);
  43. }
  44. else
  45. {
  46. setTimeout(function(){location.href = response.locate;}, 1200);
  47. }
  48. }
  49. $('input[name=cover]').remove();
  50. });
  51. })
  52. window.enableApproval = function(workflow, flowID)
  53. {
  54. const approval = 'enabled';
  55. const approvalFlow = flowID;
  56. const url = createLink('workflow', 'setapproval', `workflow=${workflow}`);
  57. $.post(url, {approval, approvalFlow}, function(response)
  58. {
  59. location.reload();
  60. })
  61. }