Commit 94693266 authored by Dietmar Maurer's avatar Dietmar Maurer

use new button class

parent fe212ada
...@@ -203,6 +203,8 @@ Ext.define('PVE.storage.ContentView', { ...@@ -203,6 +203,8 @@ Ext.define('PVE.storage.ContentView', {
} }
}); });
var sm = Ext.create('Ext.selection.RowModel', {});
var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{ var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: 'ContentType: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})' groupHeaderTpl: 'ContentType: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
}); });
...@@ -211,53 +213,9 @@ Ext.define('PVE.storage.ContentView', { ...@@ -211,53 +213,9 @@ Ext.define('PVE.storage.ContentView', {
store.load(); store.load();
}; };
var remove_btn = new Ext.Button({ Ext.apply(me, {
text: 'Delete',
disabled: true,
handler: function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec) {
return;
}
var volid = rec.data.volid;
var msg = 'Are you sure you want to delete volume "' + volid + '"';
Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
if (btn !== 'yes') {
return;
}
PVE.Utils.API2Request({
url: baseurl + '/' + volid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
});
}
});
var set_button_status = function() {
var sm = me.getSelectionModel();
var rec = sm.getSelection()[0];
if (!rec || rec.data.content === 'images') {
remove_btn.setDisabled(true);
return;
}
remove_btn.setDisabled(false);
};
Ext.apply(me, {
store: store, store: store,
selModel: sm,
stateful: false, stateful: false,
viewConfig: { viewConfig: {
trackOver: false trackOver: false
...@@ -267,7 +225,31 @@ Ext.define('PVE.storage.ContentView', { ...@@ -267,7 +225,31 @@ Ext.define('PVE.storage.ContentView', {
{ {
text: 'Restore' text: 'Restore'
}, },
remove_btn, {
xtype: 'pveButton',
text: 'Delete',
selModel: sm,
disabled: true,
confirmMsg: function(rec) {
return 'Are you sure you want to delete volume "' + rec.data.volid + '"';
},
enableFn: function(rec) {
return rec && rec.data.content !== 'images';
},
handler: function(b, e, rec) {
PVE.Utils.API2Request({
url: baseurl + '/' + rec.data.volid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
reload();
},
failure: function (response, opts) {
Ext.Msg.alert('Error', response.htmlStatus);
}
});
}
},
{ {
text: 'Upload', text: 'Upload',
handler: function() { handler: function() {
...@@ -301,8 +283,7 @@ Ext.define('PVE.storage.ContentView', { ...@@ -301,8 +283,7 @@ Ext.define('PVE.storage.ContentView', {
} }
], ],
listeners: { listeners: {
show: reload, show: reload
selectionchange: set_button_status
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment