mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-16 18:26: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',
|
colLastModifiedText: 'Last modified',
|
||||||
colTypeText: 'Type',
|
colTypeText: 'Type',
|
||||||
|
|
||||||
|
// parent for history
|
||||||
|
parentPanel: null,
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
|
|
||||||
var userStore = new Sonia.rest.JsonStore({
|
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));
|
Ext.apply(this, Ext.apply(this.initialConfig, config));
|
||||||
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
|
Sonia.user.Grid.superclass.initComponent.apply(this, arguments);
|
||||||
|
|
||||||
|
if (this.parentPanel){
|
||||||
|
this.parentPanel.userGrid = this;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFallBelowMinHeight: function(height, minHeight){
|
onFallBelowMinHeight: function(height, minHeight){
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
errorTitleText: 'Error',
|
errorTitleText: 'Error',
|
||||||
errorMsgText: 'User deletion failed',
|
errorMsgText: 'User deletion failed',
|
||||||
|
|
||||||
|
// userGrid for history
|
||||||
|
userGrid: null,
|
||||||
|
|
||||||
initComponent: function(){
|
initComponent: function(){
|
||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
@@ -51,7 +54,8 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
items: [{
|
items: [{
|
||||||
id: 'userGrid',
|
id: 'userGrid',
|
||||||
xtype: 'userGrid',
|
xtype: 'userGrid',
|
||||||
region: 'center'
|
region: 'center',
|
||||||
|
parentPanel: this
|
||||||
},{
|
},{
|
||||||
id: 'userEditPanel',
|
id: 'userEditPanel',
|
||||||
layout: 'fit',
|
layout: 'fit',
|
||||||
@@ -73,6 +77,16 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
Sonia.user.Panel.superclass.initComponent.apply(this, arguments);
|
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(){
|
showAddPanel: function(){
|
||||||
var editPanel = Ext.getCmp('userEditPanel');
|
var editPanel = Ext.getCmp('userEditPanel');
|
||||||
editPanel.removeAll();
|
editPanel.removeAll();
|
||||||
@@ -99,7 +113,7 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
|
|
||||||
removeUser: function(){
|
removeUser: function(){
|
||||||
|
|
||||||
var grid = Ext.getCmp('userGrid');
|
var grid = this.getGrid();
|
||||||
var selected = grid.getSelectionModel().getSelected();
|
var selected = grid.getSelectionModel().getSelected();
|
||||||
if ( selected ){
|
if ( selected ){
|
||||||
var item = selected.data;
|
var item = selected.data;
|
||||||
@@ -153,3 +167,32 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
|
|||||||
|
|
||||||
// register xtype
|
// register xtype
|
||||||
Ext.reg('userPanel', Sonia.user.Panel);
|
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