toggle remove and archive button

This commit is contained in:
Sebastian Sdorra
2012-03-30 10:32:48 +02:00
parent e79eeb9028
commit a5c5b4b7ff
2 changed files with 42 additions and 4 deletions

View File

@@ -196,6 +196,8 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
groupTextTpl: '{group} ({[values.rs.length]} {[values.rs.length > 1 ? "Repositories" : "Repository"]})'
})
};
this.addEvents('repositorySelected');
Ext.apply(this, Ext.apply(this.initialConfig, config));
Sonia.repository.Grid.superclass.initComponent.apply(this, arguments);
@@ -324,6 +326,9 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
}
},
/**
* TODO move to panel
*/
selectItem: function(item){
if ( debug ){
console.debug( item.name + ' selected' );
@@ -332,14 +337,17 @@ Sonia.repository.Grid = Ext.extend(Sonia.rest.Grid, {
if ( this.parentPanel ){
this.parentPanel.updateHistory(item);
}
var owner = Sonia.repository.isOwner(item);
this.fireEvent('repositorySelected', item, owner);
var infoPanel = main.getInfoPanel(item.type);
infoPanel.item = item;
var panels = [infoPanel];
if ( Sonia.repository.isOwner(item) ){
Ext.getCmp('repoRmButton').setDisabled(false);
if ( owner ){
panels.push({
item: item,
xtype: 'repositorySettingsForm',

View File

@@ -37,6 +37,7 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
// TODO i18n
archiveText: 'Archive',
unarchiveText: 'Unarchive',
archiveTitleText: 'Archive Repository',
archiveMsgText: 'Archive Repository "{0}"?',
errorArchiveMsgText: 'Repository archival failed',
@@ -83,7 +84,7 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
toolbar.push({
xtype: 'tbbutton',
id: 'repoArchiveButton',
disabled: false,
disabled: true,
text: this.archiveText,
// TODO find icon
icon: this.removeIcon,
@@ -173,7 +174,13 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
id: 'repositoryGrid',
xtype: 'repositoryGrid',
region: 'center',
parentPanel: this
parentPanel: this,
listeners: {
repositorySelected: {
fn: this.onRepositorySelection,
scope: this
}
}
},{
id: 'repositoryEditPanel',
xtype: 'tabpanel',
@@ -328,6 +335,29 @@ Sonia.repository.Panel = Ext.extend(Sonia.rest.Panel, {
);
}
},
onRepositorySelection: function(item, owner){
if ( owner ){
if (state.clientConfig.enableRepositoryArchive){
var archiveBt = Ext.getCmp('repoArchiveButton');
if ( item.archived ){
archiveBt.setText(this.unarchiveText);
Ext.getCmp('repoRmButton').setDisabled(false);
} else {
archiveBt.setText(this.archiveText);
Ext.getCmp('repoRmButton').setDisabled(true);
}
archiveBt.setDisabled(false);
} else {
Ext.getCmp('repoRmButton').setDisabled(false);
}
} else {
Ext.getCmp('repoRmButton').setDisabled(false);
if (state.clientConfig.enableRepositoryArchive){
Ext.getCmp('repoArchiveButton').setDisabled(false);
}
}
},
resetPanel: function(){
Sonia.repository.setEditPanel(Sonia.repository.DefaultPanel);