Various fixes to mailbox sharing ui

This commit is contained in:
Girish Ramakrishnan
2021-12-08 11:33:36 -08:00
parent 9cad1c19c0
commit afd4c16763
6 changed files with 46 additions and 31 deletions
+8 -23
View File
@@ -157,9 +157,7 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
$scope.mailboxSharing = {
busy: false,
error: null,
size: 0,
enable: false,
enabled: false,
enabled: null, // null means we have not refreshed yet
refresh: function () {
Client.getMailboxSharing(function (error, enabled) {
@@ -169,30 +167,17 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
});
},
show: function() {
$scope.mailboxSharing.busy = false;
$scope.mailboxSharing.error = null;
$scope.mailboxSharing.enable = $scope.mailboxSharing.enabled;
$scope.mailboxSharingChangeForm.$setUntouched();
$scope.mailboxSharingChangeForm.$setPristine();
$('#mailboxSharingChangeModal').modal('show');
},
submit: function () {
$scope.mailboxSharing.busy = true;
Client.setMailboxSharing($scope.mailboxSharing.enable, function (error) {
$scope.mailboxSharing.busy = false;
if (error) return console.error(error);
$scope.mailboxSharing.enabled = $scope.mailboxSharing.enable;
$('#mailboxSharingChangeModal').modal('hide');
Client.setMailboxSharing(!$scope.mailboxSharing.enabled, function (error) {
// give sometime for mail server to restart
$timeout(function () {
$scope.mailboxSharing.busy = false;
if (error) return console.error(error);
$scope.mailboxSharing.enabled = !$scope.mailboxSharing.enabled;
}, 3000);
});
}
};