Ensure catchall uses the same origin array as the dropdown model

Otherwise angular would not reliably detect the same objects
This commit is contained in:
Johannes Zellner
2020-12-18 16:56:09 +01:00
parent 98ac637ada
commit 0bed8c89f6
2 changed files with 6 additions and 3 deletions
+1 -1
View File
@@ -451,7 +451,7 @@
<div class="row" ng-show="config.features.emailPremium">
<div class="col-md-6">
<multiselect ng-model="catchall.mailboxes" options="mailbox.name for mailbox in mailboxes.mailboxes" data-compare-by="name" data-multiple="true" filter-after-rows="5" scroll-after-rows="10"></multiselect>
<multiselect ng-model="catchall.mailboxes" options="mailbox.name for mailbox in catchall.availableMailboxes" data-compare-by="name" data-multiple="true" filter-after-rows="5" scroll-after-rows="10"></multiselect>
<button class="btn btn-outline btn-primary" ng-click="catchall.submit()" ng-disabled="catchall.busy || !domain.mailConfig.enabled" tooltip-enable="!domain.mailConfig.enabled" uib-tooltip="{{ 'email.incoming.mailboxes.disabledTooltip' | tr }}">
<i class="fa fa-circle-notch fa-spin" ng-show="catchall.busy"></i> {{ 'email.incoming.catchall.saveAction' | tr }}
</button>
+5 -2
View File
@@ -44,6 +44,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
$scope.catchall = {
mailboxes: [],
availableMailboxes: [],
busy: false,
submit: function () {
@@ -59,11 +60,13 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
},
refresh: function () {
Client.getMailboxes($scope.domain.domain, '', 1, 1000, function (error, mailboxes) {
Client.getMailboxes($scope.domain.domain, '', 1, 1000, function (error, result) {
if (error) return console.error(error);
$scope.catchall.availableMailboxes = result;
$scope.catchall.mailboxes = $scope.domain.mailConfig.catchAll.map(function (name) {
return mailboxes.find(function (m) { return m.name === name; });
return $scope.catchall.availableMailboxes.find(function (m) { return m.name === name; });
}).filter(function (m) { return !!m; });
});
}