Skip to content

Commit

Permalink
Merge branch 'MDL-67910-37' of git://github.com/sarjona/moodle into M…
Browse files Browse the repository at this point in the history
…OODLE_37_STABLE
  • Loading branch information
stronk7 committed Apr 10, 2020
2 parents 1ea8b34 + c137a7d commit 7098d7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion calendar/amd/build/crud.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 10 additions & 9 deletions calendar/amd/src/crud.js
Expand Up @@ -35,6 +35,7 @@ define([
'core_calendar/events',
'core_calendar/modal_delete',
'core_calendar/selectors',
'core/pending',
],
function(
$,
Expand All @@ -49,7 +50,8 @@ function(
CalendarRepository,
CalendarEvents,
ModalDelete,
CalendarSelectors
CalendarSelectors,
Pending
) {

/**
Expand Down Expand Up @@ -101,13 +103,6 @@ function(
);
}

deletePromise.then(function(deleteModal) {
deleteModal.show();

return;
})
.fail(Notification.exception);

var stringsPromise = Str.get_strings(deleteStrings);

var finalPromise = $.when(stringsPromise, deletePromise)
Expand All @@ -118,27 +113,33 @@ function(
deleteModal.setSaveButtonText(strings[0]);
}

deleteModal.show();

deleteModal.getRoot().on(ModalEvents.save, function() {
var pendingPromise = new Pending('calendar/crud:initModal:deletedevent');
CalendarRepository.deleteEvent(eventId, false)
.then(function() {
$('body').trigger(CalendarEvents.deleted, [eventId, false]);
return;
})
.then(pendingPromise.resolve)
.catch(Notification.exception);
});

deleteModal.getRoot().on(CalendarEvents.deleteAll, function() {
var pendingPromise = new Pending('calendar/crud:initModal:deletedallevent');
CalendarRepository.deleteEvent(eventId, true)
.then(function() {
$('body').trigger(CalendarEvents.deleted, [eventId, true]);
return;
})
.then(pendingPromise.resolve)
.catch(Notification.exception);
});

return deleteModal;
})
.fail(Notification.exception);
.catch(Notification.exception);

return finalPromise;
}
Expand Down

0 comments on commit 7098d7c

Please sign in to comment.