Autocreate system folders in folder list request.

Additional plugin hooks
This commit is contained in:
RainLoop Team 2013-12-18 03:00:57 +04:00
parent 972067b6d9
commit 394e22520e
19 changed files with 357 additions and 288 deletions

View file

@ -164,18 +164,17 @@ RainLoopApp.prototype.recacheInboxMessageList = function ()
};
/**
* @param {boolean=} bUseCache = true
* @param {Function=} fCallback
*/
RainLoopApp.prototype.folders = function (bUseCache, fCallback)
RainLoopApp.prototype.folders = function (fCallback)
{
this.data().foldersLoading(true);
this.remote().folders(_.bind(function (sResult, oData, bCached) {
this.remote().folders(_.bind(function (sResult, oData) {
RL.data().foldersLoading(false);
if (Enums.StorageResultType.Success === sResult)
{
this.data().setFolders(oData, bCached);
this.data().setFolders(oData);
if (fCallback)
{
fCallback(true);
@ -188,7 +187,7 @@ RainLoopApp.prototype.folders = function (bUseCache, fCallback)
fCallback(false);
}
}
}, this), bUseCache);
}, this));
};
RainLoopApp.prototype.accountsAndIdentities = function ()
@ -775,7 +774,7 @@ RainLoopApp.prototype.bootstart = function ()
{
this.setTitle(Utils.i18n('TITLES/LOADING'));
this.folders(true, _.bind(function (bValue) {
this.folders(_.bind(function (bValue) {
kn.hideLoading();

View file

@ -45,10 +45,6 @@ function FolderModel()
}
}, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type();
}, this);
this.privateMessageCountAll = ko.observable(0);
this.privateMessageCountUnread = ko.observable(0);
@ -77,6 +73,10 @@ FolderModel.prototype.initComputed = function ()
});
}, this);
this.canBeEdited = ko.computed(function () {
return Enums.FolderType.User === this.type() && this.existen && this.selectable;
}, this);
this.visible = ko.computed(function () {
var
bSubScribed = this.subScribed(),

View file

@ -95,7 +95,7 @@ SettingsFolders.prototype.folderEditOnEnter = function (oFolder)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_RENAME_FOLDER'));
}
RL.folders(false);
RL.folders();
}, oFolder.fullNameRaw, sEditName);
@ -166,7 +166,7 @@ SettingsFolders.prototype.deleteFolder = function (oFolderToRemove)
oData && oData.ErrorCode ? Utils.getNotification(oData.ErrorCode) : Utils.i18n('NOTIFICATIONS/CANT_DELETE_FOLDER'));
}
RL.folders(false);
RL.folders();
}, oFolderToRemove.fullNameRaw);

View file

@ -15,21 +15,15 @@ _.extend(WebMailAjaxRemoteStorage.prototype, AbstractAjaxRemoteStorage.prototype
/**
* @param {?Function} fCallback
* @param {boolean=} bUseCache = true
*/
WebMailAjaxRemoteStorage.prototype.folders = function (fCallback, bUseCache)
WebMailAjaxRemoteStorage.prototype.folders = function (fCallback)
{
var sFoldersHash = RL.data().lastFoldersHash;
bUseCache = Utils.isUnd(bUseCache) ? false : !!bUseCache;
if (bUseCache && '' !== sFoldersHash)
{
this.defaultRequest(fCallback, 'Folders', {}, null, 'Folders/' + RL.data().projectHash() + '-' + sFoldersHash, ['Folders']);
}
else
{
this.defaultRequest(fCallback, 'Folders', {}, null, '', ['Folders']);
}
this.defaultRequest(fCallback, 'Folders', {
'SentFolder': RL.settingsGet('SentFolder'),
'DraftFolder': RL.settingsGet('DraftFolder'),
'SpamFolder': RL.settingsGet('SpamFolder'),
'TrashFolder': RL.settingsGet('TrashFolder')
}, null, '', ['Folders']);
};
/**

View file

@ -486,10 +486,9 @@ WebMailDataStorage.prototype.initUidNextAndNewMessages = function (sFolder, sUid
/**
* @param {string} sNamespace
* @param {Array} aFolders
* @param {boolean} bCached
* @return {Array}
*/
WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders, bCached)
WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFolders)
{
var
iIndex = 0,
@ -501,8 +500,6 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aList = []
;
bCached = !!bCached;
for (iIndex = 0, iLen = aFolders.length; iIndex < iLen; iIndex++)
{
oFolder = aFolders[iIndex];
@ -536,7 +533,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
{
oCacheFolder.collapsed(!Utils.isFolderExpanded(oCacheFolder.fullNameHash));
if (!bCached && oFolder.Extended)
if (oFolder.Extended)
{
if (oFolder.Extended.Hash)
{
@ -559,7 +556,7 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
aSubFolders['@Collection'] && Utils.isArray(aSubFolders['@Collection']))
{
oCacheFolder.subFolders(
this.folderResponseParseRec(sNamespace, aSubFolders['@Collection'], bCached));
this.folderResponseParseRec(sNamespace, aSubFolders['@Collection']));
}
aList.push(oCacheFolder);
@ -572,16 +569,13 @@ WebMailDataStorage.prototype.folderResponseParseRec = function (sNamespace, aFol
/**
* @param {*} oData
* @param {boolean=} bCached = false
*/
WebMailDataStorage.prototype.setFolders = function (oData, bCached)
WebMailDataStorage.prototype.setFolders = function (oData)
{
var
aList = [],
bUpdate = false,
oRLData = RL.data(),
aFolders = oRLData.folderList(),
bFoldersFirst = 0 === aFolders.length,
fNormalizeFolder = function (sFolderFullNameRaw) {
return ('' === sFolderFullNameRaw || Consts.Values.UnuseOptionValue === sFolderFullNameRaw ||
null !== RL.cache().getFolderFromCacheList(sFolderFullNameRaw)) ? sFolderFullNameRaw : '';
@ -598,12 +592,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
this.threading(!!RL.settingsGet('UseImapThread') && oData.Result.IsThreadsSupported && true);
aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection'], !!bCached);
aList = this.folderResponseParseRec(oRLData.namespace, oData.Result['@Collection']);
oRLData.folderList(aList);
if (oData.Result['SystemFolders'] &&
'' === '' + RL.settingsGet('SentFolder') + RL.settingsGet('DraftFolder') +
RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder'))
RL.settingsGet('SpamFolder') + RL.settingsGet('TrashFolder') + RL.settingsGet('NullFolder'))
{
// TODO Magic Numbers
RL.settingsSet('SentFolder', oData.Result['SystemFolders'][2] || null);
@ -625,19 +619,12 @@ WebMailDataStorage.prototype.setFolders = function (oData, bCached)
'SentFolder': oRLData.sentFolder(),
'DraftFolder': oRLData.draftFolder(),
'SpamFolder': oRLData.spamFolder(),
'TrashFolder': oRLData.trashFolder()
'TrashFolder': oRLData.trashFolder(),
'NullFolder': 'NullFolder'
});
}
if (!bCached)
{
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
}
if (bFoldersFirst && bCached)
{
RL.folders(false);
}
RL.local().set(Enums.ClientSideKeyName.FoldersLashHash, oData.Result.FoldersHash);
}
};

View file

@ -1,104 +1,125 @@
.folderPaddingHelper(@i) {
(~".folder-padding.deep-@{i}") {
width: 15px * @i + 10px;
}
}
.b-settings-folders {
&.ignore-folder-subscribe {
.subscribe-folder, .unsubscribe-folder {
display: none;
}
}
.process-place {
text-align: center;
width: 600px;
padding: 14px 0;
}
.folders-list-error {
width: 550px;
margin: 10px 0px;
}
.list-table {
width: 600px;
.e-action {
cursor: pointer;
}
td {
padding: 4px 8px;
line-height: 30px;
}
.folder-padding {
display: inline-block;
width: 0;
}
.folder-name {
display: inline-block;
word-break: break-all;
.box-sizing(border-box);
margin-left: 7px;
line-height: 22px;
cursor: default;
}
.folder-system-name {
display: inline-block;
line-height: 22px;
color: #999;
cursor: default;
}
.folder-name.can-be-edited:hover {
border-bottom: 1px dashed #333;
cursor: pointer;
}
.folder-name-input {
border-width: 1px;
margin-bottom: 0;
}
}
.folder-item {
.button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
.opacity(0);
}
.delete-access {
&.button-delete {
visibility: visible;
margin-right: 0;
.opacity(100);
}
}
.delete-folder, .subscribe-folder, .unsubscribe-folder {
cursor: pointer;
.opacity(60);
}
.unsubscribe-folder {
.opacity(25);
}
}
.folderPaddingHelper(1);
.folderPaddingHelper(2);
.folderPaddingHelper(3);
.folderPaddingHelper(4);
.folderPaddingHelper(5);
/*.folderPaddingHelper(@i) {
(~".folder-padding.deep-@{i}") {
width: 15px * @i + 10px;
}
}*/
.b-settings-folders {
&.ignore-folder-subscribe {
.subscribe-folder, .unsubscribe-folder {
display: none;
}
}
.process-place {
text-align: center;
width: 600px;
padding: 14px 0;
}
.folders-list-error {
width: 550px;
margin: 10px 0px;
}
.list-table {
width: 600px;
.e-action {
cursor: pointer;
}
td {
padding: 4px 8px;
line-height: 30px;
}
.folder-padding {
display: inline-block;
width: 0;
}
.folder-name {
display: inline-block;
word-break: break-all;
.box-sizing(border-box);
margin-left: 7px;
line-height: 22px;
cursor: default;
}
.folder-system-name {
display: inline-block;
line-height: 22px;
color: #999;
cursor: default;
}
.folder-name.can-be-edited:hover {
border-bottom: 1px dashed #333;
cursor: pointer;
}
.folder-name-input {
border-width: 1px;
margin-bottom: 0;
margin-left: -4px;
}
}
.folder-item {
&.system .folder-name {
font-weight: bold;
}
.button-delete {
margin-right: 15px;
margin-top: 5px;
visibility: hidden;
.opacity(0);
}
.delete-access {
&.button-delete {
visibility: visible;
margin-right: 0;
.opacity(100);
}
}
.delete-folder, .subscribe-folder, .unsubscribe-folder {
cursor: pointer;
.opacity(60);
}
.unsubscribe-folder {
.opacity(25);
}
}
.folder-padding.deep-1 {
width: 15px * 1 + 10px;
}
.folder-padding.deep-2 {
width: 15px * 2 + 10px;
}
.folder-padding.deep-3 {
width: 15px * 3 + 10px;
}
.folder-padding.deep-4 {
width: 15px * 4 + 10px;
}
.folder-padding.deep-5 {
width: 15px * 5 + 10px;
}
/* .folderPaddingHelper(1);
.folderPaddingHelper(2);
.folderPaddingHelper(3);
.folderPaddingHelper(4);
.folderPaddingHelper(5);*/
}

View file

@ -1,5 +0,0 @@
input[type="text"], input[type="password"], input[type="email"], input[type="search"] {
height: 20px;
line-height: 21px;
}

View file

@ -63,7 +63,7 @@ function PopupsFolderCreateViewModel()
RL.data().foldersCreating(false);
if (Enums.StorageResultType.Success === sResult && oData && oData.Result)
{
RL.folders(false);
RL.folders();
}
else
{

View file

@ -45,7 +45,8 @@ function PopupsFolderSystemViewModel()
'SentFolder': self.sentFolder(),
'DraftFolder': self.draftFolder(),
'SpamFolder': self.spamFolder(),
'TrashFolder': self.trashFolder()
'TrashFolder': self.trashFolder(),
'NullFolder': 'NullFolder'
});
}, 1000);