story.ui.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. $(document).off('click', '[data-formaction]').on('click', '[data-formaction]', function()
  2. {
  3. const $this = $(this);
  4. const dtable = zui.DTable.query($('#stories'));
  5. const checkedList = dtable.$.getChecks();
  6. if(!checkedList.length) return;
  7. const postData = new FormData();
  8. checkedList.forEach((id) => postData.append('storyIDList[]', id));
  9. if($this.data('account')) postData.append('assignedTo', $this.data('account'));
  10. if($this.data('page') == 'batch')
  11. {
  12. postAndLoadPage($this.data('formaction'), postData);
  13. }
  14. else
  15. {
  16. $.ajaxSubmit({"url": $this.data('formaction'), "data": postData});
  17. }
  18. });
  19. window.renderCell = function(result, info)
  20. {
  21. if(info.col.name == 'title' && result)
  22. {
  23. const story = info.row.data;
  24. let html = '';
  25. let gradeLabel = '';
  26. if(showGrade || story.grade >= 2) gradeLabel = gradeGroup[story.type][story.grade]?.name;
  27. if(gradeLabel) html += "<span class='label gray-pale rounded-xl clip'>" + gradeLabel + "</span> ";
  28. if(story.color) result[0].props.style = 'color: ' + story.color;
  29. if(html) result.unshift({html});
  30. }
  31. return result;
  32. };
  33. $(document).off('click', '.switchButton').on('click', '.switchButton', function()
  34. {
  35. const storyViewType = $(this).attr('data-type');
  36. $.cookie.set('storyViewType', storyViewType, {expires:config.cookieLife, path:config.webRoot});
  37. loadCurrentPage();
  38. });
  39. window.setShowGrades = function()
  40. {
  41. const showGrades = $('[name^=showGrades]').zui('picker').$.state.value;
  42. if(oldShowGrades == showGrades) return;
  43. const link = $.createLink('product', 'ajaxSetShowGrades', 'module=assetlib&showGrades=' + showGrades);
  44. $.get(link, function()
  45. {
  46. loadCurrentPage();
  47. });
  48. }