mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
start rebuilding of bookmarkable functions
This commit is contained in:
@@ -115,8 +115,6 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
if ( debug ){
|
||||
console.debug( group.name + ' selected' );
|
||||
}
|
||||
|
||||
Sonia.History.append(group.name);
|
||||
|
||||
Ext.getCmp('groupRmButton').setDisabled(false);
|
||||
Sonia.group.setEditPanel([{
|
||||
|
||||
@@ -34,7 +34,6 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||
repository: null,
|
||||
start: 0,
|
||||
pageSize: 20,
|
||||
historyId: null,
|
||||
changesetStore: null,
|
||||
|
||||
// parameters for file history view
|
||||
@@ -45,13 +44,6 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||
changesetViewerTitleText: 'Commits {0}',
|
||||
|
||||
initComponent: function(){
|
||||
this.historyId = Sonia.History.createToken([
|
||||
'changesetviewer',
|
||||
this.repository.id,
|
||||
this.start,
|
||||
this.pageSize
|
||||
]);
|
||||
|
||||
if (! this.url){
|
||||
this.url = restUrl + 'repositories/' + this.repository.id + '/changesets.json';
|
||||
}
|
||||
@@ -114,10 +106,7 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||
},
|
||||
|
||||
updateHistory: function(store, records, options){
|
||||
var id = Sonia.History.appendWithDepth([options.params.start, options.params.limit], 2);
|
||||
if (id){
|
||||
this.historyId = id;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
loadChangesets: function(start, limit){
|
||||
@@ -131,38 +120,3 @@ Sonia.repository.ChangesetViewerPanel = Ext.extend(Ext.Panel, {
|
||||
|
||||
// register xtype
|
||||
Ext.reg('repositoryChangesetViewerPanel', Sonia.repository.ChangesetViewerPanel);
|
||||
|
||||
// register history handler
|
||||
Sonia.History.register('changesetviewer', function(params){
|
||||
|
||||
if (params){
|
||||
|
||||
var id = params[0] + '-changesetViewer';
|
||||
var start = Sonia.util.parseInt(params[1], 0);
|
||||
var pageSize = Sonia.util.parseInt(params[2], 20);
|
||||
|
||||
if (debug){
|
||||
console.debug('load changesetviewer for ' + id + ', ' + start + ', ' + pageSize );
|
||||
}
|
||||
|
||||
var tab = Ext.getCmp(id);
|
||||
|
||||
if ( tab ){
|
||||
main.getMainTabPanel().setActiveTab(id);
|
||||
tab.loadChangesets(start, pageSize);
|
||||
} else {
|
||||
Sonia.repository.get(params[0], function(repository){
|
||||
main.addTab({
|
||||
id: repository.id + '-changesetViewer',
|
||||
xtype: 'repositoryChangesetViewerPanel',
|
||||
repository: repository,
|
||||
start: start,
|
||||
pageSize: pageSize,
|
||||
closable: true
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -41,6 +41,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
searchValue: null,
|
||||
typeFilter: null,
|
||||
|
||||
// for history
|
||||
parentPanel: null,
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
@@ -93,6 +96,10 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
if (this.parentPanel){
|
||||
this.parentPanel.repositoryGrid = this;
|
||||
}
|
||||
},
|
||||
|
||||
storeLoad: function(){
|
||||
@@ -152,7 +159,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
console.debug( item.name + ' selected' );
|
||||
}
|
||||
|
||||
Sonia.History.append(item.id);
|
||||
if ( this.parentPanel ){
|
||||
this.parentPanel.updateHistory(item);
|
||||
}
|
||||
|
||||
var infoPanel = main.getInfoPanel(item.type);
|
||||
infoPanel.item = item;
|
||||
|
||||
@@ -38,6 +38,8 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
removeMsgText: 'Remove Repository "{0}"?',
|
||||
errorTitleText: 'Error',
|
||||
errorMsgText: 'Repository deletion failed',
|
||||
|
||||
repositoryGrid: null,
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
@@ -126,41 +128,56 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
var config = {
|
||||
tbar: toolbar,
|
||||
items: [{
|
||||
id: 'repositoryGrid',
|
||||
xtype: 'repositoryGrid',
|
||||
region: 'center'
|
||||
}, {
|
||||
id: 'repositoryEditPanel',
|
||||
xtype: 'tabpanel',
|
||||
activeTab: 0,
|
||||
height: 250,
|
||||
split: true,
|
||||
border: true,
|
||||
region: 'south',
|
||||
items: [{
|
||||
bodyCssClass: 'x-panel-mc',
|
||||
title: this.titleText,
|
||||
padding: 5,
|
||||
html: this.emptyText
|
||||
}]
|
||||
}
|
||||
]
|
||||
id: 'repositoryGrid',
|
||||
xtype: 'repositoryGrid',
|
||||
region: 'center',
|
||||
parentPanel: this
|
||||
},{
|
||||
id: 'repositoryEditPanel',
|
||||
xtype: 'tabpanel',
|
||||
activeTab: 0,
|
||||
height: 250,
|
||||
split: true,
|
||||
border: true,
|
||||
region: 'south',
|
||||
items: [{
|
||||
bodyCssClass: 'x-panel-mc',
|
||||
title: this.titleText,
|
||||
padding: 5,
|
||||
html: this.emptyText
|
||||
}]
|
||||
}]
|
||||
}
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.repository.Panel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
getGrid: function(){
|
||||
if ( ! this.repositoryGrid ){
|
||||
if ( debug ){
|
||||
console.debug('repository grid not found, retrive by cmp id');
|
||||
}
|
||||
this.repositoryGrid = Ext.getCmp('repositoryGrid');
|
||||
}
|
||||
return this.repositoryGrid;
|
||||
},
|
||||
|
||||
updateHistory: function(item){
|
||||
var token = Sonia.History.createToken(['repositoryPanel', item.id]);
|
||||
Sonia.History.add(token);
|
||||
},
|
||||
|
||||
filterByType: function(combo, rec){
|
||||
Ext.getCmp('repositoryGrid').filter(rec.get('name'));
|
||||
this.getGrid().filter(rec.get('name'));
|
||||
},
|
||||
|
||||
search: function(field){
|
||||
Ext.getCmp('repositoryGrid').search(field.getValue());
|
||||
this.getGrid().search(field.getValue());
|
||||
},
|
||||
|
||||
removeRepository: function(){
|
||||
var grid = Ext.getCmp('repositoryGrid');
|
||||
var grid = this.getGrid();
|
||||
var selected = grid.getSelectionModel().getSelected();
|
||||
if ( selected ){
|
||||
var item = selected.data;
|
||||
@@ -227,7 +244,7 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
},
|
||||
|
||||
repositoryCreated: function(item){
|
||||
var grid = Ext.getCmp('repositoryGrid');
|
||||
var grid = this.getGrid();
|
||||
this.clearRepositoryFilter(grid);
|
||||
|
||||
grid.reload(function(){
|
||||
@@ -243,7 +260,7 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
console.debug('clear repository filter');
|
||||
}
|
||||
if (! grid ){
|
||||
grid = Ext.getCmp('repositoryGrid');
|
||||
grid = this.getGrid();
|
||||
}
|
||||
Ext.getCmp('repositorySearch').setValue('');
|
||||
Ext.getCmp('repositoryTypeFilter').setValue('');
|
||||
@@ -251,10 +268,36 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
},
|
||||
|
||||
reload: function(){
|
||||
Ext.getCmp('repositoryGrid').reload();
|
||||
this.getGrid().reload();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// register xtype
|
||||
Ext.reg('repositoryPanel', Sonia.repository.Panel);
|
||||
Ext.reg('repositoryPanel', Sonia.repository.Panel);
|
||||
|
||||
// register history handler
|
||||
Sonia.History.register('repositoryPanel', {
|
||||
|
||||
onActivate: function(panel){
|
||||
var token = null;
|
||||
var rec = panel.getGrid().getSelectionModel().getSelected();
|
||||
if ( rec != null ){
|
||||
token = Sonia.History.createToken('repositoryPanel', rec.get('id'));
|
||||
} else {
|
||||
token = Sonia.History.createToken('repositoryPanel');
|
||||
}
|
||||
return token;
|
||||
},
|
||||
|
||||
onChange: function(repoId){
|
||||
var panel = Ext.getCmp('repositories');
|
||||
if ( ! panel ){
|
||||
main.addRepositoriesTabPanel();
|
||||
panel = Ext.getCmp('repositories');
|
||||
}
|
||||
if (repoId){
|
||||
panel.getGrid().selectById(repoId);
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -32,7 +32,6 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
repository: null,
|
||||
revision: null,
|
||||
historyId: null,
|
||||
path: null,
|
||||
|
||||
repositoryBrowserTitleText: 'Source {0}',
|
||||
@@ -50,12 +49,6 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
console.debug('create new browser for repository ' + this.repository.name + " and revision " + this.revision);
|
||||
}
|
||||
|
||||
this.historyId = Sonia.History.createToken([
|
||||
'repositorybrowser',
|
||||
this.repository.id,
|
||||
this.revision ? this.revision : '_'
|
||||
]);
|
||||
|
||||
var browserStore = new Sonia.rest.JsonStore({
|
||||
proxy: new Ext.data.HttpProxy({
|
||||
url: restUrl + 'repositories/' + this.repository.id + '/browse.json',
|
||||
@@ -174,22 +167,6 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
length: 0
|
||||
}));
|
||||
}
|
||||
|
||||
var historyParams = [];
|
||||
if ( this.revision ){
|
||||
historyParams.push(this.revision)
|
||||
} else {
|
||||
historyParams.push('_');
|
||||
}
|
||||
|
||||
if ( extra.params.path ){
|
||||
historyParams.push(extra.params.path);
|
||||
}
|
||||
|
||||
var id = Sonia.History.appendWithDepth(historyParams, 2);
|
||||
if (id){
|
||||
this.historyId = id;
|
||||
}
|
||||
},
|
||||
|
||||
onClick: function(e){
|
||||
@@ -318,41 +295,3 @@ Sonia.repository.RepositoryBrowser = Ext.extend(Ext.grid.GridPanel, {
|
||||
|
||||
// register xtype
|
||||
Ext.reg('repositoryBrowser', Sonia.repository.RepositoryBrowser);
|
||||
|
||||
// register history handler
|
||||
Sonia.History.register('repositorybrowser', function(params){
|
||||
|
||||
if (params){
|
||||
|
||||
var id = 'repositorybrowser-' + params[0] + ':';
|
||||
var revision = params[1];
|
||||
id += revision;
|
||||
var path = params[2] ? params[2] : '';
|
||||
|
||||
if ( revision == '_' ){
|
||||
revision = null;
|
||||
}
|
||||
|
||||
if (debug){
|
||||
console.debug('load repositorybrowser for ' + id + ', ' + revision + ', ' + path );
|
||||
}
|
||||
|
||||
var tab = Ext.getCmp(id);
|
||||
|
||||
if ( tab ){
|
||||
main.getMainTabPanel().setActiveTab(id);
|
||||
tab.changeDirectory(path);
|
||||
} else {
|
||||
Sonia.repository.get(params[0], function(repository){
|
||||
main.addTab({
|
||||
id: id,
|
||||
xtype: 'repositoryBrowser',
|
||||
repository: repository,
|
||||
revision: revision,
|
||||
path: path,
|
||||
closable: true
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -117,6 +117,20 @@ Sonia.History = {
|
||||
return invokeable;
|
||||
},
|
||||
|
||||
onActivate: function(tab){
|
||||
if (tab){
|
||||
var el = this.historyElements[tab.xtype];
|
||||
if (el){
|
||||
var token = Sonia.util.apply(el.onActivate, tab);
|
||||
if (token){
|
||||
this.add(token);
|
||||
}
|
||||
} else if (debug) {
|
||||
console.debug('could not find xtype ' + tab.xtype);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onChange: function(token){
|
||||
if (!this.initialized){
|
||||
this.initialized = true;
|
||||
@@ -133,17 +147,13 @@ Sonia.History = {
|
||||
}
|
||||
},
|
||||
|
||||
handleChange: function(id, params){
|
||||
handleChange: function(id, p){
|
||||
var el = this.historyElements[id];
|
||||
if (el){
|
||||
if (debug){
|
||||
console.debug('handle history event for ' + id + ' with "' + params + '"');
|
||||
}
|
||||
if (Ext.isFunction(el) ){
|
||||
el(params);
|
||||
} else {
|
||||
el.fn.call(el.scope, params);
|
||||
console.debug('handle history event for ' + id + ' with "' + p + '"');
|
||||
}
|
||||
Sonia.util.apply(el.onChange, p);
|
||||
} else if (Ext.ComponentMgr.isRegistered(id)) {
|
||||
try {
|
||||
main.addTabPanel(id);
|
||||
|
||||
@@ -74,7 +74,6 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
this.addEvents('login', 'logout', 'init');
|
||||
this.mainTabPanel = Ext.getCmp('mainTabPanel');
|
||||
this.addListener('login', this.postLogin, this);
|
||||
this.createHistory();
|
||||
Sonia.scm.Main.superclass.constructor.call(this, config);
|
||||
},
|
||||
|
||||
@@ -151,39 +150,6 @@ Sonia.scm.Main = Ext.extend(Ext.util.Observable, {
|
||||
this.addTabPanel('groups', 'groupPanel', this.tabGroupsText);
|
||||
}
|
||||
},
|
||||
|
||||
createHistory: function(){
|
||||
Sonia.History.register('repositories', function(params){
|
||||
this.addRepositoriesTabPanel();
|
||||
var grid = Ext.getCmp('repositoryGrid');
|
||||
if (grid){
|
||||
grid.handleHistory(params);
|
||||
} else if (debug){
|
||||
console.debug('could not find repository grid');
|
||||
}
|
||||
}, this);
|
||||
Sonia.History.register('scmConfig', this.addScmConfigTabPanel, this);
|
||||
Sonia.History.register('repositoryConfig', this.addRepositoryConfigTabPanel, this);
|
||||
Sonia.History.register('plugins', this.addPluginTabPanel, this);
|
||||
Sonia.History.register('users', function(params){
|
||||
this.addUsersTabPanel();
|
||||
var grid = Ext.getCmp('userGrid');
|
||||
if (grid){
|
||||
grid.handleHistory(params);
|
||||
} else if (debug){
|
||||
console.debug('could not find user grid');
|
||||
}
|
||||
}, this);
|
||||
Sonia.History.register('groups', function(params){
|
||||
this.addGroupsTabPanel();
|
||||
var grid = Ext.getCmp('groupGrid');
|
||||
if (grid){
|
||||
grid.handleHistory(params);
|
||||
} else if (debug){
|
||||
console.debug('could not find group grid');
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
createMainMenu: function(){
|
||||
if ( debug ){
|
||||
@@ -510,10 +476,7 @@ Ext.onReady(function(){
|
||||
listeners: {
|
||||
tabchange: function(tabPanel, tab){
|
||||
if ( Ext.isDefined(tab) ){
|
||||
var id = tab.historyId ? tab.historyId : tab.id;
|
||||
if (id){
|
||||
Sonia.History.add(id, true);
|
||||
}
|
||||
Sonia.History.onActivate(tab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,40 @@ Sonia.util.getStringFromArray = function(array){
|
||||
return value;
|
||||
}
|
||||
|
||||
Sonia.util.applySub = function(obj, name, p){
|
||||
if (name){
|
||||
obj = obj[name];
|
||||
}
|
||||
return Sonia.util.call(obj, p);
|
||||
}
|
||||
|
||||
Sonia.util.apply = function(obj, p){
|
||||
var result = null;
|
||||
// use call instead of apply for compatiblity
|
||||
if (Ext.isFunction(obj)) {
|
||||
if (p){
|
||||
if (Ext.isArray(p)){
|
||||
result = obj(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]);
|
||||
} else {
|
||||
result = obj(p);
|
||||
}
|
||||
} else {
|
||||
result = obj();
|
||||
}
|
||||
} else {
|
||||
if (p){
|
||||
if ( Ext.isArray(p) ){
|
||||
obj.fn.call(obj.scope, p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]);
|
||||
} else {
|
||||
obj.fn.call(obj.scope, p);
|
||||
}
|
||||
} else {
|
||||
obj.fn.call(obj.scope);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
if (!Array.prototype.filter) {
|
||||
|
||||
Array.prototype.filter = function(fn, scope){
|
||||
|
||||
Reference in New Issue
Block a user