Commit 8242027d authored by Andrew Nicols's avatar Andrew Nicols
Browse files

MDL-60558 calendar: Move edit event to CRUD

parent fd2f1ae1
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
......@@ -163,19 +163,7 @@ define([
CalendarViewManager.reloadCurrentMonth(root);
});
eventFormModalPromise
.then(function(modal) {
// When something within the calendar tells us the user wants
// to edit an event then show the event form modal.
body.on(CalendarEvents.editEvent, function(e, eventId) {
var calendarWrapper = root.find(CalendarSelectors.wrapper);
modal.setEventId(eventId);
modal.setContextId(calendarWrapper.data('contextId'));
modal.show();
});
return;
})
.fail(Notification.exception);
CalendarCrud.registerEditListeners(root, eventFormModalPromise);
};
/**
......
......@@ -51,7 +51,6 @@ define([
var registerEventListeners = function(root, type) {
var body = $('body');
CalendarCrud.registerEventFormModal(root);
CalendarCrud.registerRemove(root);
var reloadFunction = 'reloadCurrent' + type.charAt(0).toUpperCase() + type.slice(1);
......@@ -85,6 +84,9 @@ define([
daysWithEvent.removeClass('hidden');
}
});
var eventFormPromise = CalendarCrud.registerEventFormModal(root);
CalendarCrud.registerEditListeners(root, eventFormPromise);
};
return {
......
......@@ -198,6 +198,8 @@ function(
modal.setContextId(calendarWrapper.data('contextId'));
modal.show();
e.stopImmediatePropagation();
return;
}).fail(Notification.exception);
});
......@@ -223,8 +225,36 @@ function(
});
}
/**
* Register the listeners required to edit the event.
*
* @param {jQuery} root
* @param {Promise} eventFormModalPromise
* @returns {Promise}
*/
function registerEditListeners(root, eventFormModalPromise) {
eventFormModalPromise
.then(function(modal) {
// When something within the calendar tells us the user wants
// to edit an event then show the event form modal.
$('body').on(CalendarEvents.editEvent, function(e, eventId) {
var calendarWrapper = root.find(CalendarSelectors.wrapper);
modal.setEventId(eventId);
modal.setContextId(calendarWrapper.data('contextId'));
modal.show();
e.stopImmediatePropagation();
});
return;
})
.fail(Notification.exception);
return eventFormModalPromise;
}
return {
registerRemove: registerRemove,
registerEditListeners: registerEditListeners,
registerEventFormModal: registerEventFormModal
};
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment