mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 10:16:16 +01:00
added history functions for user panel
This commit is contained in:
@@ -41,6 +41,9 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
colLastModifiedText: 'Last modified',
|
||||
colTypeText: 'Type',
|
||||
|
||||
// parent for history
|
||||
parentPanel: null,
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var userStore = new Sonia.rest.JsonStore({
|
||||
@@ -85,6 +88,10 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
|
||||
|
||||
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
|
||||
|
||||
if (this.parentPanel){
|
||||
this.parentPanel.userGrid = this;
|
||||
}
|
||||
},
|
||||
|
||||
onFallBelowMinHeight: function(height, minHeight){
|
||||
|
||||
@@ -38,6 +38,9 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
errorTitleText: 'Error',
|
||||
errorMsgText: 'User deletion failed',
|
||||
|
||||
// userGrid for history
|
||||
userGrid: null,
|
||||
|
||||
initComponent: function(){
|
||||
|
||||
var config = {
|
||||
@@ -51,7 +54,8 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
items: [{
|
||||
id: 'userGrid',
|
||||
xtype: 'userGrid',
|
||||
region: 'center'
|
||||
region: 'center',
|
||||
parentPanel: this
|
||||
},{
|
||||
id: 'userEditPanel',
|
||||
layout: 'fit',
|
||||
@@ -73,6 +77,16 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
Sonia.user.Panel.superclass.initComponent.apply(this, arguments);
|
||||
},
|
||||
|
||||
getGrid: function(){
|
||||
if (!this.userGrid){
|
||||
if (debug){
|
||||
console.debug('userGrid not found retrvie by id');
|
||||
}
|
||||
this.userGrid = Ext.getCmp('userGrid');
|
||||
}
|
||||
return this.userGrid;
|
||||
},
|
||||
|
||||
showAddPanel: function(){
|
||||
var editPanel = Ext.getCmp('userEditPanel');
|
||||
editPanel.removeAll();
|
||||
@@ -99,7 +113,7 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
|
||||
removeUser: function(){
|
||||
|
||||
var grid = Ext.getCmp('userGrid');
|
||||
var grid = this.getGrid();
|
||||
var selected = grid.getSelectionModel().getSelected();
|
||||
if ( selected ){
|
||||
var item = selected.data;
|
||||
@@ -153,3 +167,32 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
||||
|
||||
// register xtype
|
||||
Ext.reg('userPanel', Sonia.user.Panel);
|
||||
|
||||
|
||||
// register history handler
|
||||
Sonia.History.register('userPanel', {
|
||||
|
||||
onActivate: function(panel){
|
||||
var token = null;
|
||||
var rec = panel.getGrid().getSelectionModel().getSelected();
|
||||
if (rec){
|
||||
token = Sonia.History.createToken('userPanel', rec.get('name'));
|
||||
} else {
|
||||
token = Sonia.History.createToken('userPanel');
|
||||
}
|
||||
return token;
|
||||
},
|
||||
|
||||
onChange: function(userId){
|
||||
var panel = Ext.getCmp('users');
|
||||
if ( ! panel ){
|
||||
main.addUsersTabPanel();
|
||||
panel = Ext.getCmp('users');
|
||||
} else {
|
||||
main.addTab(panel);
|
||||
}
|
||||
if (userId){
|
||||
panel.getGrid().selectById(userId);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user