mirror of
https://github.com/moparisthebest/mail
synced 2024-11-24 18:02:15 -05:00
[WO-997] Select multiple messages at once
This commit is contained in:
parent
b038ac2c16
commit
4683583a0a
@ -8,6 +8,42 @@ var ActionBarCtrl = function($scope, $q, email, dialog, status) {
|
||||
// scope functions
|
||||
//
|
||||
|
||||
$scope.CHECKNONE = 0;
|
||||
$scope.CHECKALL = 1;
|
||||
$scope.CHECKUNREAD = 2;
|
||||
$scope.CHECKREAD = 3;
|
||||
$scope.CHECKFLAGGED = 4;
|
||||
$scope.CHECKUNFLAGGED = 5;
|
||||
$scope.CHECKENCRYPTED = 6;
|
||||
$scope.CHECKUNENCRYPTED = 7;
|
||||
|
||||
$scope.check = function(option) {
|
||||
currentFolder().messages.forEach(function(email) {
|
||||
if (!email.from) {
|
||||
// only mark loaded messages, not the dummy messages
|
||||
return;
|
||||
}
|
||||
|
||||
if (option === $scope.CHECKNONE) {
|
||||
email.checked = false;
|
||||
} else if (option === $scope.CHECKALL) {
|
||||
email.checked = true;
|
||||
} else if (option === $scope.CHECKUNREAD) {
|
||||
email.checked = !!email.unread;
|
||||
} else if (option === $scope.CHECKREAD) {
|
||||
email.checked = !email.unread;
|
||||
} else if (option === $scope.CHECKFLAGGED) {
|
||||
email.checked = !!email.flagged;
|
||||
} else if (option === $scope.CHECKUNFLAGGED) {
|
||||
email.checked = !email.flagged;
|
||||
} else if (option === $scope.CHECKENCRYPTED) {
|
||||
email.checked = !!email.encrypted;
|
||||
} else if (option === $scope.CHECKUNENCRYPTED) {
|
||||
email.checked = !email.encrypted;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Move a single message from the currently selected folder to another folder
|
||||
* @param {Object} message The message that is to be moved
|
||||
|
@ -1,5 +1,9 @@
|
||||
<div class="action-bar" ng-controller="ActionBarCtrl">
|
||||
<div class="action-bar__primary">
|
||||
<button class="btn btn--light-dropdown" ng-hide="state.read.open" wo-dropdown="#dropdown-checkmessages">
|
||||
<svg role="presentation"><use xlink:href="#icon-check" />Check messages</svg>
|
||||
<svg class="btn__dropdown" role="presentation"><use xlink:href="#icon-dropdown" /></svg>
|
||||
</button>
|
||||
<button class="btn btn--light" wo-touch="state.read.open ? deleteMessage(state.mailList.selected) : deleteCheckedMessages()">Delete</button>
|
||||
<button class="btn btn--light" wo-touch="state.read.open ? moveMessage(state.mailList.selected, getJunkFolder()) : moveCheckedMessages(getJunkFolder())">Spam</button>
|
||||
<button class="btn btn--light-dropdown" wo-dropdown="#dropdown-folder">
|
||||
@ -34,6 +38,17 @@
|
||||
</li>
|
||||
</ul><!--/dropdown-->
|
||||
|
||||
<ul id="dropdown-checkmessages" class="dropdown">
|
||||
<li><button wo-touch="check(CHECKALL)">All</button></li>
|
||||
<li><button wo-touch="check(CHECKNONE)">None</button></li>
|
||||
<li><button wo-touch="check(CHECKENCRYPTED)">Encrypted</button></li>
|
||||
<li><button wo-touch="check(CHECKUNENCRYPTED)">Unencrypted</button></li>
|
||||
<li><button wo-touch="check(CHECKUNREAD)">Unread</button></li>
|
||||
<li><button wo-touch="check(CHECKREAD)">Read</button></li>
|
||||
<li><button wo-touch="check(CHECKFLAGGED)">Starred</button></li>
|
||||
<li><button wo-touch="check(CHECKUNFLAGGED)">Unstarred</button></li>
|
||||
</ul><!--/checkmessages-->
|
||||
|
||||
<ul id="dropdown-more" class="dropdown">
|
||||
<li><button wo-touch="state.read.open ? markMessage(state.mailList.selected, false) : markCheckedMessages(false)">Mark as read</button></li>
|
||||
<li><button wo-touch="state.read.open ? markMessage(state.mailList.selected, true) : markCheckedMessages(true)">Mark as unread</button></li>
|
||||
|
@ -24,9 +24,20 @@ describe('Action Bar Controller unit test', function() {
|
||||
type: 'Inbox',
|
||||
path: 'INBOX',
|
||||
messages: [{
|
||||
from: [],
|
||||
checked: true
|
||||
}, {
|
||||
from: [],
|
||||
checked: false
|
||||
}, {
|
||||
from: [],
|
||||
flagged: true
|
||||
}, {
|
||||
from: [],
|
||||
encrypted: true
|
||||
}, {
|
||||
from: [],
|
||||
unread: true
|
||||
}]
|
||||
}
|
||||
};
|
||||
@ -43,6 +54,83 @@ describe('Action Bar Controller unit test', function() {
|
||||
|
||||
afterEach(function() {});
|
||||
|
||||
describe('check', function() {
|
||||
it('should check all', function() {
|
||||
scope.check(scope.CHECKALL);
|
||||
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.true;
|
||||
});
|
||||
|
||||
it('should check none', function() {
|
||||
scope.check(scope.CHECKNONE);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.false;
|
||||
});
|
||||
|
||||
it('should check encrypted', function() {
|
||||
scope.check(scope.CHECKENCRYPTED);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.false;
|
||||
});
|
||||
|
||||
it('should check unencrypted', function() {
|
||||
scope.check(scope.CHECKUNENCRYPTED);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.true;
|
||||
});
|
||||
|
||||
it('should check unread', function() {
|
||||
scope.check(scope.CHECKUNREAD);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.true;
|
||||
});
|
||||
|
||||
it('should check read', function() {
|
||||
scope.check(scope.CHECKREAD);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.false;
|
||||
|
||||
});
|
||||
|
||||
it('should check starred', function() {
|
||||
scope.check(scope.CHECKFLAGGED);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.false;
|
||||
|
||||
});
|
||||
|
||||
it('should check unstarred', function() {
|
||||
scope.check(scope.CHECKUNFLAGGED);
|
||||
expect(scope.state.nav.currentFolder.messages[0].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[1].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[2].checked).to.be.false;
|
||||
expect(scope.state.nav.currentFolder.messages[3].checked).to.be.true;
|
||||
expect(scope.state.nav.currentFolder.messages[4].checked).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
describe('deleteMessage', function() {
|
||||
it('should not delete without a selected mail', function() {
|
||||
scope.deleteMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user