Improve lists in sidenav

- the ripple effect is now visible when clicking on list items;
- the fab icon has been moved over the items list;
- colorized the checkboxes of the calendars list.
This commit is contained in:
Francis Lachapelle
2015-04-29 11:23:21 -04:00
parent 4dbd796fd5
commit 16b75b1deb
13 changed files with 249 additions and 186 deletions
@@ -140,8 +140,10 @@
* @desc Return the calendar CSS class name based on its ID.
* @returns a string representing the foreground CSS class name
*/
Calendar.prototype.getClassName = function() {
return 'fg-folder' + this.id;
Calendar.prototype.getClassName = function(base) {
if (angular.isUndefined(base))
base = 'fg';
return base + '-folder' + this.id;
};
/**
+12 -8
View File
@@ -702,15 +702,19 @@
scope: {
ngModel: '='
},
template:
'<style type="text/css">' +
' .bg-folder{{ ngModel.id }} {' +
' background-color: {{ ngModel.color }} !important;' +
' }' +
' .fg-folder{{ ngModel.id }} {' +
' color: {{ ngModel.color }} !important;' +
' }' +
template: [
'<style type="text/css">',
' .bg-folder{{ ngModel.id }} {',
' background-color: {{ ngModel.color }} !important;',
' }',
' .fg-folder{{ ngModel.id }} {',
' color: {{ ngModel.color }} !important;',
' }',
' .checkbox-folder{{ ngModel.id }}.md-checked .md-icon {',
' background-color: {{ ngModel.color }} !important;',
' }',
'</style>'
].join('')
}
}])
+8 -3
View File
@@ -32,7 +32,7 @@
},
resolve: {
stateAddressbooks: ['sgAddressBook', function(AddressBook) {
return AddressBook.$findAll(contactFolders);
return AddressBook.$findAll(window.contactFolders);
}]
}
})
@@ -112,7 +112,7 @@
// $scope functions
$scope.select = function(folder) {
$scope.editMode = false;
//$rootScope.currentFolder = folder;
$state.go('app.addressbook', {addressbookId: folder.id});
};
$scope.newAddressbook = function(ev) {
$scope.editMode = false;
@@ -215,7 +215,12 @@
$scope.exportCards = function() {
window.location.href = ApplicationBaseURL + '/' + $scope.currentFolder.id + '/exportFolder';
};
$scope.share = function() {
$scope.share = function(folder) {
if (folder.id != $scope.currentFolder.id) {
// Counter the possibility to click on the "hidden" secondary button
$scope.select(folder);
return;
}
$mdDialog.show({
templateUrl: $scope.currentFolder.id + '/UIxAclEditor', // UI/Templates/UIxAclEditor.wox
controller: AddressBookACLController,
@@ -83,6 +83,7 @@
else {
Account.$Mailbox.$find(this).then(function(data) {
_this.$mailboxes = data;
_this.$flattenMailboxes({reload: true});
deferred.resolve(_this.$mailboxes);
});
}
@@ -90,23 +91,30 @@
return deferred.promise;
};
Account.prototype.$flattenMailboxes = function() {
/**
* @function $flattenMailboxes
* @memberof Account.prototype
* @desc Get a flatten array of the mailboxes.
* @param {object} [options] - force a reload
* @returns an array of Mailbox instances
*/
Account.prototype.$flattenMailboxes = function(options) {
var _this = this,
allMailboxes = [],
_visit = function(level, mailboxes) {
_visit = function(mailboxes) {
_.each(mailboxes, function(o) {
allMailboxes.push({ id: o.id, path: o.path, name: o.name, level: level });
allMailboxes.push(o);
if (o.children && o.children.length > 0) {
_visit(level+1, o.children);
_visit(o.children);
}
});
};
if (this.$$flattenMailboxes) {
if (this.$$flattenMailboxes && !(options && options.reload)) {
allMailboxes = this.$$flattenMailboxes;
}
else {
_visit(0, this.$mailboxes);
_visit(this.$mailboxes);
_this.$$flattenMailboxes = allMailboxes;
}
@@ -88,10 +88,11 @@
Mailbox.$unwrapCollection = function(account, futureMailboxData) {
var collection = [],
// Local recursive function
createMailboxes = function(mailbox) {
createMailboxes = function(level, mailbox) {
for (var i = 0; i < mailbox.children.length; i++) {
mailbox.children[i].level = level;
mailbox.children[i] = new Mailbox(account, mailbox.children[i]);
createMailboxes(mailbox.children[i]);
createMailboxes(level+1, mailbox.children[i]);
}
};
//collection.$futureMailboxData = futureMailboxData;
@@ -100,8 +101,9 @@
return Mailbox.$timeout(function() {
// Each entry is spun up as a Mailbox instance
angular.forEach(data.mailboxes, function(data, index) {
data.level = 0;
var mailbox = new Mailbox(account, data);
createMailboxes(mailbox); // recursively create all sub-mailboxes
createMailboxes(1, mailbox); // recursively create all sub-mailboxes
collection.push(mailbox);
});
return collection;
+29 -32
View File
@@ -186,45 +186,45 @@
});
};
$scope.editFolder = function(folder) {
$rootScope.$broadcast('sgEditFolder', folder.id);
$scope.editMode = folder.path;
focus('mailboxName_' + folder.path);
};
$scope.setCurrentFolder = function(account, folder) {
$scope.revertEditing = function(folder) {
folder.$reset();
$scope.editMode = false;
};
$scope.selectFolder = function(account, folder) {
if ($scope.editMode == folder.path)
return;
$rootScope.currentFolder = folder;
$scope.editMode = false;
$state.go('mail.account.mailbox', { accountId: account.id, mailboxId: encodeUriFilter(folder.path) });
};
$scope.saveFolder = function(folder) {
folder.$rename();
};
$scope.exportMails = function() {
window.location.href = ApplicationBaseURL + '/' + $rootScope.currentFolder.id + '/exportFolder';
};
$scope.confirmDelete = function() {
$scope.confirmDelete = function(folder) {
if (folder.path != $scope.currentFolder.path) {
// Counter the possibility to click on the "hidden" secondary button
$scope.selectFolder(folder.$account, folder);
return;
}
Dialog.confirm(l('Confirmation'), l('Do you really want to move this folder into the trash ?'))
.then(function(res) {
if (res) {
$rootScope.currentFolder.$delete()
.then(function() {
$rootScope.currentFolder = null;
}, function(data, status) {
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".',
$rootScope.currentFolder.name),
l(data.error));
});
}
});
.then(function() {
folder.$delete()
.then(function() {
$rootScope.currentFolder = null;
$state.go('mail');
}, function(data, status) {
Dialog.alert(l('An error occured while deleting the mailbox "%{0}".', folder.name),
l(data.error));
});
});
};
// Register listeners
$scope.$on('sgRevertFolder', function(event, folderId) {
if (folderId == $scope.currentFolder.id) {
$scope.currentFolder.$reset();
event.stopPropagation();
}
});
$scope.$on('sgSaveFolder', function(event, folderId) {
if (folderId == $scope.currentFolder.id) {
$scope.currentFolder.$rename();
event.stopPropagation();
}
});
if ($state.current.name == 'mail' && $scope.accounts.length > 0 && $scope.accounts[0].$mailboxes.length > 0) {
// Redirect to first mailbox of first account if no mailbox is selected
var account = $scope.accounts[0];
@@ -237,9 +237,6 @@
$scope.account = stateAccount;
$rootScope.mailbox = stateMailbox;
$rootScope.currentFolder = stateMailbox;
$timeout(function() {
$rootScope.$broadcast('sgSelectFolder', stateMailbox.id);
});
}])
.controller('MessageCtrl', ['$scope', '$rootScope', '$stateParams', '$state', 'stateAccount', 'stateMailbox', 'stateMessage', '$timeout', 'encodeUriFilter', 'sgFocus', 'sgDialog', 'sgAccount', 'sgMailbox', function($scope, $rootScope, $stateParams, $state, stateAccount, stateMailbox, stateMessage, $timeout, encodeUriFilter, focus, Dialog, Account, Mailbox) {