From 9d159c880ab0fdb3f6f632dcb80577c6c2fb2f11 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 15 Oct 2015 16:28:42 +1300 Subject: Load and select user device list --- web/app/view/UserDevicesController.js | 24 +++++++++++++++++++++++- web/app/view/UsersController.js | 4 +++- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'web') diff --git a/web/app/view/UserDevicesController.js b/web/app/view/UserDevicesController.js index a0b3de36d..aefc9d83e 100644 --- a/web/app/view/UserDevicesController.js +++ b/web/app/view/UserDevicesController.js @@ -19,7 +19,29 @@ Ext.define('Traccar.view.UserDevicesController', { alias: 'controller.userDevices', init: function () { - this.getView().getStore().load(); + console.log(this.getView().user.getData().id); + this.getView().getStore().load({ + scope: this, + callback: function (records, operation, success) { + var userStore = Ext.create('Traccar.store.Devices'); + + userStore.load({ + params: { + userId: this.getView().user.getData().id + }, + scope: this, + callback: function (records, operation, success) { + var i, index; + if (success) { + for (i = 0; i < records.length; i++) { + index = this.getView().getStore().find('id', records[i].getData().id); + this.getView().getSelectionModel().select(index, true, true); + } + } + } + }); + } + }); }, onSelectionChange: function (selected) { diff --git a/web/app/view/UsersController.js b/web/app/view/UsersController.js index cfcf17fe1..30eb8b1a5 100644 --- a/web/app/view/UsersController.js +++ b/web/app/view/UsersController.js @@ -65,10 +65,12 @@ Ext.define('Traccar.view.UsersController', { }, onDevicesClick: function () { + var user = this.getView().getSelectionModel().getSelection()[0]; Ext.create('Traccar.view.BaseWindow', { title: Strings.deviceTitle, items: { - xtype: 'userDevicesView' + xtype: 'userDevicesView', + user: user } }).show(); }, -- cgit v1.2.3