view.ui.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. window.handleBatchBtnClick = function(target)
  2. {
  3. const $this = $(target).closest('a,.batch-btn');
  4. const dtable = zui.DTable.query($this);
  5. const checkedList = dtable.$.getChecks();
  6. if(!checkedList.length) return;
  7. const tabType = $this.data('type');
  8. const form = new FormData();
  9. checkedList.forEach((id) => form.append(`${tabType}IdList[]`, id));
  10. const url = $this.data('url')
  11. if($this.hasClass('ajax-btn'))
  12. {
  13. $.ajaxSubmit({
  14. url: url,
  15. data: form
  16. });
  17. }
  18. else
  19. {
  20. postAndLoadPage(url, form);
  21. }
  22. };
  23. window.showLink = function(type, params, onlyUpdateTable)
  24. {
  25. if(type == 'story') type = 'linkStory';
  26. const url = $.createLink(buildModule, type === 'linkStory' ? 'linkStory' : 'linkBug', 'buildID=' + buildID + (params || '&browseType=&param='));
  27. if(onlyUpdateTable)
  28. {
  29. loadComponent($('#' + type).find('.dtable').attr('id'), {url: url, component: 'dtable', partial: true});
  30. return;
  31. }
  32. loadTarget({url: url, target: type});
  33. };
  34. window.onSearchLinks = function(type, result)
  35. {
  36. const params = $.parseLink(result.load).vars[3];
  37. showLink(type, params ? atob(params[1]) : null, true);
  38. return false;
  39. };
  40. window.handleLinkObjectClick = function($this)
  41. {
  42. const type = $this.data('type');
  43. const dtable = zui.DTable.query($this);
  44. const checkedList = dtable.$.getChecks();
  45. if(!checkedList.length) return;
  46. const postKey = type == 'linkStory' ? 'stories' : 'bugs';
  47. const postData = new FormData();
  48. checkedList.forEach(function(id)
  49. {
  50. postData.append(postKey + '[]', id)
  51. if(type == 'bug')
  52. {
  53. const formData = dtable.$.getFormData();
  54. let resolvedBy = formData['resolvedByControl[' + id + ']'];
  55. if(typeof resolvedBy == 'undefined') resolvedBy = currentAccount;
  56. if(resolvedBy) postData.append('resolvedBy[' + id + ']', resolvedBy);
  57. }
  58. });
  59. $.ajaxSubmit({url: $this.data('url'), data: postData});
  60. };
  61. $(function()
  62. {
  63. if(initLink == 'true') window.showLink(type, linkParams);
  64. });
  65. window.renderStoryCell = function(result, info)
  66. {
  67. const story = info.row.data;
  68. if(info.col.name == 'title' && result)
  69. {
  70. let html = '';
  71. let gradeLabel = (showGrade || story.grade >= 2) ? grades[story.grade] : '';
  72. if(gradeLabel) html += "<span class='label gray-pale rounded-xl'>" + gradeLabel + "</span>";
  73. if(html) result.unshift({html});
  74. }
  75. return result;
  76. };