createbranch.ui.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. window.onRepoChange = function()
  2. {
  3. toggleLoading('#branchFrom', true);
  4. $('#branchCreateForm [type=submit]').addClass('disabled');
  5. const repoID = $('input[name="codeRepo"]').val();
  6. const $fromDom = $('[name=branchFrom]').zui('picker');
  7. $fromDom.$.clear();
  8. $.getJSON($.createLink('repo', 'ajaxGetBranchesAndTags', `repoID=${repoID}`), function(data)
  9. {
  10. const items = []
  11. let selected = '';
  12. if(data.branches)
  13. {
  14. items.push({text: branchLang, items: [], disabled: true, key: undefined});
  15. for(const branch in data.branches)
  16. {
  17. if(!selected) selected = branch;
  18. items[0].items.push({'text': branch, 'value': branch});
  19. }
  20. if(!selected) delete items[0];
  21. }
  22. if(data.tags)
  23. {
  24. items.push({text: tagLang, items: [], disabled: true, key: undefined});
  25. const index = items.length - 1;
  26. for(const tag in data.tags)
  27. {
  28. if(!selected) selected = tag;
  29. items[index].items.push({'text': tag, 'value': tag});
  30. }
  31. if(items[index].items.length == 0) delete items[index];
  32. }
  33. $fromDom.render({items: items});
  34. $fromDom.$.setValue(selected);
  35. toggleLoading('#branchFrom', false);
  36. $('#branchCreateForm [type=submit]').removeClass('disabled');
  37. });
  38. }
  39. $(document).on('click', '.modal-actions > button', function()
  40. {
  41. loadCurrentPage();
  42. })