Skip to content
This repository has been archived by the owner on Aug 4, 2019. It is now read-only.

Commit

Permalink
Move groups post-processor to store onProxyLoad and initial sort to c…
Browse files Browse the repository at this point in the history
…onfig
  • Loading branch information
themightychris committed Sep 14, 2015
1 parent 944113a commit af9474c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
18 changes: 1 addition & 17 deletions sencha-workspace/SlateAdmin/app/controller/People.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,9 @@ Ext.define('SlateAdmin.controller.People', {
// selector: 'people-navpanel #searchOptionsForm'
}],


// controller template methods
init: function() {
var me = this,
groupStore = Ext.getStore('people.Groups'),
path, parentGroup;
var me = this;

me.control({
'people-navpanel': {
Expand Down Expand Up @@ -185,19 +182,6 @@ Ext.define('SlateAdmin.controller.People', {
// }
});

groupStore.on('load', function (group) {
groupStore.sort('LEFT', 'ASC');
groupStore.each(function(group) {
path = '';
if(group.get('ParentID')) {
parentGroup = groupStore.getById(group.get('ParentID'));
path = parentGroup.get('namesPath');
}

group.set('namesPath', path + '/' + group.get('Name'));
});
});

me.listen({
store: {
'#People': {
Expand Down
16 changes: 16 additions & 0 deletions sencha-workspace/SlateAdmin/app/store/people/Groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Ext.define('SlateAdmin.store.people.Groups', {
extend: 'Ext.data.Store',

model: 'SlateAdmin.model.person.Group',
sorters: 'Left',
proxy: {
type: 'slaterecords',
url: '/groups',
Expand All @@ -12,5 +13,20 @@ Ext.define('SlateAdmin.store.people.Groups', {
extraParams: {
parentGroup: 'any'
}
},

onProxyLoad: function(operation) {
var me = this,
i = 0, count, group, parentGroup;

me.callParent(arguments);

if (operation.wasSuccessful()) {
for (count = me.getCount(); i < count; i++) {
group = me.getAt(i);
parentGroup = me.getById(group.get('ParentID'));
group.set('namesPath', (parentGroup ? parentGroup.get('namesPath') : '') + '/' + group.get('Name'));
}
}
}
});

0 comments on commit af9474c

Please sign in to comment.