manageview.ui.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /**
  2. * Toggle program.
  3. *
  4. * @access public
  5. * @return void
  6. */
  7. function toggleProgram()
  8. {
  9. $('#programBox').toggleClass('hidden', !$('#program').prop('checked'));
  10. }
  11. /**
  12. * Toggle product.
  13. *
  14. * @access public
  15. * @return void
  16. */
  17. function toggleProduct()
  18. {
  19. $('#productBox').toggleClass('hidden', !$('#product').prop('checked'));
  20. }
  21. /**
  22. * Toggle project.
  23. *
  24. * @access public
  25. * @return void
  26. */
  27. function toggleProject()
  28. {
  29. $('#projectBox').toggleClass('hidden', !$('#project').prop('checked'));
  30. }
  31. /**
  32. * Toggle execution.
  33. *
  34. * @access public
  35. * @return void
  36. */
  37. function toggleExecution()
  38. {
  39. $('#executionBox').toggleClass('hidden', !$('#execution').prop('checked'));
  40. }
  41. /**
  42. * Select all.
  43. *
  44. * @param obj $obj
  45. * @access public
  46. * @return void
  47. */
  48. function selectAll(e)
  49. {
  50. $(e.target).closest('.check-list-inline').find('input[type=checkbox]').prop('checked', $(e.target).prop('checked'));
  51. $('div.group-item input[name^=actions]').each(function()
  52. {
  53. $(this).trigger('change');
  54. });
  55. }
  56. /**
  57. * Select items.
  58. *
  59. * @param obj $obj
  60. * @access public
  61. * @return void
  62. */
  63. function selectItems(e)
  64. {
  65. $(e.target).closest("div[id$='ActionBox']").find('.check-list-inline input[type=checkbox]').prop('checked', $(e.target).prop('checked'));
  66. $('div.group-item input[name^=actions]').each(function()
  67. {
  68. $(this).trigger('change');
  69. });
  70. }
  71. $(function()
  72. {
  73. $('div.group-item input[name^=actions]').each(function()
  74. {
  75. $(this).trigger('change');
  76. });
  77. $(document).on('click', '.action-item input[type=checkbox]', function()
  78. {
  79. let allChecked = true;
  80. const checkedCount = $(this).closest('.check-list-inline').find('input[name^=actions]:checked').length;
  81. const totalCount = $(this).closest('.check-list-inline').find('input[name^=actions]').length;
  82. if(checkedCount < totalCount) allChecked = false;
  83. $(this).closest("div[id$='ActionBox']").find('input[name^="allchecker"]').prop('checked', allChecked);
  84. })
  85. });
  86. /**
  87. * Toggle program.
  88. *
  89. * @access public
  90. * @return void
  91. */
  92. function toggleBox(e)
  93. {
  94. let allChecked = true;
  95. const $obj = $(e.target);
  96. const checkedCount = $obj.closest('.form-group').find('input[name^=actions]:checked').length;
  97. const totalCount = $obj.closest('.form-group').find('input[name^=actions]').length;
  98. if(checkedCount < totalCount) allChecked = false;
  99. $('.group-item input[name^="actionallchecker"]').prop('checked', allChecked);
  100. let id = $obj.attr('id');
  101. if(id == 'program') toggleProgram();
  102. if(id == 'product') toggleProduct();
  103. if(id == 'project') toggleProject();
  104. if(id == 'execution') toggleExecution();
  105. if($('#' + id + 'ActionBox').length == 1) $('#' + id + 'ActionBox').toggle($obj.prop('checked'));
  106. $("div[id$='ActionBox']").each(function()
  107. {
  108. let allChecked = true;
  109. const checkedCount = $(this).find('input[name^=actions]:checked').length;
  110. const totalCount = $(this).find('input[name^=actions]').length;
  111. if(checkedCount < totalCount) allChecked = false;
  112. $(this).find('input[name^="actionallchecker"]').prop('checked', allChecked);
  113. });
  114. }