diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-08-11 17:53:01 +0100 |
---|---|---|
committer | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-09-05 00:31:23 +0100 |
commit | c567b7f4f4aeecc3c4725dabc72ab8a3cdcec975 (patch) | |
tree | c6c8cc1f9f81857d2bdcef3017a26c5380d009d6 /templates | |
parent | b5074ed2aae6923b0b2781a2fb36b42318eeb126 (diff) | |
download | openembedded-core-contrib-c567b7f4f4aeecc3c4725dabc72ab8a3cdcec975.tar.gz |
Disable web URL fields when repository is known
Some users seem to think it's necessary to clear these fields out when
they are auto-set. The most appropriate thing to do seems to be to
disable editing them if we know what their values should be.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/layerindex/editlayer.html | 59 |
1 files changed, 42 insertions, 17 deletions
diff --git a/templates/layerindex/editlayer.html b/templates/layerindex/editlayer.html index ba37ee97fa..e2b4fcb53a 100644 --- a/templates/layerindex/editlayer.html +++ b/templates/layerindex/editlayer.html @@ -168,43 +168,67 @@ }; } - auto_web_fields = function (e) { - repoval = $('#id_vcs_url').val() + function AutoWebFields(repoval) { if( repoval[repoval.length-1] == '/' ) repoval = repoval.slice(0, repoval.length-1) if( repoval.startsWith('git://git.openembedded.org/') ) { reponame = repoval.replace(/^.*\//, '') - $('#id_vcs_web_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame) - $('#id_vcs_web_tree_base_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%') - $('#id_vcs_web_file_base_url').val('http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%') + this.vcs_web_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame + this.vcs_web_tree_base_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%' + this.vcs_web_file_base_url = 'http://cgit.openembedded.org/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%' } else if( repoval.indexOf('git.yoctoproject.org/') > -1 ) { reponame = repoval.replace(/^.*\//, '') - $('#id_vcs_web_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame) - $('#id_vcs_web_tree_base_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%') - $('#id_vcs_web_file_base_url').val('http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%') + this.vcs_web_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + this.vcs_web_tree_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%' + this.vcs_web_file_base_url = 'http://git.yoctoproject.org/cgit/cgit.cgi/' + reponame + '/tree/%path%?h=%branch%' } else if( repoval.indexOf('github.com/') > -1 ) { reponame = repoval.replace(/^.*github.com\//, '') reponame = reponame.replace(/.git$/, '') - $('#id_vcs_web_url').val('http://github.com/' + reponame) - $('#id_vcs_web_tree_base_url').val('http://github.com/' + reponame + '/tree/%branch%/') - $('#id_vcs_web_file_base_url').val('http://github.com/' + reponame + '/blob/%branch%/') + this.vcs_web_url = 'http://github.com/' + reponame + this.vcs_web_tree_base_url = 'http://github.com/' + reponame + '/tree/%branch%/' + this.vcs_web_file_base_url = 'http://github.com/' + reponame + '/blob/%branch%/' } else if( repoval.indexOf('gitorious.org/') > -1 ) { reponame = repoval.replace(/^.*gitorious.org\//, '') reponame = reponame.replace(/.git$/, '') - $('#id_vcs_web_url').val('http://gitorious.org/' + reponame) - $('#id_vcs_web_tree_base_url').val('http://gitorious.org/' + reponame + '/trees/%branch%/') - $('#id_vcs_web_file_base_url').val('http://gitorious.org/' + reponame + '/blobs/%branch%/') + this.vcs_web_url = 'http://gitorious.org/' + reponame + this.vcs_web_tree_base_url = 'http://gitorious.org/' + reponame + '/trees/%branch%/' + this.vcs_web_file_base_url = 'http://gitorious.org/' + reponame + '/blobs/%branch%/' } else if( repoval.indexOf('bitbucket.org/') > -1 ) { reponame = repoval.replace(/^.*bitbucket.org\//, '') reponame = reponame.replace(/.git$/, '') - $('#id_vcs_web_url').val('http://bitbucket.org/' + reponame) - $('#id_vcs_web_tree_base_url').val('http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%') - $('#id_vcs_web_file_base_url').val('http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%') + this.vcs_web_url = 'http://bitbucket.org/' + reponame + this.vcs_web_tree_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%' + this.vcs_web_file_base_url = 'http://bitbucket.org/' + reponame + '/src/%branch%/%path%?at=%branch%' + } + else { + this.vcs_web_url = '' + this.vcs_web_tree_base_url = '' + this.vcs_web_file_base_url = '' + } + } + + auto_web_fields = function (e) { + repoval = $('#id_vcs_url').val() + awf = new AutoWebFields(repoval) + if (awf.vcs_web_url) { + if (e) { + $('#id_vcs_web_url').val(awf.vcs_web_url) + $('#id_vcs_web_tree_base_url').val(awf.vcs_web_tree_base_url) + $('#id_vcs_web_file_base_url').val(awf.vcs_web_file_base_url) + } + $('#id_vcs_web_url').prop('disabled', true); + $('#id_vcs_web_tree_base_url').prop('disabled', true); + $('#id_vcs_web_file_base_url').prop('disabled', true); + } + else { + $('#id_vcs_web_url').prop('disabled', false); + $('#id_vcs_web_tree_base_url').prop('disabled', false); + $('#id_vcs_web_file_base_url').prop('disabled', false); } }; @@ -256,6 +280,7 @@ $('#addanothermaintainer').click(expand_maintainer) $('#id_vcs_url').change(auto_web_fields) + auto_web_fields(null) firstfield = $("#edit_layer_form input:text, #edit_layer_form textarea").first(); if( ! firstfield.val() ) |