From 97f1132023801d6e52309cfd4fe82f94b0a11b86 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Tue, 2 Dec 2014 10:55:22 +0100 Subject: [PATCH] Implement move to junk --- src/js/controller/app/action-bar.js | 19 ++++++++++++++- src/tpl/action-bar.html | 2 +- .../controller/app/action-bar-ctrl-test.js | 23 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/js/controller/app/action-bar.js b/src/js/controller/app/action-bar.js index b997975..72f0542 100644 --- a/src/js/controller/app/action-bar.js +++ b/src/js/controller/app/action-bar.js @@ -1,5 +1,7 @@ 'use strict'; +var JUNK_FOLDER_TYPE = 'Junk'; + 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 */ $scope.moveMessage = function(message, destination) { - if (!message) { + if (!message || !destination) { 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, * or if the current folder is the trash folder, the message will be purged. diff --git a/src/tpl/action-bar.html b/src/tpl/action-bar.html index 8c64a06..8c81abd 100644 --- a/src/tpl/action-bar.html +++ b/src/tpl/action-bar.html @@ -1,7 +1,7 @@
- +