start implementation of ui for global user permissions

This commit is contained in:
Sebastian Sdorra
2013-05-01 19:17:43 +02:00
parent 3f9cc02ebb
commit 341716df49
10 changed files with 39 additions and 37 deletions

View File

@@ -47,7 +47,7 @@ Sonia.group.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
initComponent: function(){ initComponent: function(){
this.addEvents('preCreate', 'created', 'preUpdate', 'updated', 'updateFailed', 'creationFailed'); this.addEvents('preCreate', 'created', 'preUpdate', 'updated', 'updateFailed', 'creationFailed');
Sonia.repository.FormPanel.superclass.initComponent.apply(this, arguments); Sonia.group.FormPanel.superclass.initComponent.apply(this, arguments);
}, },
update: function(group){ update: function(group){

View File

@@ -105,7 +105,7 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, {
renderMembers: function(members){ renderMembers: function(members){
var out = ''; var out = '';
if ( members != null ){ if ( members !== null ){
var s = members.length; var s = members.length;
for ( var i=0; i<s; i++ ){ for ( var i=0; i<s; i++ ){
out += members[i]; out += members[i];
@@ -152,7 +152,6 @@ Sonia.group.Grid = Ext.extend(Sonia.rest.Grid, {
} }
} }
},{ },{
item: group,
xtype: 'permissionsPanel', xtype: 'permissionsPanel',
baseUrl: 'security/permission/group/' + group.name baseUrl: 'security/permission/group/' + group.name
}]); }]);

View File

@@ -39,7 +39,7 @@ Sonia.group.setEditPanel = function(panels){
}); });
editPanel.setActiveTab(0); editPanel.setActiveTab(0);
editPanel.doLayout(); editPanel.doLayout();
} };
/** /**
* panels * panels
@@ -51,4 +51,4 @@ Sonia.group.DefaultPanel = {
bodyCssClass: 'x-panel-mc', bodyCssClass: 'x-panel-mc',
padding: 5, padding: 5,
html: 'Add or select a Group' html: 'Add or select a Group'
} };

View File

@@ -69,9 +69,9 @@ Sonia.group.MemberFormPanel = Ext.extend(Sonia.group.FormPanel, {
singleSelect: true singleSelect: true
}); });
if ( this.item != null ){ if ( this.item !== null ){
var data = []; var data = [];
if ( this.item.members != null ){ if ( this.item.members !== null ){
for ( var i=0; i<this.item.members.length; i++ ){ for ( var i=0; i<this.item.members.length; i++ ){
var a = []; var a = [];
a.push( this.item.members[i] ); a.push( this.item.members[i] );

View File

@@ -70,7 +70,7 @@ Sonia.group.Panel = Ext.extend(Sonia.rest.Panel, {
}] }]
} }
] ]
} };
Ext.apply(this, Ext.apply(this.initialConfig, config)); Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.group.Panel.superclass.initComponent.apply(this, arguments); Sonia.group.Panel.superclass.initComponent.apply(this, arguments);
@@ -104,7 +104,7 @@ Sonia.group.Panel = Ext.extend(Sonia.rest.Panel, {
buttons: Ext.MessageBox.OKCANCEL, buttons: Ext.MessageBox.OKCANCEL,
icon: Ext.MessageBox.QUESTION, icon: Ext.MessageBox.QUESTION,
fn: function(result){ fn: function(result){
if ( result == 'ok' ){ if ( result === 'ok' ){
if ( debug ){ if ( debug ){
console.debug( 'remove group ' + item.name ); console.debug( 'remove group ' + item.name );

View File

@@ -38,7 +38,7 @@ Sonia.group.PropertiesFormPanel = Ext.extend(Sonia.group.FormPanel, {
fieldLabel: this.nameText, fieldLabel: this.nameText,
name: 'name', name: 'name',
allowBlank: false, allowBlank: false,
readOnly: this.item != null, readOnly: this.item !== null,
helpText: this.nameHelpText, helpText: this.nameHelpText,
vtype: 'name' vtype: 'name'
},{ },{
@@ -47,7 +47,7 @@ Sonia.group.PropertiesFormPanel = Ext.extend(Sonia.group.FormPanel, {
xtype: 'textarea', xtype: 'textarea',
helpText: this.descriptionHelpText helpText: this.descriptionHelpText
}] }]
} };
Ext.apply(this, Ext.apply(this.initialConfig, config)); Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.group.PropertiesFormPanel.superclass.initComponent.apply(this, arguments); Sonia.group.PropertiesFormPanel.superclass.initComponent.apply(this, arguments);

View File

@@ -57,7 +57,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
fieldLabel: this.nameText, fieldLabel: this.nameText,
name: 'name', name: 'name',
allowBlank: false, allowBlank: false,
readOnly: this.item != null, readOnly: this.item !== null,
helpText: this.usernameHelpText, helpText: this.usernameHelpText,
vtype: 'username' vtype: 'username'
},{ },{
@@ -75,7 +75,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
helpText: this.mailHelpText helpText: this.mailHelpText
}]; }];
if ( this.item == null || this.item.type == state.defaultUserType ){ if ( this.item === null || this.item.type === state.defaultUserType ){
items.push({ items.push({
fieldLabel: this.passwordText, fieldLabel: this.passwordText,
id: 'pwd', id: 'pwd',
@@ -115,7 +115,7 @@ Sonia.user.FormPanel = Ext.extend(Sonia.rest.FormPanel,{
}, },
isReadOnly: function(){ isReadOnly: function(){
return this.item != null && this.item.type != state.defaultUserType; return this.item !== null && this.item.type !== state.defaultUserType;
}, },
fixRequest: function(user){ fixRequest: function(user){

View File

@@ -128,13 +128,16 @@ Sonia.user.Grid = Ext.extend(Sonia.rest.Grid, {
scope: this scope: this
} }
}); });
if ( item.type == state.defaultUserType ){ if ( item.type === state.defaultUserType ){
panel.getForm().setValues([ panel.getForm().setValues([
{id: 'password', value: dummyPassword}, {id: 'password', value: dummyPassword},
{id: 'password-confirm', value: dummyPassword} {id: 'password-confirm', value: dummyPassword}
]); ]);
} }
Sonia.user.setEditPanel(panel); Sonia.user.setEditPanel([panel,{
xtype: 'permissionsPanel',
baseUrl: 'security/permission/user/' + item.name
}]);
} }
}); });

View File

@@ -34,12 +34,15 @@ Ext.ns('Sonia.user');
// functions // functions
Sonia.user.setEditPanel = function(panel){ Sonia.user.setEditPanel = function(panels){
var editPanel = Ext.getCmp('userEditPanel'); var editPanel = Ext.getCmp('userEditPanel');
editPanel.removeAll(); editPanel.removeAll();
editPanel.add(panel); Ext.each(panels, function(panel){
editPanel.add(panel);
});
editPanel.setActiveTab(0);
editPanel.doLayout(); editPanel.doLayout();
} };
/** /**
* Panels * Panels
@@ -49,6 +52,7 @@ Sonia.user.DefaultPanel = {
title: 'User Form', title: 'User Form',
padding: 5, padding: 5,
xtype: 'panel', xtype: 'panel',
bodyCssClass: 'x-panel-mc',
html: 'Add or select an User' html: 'Add or select an User'
}; };

View File

@@ -61,20 +61,20 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
xtype: 'userGrid', xtype: 'userGrid',
region: 'center', region: 'center',
parentPanel: this parentPanel: this
},{ }, {
id: 'userEditPanel', id: 'userEditPanel',
layout: 'fit', xtype: 'tabpanel',
items: [{ activeTab: 0,
region: 'south',
title: 'User Form',
xtype: 'panel',
padding: 5,
html: this.emptyText
}],
height: 250, height: 250,
split: true, split: true,
border: false, border: true,
region: 'south' region: 'south',
items: [{
bodyCssClass: 'x-panel-mc',
title: 'User Form',
padding: 5,
html: this.emptyText
}]
}] }]
}; };
@@ -103,10 +103,8 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
}, },
showAddPanel: function(){ showAddPanel: function(){
var editPanel = Ext.getCmp('userEditPanel'); Sonia.user.setEditPanel({
editPanel.removeAll(); xtype: 'userEditPanel',
var panel = new Sonia.user.FormPanel({
region: 'south',
title: this.titleText, title: this.titleText,
padding: 5, padding: 5,
onUpdate: { onUpdate: {
@@ -118,8 +116,6 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
scope: this scope: this
} }
}); });
editPanel.add(panel);
editPanel.doLayout();
}, },
resetPanel: function(){ resetPanel: function(){
@@ -140,7 +136,7 @@ Sonia.user.Panel = Ext.extend(Sonia.rest.Panel, {
buttons: Ext.MessageBox.OKCANCEL, buttons: Ext.MessageBox.OKCANCEL,
icon: Ext.MessageBox.QUESTION, icon: Ext.MessageBox.QUESTION,
fn: function(result){ fn: function(result){
if ( result == 'ok' ){ if ( result === 'ok' ){
if ( debug ){ if ( debug ){
console.debug( 'remove user ' + item.name ); console.debug( 'remove user ' + item.name );