From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 3/5] APTRepositories: change updating button text/state to viewcontroller
Date: Wed, 30 Jun 2021 17:14:57 +0200 [thread overview]
Message-ID: <20210630151459.231895-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210630151459.231895-1-d.csapak@proxmox.com>
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>
---
src/node/APTRepositories.js | 41 ++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js
index 1985e50..23cd984 100644
--- a/src/node/APTRepositories.js
+++ b/src/node/APTRepositories.js
@@ -81,6 +81,9 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
altText: gettext('Disable'),
id: 'repoEnableButton',
disabled: true,
+ bind: {
+ text: '{enableButtonText}',
+ },
handler: function(button, event, record) {
let me = this;
let panel = me.up('proxmoxNodeAPTRepositories');
@@ -290,19 +293,6 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', {
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', {
@@ -314,6 +304,20 @@ Ext.define('Proxmox.node.APTRepositories', {
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: {
data: {
product: 'Proxmox VE', // default
@@ -321,9 +325,12 @@ Ext.define('Proxmox.node.APTRepositories', {
subscriptionActive: '',
noSubscriptionRepo: '',
enterpriseRepo: '',
+ selectionenabled: false,
},
formulas: {
noErrors: (get) => get('errorCount') === 0,
+ enableButtonText: (get) => get('selectionenabled')
+ ? gettext('Disable') : gettext('Enable'),
mainWarning: function(get) {
// Not yet initialized
if (get('subscriptionActive') === '' ||
@@ -390,12 +397,8 @@ Ext.define('Proxmox.node.APTRepositories', {
nodename: '{nodename}',
},
majorUpgradeAllowed: false, // TODO get release information from an API call?
- onSelectionChange: function(rec, sm) {
- let me = this;
- if (rec) {
- let btn = me.up('proxmoxNodeAPTRepositories').down('#repoEnableButton');
- btn.setText(rec.get('Enabled') ? gettext('Disable') : gettext('Enable'));
- }
+ listeners: {
+ selectionchange: 'selectionChange',
},
},
],
--
2.30.2
next prev parent reply other threads:[~2021-06-30 15:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-30 15:14 [pve-devel] [PATCH widget-toolkit 0/5] some APTRepositories improvements Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 1/5] APTRepositories: change separation style between panels Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 2/5] APTRepositories: make panel scrollable Dominik Csapak
2021-06-30 15:14 ` Dominik Csapak [this message]
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 4/5] APTRepositories: make the Suites warnings inline errors Dominik Csapak
2021-06-30 15:14 ` [pve-devel] [PATCH widget-toolkit 5/5] APTRepositories: remove unecessary selection model Dominik Csapak
2021-06-30 19:36 ` [pve-devel] applied-series: [PATCH widget-toolkit 0/5] some APTRepositories improvements Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210630151459.231895-4-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal