mirror of
https://github.com/moparisthebest/mail
synced 2024-11-26 10:52:17 -05:00
Merge pull request #215 from whiteout-io/dev/WO-768
Implement move to junk
This commit is contained in:
commit
2a6d4e0d9b
@ -1,5 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var JUNK_FOLDER_TYPE = 'Junk';
|
||||||
|
|
||||||
var ActionBarCtrl = function($scope, email, dialog, statusDisplay) {
|
var ActionBarCtrl = function($scope, email, dialog, statusDisplay) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8,7 +10,7 @@ var ActionBarCtrl = function($scope, email, dialog, statusDisplay) {
|
|||||||
* @param {Object} destination The folder object where the message should be moved to
|
* @param {Object} destination The folder object where the message should be moved to
|
||||||
*/
|
*/
|
||||||
$scope.moveMessage = function(message, destination) {
|
$scope.moveMessage = function(message, destination) {
|
||||||
if (!message) {
|
if (!message || !destination) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,6 +50,21 @@ var ActionBarCtrl = function($scope, email, dialog, statusDisplay) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the junk folder to mark a message as spam. If no junk folder is found, an error message will be displayed.
|
||||||
|
* @return {Object} The junk folder object tied to the account
|
||||||
|
*/
|
||||||
|
$scope.getJunkFolder = function() {
|
||||||
|
var folder = _.findWhere($scope.account.folders, {
|
||||||
|
type: JUNK_FOLDER_TYPE
|
||||||
|
});
|
||||||
|
if (!folder) {
|
||||||
|
dialog.error(new Error('Spam folder not found!'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return folder;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a message. This moves the message from the current folder to the trash folder,
|
* Delete a message. This moves the message from the current folder to the trash folder,
|
||||||
* or if the current folder is the trash folder, the message will be purged.
|
* or if the current folder is the trash folder, the message will be purged.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<div class="action-bar" ng-controller="ActionBarCtrl">
|
<div class="action-bar" ng-controller="ActionBarCtrl">
|
||||||
<div class="action-bar__primary">
|
<div class="action-bar__primary">
|
||||||
<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 ? deleteMessage(state.mailList.selected) : deleteCheckedMessages()">Delete</button>
|
||||||
<button class="btn btn--light" disabled>Spam</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">
|
<button class="btn btn--light-dropdown" wo-dropdown="#dropdown-folder">
|
||||||
<svg><use xlink:href="#icon-folder" /><title>Folder</title></svg>
|
<svg><use xlink:href="#icon-folder" /><title>Folder</title></svg>
|
||||||
<svg class="btn__dropdown" role="presentation"><use xlink:href="#icon-dropdown" /></svg>
|
<svg class="btn__dropdown" role="presentation"><use xlink:href="#icon-dropdown" /></svg>
|
||||||
|
@ -114,6 +114,29 @@ describe('Action Bar Controller unit test', function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('getJunkFolder', function() {
|
||||||
|
it('should work', function() {
|
||||||
|
scope.account = {
|
||||||
|
folders: [{
|
||||||
|
type: 'Junk'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
var folder = scope.getJunkFolder();
|
||||||
|
expect(folder).to.exist;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should fail', function() {
|
||||||
|
scope.account = {
|
||||||
|
folders: [{
|
||||||
|
type: 'NotJunk'
|
||||||
|
}]
|
||||||
|
};
|
||||||
|
var folder = scope.getJunkFolder();
|
||||||
|
expect(folder).to.not.exist;
|
||||||
|
expect(dialogMock.error.calledOnce).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('markMessage', function() {
|
describe('markMessage', function() {
|
||||||
it('should not move without a selected mail', function() {
|
it('should not move without a selected mail', function() {
|
||||||
scope.markMessage();
|
scope.markMessage();
|
||||||
|
Loading…
Reference in New Issue
Block a user