mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-06 18:26:15 +02:00
#873 added reusable components for branch and tag combo boxes
This commit is contained in:
@@ -115,6 +115,8 @@
|
||||
|
||||
<!-- sonia.repository -->
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.js"></script>
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.branchcombobox.js"></script>
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.tagcombobox.js"></script>
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.grid.js"></script>
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.infopanel.js"></script>
|
||||
<script type="text/javascript" src="resources/js/repository/sonia.repository.extendedinfopanel.js"></script>
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* *
|
||||
* Copyright (c) 2014, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Sonia.repository.BranchComboBox = Ext.extend(Ext.form.ComboBox, {
|
||||
|
||||
repositoryId: null,
|
||||
|
||||
initComponent: function(){
|
||||
var branchStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repositoryId + '/branches.json',
|
||||
method: 'GET',
|
||||
disableCaching: false
|
||||
}),
|
||||
root: 'branch',
|
||||
idProperty: 'name',
|
||||
fields: ['name', 'revision']
|
||||
});
|
||||
|
||||
var config = {
|
||||
valueField: 'revision',
|
||||
displayField: 'name',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: branchStore
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.BranchComboBox.superclass.initComponent.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// register xtype
|
||||
Ext.reg('repositoryBranchComboBox', Sonia.repository.BranchComboBox);
|
||||
@@ -120,33 +120,14 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||
},
|
||||
|
||||
createTopToolbar: function(){
|
||||
var branchStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repository.id + '/branches.json',
|
||||
method: 'GET',
|
||||
disableCaching: false
|
||||
}),
|
||||
root: 'branch',
|
||||
idProperty: 'name',
|
||||
fields: [ 'name' ],
|
||||
sortInfo: {
|
||||
field: 'name'
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
xtype: 'toolbar',
|
||||
items: [
|
||||
this.repository.name,
|
||||
'->',
|
||||
'Branches:', ' ',{
|
||||
xtype: 'combo',
|
||||
valueField: 'name',
|
||||
displayField: 'name',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: branchStore,
|
||||
xtype: 'repositoryBranchComboBox',
|
||||
repositoryId: this.repository.id,
|
||||
listeners: {
|
||||
select: {
|
||||
fn: this.selectBranch,
|
||||
|
||||
@@ -159,26 +159,10 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
branches = true;
|
||||
|
||||
var branchStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repository.id + '/branches.json',
|
||||
method: 'GET',
|
||||
disableCaching: false
|
||||
}),
|
||||
root: 'branch',
|
||||
idProperty: 'name',
|
||||
fields: [ 'name', 'revision' ]
|
||||
});
|
||||
|
||||
items.push('->','Branches:', ' ',{
|
||||
id: 'branchComboBox',
|
||||
xtype: 'combo',
|
||||
valueField: 'revision',
|
||||
displayField: 'name',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: branchStore,
|
||||
xtype: 'repositoryBranchComboBox',
|
||||
repositoryId: this.repository.id,
|
||||
listeners: {
|
||||
select: {
|
||||
fn: this.selectBranch,
|
||||
@@ -191,17 +175,6 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
if ( type && type.supportedCommands && type.supportedCommands.indexOf('TAGS') >= 0){
|
||||
|
||||
var tagStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repository.id + '/tags.json',
|
||||
method: 'GET',
|
||||
disableCaching: false
|
||||
}),
|
||||
root: 'tag',
|
||||
idProperty: 'name',
|
||||
fields: [ 'name', 'revision' ]
|
||||
});
|
||||
|
||||
if (branches){
|
||||
items.push(' ');
|
||||
} else {
|
||||
@@ -210,13 +183,8 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
items.push('Tags:', ' ',{
|
||||
id: 'tagComboBox',
|
||||
xtype: 'combo',
|
||||
valueField: 'revision',
|
||||
displayField: 'name',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: tagStore,
|
||||
xtype: 'repositoryTagComboBox',
|
||||
repositoryId: this.repository.id,
|
||||
listeners: {
|
||||
select: {
|
||||
fn: this.selectTag,
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* *
|
||||
* Copyright (c) 2014, Sebastian Sdorra
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* http://bitbucket.org/sdorra/scm-manager
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
Sonia.repository.TagComboBox = Ext.extend(Ext.form.ComboBox, {
|
||||
|
||||
repositoryId: null,
|
||||
|
||||
initComponent: function(){
|
||||
var tagStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repositoryId + '/tags.json',
|
||||
method: 'GET',
|
||||
disableCaching: false
|
||||
}),
|
||||
root: 'tag',
|
||||
idProperty: 'name',
|
||||
fields: [ 'name', 'revision' ]
|
||||
});
|
||||
|
||||
var config = {
|
||||
valueField: 'revision',
|
||||
displayField: 'name',
|
||||
typeAhead: false,
|
||||
editable: false,
|
||||
triggerAction: 'all',
|
||||
store: tagStore,
|
||||
};
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.TagComboBox.superclass.initComponent.apply(this, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// register xtype
|
||||
Ext.reg('repositoryTagComboBox', Sonia.repository.TagComboBox);
|
||||
Reference in New Issue
Block a user