mirror of
https://github.com/moparisthebest/mail
synced 2024-12-24 00:08:48 -05:00
check valid send states in editor
This commit is contained in:
parent
4b638a0dee
commit
2eaf7ca172
@ -108,6 +108,7 @@ define(function(require) {
|
||||
// verify email address
|
||||
if (!util.validateEmailAddress(recipient.address)) {
|
||||
recipient.secure = undefined;
|
||||
checkSendStatus();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,21 +123,48 @@ define(function(require) {
|
||||
if (key && key.userId === recipient.address) {
|
||||
recipient.key = key;
|
||||
recipient.secure = true;
|
||||
$scope.$apply();
|
||||
}
|
||||
|
||||
checkSendStatus();
|
||||
$scope.$apply();
|
||||
});
|
||||
}
|
||||
|
||||
function resetDisplay() {
|
||||
function checkSendStatus() {
|
||||
$scope.okToSend = false;
|
||||
$scope.sendBtnText = undefined;
|
||||
}
|
||||
$scope.sendBtnSecure = undefined;
|
||||
|
||||
function displaySecure() {
|
||||
$scope.sendBtnText = 'Send securely';
|
||||
}
|
||||
var allSecure = true;
|
||||
var numReceivers = 0;
|
||||
|
||||
function displayInsecure() {
|
||||
$scope.sendBtnText = 'Invite & send securely';
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// sender can invite only one use at a time
|
||||
if (!allSecure && numReceivers === 1) {
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -7,7 +7,7 @@
|
||||
.headers {
|
||||
p {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.subject {
|
||||
|
@ -20,6 +20,12 @@
|
||||
|
||||
.headers {
|
||||
margin-top: 10px;
|
||||
|
||||
p {
|
||||
margin: 0.2em 0;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $color-grey;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@
|
||||
</div><!--/.body-->
|
||||
|
||||
<div class="send-control">
|
||||
<button ng-click="sendToOutbox()" class="btn" data-icon="{{(toSecure === false) ? '' : (toSecure === true) ? '' : ''}}" ng-disabled="!to" tabindex="4">{{sendBtnText || 'Send'}}</button>
|
||||
<button ng-click="sendToOutbox()" class="btn" data-icon="{{(sendBtnSecure === false) ? '' : (sendBtnSecure === true) ? '' : ''}}" ng-disabled="!okToSend" tabindex="4">{{sendBtnText || 'Send'}}</button>
|
||||
</div>
|
||||
</div><!--/.write-view-->
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user