2015-01-28 06:16:00 +08:00
|
|
|
|
|
|
|
(function () {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var
|
|
|
|
_ = require('_'),
|
|
|
|
ko = require('ko'),
|
|
|
|
|
2015-02-08 09:11:13 +08:00
|
|
|
Settings = require('Storage/Settings')
|
2015-01-28 06:16:00 +08:00
|
|
|
;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
function AccountUserStore()
|
|
|
|
{
|
2015-02-03 07:58:58 +08:00
|
|
|
this.email = ko.observable('');
|
2015-03-26 06:16:53 +08:00
|
|
|
this.parentEmail = ko.observable('');
|
2015-02-03 07:58:58 +08:00
|
|
|
// this.incLogin = ko.observable('');
|
|
|
|
// this.outLogin = ko.observable('');
|
|
|
|
|
|
|
|
this.signature = ko.observable('');
|
|
|
|
|
2015-02-02 04:46:23 +08:00
|
|
|
this.accounts = ko.observableArray([]);
|
|
|
|
this.accounts.loading = ko.observable(false).extend({'throttle': 100});
|
2015-01-28 06:16:00 +08:00
|
|
|
|
2015-02-19 03:52:52 +08:00
|
|
|
this.computers();
|
|
|
|
}
|
|
|
|
|
|
|
|
AccountUserStore.prototype.computers = function ()
|
|
|
|
{
|
2015-02-08 09:11:13 +08:00
|
|
|
this.accountsEmails = ko.computed(function () {
|
|
|
|
return _.compact(_.map(this.accounts(), function (oItem) {
|
2015-01-28 06:16:00 +08:00
|
|
|
return oItem ? oItem.email : null;
|
2015-02-08 09:11:13 +08:00
|
|
|
}));
|
2015-01-28 06:16:00 +08:00
|
|
|
}, this);
|
2015-02-02 04:46:23 +08:00
|
|
|
|
|
|
|
this.accountsUnreadCount = ko.computed(function () {
|
|
|
|
|
|
|
|
var iResult = 0;
|
|
|
|
|
2015-02-03 07:58:58 +08:00
|
|
|
// _.each(this.accounts(), function (oItem) {
|
|
|
|
// if (oItem)
|
|
|
|
// {
|
|
|
|
// iResult += oItem.count();
|
|
|
|
// }
|
|
|
|
// });
|
2015-02-02 04:46:23 +08:00
|
|
|
|
|
|
|
return iResult;
|
|
|
|
|
|
|
|
}, this);
|
2015-02-19 03:52:52 +08:00
|
|
|
};
|
2015-01-28 06:16:00 +08:00
|
|
|
|
2015-02-03 07:58:58 +08:00
|
|
|
AccountUserStore.prototype.populate = function ()
|
|
|
|
{
|
|
|
|
this.email(Settings.settingsGet('Email'));
|
2015-03-26 06:16:53 +08:00
|
|
|
this.parentEmail(Settings.settingsGet('ParentEmail'));
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2015-04-14 02:45:09 +08:00
|
|
|
* @return {boolean}
|
2015-03-26 06:16:53 +08:00
|
|
|
*/
|
|
|
|
AccountUserStore.prototype.isRootAccount = function ()
|
|
|
|
{
|
|
|
|
return '' === this.parentEmail();
|
2015-02-03 07:58:58 +08:00
|
|
|
};
|
|
|
|
|
2015-01-28 06:16:00 +08:00
|
|
|
module.exports = new AccountUserStore();
|
|
|
|
|
|
|
|
}());
|