From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui v3] StatTimeSelector: don't show invalid month/day combinations
Date: Fri, 1 Jul 2022 13:42:00 +0200 [thread overview]
Message-ID: <20220701114200.2984712-1-d.csapak@proxmox.com> (raw)
by limiting the store of the day selector by the selected month
reported by a user in the forum:
https://forum.proxmox.com/threads/wrong-calendar.111631/
Reviewed-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v2:
* got rid of unnecessary intermed. variables
* lookup instead of lookupReference
* shorter (one line) comment
* change function name to updateMaxDays
js/StatTimeSelector.js | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/js/StatTimeSelector.js b/js/StatTimeSelector.js
index f01b058..81958eb 100644
--- a/js/StatTimeSelector.js
+++ b/js/StatTimeSelector.js
@@ -73,7 +73,20 @@ Ext.define('PMG.StatTimeSelector', {
Ext.GlobalEvents.fireEvent('pmgStatTimeSelectorUpdate', data);
},
+ updateMaxDays: function() {
+ let year = this.lookup('yearsel').getValue();
+ let month = this.lookup('monthsel').getValue();
+ // get last day of current month by wrapping back day 0 from next (zero indexed) month
+ let maxDays = new Date(year, month, 0).getDate();
+ this.lookup('daysel').getStore().setFilters([{
+ property: 'day',
+ operator: '<=',
+ value: maxDays,
+ }]);
+ },
+
onSelect: function() {
+ this.updateMaxDays();
this.updateVisibility();
},
--
2.30.2
next reply other threads:[~2022-07-01 11:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-01 11:42 Dominik Csapak [this message]
2022-10-04 11:58 ` [pmg-devel] applied: " Stoiko Ivanov
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=20220701114200.2984712-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox