[pmg-devel] [PATCH pmg-gui v3] StatTimeSelector: don't show invalid month/day combinations
Dominik Csapak
d.csapak at proxmox.com
Fri Jul 1 13:42:00 CEST 2022
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 at proxmox.com>
Signed-off-by: Dominik Csapak <d.csapak at 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
More information about the pmg-devel
mailing list