1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(impv) add loader for create/delete availability slot

This commit is contained in:
Du Peng 2024-03-12 18:58:27 +01:00
parent d5d3e61538
commit 8a2a9085be
5 changed files with 21 additions and 4 deletions

View File

@ -789,6 +789,8 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
// number of slots for this availability
$scope.slots_nb = slots;
$scope.saving = false;
/**
* Adds or removes the provided machine from the current slot
* @param machine {Object}
@ -867,9 +869,14 @@ Application.Controllers.controller('CreateEventModalController', ['$scope', '$ui
if ($scope.isOnlySubscriptions && $scope.selectedPlans.length > 0) {
$scope.availability.plan_ids = $scope.selectedPlans.map(function (p) { return p.id; });
}
$scope.saving = true;
return Availability.save(
{ availability: $scope.availability },
function (availability) { $uibModalInstance.close(availability); }
function (availability) { $uibModalInstance.close(availability); },
function (error) {
console.error(error);
$scope.saving = false;
}
);
};
@ -1158,15 +1165,19 @@ Application.Controllers.controller('DeleteRecurrentAvailabilityController', ['$s
// with recurrent slots: how many slots should we delete?
$scope.deleteMode = 'single';
$scope.deleting = false;
/**
* Confirmation callback
*/
$scope.ok = function () {
const { id, start_at, end_at } = availabilityPromise;
$scope.deleting = true;
// the admin has confirmed, delete the slot
Availability.delete(
{ id, mode: $scope.deleteMode },
function (res) {
$scope.deleting = false;
// delete success
if (res.deleted > 1) {
growl.success(_t(
@ -1185,6 +1196,7 @@ Application.Controllers.controller('DeleteRecurrentAvailabilityController', ['$s
});
},
function (res) {
$scope.deleting = false;
// not everything was deleted
const { data } = res;
if (data.total > 1) {

View File

@ -1096,15 +1096,19 @@ Application.Controllers.controller('DeleteRecurrentEventController', ['$scope',
// with recurrent slots: how many slots should we delete?
$scope.deleteMode = 'single';
$scope.deleting = false;
/**
* Confirmation callback
*/
$scope.ok = function () {
$scope.deleting = true;
const { id, start_at, end_at } = eventPromise;
// the admin has confirmed, delete the slot
Event.delete(
{ id, mode: $scope.deleteMode },
function (res) {
$scope.deleting = false;
// delete success
if (res.deleted > 1) {
growl.success(_t(
@ -1122,6 +1126,7 @@ Application.Controllers.controller('DeleteRecurrentEventController', ['$scope',
});
},
function (res) {
$scope.deleting = false;
// not everything was deleted
const { data } = res;
if (data.total > 1) {

View File

@ -21,6 +21,6 @@
</div>
</div>
<div class="modal-footer">
<button class="btn btn-info" ng-click="ok()" translate>{{ 'app.shared.buttons.delete' }}</button>
<button class="btn btn-info" ng-class="{'btn-loading': deleting}" ng-click="ok()" ng-disabled="deleting" translate>{{ 'app.shared.buttons.delete' }}</button>
<button class="btn btn-default" ng-click="cancel()" translate>{{ 'app.shared.buttons.cancel' }}</button>
</div>

View File

@ -252,6 +252,6 @@
</div>
<div class="modal-footer" ng-show="step === 6">
<button class="fab-button is-info" ng-click="previous()" translate>{{ 'app.admin.calendar.previous' }}</button>
<button class="fab-button is-secondary" ng-click="ok()" translate>{{ 'app.shared.buttons.confirm' }}</button>
<button class="fab-button is-secondary" ng-class="{'btn-loading': saving}" ng-disabled="saving" ng-click="ok()" translate>{{ 'app.shared.buttons.confirm' }}</button>
<button class="fab-button" ng-click="cancel()" translate>{{ 'app.shared.buttons.cancel' }}</button>
</div>

View File

@ -22,6 +22,6 @@
</div>
</div>
<div class="modal-footer">
<button class="btn btn-info" ng-click="ok()" translate>{{ 'app.shared.buttons.delete' }}</button>
<button class="btn btn-info" ng-class="{'btn-loading': deleting}" ng-click="ok()" ng-disabled="deleting" translate>{{ 'app.shared.buttons.delete' }}</button>
<button class="btn btn-default" ng-click="cancel()" translate>{{ 'app.shared.buttons.cancel' }}</button>
</div>