importstory.ui.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. postData.append('lib', libID);
  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(html) result.unshift({html});
  29. }
  30. return result;
  31. };
  32. $(document).off('click', '.switchButton').on('click', '.switchButton', function()
  33. {
  34. const storyViewType = $(this).attr('data-type');
  35. $.cookie.set('storyViewType', storyViewType, {expires:config.cookieLife, path:config.webRoot});
  36. loadCurrentPage();
  37. });
  38. window.changeProject = function(e)
  39. {
  40. const projectID = e.target.value;
  41. const link = $.createLink('assetlib', 'importstory', `libID=${libID}&projectID=${projectID}`);
  42. loadPage(link);
  43. }
  44. window.changeProduct = function(e)
  45. {
  46. const projectID = $('[name="fromProject"]').val();
  47. const productID = e.target.value;
  48. const link = $.createLink('assetlib', 'importstory', `libID=${libID}&projectID=${projectID}&productID=${productID}`);
  49. loadPage(link);
  50. }