]> git.proxmox.com Git - extjs.git/blob - extjs/templates/admin-dashboard/classic/src/view/email/FriendsListViewController.js
add extjs 6.0.1 sources
[extjs.git] / extjs / templates / admin-dashboard / classic / src / view / email / FriendsListViewController.js
1 Ext.define('Admin.view.email.FriendsListViewController', {
2 extend: 'Ext.app.ViewController',
3 alias: 'controller.emailfriendslist',
4
5 init: function() {
6 var me = this,
7 friendsStore = me.getViewModel().getStore('friends');
8
9 //Trigger local sorting once new data is available
10 friendsStore.on('load', function (store) {
11 store.sort();
12 });
13
14 //Sort locally and then update menu
15 friendsStore.on('sort', function (store) {
16 me.mutateData(store, store.getRange());
17 });
18
19 me.callParent(arguments);
20 },
21
22 mutateData: function (store, records) {
23 var view = this.getView(),
24 arr = [],
25 len = records.length,
26 i;
27
28 for (i = 0; i < len; i++) {
29 arr.push({
30 xtype: 'menuitem',
31 text : records[i].get('name'),
32 cls: 'font-icon ' + (records[i].get('online') ? 'online-user' : 'offline-user')
33 });
34 }
35
36 Ext.suspendLayouts();
37 view.removeAll(true);
38 view.add(arr);
39 Ext.resumeLayouts(true);
40 }
41 });