1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 10:52:17 -05:00

check valid send states in editor

This commit is contained in:
Tankred Hase 2014-01-13 23:54:53 +01:00
parent 4b638a0dee
commit 2eaf7ca172
4 changed files with 44 additions and 10 deletions

View File

@ -108,6 +108,7 @@ define(function(require) {
// verify email address // verify email address
if (!util.validateEmailAddress(recipient.address)) { if (!util.validateEmailAddress(recipient.address)) {
recipient.secure = undefined; recipient.secure = undefined;
checkSendStatus();
return; return;
} }
@ -122,21 +123,48 @@ define(function(require) {
if (key && key.userId === recipient.address) { if (key && key.userId === recipient.address) {
recipient.key = key; recipient.key = key;
recipient.secure = true; recipient.secure = true;
$scope.$apply();
} }
checkSendStatus();
$scope.$apply();
}); });
} }
function resetDisplay() { function checkSendStatus() {
$scope.okToSend = false;
$scope.sendBtnText = undefined; $scope.sendBtnText = undefined;
$scope.sendBtnSecure = undefined;
var allSecure = true;
var numReceivers = 0;
// count number of receivers and check security
$scope.to.forEach(check);
$scope.cc.forEach(check);
$scope.bcc.forEach(check);
function check(recipient) {
// validate address
if (!util.validateEmailAddress(recipient.address)) {
return;
}
numReceivers++;
if (!recipient.secure) {
allSecure = false;
}
} }
function displaySecure() { // sender can invite only one use at a time
$scope.sendBtnText = 'Send securely'; if (!allSecure && numReceivers === 1) {
}
function displayInsecure() {
$scope.sendBtnText = 'Invite & send securely'; $scope.sendBtnText = 'Invite & send securely';
$scope.okToSend = true;
$scope.sendBtnSecure = false;
} else if (allSecure && numReceivers > 0) {
// all recipients are secure
$scope.sendBtnText = 'Send securely';
$scope.okToSend = true;
$scope.sendBtnSecure = true;
}
} }
// //

View File

@ -20,6 +20,12 @@
.headers { .headers {
margin-top: 10px; margin-top: 10px;
p {
margin: 0.2em 0;
padding: 0.2em 0;
}
span { span {
color: $color-grey; color: $color-grey;
} }

View File

@ -39,7 +39,7 @@
</div><!--/.body--> </div><!--/.body-->
<div class="send-control"> <div class="send-control">
<button ng-click="sendToOutbox()" class="btn" data-icon="{{(toSecure === false) ? '&#xe001;' : (toSecure === true) ? '&#xe009;' : ''}}" ng-disabled="!to" tabindex="4">{{sendBtnText || 'Send'}}</button> <button ng-click="sendToOutbox()" class="btn" data-icon="{{(sendBtnSecure === false) ? '&#xe001;' : (sendBtnSecure === true) ? '&#xe009;' : ''}}" ng-disabled="!okToSend" tabindex="4">{{sendBtnText || 'Send'}}</button>
</div> </div>
</div><!--/.write-view--> </div><!--/.write-view-->