added remove repository method

This commit is contained in:
Sebastian Sdorra
2010-11-05 14:25:56 +01:00
parent b3c551b771
commit d7c1f60541

View File

@@ -302,7 +302,8 @@ Sonia.repository.Panel = Ext.extend(Ext.Panel, {
region:'center',
autoScroll: true,
tbar: [
{xtype: 'tbbutton', text: 'Add', scope: this, handler: this.showAddForm}
{xtype: 'tbbutton', text: 'Add', scope: this, handler: this.showAddForm},
{xtype: 'tbbutton', text: 'Remove', scope: this, handler: this.remove}
],
items: [{
id: 'repositoryGrid',
@@ -331,6 +332,61 @@ Sonia.repository.Panel = Ext.extend(Ext.Panel, {
Sonia.repository.Panel.superclass.initComponent.apply(this, arguments);
},
remove: function(){
var grid = Ext.getCmp('repositoryGrid');
var selected = grid.getSelectionModel().getSelected();
if ( selected ){
var item = selected.data;
var url = restUrl + 'repositories/' + item.id + '.json';
Ext.MessageBox.show({
title: 'Remove Repository',
msg: 'Remove Repository "' + item.name + '"?',
buttons: Ext.MessageBox.OKCANCEL,
icon: Ext.MessageBox.QUESTION,
fn: function(result){
if ( result == 'ok' ){
if ( debug ){
console.debug( 'remove repository ' + item.name );
}
Ext.Ajax.request({
url: url,
method: 'DELETE',
scope: this,
success: function(){
this.reload();
this.resetPanel();
},
failure: function(){
alert( 'failure' );
}
});
}
},
scope: this
});
} else if ( debug ){
console.debug( 'no repository selected' );
}
},
resetPanel: function(){
var editPanel = Ext.getCmp('repositoryEditPanel');
editPanel.removeAll();
editPanel.add({
region: 'south',
title: 'Repository Form',
padding: 5,
xtype: 'panel',
html: 'Add or select an Repository'
});
editPanel.doLayout();
},
showAddForm: function(){
var editPanel = Ext.getCmp('repositoryEditPanel');
editPanel.removeAll();