1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-19 13:54:25 +01:00

alert on date change

This commit is contained in:
Sylvain 2020-02-11 15:42:43 +01:00
parent aecbaa7f04
commit db26533d94
6 changed files with 27 additions and 5 deletions

View File

@ -505,7 +505,7 @@ Application.Controllers.controller('NewEventController', ['$scope', '$state', 'C
*/
Application.Controllers.controller('EditEventController', ['$scope', '$state', '$stateParams', 'CSRF', 'eventPromise', 'categoriesPromise', 'themesPromise', 'ageRangesPromise', 'priceCategoriesPromise', '$uibModal', 'growl', '_t',
function ($scope, $state, $stateParams, CSRF, eventPromise, categoriesPromise, themesPromise, ageRangesPromise, priceCategoriesPromise, $uibModal, growl, _t) {
/* PUBLIC SCOPE */
/* PUBLIC SCOPE */
// API URL where the form will be posted
$scope.actionUrl = `/api/events/${$stateParams.id}`;
@ -516,6 +516,9 @@ Application.Controllers.controller('EditEventController', ['$scope', '$state', '
// Retrieve the event details, in case of error the user is redirected to the events listing
$scope.event = eventPromise;
// We'll keep track of the initial dates here, for later comparison
$scope.initialDates = {};
// List of categories for the events
$scope.categories = categoriesPromise;
@ -545,7 +548,9 @@ Application.Controllers.controller('EditEventController', ['$scope', '$state', '
size: 'md',
controller: 'EditRecurrentEventController',
resolve: {
editMode: function () { return $scope.editMode; }
editMode: function () { return $scope.editMode; },
initialDates: function () { return $scope.initialDates; },
currentEvent: function () { return $scope.event; }
}
});
// submit form event by edit-mode
@ -615,6 +620,11 @@ Application.Controllers.controller('EditEventController', ['$scope', '$state', '
$scope.event.start_date = moment($scope.event.start_date).toDate();
$scope.event.end_date = moment($scope.event.end_date).toDate();
$scope.initialDates = {
start: new Date($scope.event.start_date.valueOf()),
end: new Date($scope.event.end_date.valueOf())
};
// Using the EventsController
return new EventsController($scope, $state);
};
@ -627,8 +637,8 @@ Application.Controllers.controller('EditEventController', ['$scope', '$state', '
/**
* Controller used in the event edit-mode modal window
*/
Application.Controllers.controller('EditRecurrentEventController', ['$scope', '$uibModalInstance', 'editMode', 'growl', '_t',
function ($scope, $uibModalInstance, editMode, growl, _t) {
Application.Controllers.controller('EditRecurrentEventController', ['$scope', '$uibModalInstance', 'editMode', 'growl', 'initialDates', 'currentEvent', '_t',
function ($scope, $uibModalInstance, editMode, growl, initialDates, currentEvent, _t) {
// with recurrent slots: how many slots should we update?
$scope.editMode = editMode;
@ -637,10 +647,17 @@ Application.Controllers.controller('EditRecurrentEventController', ['$scope', '$
*/
$scope.ok = function () {
$uibModalInstance.close({
editMode: $scope.editMode,
editMode: $scope.editMode
});
}
/**
* Test if any of the dates of the event has changed
*/
$scope.hasDateChanged = function() {
return (!moment(initialDates.start).isSame(currentEvent.start_date, 'day') || !moment(initialDates.end).isSame(currentEvent.end_date, 'day'));
}
/**
* Cancellation callback
*/

View File

@ -18,6 +18,7 @@
<span translate>{{ 'app.admin.events_edit.edit_all' }}</span>
</label>
</div>
<p class="alert alert-warning" ng-show="hasDateChanged() && editMode !== 'single'" translate>{{ 'app.admin.events_edit.date_wont_change' }}</p>
</div>
<div class="modal-footer">
<button class="btn btn-info" ng-click="ok()" translate>{{ 'app.shared.buttons.apply' }}</button>

View File

@ -235,6 +235,7 @@ en:
edit_this_event: "Only this event"
edit_this_and_next: "This event and the following"
edit_all: "All events"
date_wont_change: "Warning: you have changed the event date. This modification won't be propagated to other occurrences of the periodic event."
event_successfully_updated: "Event successfully updated"
events_updated: "The event, and {COUNT, plural, =1{one other} other{{COUNT} others}}, have been updated"
unable_to_update_the_event: "Unable to update the event"

View File

@ -235,6 +235,7 @@ es:
edit_this_event: "Only this event"
edit_this_and_next: "This event and the following"
edit_all: "All events"
date_wont_change: "Warning: you have changed the event date. This modification won't be propagated to other occurrences of the periodic event."
event_successfully_updated: "Event successfully updated"
events_updated: "The event, and {COUNT, plural, =1{one other} other{{COUNT} others}}, have been updated"
unable_to_update_the_event: "Unable to update the event"

View File

@ -235,6 +235,7 @@ fr:
edit_this_event: "Uniquement cet évènement"
edit_this_and_next: "Cet évènement et tous les suivants"
edit_all: "Tous les évènements"
date_wont_change: "Attention : vous avez modifié la date de l'évènement. Cette modification ne sera pas être répercutée sur les autres occurrences de l'évènement périodique."
event_successfully_updated: "L'évènement a bien été modifié."
events_updated: "L'évènement, ainsi {COUNT, plural, =1{qu'un autre} other{que {COUNT} autres}}, ont été modifiés"
unable_to_update_the_event: "L'évènement n'a pu être modifié"

View File

@ -235,6 +235,7 @@ pt:
edit_this_event: "Only this event"
edit_this_and_next: "This event and the following"
edit_all: "All events"
date_wont_change: "Warning: you have changed the event date. This modification won't be propagated to other occurrences of the periodic event."
event_successfully_updated: "Event successfully updated"
events_updated: "The event, and {COUNT, plural, =1{one other} other{{COUNT} others}}, have been updated"
unable_to_update_the_event: "Unable to update the event"