showimport.ui.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. window.renderRowCol = function($result, col, row)
  2. {
  3. if(col.name == 'module')
  4. {
  5. $result.find('.picker-box').on('inited', function(e, info)
  6. {
  7. const $modulePicker = info[0];
  8. $modulePicker.render({items: modules[row.branch == undefined || row.branch == '' ? 0 : row.branch]});
  9. $modulePicker.$.setValue(row.module);
  10. });
  11. }
  12. if(col.name == 'story')
  13. {
  14. $result.find('.picker-box').on('inited', function(e, info)
  15. {
  16. const storyLink = $.createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + row.branch + '&moduleID=' + row.module + '&storyID=' + row.story + '&onlyOption=false&status=active&limit=0&type=&hasParent=0');
  17. $.getJSON(storyLink, function(stories)
  18. {
  19. let $story = info[0];
  20. $story.render({items: stories});
  21. $story.$.setValue(row.story);
  22. });
  23. });
  24. }
  25. if(col.name == 'scene')
  26. {
  27. $result.find('.picker-box').on('inited', function(e, info)
  28. {
  29. const sceneLink = $.createLink('testcase', 'ajaxGetProductScenes', 'productID=' + productID + '&moduleID=' + row.module + '&branch=' + (row.branch ? row.branch : 'all'));
  30. $.getJSON(sceneLink, function(scenes)
  31. {
  32. let $scene = info[0];
  33. $scene.render({items: scenes});
  34. $scene.$.setValue(row.scene);
  35. });
  36. });
  37. }
  38. }
  39. function computeImportTimes()
  40. {
  41. if(parseInt($(this).val()))
  42. {
  43. $('#times').html(Math.ceil(parseInt($("#totalAmount").html()) / parseInt($(this).val())));
  44. }
  45. }
  46. function importNextPage()
  47. {
  48. $.cookie.set('maxImport', $('#maxImport').val(), {expires:config.cookieLife, path:config.webRoot});
  49. link = $.createLink('testcase', 'showImport', "productID=" + productID + "&branch=" + branch + "&pageID=1&maxImport=" + $('#maxImport').val());
  50. loadPage(link);
  51. }
  52. function changeModule(event)
  53. {
  54. const $target = $(event.target);
  55. const moduleID = $target.val();
  56. const $currentRow = $target.closest('tr');
  57. const $storyPicker = $currentRow.find('.form-batch-control[data-name="story"] .picker').zui('picker');
  58. const oldStory = $currentRow.find('input[name^=story]').val();
  59. const storyLink = $.createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=active&limit=0&type=&hasParent=0');
  60. $.getJSON(storyLink, function(stories)
  61. {
  62. $storyPicker.render({items: stories});
  63. $storyPicker.$.setValue(oldStory);
  64. });
  65. const $scenePicker = $currentRow.find('.form-batch-control[data-name="scene"] .picker').zui('picker');
  66. const oldScene = $currentRow.find('input[name^=scene]').val();
  67. const sceneLink = $.createLink('testcase', 'ajaxGetProductScenes', 'productID=' + productID + '&moduleID=' + moduleID + '&branch=' + branch);
  68. $.getJSON(sceneLink, function(scenes)
  69. {
  70. $scenePicker.render({items: scenes});
  71. $scenePicker.$.setValue(oldScene);
  72. });
  73. }
  74. function changeBranch(event)
  75. {
  76. const $target = $(event.target);
  77. const branchID = $target.val();
  78. const $modulePicker = $target.closest('tr').find('.form-batch-control[data-name="module"] .picker').zui('picker');
  79. const oldModule = $modulePicker.$.value;
  80. $modulePicker.render({items: modules[branchID]});
  81. $modulePicker.$.setValue(oldModule);
  82. }