diff --git a/src/views/app.html b/src/views/app.html index b1ee38c22..62af4d3d9 100644 --- a/src/views/app.html +++ b/src/views/app.html @@ -466,17 +466,17 @@
+ +

This sets the address from which this app sends email. This app is already configured to send mail using {{app.domain}}'s Outbound Email settings.

+
-
- - -

This sets the address from which this app sends email. This app is already configured to send mail using {{app.domain}}'s Outbound Email settings.

-
{{ email.error.mailboxName }}
+
+
{{ email.error.mailboxName }}
- +
- - +
- +
diff --git a/src/views/app.js b/src/views/app.js index ed437b0d1..9eb3e2b15 100644 --- a/src/views/app.js +++ b/src/views/app.js @@ -365,17 +365,15 @@ angular.module('Application').controller('AppController', ['$scope', '$location' $scope.email = { busy: false, error: {}, - success: false, - mailboxNameEnabled: false, mailboxName: '', domain: '', show: function () { var app = $scope.app; + $scope.emailForm.$setPristine(); $scope.email.error = {}; - $scope.email.mailboxNameEnabled = app.mailboxName && (app.mailboxName.match(/\.app$/) === null); $scope.email.mailboxName = app.mailboxName || ''; $scope.email.domain = $scope.domains.filter(function (d) { return d.domain === app.domain; })[0]; }, @@ -384,7 +382,7 @@ angular.module('Application').controller('AppController', ['$scope', '$location' $scope.email.error = {}; $scope.email.busy = true; - Client.configureApp($scope.app.id, 'mailbox', { mailboxName: $scope.email.mailboxNameEnabled ? $scope.email.mailboxName : null }, function (error) { + Client.configureApp($scope.app.id, 'mailbox', { mailboxName: $scope.email.mailboxName || null }, function (error) { if (error && error.statusCode === 400) { $scope.email.busy = false; $scope.email.error.mailboxName = error.message; @@ -393,10 +391,15 @@ angular.module('Application').controller('AppController', ['$scope', '$location' } if (error) return Client.error(error); - $scope.email.success = true; + $scope.emailForm.$setPristine(); + $scope.email.busy = false; - refreshApp(); + refreshApp(function (error) { + if (error) return; + // when the mailboxName is 'reset', this will fill it up with the default again + $scope.email.mailboxName = $scope.app.mailboxName || ''; + }); }); } };