From a09d2276f093504f8ab07bfadf0fbb3854ce5292 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 30 Aug 2016 09:02:21 +0500 Subject: Disable buttons if report not configured --- web/app/view/Report.js | 2 ++ web/app/view/ReportConfigController.js | 1 + web/app/view/ReportController.js | 11 +++++++++++ 3 files changed, 14 insertions(+) (limited to 'web/app') diff --git a/web/app/view/Report.js b/web/app/view/Report.js index 161ac4c64..02513c05f 100644 --- a/web/app/view/Report.js +++ b/web/app/view/Report.js @@ -46,10 +46,12 @@ Ext.define('Traccar.view.Report', { }, '-', { text: Strings.reportShow, reference: 'showButton', + disabled: true, handler: 'onReportClick' }, { text: Strings.reportCsv, reference: 'csvButton', + disabled: true, handler: 'onReportClick' }, { text: Strings.reportClear, diff --git a/web/app/view/ReportConfigController.js b/web/app/view/ReportConfigController.js index 2ee68ea9f..d98690e95 100644 --- a/web/app/view/ReportConfigController.js +++ b/web/app/view/ReportConfigController.js @@ -54,6 +54,7 @@ Ext.define('Traccar.view.ReportConfigController', { this.getView().callingPanel.fromTime = this.lookupReference('fromTimeField').getValue(); this.getView().callingPanel.toDate = this.lookupReference('toDateField').getValue(); this.getView().callingPanel.toTime = this.lookupReference('toTimeField').getValue(); + this.getView().callingPanel.updateButtons(); button.up('window').close(); } }); diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 0247c96a9..6f998396c 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -60,6 +60,15 @@ Ext.define('Traccar.view.ReportController', { dialog.show(); }, + updateButtons: function () { + var reportType, disabled, devices; + reportType = this.lookupReference('reportTypeField').getValue(); + devices = this.deviceId && this.deviceId.length !== 0 || this.groupId && this.groupId.length !== 0; + disabled = !reportType || !devices; + this.lookupReference('showButton').setDisabled(disabled); + this.lookupReference('csvButton').setDisabled(disabled); + }, + onReportClick: function (button) { var reportType, from, to, store, url; @@ -324,6 +333,8 @@ Ext.define('Traccar.view.ReportController', { } else if (newValue === 'trips') { this.getView().reconfigure('ReportTrips', tripsColumns); } + + this.updateButtons(); } }); -- cgit v1.2.3