Commit ecc5203d authored by Dietmar Maurer's avatar Dietmar Maurer

do not disable the selection model

Because that reveals several bugs inside the ExtJS framework (very strange behaviour with chrome). Instead we disable/enable the whole grid.
parent 973b550e
...@@ -7,7 +7,7 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -7,7 +7,7 @@ Ext.define('PVE.dc.BackupEdit', {
me.create = !me.jobid; me.create = !me.jobid;
if (me.create) { if (me.create) {
url = '/api2/extjs/cluster/backup'; url = '/api2/extjs/cluster/backup';
method = 'POST'; method = 'POST';
} else { } else {
...@@ -31,6 +31,24 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -31,6 +31,24 @@ Ext.define('PVE.dc.BackupEdit', {
value: '' value: ''
}); });
var insideUpdate = false;
var sm = Ext.create('Ext.selection.CheckboxModel', {
mode: 'SIMPLE',
listeners: {
selectionchange: function(model, selected) {
if (!insideUpdate) { // avoid endless loop
var sel = [];
Ext.Array.each(selected, function(record) {
sel.push(record.data.vmid);
});
vmidField.setValue(sel);
}
}
}
});
var storagesel = Ext.create('PVE.form.StorageSelector', { var storagesel = Ext.create('PVE.form.StorageSelector', {
fieldLabel: 'Storage', fieldLabel: 'Storage',
nodename: 'localhost', nodename: 'localhost',
...@@ -47,6 +65,46 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -47,6 +65,46 @@ Ext.define('PVE.dc.BackupEdit', {
} }
}); });
var vmgrid = Ext.createWidget('grid', {
store: store,
border: true,
height: 300,
selModel: sm,
disabled: true,
columns: [
{
header: 'VMID',
dataIndex: 'vmid',
width: 60
},
{
header: 'Node',
dataIndex: 'node'
},
{
header: 'Status',
dataIndex: 'vmid',
dataIndex: 'uptime',
renderer: function(value) {
if (value) {
return 'running';
} else {
return 'stopped';
}
}
},
{
header: 'Name',
dataIndex: 'name',
flex: 1
},
{
header: 'VM Type',
dataIndex: 'type'
}
]
});
var nodesel = Ext.create('PVE.form.NodeSelector', { var nodesel = Ext.create('PVE.form.NodeSelector', {
name: 'node', name: 'node',
fieldLabel: 'Node', fieldLabel: 'Node',
...@@ -58,14 +116,12 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -58,14 +116,12 @@ Ext.define('PVE.dc.BackupEdit', {
change: function(f, value) { change: function(f, value) {
storagesel.setNodename(value || 'localhost'); storagesel.setNodename(value || 'localhost');
var mode = selModeField.getValue(); var mode = selModeField.getValue();
sm.setLocked(false); // else selection gets confused
store.clearFilter(); store.clearFilter();
store.filterBy(function(rec) { store.filterBy(function(rec) {
return (!value || rec.get('node') === value); return (!value || rec.get('node') === value);
}); });
if (mode === 'all') { if (mode === 'all') {
sm.selectAll(true); sm.selectAll(true);
sm.setLocked(true);
} }
} }
} }
...@@ -157,24 +213,6 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -157,24 +213,6 @@ Ext.define('PVE.dc.BackupEdit', {
} }
}); });
var insideUpdate = false;
var sm = Ext.create('Ext.selection.CheckboxModel', {
mode: 'SIMPLE',
listeners: {
selectionchange: function(model, selected) {
if (!insideUpdate) { // avoid endless loop
var sel = [];
Ext.Array.each(selected, function(record) {
sel.push(record.data.vmid);
});
vmidField.setValue(sel);
}
}
}
});
var update_vmid_selection = function(list, mode) { var update_vmid_selection = function(list, mode) {
if (insideUpdate) { if (insideUpdate) {
return; // should not happen - just to be sure return; // should not happen - just to be sure
...@@ -202,9 +240,9 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -202,9 +240,9 @@ Ext.define('PVE.dc.BackupEdit', {
selModeField.on('change', function(f, value, oldValue) { selModeField.on('change', function(f, value, oldValue) {
if (value === 'all') { if (value === 'all') {
sm.selectAll(true); sm.selectAll(true);
sm.setLocked(true); vmgrid.setDisabled(true);
} else { } else {
sm.setLocked(false); vmgrid.setDisabled(false);
} }
if (oldValue === 'all') { if (oldValue === 'all') {
sm.deselectAll(true); sm.deselectAll(true);
...@@ -215,7 +253,6 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -215,7 +253,6 @@ Ext.define('PVE.dc.BackupEdit', {
}); });
var reload = function() { var reload = function() {
sm.setLocked(false);
store.load({ store.load({
params: { type: 'vm' }, params: { type: 'vm' },
callback: function() { callback: function() {
...@@ -227,9 +264,7 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -227,9 +264,7 @@ Ext.define('PVE.dc.BackupEdit', {
var list = vmidField.getValue(); var list = vmidField.getValue();
var mode = selModeField.getValue(); var mode = selModeField.getValue();
if (mode === 'all') { if (mode === 'all') {
sm.setLocked(false);
sm.selectAll(true); sm.selectAll(true);
sm.setLocked(true);
} else { } else {
update_vmid_selection(list, mode); update_vmid_selection(list, mode);
} }
...@@ -241,48 +276,7 @@ Ext.define('PVE.dc.BackupEdit', { ...@@ -241,48 +276,7 @@ Ext.define('PVE.dc.BackupEdit', {
title: me.create ? "Create Backup Job" : "Edit Backup Job", title: me.create ? "Create Backup Job" : "Edit Backup Job",
url: url, url: url,
method: method, method: method,
items: [ items: [ ipanel, vmgrid ]
ipanel,
{
xtype: 'grid',
store: store,
border: true,
height: 300,
selModel: sm,
columns: [
{
header: 'VMID',
dataIndex: 'vmid',
width: 60
},
{
header: 'Node',
dataIndex: 'node'
},
{
header: 'Status',
dataIndex: 'vmid',
dataIndex: 'uptime',
renderer: function(value) {
if (value) {
return 'running';
} else {
return 'stopped';
}
}
},
{
header: 'Name',
dataIndex: 'name',
flex: 1
},
{
header: 'VM Type',
dataIndex: 'type'
}
]
}
]
}); });
me.callParent(); me.callParent();
......
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