edit mailinglists with a dialog instead of inline
This commit is contained in:
@@ -75,6 +75,34 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal edit mailinglist -->
|
||||
<div class="modal fade" id="mailinglistEditModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Edit mailinglist {{ mailinglists.edit.list.name }}@{{selectedDomain.domain}}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form name="mailinglistedit_form" role="form" ng-submit="mailinglists.edit.submit()" autocomplete="off">
|
||||
<input type="password" style="display: none;">
|
||||
<div class="form-group" ng-class="{ 'has-error': mailinglists.edit.error }">
|
||||
<label class="control-label">Associated Mailboxes</label><br/>
|
||||
<div class="control-label" ng-show="mailinglists.edit.error">
|
||||
<small>{{ mailinglists.edit.error.message }}</small>
|
||||
</div>
|
||||
<multiselect ng-model="mailinglists.edit.list.members" options="name for name in mailinglists.availableMailboxNames" data-multiple="true"></multiselect>
|
||||
</div>
|
||||
<input class="hide" type="submit" ng-disabled="mailinglistedit_form.$invalid || mailinglists.edit.busy"/>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-success" ng-click="mailinglists.edit.submit()" ng-disabled="mailinglistedit_form.$invalid || mailinglists.edit.busy"><i class="fa fa-circle-o-notch fa-spin" ng-show="mailinglists.edit.busy"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal remove mailinglist -->
|
||||
<div class="modal fade" id="mailinglistRemoveModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
@@ -245,20 +273,20 @@
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Mailboxes</th>
|
||||
<th class="text-right" style="width: 100px;">Action</th>
|
||||
<th class="text-right">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="list in mailinglists.mailinglists">
|
||||
<td style="vertical-align: middle;">
|
||||
<td class="hand" ng-click="mailinglists.edit.show(list)">
|
||||
{{ list.name }}
|
||||
</td>
|
||||
<td>
|
||||
<multiselect ng-model="list.members" options="name for name in mailinglists.availableMailboxNames" data-multiple="true"></multiselect>
|
||||
<td class="hand" ng-click="mailinglists.edit.show(list)">
|
||||
{{ list.members.join(', ') }}
|
||||
</td>
|
||||
<td class="text-right no-wrap">
|
||||
<button ng-show="list.members !== list.orig.members" class="btn btn-success" ng-disabled="list.busy" ng-click="mailinglists.submit(list)"><i class="fa" ng-class="{ 'fa-spin': list.busy, 'fa-circle-o-notch': list.busy, 'fa-check': !list.busy }"></i></button>
|
||||
<button class="btn btn-danger" ng-click="mailinglists.remove.show(list)"><i class="fa fa-trash"></i></button>
|
||||
<button class="btn btn-xs btn-default" ng-click="mailinglists.edit.show(list)"><i class="fa fa-pencil"></i></button>
|
||||
<button class="btn btn-xs btn-danger" ng-click="mailinglists.remove.show(list)"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -91,6 +91,30 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
}
|
||||
},
|
||||
|
||||
edit: {
|
||||
busy: false,
|
||||
error: null,
|
||||
list: null,
|
||||
|
||||
show: function (list) {
|
||||
$scope.mailinglists.edit.list = list;
|
||||
|
||||
$('#mailinglistEditModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.mailinglists.edit.busy = true;
|
||||
|
||||
Client.updateMailingList($scope.selectedDomain.domain, $scope.mailinglists.edit.list.name, $scope.mailinglists.edit.list.members, function (error) {
|
||||
$scope.mailinglists.edit.busy = false;
|
||||
|
||||
if (error) return console.error(error);
|
||||
|
||||
$('#mailinglistEditModal').modal('hide');
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
remove: {
|
||||
busy: false,
|
||||
list: null,
|
||||
@@ -134,17 +158,6 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
submit: function (list) {
|
||||
list.busy = true;
|
||||
|
||||
Client.updateMailingList($scope.selectedDomain.domain, list.name, list.members, function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
list.orig.members = list.members;
|
||||
list.busy = false;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -216,7 +229,7 @@ angular.module('Application').controller('EmailController', ['$scope', '$locatio
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.mailboxes.remove.busy = true;
|
||||
$scope.mailboxes.edit.busy = true;
|
||||
|
||||
Client.updateMailbox($scope.selectedDomain.domain, $scope.mailboxes.edit.mailbox.name, $scope.mailboxes.edit.mailbox.owner.id, function (error) {
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user