edit.ui.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. function changeProduct()
  2. {
  3. let oldExecutionID = $('input[name=execution]').val();
  4. let productID = $('input[name=product]').val();
  5. if(executionID)
  6. {
  7. loadExecutions(oldExecutionID);
  8. }
  9. else
  10. {
  11. $.get($.createLink('build', 'ajaxGetProjectBuilds', 'projectID=' + projectID + '&productID=' + productID + '&letName=builds&build=&branch=all&needCreate=&type=noempty,notrunk,separate,singled'), function(data)
  12. {
  13. if(data)
  14. {
  15. data = JSON.parse(data);
  16. const $buildsPicker = $('select[name^=builds]').zui('picker');
  17. $buildsPicker.render({items: data, multiple: true});
  18. $buildsPicker.$.setValue('');
  19. $('#builds').attr('data-placeholder', multipleSelect);
  20. }
  21. });
  22. }
  23. $.get($.createLink('product', 'ajaxGetProductById', 'productID=' + productID), function(data)
  24. {
  25. $('[name^=branch]').closest('.form-group').find('.form-label').html(data.branchName);
  26. }, 'json');
  27. $('[name^=branch]').zui('picker').$.setValue('');
  28. loadBranches();
  29. if(!build.isChild) loadSystem();
  30. }
  31. function changeBranches()
  32. {
  33. let newBranch = $('[name^=branch]').val() ? $('[name^=branch]').val().toString() : '';
  34. $.get($.createLink('build', 'ajaxGetBranch', 'buildID=' + buildID + '&newBranch=' + newBranch), function(unlinkBranch)
  35. {
  36. if(unlinkBranch != '')
  37. {
  38. let result = confirm(unlinkBranch) ? true : false;
  39. if(!result)
  40. {
  41. $('[name^=branch]').zui('picker').$.setValue(build.branch.split(','));
  42. }
  43. }
  44. });
  45. }
  46. function loadExecutions(oldExecutionID)
  47. {
  48. let productID = $('input[name=product]').val();
  49. let branchID = $('[name^=branch]').length > 0 ? $('[name^=branch]').val() : 0;
  50. $.get($.createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&projectID=0&branch=' + branchID + '&number=&executionID=' + oldExecutionID), function(data)
  51. {
  52. if(data)
  53. {
  54. const $executionPicker = $('input[name=execution]').zui('picker');
  55. data = JSON.parse(data);
  56. $executionPicker.render({items: data});
  57. }
  58. });
  59. }