From 279948e95f21ffed7f890e5253693a307953d255 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 30 May 2016 15:04:51 +0500 Subject: Disable command button if device is not online. --- web/app/view/DevicesController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/view/DevicesController.js') diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 9dee0ff7c..8c1bba00f 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -103,7 +103,7 @@ Ext.define('Traccar.view.DevicesController', { var empty = selected.getCount() === 0; this.lookupReference('toolbarEditButton').setDisabled(empty); this.lookupReference('toolbarRemoveButton').setDisabled(empty); - this.lookupReference('deviceCommandButton').setDisabled(empty); + this.lookupReference('deviceCommandButton').setDisabled(empty || (selected.getLastSelected().get('status') !== 'online')); if (!empty) { this.fireEvent('selectDevice', selected.getLastSelected(), true); } -- cgit v1.2.3 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/view/DevicesController.js') 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 From d23c6649970a9ae200bff03135ee409abe5627f3 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 1 Jun 2016 10:50:10 +0500 Subject: - Handle only specific store update - Call handler directly --- web/app/view/DevicesController.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/app/view/DevicesController.js') diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index 0f8c5249f..df380e2e2 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -32,7 +32,7 @@ Ext.define('Traccar.view.DevicesController', { } }, store: { - '*': { + '#Devices': { update: 'onUpdateDevice' } } @@ -124,7 +124,7 @@ Ext.define('Traccar.view.DevicesController', { } }, - onUpdateDevice: function () { - this.view.fireEvent('selectionchange',this.view.getSelectionModel()); + onUpdateDevice: function (store, data) { + this.onSelectionChange(this.view.getSelectionModel()); } }); -- cgit v1.2.3 From 0eda3f7a23d491ddaf0a96d8802ac7ccfe38b6dd Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 1 Jun 2016 11:20:25 +0500 Subject: Use getView instead view --- web/app/view/DevicesController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/app/view/DevicesController.js') diff --git a/web/app/view/DevicesController.js b/web/app/view/DevicesController.js index df380e2e2..6b79a6804 100644 --- a/web/app/view/DevicesController.js +++ b/web/app/view/DevicesController.js @@ -125,6 +125,6 @@ Ext.define('Traccar.view.DevicesController', { }, onUpdateDevice: function (store, data) { - this.onSelectionChange(this.view.getSelectionModel()); + this.onSelectionChange(this.getView().getSelectionModel()); } }); -- cgit v1.2.3