Keine Beschreibung

manage.cases.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*************************
  2. * Case creation section
  3. *************************/
  4. /* create the select picker for customer */
  5. $('#case_customer').selectpicker({
  6. liveSearch: true,
  7. title: "Select customer *",
  8. style: "btn-outline-white",
  9. size: 8
  10. });
  11. $('#case_template_id').selectpicker({
  12. liveSearch: true,
  13. title: "Select case template",
  14. style: "btn-outline-white",
  15. size: 8
  16. });
  17. $('#case_template_id').prepend(new Option('', ''));
  18. $('#classification_id').selectpicker({
  19. liveSearch: true,
  20. title: "Select classification",
  21. style: "btn-outline-white",
  22. size: 8
  23. });
  24. $('#classification_id').prepend(new Option('', ''));
  25. /*************************
  26. * Case list section
  27. *************************/
  28. /* case table creation */
  29. $.each($.find("table"), function(index, element){
  30. addFilterFields($(element).attr("id"));
  31. });
  32. $('#cases_table').dataTable({
  33. "ajax": {
  34. "url": `/manage/cases/list${case_param()}`,
  35. "contentType": "application/json",
  36. "type": "GET",
  37. "data": function (d) {
  38. if (d.status == 'success') {
  39. return JSON.stringify(d.data);
  40. } else {
  41. return [];
  42. }
  43. }
  44. },
  45. "columns": [
  46. {
  47. "render": function (data, type, row) {
  48. let a_anchor = $('<a>');
  49. a_anchor.attr('href', 'javascript:void(0);');
  50. a_anchor.attr('onclick', 'case_detail(\'' + row['case_id'] + '\');');
  51. a_anchor.text(data);
  52. return a_anchor[0].outerHTML;
  53. },
  54. "data": "case_name"
  55. },
  56. {
  57. "data": "case_description",
  58. "render": function (data, type, row) {
  59. if (type === 'display' && data != null) {
  60. return ret_obj_dt_description(data);
  61. }
  62. return data;
  63. },
  64. },
  65. {
  66. "data": "client_name",
  67. "render": function (data, type, row, meta) {
  68. if (type === 'display') { data = sanitizeHTML(data);}
  69. return data;
  70. }
  71. },
  72. {
  73. "data": "state_name",
  74. "render": function (data, type, row, meta) {
  75. if (type === 'display') { data = sanitizeHTML(data);}
  76. return data;
  77. }
  78. },
  79. {
  80. "data": "case_open_date",
  81. "render": function (data, type, row, meta) {
  82. if (type === 'display') { data = sanitizeHTML(data);}
  83. return data;
  84. },
  85. "type": "date"
  86. },
  87. {
  88. "data": "case_close_date",
  89. "type": "date",
  90. "render": function (data, type, row, meta) {
  91. if (type === 'display') { data = sanitizeHTML(data);}
  92. return data;
  93. }
  94. },
  95. {
  96. "data": "case_soc_id",
  97. "render": function (data, type, row, meta) {
  98. if (type === 'display') {
  99. let span_anchor = $('<span>');
  100. span_anchor.text(data);
  101. return span_anchor.html();
  102. }
  103. return data;
  104. }
  105. },
  106. {
  107. "data": "opened_by",
  108. "render": function (data, type, row, meta) {
  109. if (type === 'display') { data = sanitizeHTML(data);}
  110. return data;
  111. }
  112. }
  113. ],
  114. dom: '<"container-fluid"<"row"<"col"l><"col"f>>>rt<"container-fluid"<"row"<"col"i><"col"p>>>',
  115. filter: true,
  116. info: true,
  117. ordering: true,
  118. processing: true,
  119. retrieve: true,
  120. lengthChange: true,
  121. pageLength: 25,
  122. select: true,
  123. sort: true,
  124. orderCellsTop: true,
  125. responsive: {
  126. details: {
  127. display: $.fn.dataTable.Responsive.display.childRow,
  128. renderer: $.fn.dataTable.Responsive.renderer.tableAll()
  129. }
  130. },
  131. initComplete: function () {
  132. tableFiltering(this.api(), 'cases_table');
  133. }
  134. }
  135. );
  136. $(document).ready(function() {
  137. if ($('.nav-tabs').length > 0) { // if .nav-tabs exists
  138. var hashtag = window.location.hash;
  139. if (hashtag!='') {
  140. $('.nav-item > a').removeClass('active').removeClass('show');
  141. $('.nav-item > a[href="'+hashtag+'"]').addClass('active');
  142. $('.nav-item > a[href="'+hashtag+'"]').addClass('show');
  143. $('.tab-content > div').removeClass('active');
  144. $(hashtag).addClass('active'); $(hashtag).addClass('show');
  145. }
  146. }
  147. });