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', {
}
});
var sm = Ext.create('Ext.selection.RowModel', {});
var groupingFeature = Ext.create('Ext.grid.feature.Grouping',{
groupHeaderTpl: 'ContentType: {name} ({rows.length} Item{[values.rows.length > 1 ? "s" : ""]})'
});
......@@ -211,26 +213,32 @@ Ext.define('PVE.storage.ContentView', {
store.load();
};
var remove_btn = new Ext.Button({
Ext.apply(me, {
store: store,
selModel: sm,
stateful: false,
viewConfig: {
trackOver: false
},
features: [ groupingFeature ],
tbar: [
{
text: 'Restore'
},
{
xtype: 'pveButton',
text: 'Delete',
selModel: sm,
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;
}
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 + '/' + volid,
url: baseurl + '/' + rec.data.volid,
method: 'DELETE',
waitMsgTarget: me,
callback: function() {
......@@ -240,34 +248,8 @@ Ext.define('PVE.storage.ContentView', {
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,
stateful: false,
viewConfig: {
trackOver: false
},
features: [ groupingFeature ],
tbar: [
{
text: 'Restore'
},
remove_btn,
{
text: 'Upload',
handler: function() {
......@@ -301,8 +283,7 @@ Ext.define('PVE.storage.ContentView', {
}
],
listeners: {
show: reload,
selectionchange: set_button_status
show: reload
}
});
......
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