Sortable accounts list

This commit is contained in:
RainLoop Team 2015-01-28 02:16:00 +04:00
parent 965ea317e4
commit b563528be7
10 changed files with 150 additions and 28 deletions

View file

@ -0,0 +1,44 @@
(function () {
'use strict';
var
_ = require('_'),
ko = require('ko'),
Remote = require('Storage/User/Remote')
;
/**
* @constructor
*/
function AccountUserStore()
{
this.loading = ko.observable(false).extend({'throttle': 100});
this.collection = ko.observableArray([]);
this.collectionEmailNames = ko.observableArray([]).extend({'throttle': 1000});
this.collectionEmailNames.skipFirst = true;
this.collection.subscribe(function (aList) {
this.collectionEmailNames(_.compact(_.map(aList, function (oItem) {
return oItem ? oItem.email : null;
})));
}, this);
this.collectionEmailNames.subscribe(function (aList) {
if (this.collectionEmailNames.skipFirst)
{
this.collectionEmailNames.skipFirst = false;
}
else if (aList && 1 < aList.length)
{
Remote.accountSortOrder(null, aList);
}
}, this);
}
module.exports = new AccountUserStore();
}());