* Adjust from data for repo branch create page.
This commit is contained in:
@@ -2,21 +2,36 @@ window.onRepoChange = function()
|
||||
{
|
||||
toggleLoading('#branchFrom', true);
|
||||
$('#branchCreateForm [type=submit]').addClass('disabled');
|
||||
|
||||
const repoID = $('input[name="codeRepo"]').val();
|
||||
const $fromDom = $('[name=branchFrom]').zui('picker');
|
||||
const items = $fromDom.$.props.items;
|
||||
items[0].items = [];
|
||||
items[1].items = [];
|
||||
$fromDom.$.clear();
|
||||
|
||||
$.getJSON($.createLink('repo', 'ajaxGetBranchesAndTags', `repoID=${repoID}`), function(data)
|
||||
{
|
||||
const branches = [];
|
||||
let selected = '';
|
||||
if(data.branches)
|
||||
{
|
||||
for(const branch in data.branches)
|
||||
{
|
||||
branches.push({'text': branch, 'value': branch});
|
||||
if(!selected) selected = branch;
|
||||
items[0].items.push({'text': branch, 'value': branch});
|
||||
}
|
||||
}
|
||||
$fromDom.render({items: branches});
|
||||
$fromDom.$.setValue(branches.length > 0 ? branches[0].value : '');
|
||||
|
||||
if(data.tags)
|
||||
{
|
||||
for(const tag in data.tags)
|
||||
{
|
||||
if(!selected) selected = tag;
|
||||
items[1].items.push({'text': tag, 'value': tag});
|
||||
}
|
||||
}
|
||||
$fromDom.render({items: items});
|
||||
$fromDom.$.setValue(selected);
|
||||
toggleLoading('#branchFrom', false);
|
||||
$('#branchCreateForm [type=submit]').removeClass('disabled');
|
||||
});
|
||||
|
||||
@@ -128,7 +128,8 @@ $canCreate ? formPanel
|
||||
set::name('branchFrom'),
|
||||
set::required(true),
|
||||
set::popPlacement('bottom'),
|
||||
set::items($branches)
|
||||
set::items($fromList),
|
||||
set::value(!empty($fromList[0]['items']) ? $fromList[0]['items'][0]['value'] : '')
|
||||
)
|
||||
),
|
||||
formGroup
|
||||
|
||||
Reference in New Issue
Block a user