batchclose.ui.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. window.renderRowData = function($row, index, story)
  2. {
  3. let $title = $row.find('.form-batch-input[data-name="title"]');
  4. if(story.twins)
  5. {
  6. $title.wrap("<div class='input-group'></div>");
  7. $title.after("<span class='input-group-addon'>" + langTwins + "<span class='text-secondary'>" + twinsCount[story.id] + "</span></span>");
  8. }
  9. if(story.status == 'draft')
  10. {
  11. $row.find('[data-name="closedReasonBox"]').find('.closedReason-select').on('inited', function(e, info)
  12. {
  13. let $closedReason = info[0];
  14. $closedReason.render({items: reasonList});
  15. });
  16. }
  17. $row.find('[data-name="closedReasonBox"]').find('.duplicate-select').on('inited', function(e, info)
  18. {
  19. let $duplicateStory = info[0];
  20. let link = $.createLink('story', 'ajaxGetDuplicatedStory', 'storyID=' + story.id);
  21. $.getJSON(link, function(duplicateStoryList)
  22. {
  23. if(duplicateStoryList)
  24. {
  25. $duplicateStory.render({items: duplicateStoryList});
  26. }
  27. })
  28. });
  29. };
  30. window.toggleDuplicateBox = function(e)
  31. {
  32. const $target = $(e.target);
  33. const $currentRow = $target.closest('tr');
  34. $currentRow.find('[data-name="duplicateStory"]').toggleClass('hidden', $target.val() != 'duplicate');
  35. };
  36. window.getDuplicateStories = function(obj)
  37. {
  38. var $this = $(obj);
  39. var options = $this.find('option').length;
  40. if(options <= 1)
  41. {
  42. var storyID = $this.data('id');
  43. var link = $.createLink('story', 'ajaxGetDuplicatedStory', 'storyID=' + storyID);
  44. $this.closest('.duplicateStoryBox').load(link, function()
  45. {
  46. $(this).find('select').addClass('form-batch-input').attr('data-name', 'duplicateStory');
  47. });
  48. }
  49. };