Restore expandable mailboxes
parent
e8ca329070
commit
35d1ca8775
|
@ -253,7 +253,14 @@
|
|||
ng-dblclick="app.editFolder(folder)"
|
||||
ui-sref="mail.account.mailbox({accountId: account.id, mailboxId: (folder.path | encodeUri)})"
|
||||
ui-sref-active="md-default-theme md-background md-bg md-hue-1">
|
||||
<md-icon ng-class="'sg-child-level-' + folder.level">{{app.metadataForFolder(folder).icon}}</md-icon>
|
||||
<div ng-class="'sg-child-level-' + folder.level">
|
||||
<md-icon ng-hide="folder.children.length">{{app.metadataForFolder(folder).icon}}</md-icon>
|
||||
<md-checkbox class="sg-folder"
|
||||
label:aria-label="Expanded"
|
||||
ng-show="folder.children.length"
|
||||
ng-model="folder.$expanded"
|
||||
ng-change="account.$flattenMailboxes({ reload: true, saveState: true })"><!-- expanded --></md-checkbox>
|
||||
</div>
|
||||
<p class="sg-item-name"
|
||||
ng-show="app.editMode != folder.path">
|
||||
{{app.metadataForFolder(folder).name}}
|
||||
|
|
|
@ -31,12 +31,13 @@
|
|||
* @desc The factory we'll use to register with Angular
|
||||
* @returns the Account constructor
|
||||
*/
|
||||
Account.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Mailbox', 'Message', function($q, $timeout, $log, Settings, Resource, Mailbox, Message) {
|
||||
Account.$factory = ['$q', '$timeout', '$log', 'sgSettings', 'Resource', 'Preferences', 'Mailbox', 'Message', function($q, $timeout, $log, Settings, Resource, Preferences, Mailbox, Message) {
|
||||
angular.extend(Account, {
|
||||
$q: $q,
|
||||
$timeout: $timeout,
|
||||
$log: $log,
|
||||
$$resource: new Resource(Settings.activeUser('folderURL') + 'Mail', Settings.activeUser()),
|
||||
$Preferences: Preferences,
|
||||
$Mailbox: Mailbox,
|
||||
$Message: Message
|
||||
});
|
||||
|
@ -104,7 +105,25 @@
|
|||
else {
|
||||
return Account.$Mailbox.$find(this).then(function(data) {
|
||||
_this.$mailboxes = data;
|
||||
|
||||
// Set expanded folders from user's settings
|
||||
Account.$Preferences.ready().then(function() {
|
||||
var expandedFolders;
|
||||
if (Account.$Preferences.settings.Mail.ExpandedFolders) {
|
||||
if (angular.isString(Account.$Preferences.settings.Mail.ExpandedFolders))
|
||||
// Backward compatibility support
|
||||
expandedFolders = angular.fromJson(Account.$Preferences.settings.Mail.ExpandedFolders);
|
||||
else
|
||||
expandedFolders = Account.$Preferences.settings.Mail.ExpandedFolders;
|
||||
if (expandedFolders.length > 0) {
|
||||
_.forEach(_this.$mailboxes, function(mailbox) {
|
||||
mailbox.$expanded = (expandedFolders.indexOf('/' + mailbox.id) >= 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
_this.$flattenMailboxes({reload: true});
|
||||
});
|
||||
|
||||
return _this.$mailboxes;
|
||||
});
|
||||
}
|
||||
|
@ -120,10 +139,11 @@
|
|||
Account.prototype.$flattenMailboxes = function(options) {
|
||||
var _this = this,
|
||||
allMailboxes = [],
|
||||
expandedMailboxes = [],
|
||||
_visit = function(mailboxes) {
|
||||
_.each(mailboxes, function(o) {
|
||||
allMailboxes.push(o);
|
||||
if (o.children && o.children.length > 0) {
|
||||
if (o.$expanded && o.children && o.children.length > 0) {
|
||||
_visit(o.children);
|
||||
}
|
||||
});
|
||||
|
@ -135,6 +155,15 @@
|
|||
else {
|
||||
_visit(this.$mailboxes);
|
||||
_this.$$flattenMailboxes = allMailboxes;
|
||||
if (options && options.saveState) {
|
||||
_.reduce(allMailboxes, function(expandedFolders, mailbox) {
|
||||
if (mailbox.$expanded) {
|
||||
expandedFolders.push('/' + mailbox.id);
|
||||
}
|
||||
return expandedFolders;
|
||||
}, expandedMailboxes);
|
||||
Account.$$resource.post(null, 'saveFoldersState', expandedMailboxes);
|
||||
}
|
||||
}
|
||||
|
||||
return allMailboxes;
|
||||
|
|
|
@ -301,7 +301,7 @@
|
|||
//if ($rootScope.currentFolder == folder)
|
||||
// return 'folder_open';
|
||||
|
||||
return {name: folder.name, icon: 'folder'};
|
||||
return {name: folder.name, icon: 'folder_open'};
|
||||
}
|
||||
|
||||
function setFolderAs(folder, type) {
|
||||
|
|
|
@ -23,6 +23,13 @@ $i: 1;
|
|||
$i: $i + 1;
|
||||
}
|
||||
|
||||
[class^=sg-child-level] {
|
||||
md-icon, md-checkbox {
|
||||
margin-right: $bl * 2;
|
||||
max-width: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
// This hack is so BAD I am ashame putting it in the shame file
|
||||
// -----------------------------------------------------------
|
||||
// Folder tree's controler function are very intricate, the way
|
||||
|
|
|
@ -45,6 +45,36 @@
|
|||
// margin-bottom: ($mg/2);
|
||||
}
|
||||
|
||||
md-sidenav md-checkbox {
|
||||
&.sg-folder {
|
||||
// Show checkbox as a "closed" folder when unchecked and "opened" folder when checked
|
||||
.md-container:after {
|
||||
color: rgba(0,0,0,0.54);
|
||||
font-family: 'Material Icons';
|
||||
font-size: 24px;
|
||||
content: "\e2c7";
|
||||
top: -4px;
|
||||
left: -2px;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
}
|
||||
.md-icon {
|
||||
border-width: 0;
|
||||
}
|
||||
&.md-checked {
|
||||
.md-container:after {
|
||||
content: "\e2c8";
|
||||
}
|
||||
.md-icon {
|
||||
background-color: initial;
|
||||
&:after {
|
||||
border-style: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.msg-attachment-image {
|
||||
@media (min-width: $layout-breakpoint-sm) {
|
||||
flex: 0 0 100%;
|
||||
|
|
Loading…
Reference in New Issue