]> git.proxmox.com Git - pmg-gui.git/commitdiff
StatTimeSelector: don't show invalid month/day combinations
authorDominik Csapak <d.csapak@proxmox.com>
Fri, 1 Jul 2022 11:42:00 +0000 (13:42 +0200)
committerStoiko Ivanov <s.ivanov@proxmox.com>
Tue, 4 Oct 2022 11:46:44 +0000 (13:46 +0200)
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>
js/StatTimeSelector.js

index f01b058e778b7aa7e0f5ad3485218fddc6ebf969..81958ebf9e4da7b66f20e09c030e8223e5cb065e 100644 (file)
@@ -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();
        },