From 38ea2292b1650c6cdfdce5096ab7258dcd8cb29b Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 7 Jun 2015 18:29:19 +1200 Subject: Add row selection events --- web/app/view/device/DeviceController.js | 9 ++++++--- web/app/view/map/MapController.js | 12 +++++++++++- web/app/view/report/Report.js | 4 ++++ web/app/view/report/ReportController.js | 6 ++++++ 4 files changed, 27 insertions(+), 4 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/device/DeviceController.js b/web/app/view/device/DeviceController.js index f45f348b6..158f6c52c 100644 --- a/web/app/view/device/DeviceController.js +++ b/web/app/view/device/DeviceController.js @@ -71,9 +71,12 @@ Ext.define('Traccar.view.device.DeviceController', { }, onSelectionChange: function(selected) { - var disabled = selected.length > 0; - this.lookupReference('deviceEditButton').setDisabled(disabled); - this.lookupReference('deviceRemoveButton').setDisabled(disabled); + var empty = selected.getCount() === 0; + this.lookupReference('deviceEditButton').setDisabled(empty); + this.lookupReference('deviceRemoveButton').setDisabled(empty); + if (!empty) { + this.fireEvent("selectDevice", selected.getLastSelected()); + } }, onUserClick: function() { diff --git a/web/app/view/map/MapController.js b/web/app/view/map/MapController.js index 2564335c9..e9757daac 100644 --- a/web/app/view/map/MapController.js +++ b/web/app/view/map/MapController.js @@ -23,7 +23,9 @@ Ext.define('Traccar.view.map.MapController', { controller: { '*': { reportShow: 'reportShow', - reportClear: 'reportClear' + reportClear: 'reportClear', + selectDevice: 'selectDevice', + selectReport: 'selectReport' } } } @@ -139,6 +141,14 @@ Ext.define('Traccar.view.map.MapController', { vectorSource.removeFeature(this.reportRoute); vectorSource.removeFeature(this.reportStart); vectorSource.addFeature(this.reportFinish); + }, + + selectDevice: function(device) { + console.log(device); // DELME + }, + + selectReport: function(position) { + console.log(position); // DELME } }); diff --git a/web/app/view/report/Report.js b/web/app/view/report/Report.js index 55c8bf0e7..df8843a55 100644 --- a/web/app/view/report/Report.js +++ b/web/app/view/report/Report.js @@ -70,6 +70,10 @@ Ext.define('Traccar.view.report.Report', { handler: 'onClearClick' }], + listeners: { + selectionchange: 'onSelectionChange' + }, + columns: [ { text: strings.report_valid, dataIndex: 'valid', flex: 1 }, { text: strings.report_time, dataIndex: 'fixTime', flex: 1, xtype: 'datecolumn', format: styles.report_format }, diff --git a/web/app/view/report/ReportController.js b/web/app/view/report/ReportController.js index 415cdfe3a..daeb8ddfc 100644 --- a/web/app/view/report/ReportController.js +++ b/web/app/view/report/ReportController.js @@ -52,6 +52,12 @@ Ext.define('Traccar.view.report.ReportController', { onClearClick: function() { Ext.getStore('Positions').removeAll(); this.fireEvent("reportClear"); + }, + + onSelectionChange: function(selected) { + if (selected.getCount() > 0) { + this.fireEvent("selectReport", selected.getLastSelected()); + } } }); -- cgit v1.2.3