batchrun.ui.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. function toggleAction()
  2. {
  3. const result = $(this).val();
  4. const stepsOrReals = $(this).parents('tr').find('table .steps, table .reals');
  5. if(result == 'pass')
  6. {
  7. stepsOrReals.addClass('hidden');
  8. stepsOrReals.find('select[id^=steps]').val(result);
  9. if(stepsOrReals.parent().prop('tagName') == 'TR')
  10. {
  11. stepsOrReals.closest('tbody').children('tr').each(function()
  12. {
  13. var $td = $(this).children('td').first();
  14. if($td.attr('colspan') != undefined) $td.attr('colspan', 2);
  15. });
  16. }
  17. }
  18. else
  19. {
  20. stepsOrReals.removeClass('hidden');
  21. stepsOrReals.find('select[id^=steps]').eq(-1).val(result);
  22. if(stepsOrReals.parent().prop('tagName') == 'TR')
  23. {
  24. stepsOrReals.closest('tbody').children('tr').each(function()
  25. {
  26. var $td = $(this).children('td').first();
  27. if($td.attr('colspan') != undefined) $td.attr('colspan', 4);
  28. });
  29. }
  30. }
  31. }
  32. $(function()
  33. {
  34. /* Readjust precondition width by cases precondition. */
  35. preconditionThWidth = $('th.precondition').width();
  36. $preconditionTD = $('tbody td.precondition');
  37. preconditionTdLength = $preconditionTD.length;
  38. for(i = 0; i < preconditionTdLength; i++)
  39. {
  40. preconditionTextWidth = $preconditionTD.eq(i).find('span').first().width();
  41. if(preconditionTextWidth > preconditionThWidth)
  42. {
  43. preconditionThWidth = preconditionTextWidth;
  44. if(preconditionThWidth > 200) preconditionThWidth = 200;
  45. $('th.precondition').width(preconditionThWidth);
  46. }
  47. }
  48. })
  49. function toggleStep(event)
  50. {
  51. var $target = $(event.target);
  52. var $preSelect = $(event.target).closest('tr').find('[name^="steps"]');
  53. if($target.val() == '' && $preSelect.val() == 'fail')
  54. {
  55. $preSelect.zui('picker').$.changeState({value: 'pass'});
  56. }
  57. else if($target.val() != '' && $preSelect.val() == 'pass')
  58. {
  59. $preSelect.zui('picker').$.changeState({value: 'fail'});
  60. }
  61. }