From e6a635ac7a1ef8b674da1a01f024a4a58375e487 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 1 Jun 2016 10:20:49 +0500 Subject: Handle store update event in right place --- web/app/store/Devices.js | 6 ------ web/app/view/Devices.js | 1 - web/app/view/DevicesController.js | 9 +++++++++ 3 files changed, 9 insertions(+), 7 deletions(-) (limited to 'web/app') diff --git a/web/app/store/Devices.js b/web/app/store/Devices.js index 5084ff554..8ba513792 100644 --- a/web/app/store/Devices.js +++ b/web/app/store/Devices.js @@ -24,11 +24,5 @@ Ext.define('Traccar.store.Devices', { writer: { writeAllFields: true } - }, - listeners : { - update: function () { - devicesPanel = Ext.getCmp('devicesPanel'); - devicesPanel.fireEvent('selectionchange',devicesPanel.getSelectionModel()); - } } }); diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index 31eead2f7..f06c2658b 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -17,7 +17,6 @@ Ext.define('Traccar.view.Devices', { extend: 'Ext.grid.Panel', xtype: 'devicesView', - id: 'devicesPanel', requires: [ 'Traccar.view.DevicesController', diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 8c1bba00f..0f8c5249f 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -30,6 +30,11 @@ Ext.define('Traccar.view.DevicesController', { selectDevice: 'selectDevice', selectReport: 'selectReport' } + }, + store: { + '*': { + update: 'onUpdateDevice' + } } } }, @@ -117,5 +122,9 @@ Ext.define('Traccar.view.DevicesController', { if (position !== undefined) { this.getView().getSelectionModel().deselectAll(); } + }, + + onUpdateDevice: function () { + this.view.fireEvent('selectionchange',this.view.getSelectionModel()); } }); -- cgit v1.2.3