Skip to content
This repository has been archived by the owner on Nov 8, 2018. It is now read-only.

Commit

Permalink
Add account popover menu and remove settings account section
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophWurst committed Apr 23, 2016
1 parent edeca8a commit 416d085
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 104 deletions.
21 changes: 19 additions & 2 deletions css/mail.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@
display: none;
}

#app-navigation .navigation-account {
position: relative;
}
#app-navigation .navigation-account .app-navigation-entry-utils-menu-button {
/* show the account menu toggle (three dots) by default */
display: inline-block;
}

#app-navigation ul ul li > a {
padding-left: 32px;
}
Expand Down Expand Up @@ -160,7 +168,7 @@
display: inline-block;
opacity: .5;
padding: 20px 0 10px 25px;
width: 90%;
width: calc(100% - 50px);
margin: initial;
font-size: 100%;
overflow: hidden;
Expand Down Expand Up @@ -328,11 +336,20 @@
padding: 3px;
}

/* override core values to work with custom html */
#app-navigation .app-navigation-entry-utils {
top: 9px;
right: -12px;
}
#app-navigation .app-navigation-entry-menu {
right: -10px;
}

/* editor */
#mail-new-message-fixed {
position: fixed !important;
width: 241px !important;
z-index: 1;
z-index: 111; /* navigation menu is 110 ;-) */
padding-bottom: 12px;
background-color: rgba(255, 255, 255, .75);
}
Expand Down
16 changes: 16 additions & 0 deletions js/templates/account.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,21 @@
<div class="mail-account-color" style="background-color: {{accountColor email}}"></div>
{{/if}}
<h2 class="mail-account-email" title="{{email}}">{{email}}</h2>

{{#if hasMenu}}
<div class="app-navigation-entry-utils">
<ul>
<li class="app-navigation-entry-utils-menu-button svg"><button></button></li>
</ul>
</div>

<div class="app-navigation-entry-menu">
<ul>
<li><button class="icon-delete svg" title="delete"></button></li>
</ul>
</div>
{{/if}}


<ul id="mail_folders" class="mail_folders with-icon" data-account_id="{{id}}">
</ul>
11 changes: 6 additions & 5 deletions js/templates/folder.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
{{#each folders}}
<li data-folder_id="{{id}}"
class="
{{#if unseen}}unread{{/if}}
{{#if specialRole}} special-{{specialRole}}{{/if}}
">
{{#if unseen}}unread{{/if}}
{{#if specialRole}} special-{{specialRole}}{{/if}}
">
<a class="folder
{{#if specialRole}} icon-{{specialRole}} svg{{/if}}">
{{#if specialRole}} icon-{{specialRole}} svg{{/if}}">
{{name}}
{{#if count}}
<span class="utils">{{count}}</span>
{{/if}}
</a>
{{/each}}
</li>
{{/each}}
</ul>
</li>
5 changes: 0 additions & 5 deletions js/templates/settings-account.html

This file was deleted.

61 changes: 59 additions & 2 deletions js/views/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,84 @@
* later. See the COPYING file.
*
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
* @copyright Christoph Wurst 2015
* @copyright Christoph Wurst 2015, 2016
*/

define(function(require) {
'use strict';

var Backbone = require('backbone');
var Handlebars = require('handlebars');
var OC = require('OC');
var Radio = require('radio');
var FolderView = require('views/folder');
var AccountTemplate = require('text!templates/account.html');

return Backbone.Marionette.CompositeView.extend({
collection: null,
model: null,
template: Handlebars.compile(AccountTemplate),
ui: {
'menu': 'div.app-navigation-entry-menu',
'deleteButton': 'button[class^="icon-delete"]'
},
events: {
'click .app-navigation-entry-utils-menu-button button': 'toggleMenu',
'click @ui.deleteButton': 'onDelete'
},
templateHelpers: function() {
return {
hasMenu: this.model.get('accountId') !== -1
}
},
// 'active' is needed to show the dotdotdot menu
className: 'navigation-account',
childView: FolderView,
childViewContainer: '#mail_folders',
menuShown: false,
initialize: function(options) {
this.model = options.model;
this.collection = this.model.get('folders');
}

this.listenTo(Radio.ui, 'document:click', function(event) {
var target = $(event.target);
if (!this.$el.is(target.closest('.navigation-account'))) {
// Click was not triggered by this element -> close menu
this.menuShown = false;
this.toggleMenuClass();
}
});
},
toggleMenu: function(e) {
e.preventDefault();
this.menuShown = !this.menuShown;
this.toggleMenuClass();
},
toggleMenuClass: function() {
this.ui.menu.toggleClass('open', this.menuShown);
},
onDelete: function(e) {
e.stopPropagation();

this.ui.deleteButton.removeClass('icon-delete').addClass('icon-loading-small');

var account = this.model;

$.ajax(OC.generateUrl('/apps/mail/accounts/{accountId}'), {
data: {accountId: account.get('accountId')},
type: 'DELETE',
success: function() {
// Delete cached message lists
require('cache').removeAccount(account);

// reload the complete page
// TODO should only reload the app nav/content
window.location.reload();
},
error: function() {
OC.Notification.show(t('mail', 'Error while deleting account.'));
}
});
}
});
});
9 changes: 6 additions & 3 deletions js/views/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ define(function(require) {
// another browser tab
$(document).on('show', this.onDocumentShow);

$(document).on('click', this.onDocumentClick);

// Listens to key strokes, and executes a function based
// on the key combinations.
$(document).keyup(this.onKeyUp);
Expand All @@ -62,9 +64,7 @@ define(function(require) {
this.navigation = new NavigationView({
accounts: require('state').accounts
});
this.navigation.settings.show(new SettingsView({
accounts: require('state').accounts
}));
this.navigation.settings.show(new SettingsView());

// setup folder view
this.accountsView = new NavigationAccountsView();
Expand All @@ -73,6 +73,9 @@ define(function(require) {

this.showMessageContent();
},
onDocumentClick: function(event) {
Radio.ui.trigger('document:click', event);
},
onDocumentShow: function(e) {
e.preventDefault();
Radio.notification.trigger('favicon:change', OC.filePath('mail', 'img', 'favicon.png'));
Expand Down
52 changes: 0 additions & 52 deletions js/views/settings-account.js

This file was deleted.

26 changes: 0 additions & 26 deletions js/views/settings-accounts.js

This file was deleted.

9 changes: 0 additions & 9 deletions js/views/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ define(function(require) {
var Marionette = require('marionette');
var OC = require('OC');
var Radio = require('radio');
var SettingsAccountsView = require('views/settings-accounts');
var SettingsTemplate = require('text!templates/settings.html');

return Marionette.LayoutView.extend({
Expand All @@ -32,14 +31,6 @@ define(function(require) {
events: {
'click #new_mail_account': 'addAccount'
},
initialize: function(options) {
this.accounts = options.accounts;
},
onShow: function() {
this.accountsList.show(new SettingsAccountsView({
collection: this.accounts
}));
},
addAccount: function(e) {
e.preventDefault();
Radio.navigation.trigger('setup');
Expand Down

0 comments on commit 416d085

Please sign in to comment.