mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-05-29 13:51:50 +00:00
APTRepositories: change updating button text/state to viewcontroller
we already have a viewmodel we can use, and so the handler does not have to navigate the component tree up/down Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
82071150f7
commit
003c49829d
@ -188,6 +188,9 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
|
|||||||
altText: gettext('Disable'),
|
altText: gettext('Disable'),
|
||||||
id: 'repoEnableButton',
|
id: 'repoEnableButton',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
|
bind: {
|
||||||
|
text: '{enableButtonText}',
|
||||||
|
},
|
||||||
handler: function(button, event, record) {
|
handler: function(button, event, record) {
|
||||||
let me = this;
|
let me = this;
|
||||||
let panel = me.up('proxmoxNodeAPTRepositories');
|
let panel = me.up('proxmoxNodeAPTRepositories');
|
||||||
@ -406,19 +409,6 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
|
|||||||
|
|
||||||
me.callParent();
|
me.callParent();
|
||||||
},
|
},
|
||||||
|
|
||||||
listeners: {
|
|
||||||
selectionchange: function() {
|
|
||||||
let me = this;
|
|
||||||
|
|
||||||
if (me.onSelectionChange) {
|
|
||||||
let sm = me.getSelectionModel();
|
|
||||||
let rec = sm.getSelection()[0];
|
|
||||||
|
|
||||||
me.onSelectionChange(rec, sm);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Ext.define('Proxmox.node.APTRepositories', {
|
Ext.define('Proxmox.node.APTRepositories', {
|
||||||
@ -430,6 +420,20 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
|
|
||||||
product: 'Proxmox VE', // default
|
product: 'Proxmox VE', // default
|
||||||
|
|
||||||
|
controller: {
|
||||||
|
xclass: 'Ext.app.ViewController',
|
||||||
|
|
||||||
|
selectionChange: function(grid, selection) {
|
||||||
|
let me = this;
|
||||||
|
if (!selection || selection.length < 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let rec = selection[0];
|
||||||
|
let vm = me.getViewModel();
|
||||||
|
vm.set('selectionenabled', rec.get('Enabled'));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
viewModel: {
|
viewModel: {
|
||||||
data: {
|
data: {
|
||||||
product: 'Proxmox VE', // default
|
product: 'Proxmox VE', // default
|
||||||
@ -437,9 +441,12 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
subscriptionActive: '',
|
subscriptionActive: '',
|
||||||
noSubscriptionRepo: '',
|
noSubscriptionRepo: '',
|
||||||
enterpriseRepo: '',
|
enterpriseRepo: '',
|
||||||
|
selectionenabled: false,
|
||||||
},
|
},
|
||||||
formulas: {
|
formulas: {
|
||||||
noErrors: (get) => get('errorCount') === 0,
|
noErrors: (get) => get('errorCount') === 0,
|
||||||
|
enableButtonText: (get) => get('selectionenabled')
|
||||||
|
? gettext('Disable') : gettext('Enable'),
|
||||||
mainWarning: function(get) {
|
mainWarning: function(get) {
|
||||||
// Not yet initialized
|
// Not yet initialized
|
||||||
if (get('subscriptionActive') === '' ||
|
if (get('subscriptionActive') === '' ||
|
||||||
@ -506,12 +513,8 @@ Ext.define('Proxmox.node.APTRepositories', {
|
|||||||
nodename: '{nodename}',
|
nodename: '{nodename}',
|
||||||
},
|
},
|
||||||
majorUpgradeAllowed: false, // TODO get release information from an API call?
|
majorUpgradeAllowed: false, // TODO get release information from an API call?
|
||||||
onSelectionChange: function(rec, sm) {
|
listeners: {
|
||||||
let me = this;
|
selectionchange: 'selectionChange',
|
||||||
if (rec) {
|
|
||||||
let btn = me.up('proxmoxNodeAPTRepositories').down('#repoEnableButton');
|
|
||||||
btn.setText(rec.get('Enabled') ? gettext('Disable') : gettext('Enable'));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user