MDL-59751 calendar: Update JS to be more sharable
This commit is contained in:
committed by
Simey Lameze
parent
001366a815
commit
e00aed518f
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager","core_calendar/crud","core_calendar/selectors"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={ROOT:"[data-region='calendar']",DAY:"[data-region='day']",EVENT_ITEM:"[data-region='event-item']",EVENT_LINK:"[data-action='view-event']",NEW_EVENT_BUTTON:"[data-action='new-event-button']",DAY_CONTENT:"[data-region='day-content']",LOADING_ICON:".loading-icon",VIEW_DAY_LINK:"[data-action='view-day-link']",CALENDAR_MONTH_WRAPPER:".calendarwrapper",COURSE_SELECTOR:'select[name="course"]',TODAY:".today"},q=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a})},r=function(a){k.getEventById(a).then(function(b){if(!b.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+a);var c=b.event;return q(c.eventtype).then(function(a){return c.eventtype=a,c})}).then(function(a){var b={title:a.name,type:j.TYPE,body:d.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete,isactionevent:a.isactionevent,url:a.url}};return h.create(b)}).done(function(a){a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)},s=function(b,c,f,g){var h=null,i=g.attr("data-day-timestamp");f&&(h=f.attr("data-day-timestamp")),f&&h==i||d.render("core/loading",{}).then(function(a,b){g.find(p.DAY_CONTENT).addClass("hidden"),d.appendNodeContents(g,a,b),f&&(f.find(p.DAY_CONTENT).addClass("hidden"),d.appendNodeContents(f,a,b))}).then(function(){return k.updateEventStartDay(c,i)}).then(function(){a("body").trigger(l.eventMoved,[c,f,g])}).always(function(){var a=g.find(p.LOADING_ICON);if(g.find(p.DAY_CONTENT).removeClass("hidden"),d.replaceNode(a,"",""),f){var b=f.find(p.LOADING_ICON);f.find(p.DAY_CONTENT).removeClass("hidden"),d.replaceNode(b,"","")}}).fail(e.exception)},t=function(b,c){var d=a("body");d.on(l.created,function(){m.reloadCurrentMonth(b)}),d.on(l.deleted,function(){m.reloadCurrentMonth(b)}),d.on(l.updated,function(){m.reloadCurrentMonth(b)}),d.on(l.editActionEvent,function(a,b){window.location.assign(b)}),d.on(l.moveEvent,s),d.on(l.eventMoved,function(){m.reloadCurrentMonth(b)}),c.then(function(a){d.on(l.editEvent,function(b,c){a.setEventId(c),a.show()})}).fail(e.exception)},u=function(b){b.on("click",p.EVENT_ITEM,function(b){b.preventDefault(),b.stopPropagation();var c=a(b.target),d=null;d=c.is(p.EVENT_LINK)?c.attr("data-event-id"):c.find(p.EVENT_LINK).attr("data-event-id"),r(d)}),b.on("change",p.COURSE_SELECTOR,function(){var c=a(this),d=c.val();m.reloadCurrentMonth(b,d,null).then(function(){return b.find(p.COURSE_SELECTOR).val(d)}).fail(e.exception)});var c=n.registerEventFormModal(b,o.newEventButton);t(b,c),f.define(b,[f.events.activate]),b.on("click",p.NEW_EVENT_BUTTON,function(a){c.then(function(a){var c=b.find(p.CALENDAR_MONTH_WRAPPER);a.setCourseId(c.data("courseid"));var d=c.data("categoryid");"undefined"!=typeof d&&a.setCategoryId(d);var e=b.find(p.TODAY);e.length||a.setStartTime(b.find(p.DAY).attr("data-new-event-timestamp")),a.show()}).fail(e.exception),a.preventDefault()}),b.on("click",p.DAY,function(b){var d=a(b.target);if(!d.is(p.VIEW_DAY_LINK)){var f=a(this).attr("data-new-event-timestamp");c.then(function(a){var b=d.closest(p.CALENDAR_MONTH_WRAPPER);a.setCourseId(b.data("courseid"));var c=b.data("categoryid");"undefined"!=typeof c&&a.setCategoryId(c),a.setStartTime(f),a.show()}).fail(e.exception),b.preventDefault()}})};return{init:function(b){b=a(b),n.init(b),m.init(b),u(b)}}});
|
||||
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_events","core/modal_factory","core_calendar/modal_event_form","core_calendar/summary_modal","core_calendar/repository","core_calendar/events","core_calendar/view_manager","core_calendar/crud","core_calendar/selectors"],function(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o){var p={ROOT:"[data-region='calendar']",DAY:"[data-region='day']",EVENT_ITEM:"[data-region='event-item']",EVENT_LINK:"[data-action='view-event']",NEW_EVENT_BUTTON:"[data-action='new-event-button']",DAY_CONTENT:"[data-region='day-content']",LOADING_ICON:".loading-icon",VIEW_DAY_LINK:"[data-action='view-day-link']",CALENDAR_MONTH_WRAPPER:".calendarwrapper",COURSE_SELECTOR:'select[name="course"]',TODAY:".today"},q=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a})},r=function(a){k.getEventById(a).then(function(b){if(!b.event)throw new Error("Error encountered while trying to fetch calendar event with ID: "+a);var c=b.event;return q(c.eventtype).then(function(a){return c.eventtype=a,c})}).then(function(a){var b={title:a.name,type:j.TYPE,body:d.render("core_calendar/event_summary_body",a),templateContext:{canedit:a.canedit,candelete:a.candelete,isactionevent:a.isactionevent,url:a.url}};return h.create(b)}).done(function(a){a.getRoot().on(g.hidden,function(){a.destroy()}),a.show()}).fail(e.exception)},s=function(b,c,f,g){var h=null,i=g.attr("data-day-timestamp");f&&(h=f.attr("data-day-timestamp")),f&&h==i||d.render("core/loading",{}).then(function(a,b){g.find(p.DAY_CONTENT).addClass("hidden"),d.appendNodeContents(g,a,b),f&&(f.find(p.DAY_CONTENT).addClass("hidden"),d.appendNodeContents(f,a,b))}).then(function(){return k.updateEventStartDay(c,i)}).then(function(){a("body").trigger(l.eventMoved,[c,f,g])}).always(function(){var a=g.find(p.LOADING_ICON);if(g.find(p.DAY_CONTENT).removeClass("hidden"),d.replaceNode(a,"",""),f){var b=f.find(p.LOADING_ICON);f.find(p.DAY_CONTENT).removeClass("hidden"),d.replaceNode(b,"","")}}).fail(e.exception)},t=function(b,c){var d=a("body");d.on(l.created,function(){m.reloadCurrentMonth(b)}),d.on(l.deleted,function(){m.reloadCurrentMonth(b)}),d.on(l.updated,function(){m.reloadCurrentMonth(b)}),d.on(l.editActionEvent,function(a,b){window.location.assign(b)}),d.on(l.moveEvent,s),d.on(l.eventMoved,function(){m.reloadCurrentMonth(b)}),c.then(function(a){d.on(l.editEvent,function(c,d){var e=b.find(o.wrapper);a.setEventId(d),a.setContextId(e.data("contextId")),a.show()})}).fail(e.exception)},u=function(b){b.on("click",p.EVENT_ITEM,function(b){b.preventDefault(),b.stopPropagation();var c=a(b.target),d=null;d=c.is(p.EVENT_LINK)?c.attr("data-event-id"):c.find(p.EVENT_LINK).attr("data-event-id"),r(d)}),b.on("change",p.COURSE_SELECTOR,function(){var c=a(this),d=c.val();m.reloadCurrentMonth(b,d,null).then(function(){return b.find(p.COURSE_SELECTOR).val(d)}).fail(e.exception)});var c=n.registerEventFormModal(b);t(b,c),b.on("click",p.DAY,function(b){var d=a(b.target);if(!d.is(p.VIEW_DAY_LINK)){var f=a(this).attr("data-new-event-timestamp");c.then(function(a){var b=d.closest(o.wrapper);a.setCourseId(b.data("courseid"));var c=b.data("categoryid");"undefined"!=typeof c&&a.setCategoryId(c),a.setContextId(b.data("contextId")),a.setStartTime(f),a.show()}).fail(e.exception),b.preventDefault()}})};return{init:function(b){b=a(b),m.init(b),u(b)}}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/notification","core_calendar/selectors","core_calendar/events","core_calendar/view_manager","core_calendar/repository","core/modal_factory","core_calendar/modal_event_form","core/modal_events","core_calendar/crud"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(b){var g=a("body"),h=a(d.deleteLink),i=a(d.newEventButton),j=b.data("courseid"),l=k.registerEventFormModal(b,i);k.registerRemove(h),b.on("click",d.deleteLink,function(c){c.preventDefault();var d=a(c.currentTarget),h=d.data("event-id"),i=d.data("title"),l=d.data("event-event-count");k.confirmDeletion(h,i,l).then(function(a){g.on(e.deleted,function(){a.hide(),f.reloadCurrentUpcoming(b,j)}.bind(this))})}),b.on("click",d.editLink,function(b){b.preventDefault();var d=a(b.currentTarget);l.then(function(a){var b=d.data("event-id");b&&a.setEventId(b),a.show()}).fail(c.exception)}),b.on("change",d.courseSelector,function(){var e=a(this),g=e.val();f.reloadCurrentUpcoming(b,g).then(function(){return b.find(d.courseSelector).val(g)}).fail(c.exception)}),g.on(e.filterChanged,function(a,c){var e=b.find(d.eventType[c.type]);1==c.hidden?e.addClass("hidden"):e.removeClass("hidden")})};return{init:function(b){b=a(b),f.init(b),l(b)}}});
|
||||
define(["jquery","core/str","core/notification","core_calendar/selectors","core_calendar/events","core_calendar/view_manager","core_calendar/repository","core/modal_factory","core_calendar/modal_event_form","core/modal_events","core_calendar/crud"],function(a,b,c,d,e,f,g,h,i,j,k){var l=function(b,g){var h=a("body");k.registerEventFormModal(b),k.registerRemove(b);var i="reloadCurrent"+g.charAt(0).toUpperCase()+g.slice(1);h.on(e.created,function(){f[i](b)}),h.on(e.deleted,function(){f[i](b)}),h.on(e.updated,function(){f[i](b)}),b.on("change",d.courseSelector,function(){var e=a(this),g=e.val();f[i](b,g).then(function(){return b.find(d.courseSelector).val(g)}).fail(c.exception)}),h.on(e.filterChanged,function(a,c){var e=b.find(d.eventType[c.type]);1==c.hidden?e.addClass("hidden"):e.removeClass("hidden")})};return{init:function(b,c){b=a(b),f.init(b,c),l(b,c)}}});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/modal_event_form","core_calendar/repository","core_calendar/events","core_calendar/modal_delete","core_calendar/selectors"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(d,e,f){var i=[{key:"deleteevent",component:"calendar"}];f=parseInt(f,10);var m,n=f>1;n?(i.push({key:"confirmeventseriesdelete",component:"calendar",param:{name:e,count:f}}),m=g.create({type:l.TYPE})):(i.push({key:"confirmeventdelete",component:"calendar",param:e}),m=g.create({type:g.types.SAVE_CANCEL})),m.then(function(a){a.show()}).fail(c.exception);var o=b.get_strings(i),p=a.when(o,m).then(function(b,e){return e.setTitle(b[0]),e.setBody(b[1]),n||e.setSaveButtonText(b[0]),e.getRoot().on(h.save,function(){j.deleteEvent(d,!1).then(function(){a("body").trigger(k.deleted,[d,!1])})["catch"](c.exception)}),e.getRoot().on(k.deleteAll,function(){j.deleteEvent(d,!0).then(function(){a("body").trigger(k.deleted,[d,!0])})["catch"](c.exception)}),e}).fail(c.exception);return p}function o(b){b.on("click",m.actions.remove,function(b){var c=a(this),d=c.data("eventId"),e=c.data("eventTitle"),f=c.data("eventCount");n(d,e,f),b.preventDefault()})}var p=function(a,b){var c=b.data("context-id");return g.create({type:i.TYPE,large:!0,templateContext:{contextid:c}},[a,m.newEventButton])};return{init:function(b){p(b,a(m.newEventButton))},registerRemove:o,confirmDeletion:n,registerEventFormModal:p}});
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/modal_event_form","core_calendar/repository","core_calendar/events","core_calendar/modal_delete","core_calendar/selectors"],function(a,b,c,d,e,f,g,h,i,j,k,l,m){function n(d,e,f){var i=[{key:"deleteevent",component:"calendar"}];f=parseInt(f,10);var m,n=f>1;n?(i.push({key:"confirmeventseriesdelete",component:"calendar",param:{name:e,count:f}}),m=g.create({type:l.TYPE})):(i.push({key:"confirmeventdelete",component:"calendar",param:e}),m=g.create({type:g.types.SAVE_CANCEL})),m.then(function(a){a.show()}).fail(c.exception);var o=b.get_strings(i),p=a.when(o,m).then(function(b,e){return e.setTitle(b[0]),e.setBody(b[1]),n||e.setSaveButtonText(b[0]),e.getRoot().on(h.save,function(){j.deleteEvent(d,!1).then(function(){a("body").trigger(k.deleted,[d,!1])})["catch"](c.exception)}),e.getRoot().on(k.deleteAll,function(){j.deleteEvent(d,!0).then(function(){a("body").trigger(k.deleted,[d,!0])})["catch"](c.exception)}),e}).fail(c.exception);return p}function o(b){b.on("click",m.actions.remove,function(b){var c=a(this).closest(m.eventItem),d=c.data("eventId"),e=c.data("eventTitle"),f=c.data("eventCount");n(d,e,f),b.preventDefault()})}var p=function(b){var d=g.create({type:i.TYPE,large:!0});return b.on("click",m.actions.create,function(a){d.then(function(a){var c=b.find(m.wrapper),d=c.data("categoryid");"undefined"!=typeof d&&a.setCategoryId(d);var e=b.find(m.today),f=b.find(m.day);!e.length&&f.length&&a.setStartTime(f.data("newEventTimestamp")),a.setContextId(c.data("contextId")),a.setCourseId(c.data("courseid")),a.show()}).fail(c.exception),a.preventDefault()}),b.on("click",m.actions.edit,function(b){b.preventDefault();var e=a(b.currentTarget),f=e.closest(m.wrapper),g=e.closest(m.eventItem);d.then(function(a){a.setEventId(g.data("eventId")),a.setContextId(f.data("contextId")),a.show()}).fail(c.exception)}),d};return{registerRemove:o,registerEventFormModal:p}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/event","core/str","core/notification","core/templates","core/custom_interaction_events","core/modal","core/modal_registry","core/fragment","core_calendar/events","core_calendar/repository"],function(a,b,c,d,e,f,g,h,i,j,k){var l=!1,m={SAVE_BUTTON:'[data-action="save"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]'},n=function(a){g.call(this,a),this.eventId=null,this.startTime=null,this.courseId=null,this.categoryId=null,this.reloadingBody=!1,this.reloadingTitle=!1,this.saveButton=this.getFooter().find(m.SAVE_BUTTON)};return n.TYPE="core_calendar-modal_event_form",n.prototype=Object.create(g.prototype),n.prototype.constructor=n,n.prototype.setCourseId=function(a){this.courseId=a},n.prototype.getCourseId=function(){return this.courseId},n.prototype.setCategoryId=function(a){this.categoryId=a},n.prototype.getCategoryId=function(){return this.categoryId},n.prototype.hasCourseId=function(){return null!==this.courseId},n.prototype.hasCategoryId=function(){return null!==this.categoryId},n.prototype.setEventId=function(a){this.eventId=a},n.prototype.getEventId=function(){return this.eventId},n.prototype.hasEventId=function(){return null!==this.eventId},n.prototype.setStartTime=function(a){this.startTime=a},n.prototype.getStartTime=function(){return this.startTime},n.prototype.hasStartTime=function(){return null!==this.startTime},n.prototype.getForm=function(){return this.getBody().find("form")},n.prototype.disableButtons=function(){this.saveButton.prop("disabled",!0)},n.prototype.enableButtons=function(){this.saveButton.prop("disabled",!1)},n.prototype.reloadTitleContent=function(){return this.reloadingTitle?this.titlePromise:(this.reloadingTitle=!0,this.hasEventId()?this.titlePromise=c.get_string("editevent","calendar"):this.titlePromise=c.get_string("newevent","calendar"),this.titlePromise.then(function(a){return this.setTitle(a),a}.bind(this)).always(function(){this.reloadingTitle=!1}.bind(this)).fail(d.exception),this.titlePromise)},n.prototype.reloadBodyContent=function(a){if(this.reloadingBody)return this.bodyPromise;this.reloadingBody=!0,this.disableButtons();var b=this.saveButton.attr("data-context-id"),c={};return this.hasEventId()&&(c.eventid=this.getEventId()),this.hasStartTime()&&(c.starttime=this.getStartTime()),this.hasCourseId()&&(c.courseid=this.getCourseId()),this.hasCategoryId()&&(c.categoryid=this.getCategoryId()),"undefined"!=typeof a&&(c.formdata=a),this.bodyPromise=i.loadFragment("calendar","event_form",b,c),this.setBody(this.bodyPromise),this.bodyPromise.then(function(){this.enableButtons()}.bind(this)).fail(d.exception).always(function(){this.reloadingBody=!1}.bind(this)).fail(d.exception),this.bodyPromise},n.prototype.reloadAllContent=function(){return a.when(this.reloadTitleContent(),this.reloadBodyContent())},n.prototype.show=function(){this.reloadAllContent(),g.prototype.show.call(this)},n.prototype.hide=function(){g.prototype.hide.call(this),this.setEventId(null),this.setStartTime(null),this.setCourseId(null),this.setCategoryId(null)},n.prototype.getFormData=function(){return this.getForm().serialize()},n.prototype.save=function(){var b=this.saveButton.find(m.LOADING_ICON_CONTAINER);b.removeClass("hidden"),this.disableButtons();var c=this.getFormData();return k.submitCreateUpdateForm(c).then(function(b){return b.validationerror?void this.reloadBodyContent(c):(this.hide(),void(this.hasEventId()?a("body").trigger(j.updated,[b.event]):a("body").trigger(j.created,[b.event])))}.bind(this)).always(function(){b.addClass("hidden"),this.enableButtons()}.bind(this)).fail(d.exception)},n.prototype.registerEventListeners=function(){g.prototype.registerEventListeners.call(this),this.getModal().on(f.events.activate,m.SAVE_BUTTON,function(a,b){this.getForm().submit(),b.originalEvent.preventDefault(),a.stopPropagation()}.bind(this)),this.getModal().on("submit",function(a){this.save(),a.preventDefault(),a.stopPropagation()}.bind(this))},l||(h.register(n.TYPE,n,"calendar/modal_event_form"),l=!0),n});
|
||||
define(["jquery","core/event","core/str","core/notification","core/templates","core/custom_interaction_events","core/modal","core/modal_registry","core/fragment","core_calendar/events","core_calendar/repository"],function(a,b,c,d,e,f,g,h,i,j,k){var l=!1,m={SAVE_BUTTON:'[data-action="save"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]'},n=function(a){g.call(this,a),this.eventId=null,this.startTime=null,this.courseId=null,this.categoryId=null,this.contextId=null,this.reloadingBody=!1,this.reloadingTitle=!1,this.saveButton=this.getFooter().find(m.SAVE_BUTTON)};return n.TYPE="core_calendar-modal_event_form",n.prototype=Object.create(g.prototype),n.prototype.constructor=n,n.prototype.setContextId=function(a){this.contextId=a},n.prototype.getContextId=function(){return this.contextId},n.prototype.setCourseId=function(a){this.courseId=a},n.prototype.getCourseId=function(){return this.courseId},n.prototype.setCategoryId=function(a){this.categoryId=a},n.prototype.getCategoryId=function(){return this.categoryId},n.prototype.hasCourseId=function(){return null!==this.courseId},n.prototype.hasCategoryId=function(){return null!==this.categoryId},n.prototype.setEventId=function(a){this.eventId=a},n.prototype.getEventId=function(){return this.eventId},n.prototype.hasEventId=function(){return null!==this.eventId},n.prototype.setStartTime=function(a){this.startTime=a},n.prototype.getStartTime=function(){return this.startTime},n.prototype.hasStartTime=function(){return null!==this.startTime},n.prototype.getForm=function(){return this.getBody().find("form")},n.prototype.disableButtons=function(){this.saveButton.prop("disabled",!0)},n.prototype.enableButtons=function(){this.saveButton.prop("disabled",!1)},n.prototype.reloadTitleContent=function(){return this.reloadingTitle?this.titlePromise:(this.reloadingTitle=!0,this.hasEventId()?this.titlePromise=c.get_string("editevent","calendar"):this.titlePromise=c.get_string("newevent","calendar"),this.titlePromise.then(function(a){return this.setTitle(a),a}.bind(this)).always(function(){this.reloadingTitle=!1}.bind(this)).fail(d.exception),this.titlePromise)},n.prototype.reloadBodyContent=function(a){if(this.reloadingBody)return this.bodyPromise;this.reloadingBody=!0,this.disableButtons();var b={};return this.hasEventId()&&(b.eventid=this.getEventId()),this.hasStartTime()&&(b.starttime=this.getStartTime()),this.hasCourseId()&&(b.courseid=this.getCourseId()),this.hasCategoryId()&&(b.categoryid=this.getCategoryId()),"undefined"!=typeof a&&(b.formdata=a),this.bodyPromise=i.loadFragment("calendar","event_form",this.getContextId(),b),this.setBody(this.bodyPromise),this.bodyPromise.then(function(){this.enableButtons()}.bind(this)).fail(d.exception).always(function(){this.reloadingBody=!1}.bind(this)).fail(d.exception),this.bodyPromise},n.prototype.reloadAllContent=function(){return a.when(this.reloadTitleContent(),this.reloadBodyContent())},n.prototype.show=function(){this.reloadAllContent(),g.prototype.show.call(this)},n.prototype.hide=function(){g.prototype.hide.call(this),this.setEventId(null),this.setStartTime(null),this.setCourseId(null),this.setCategoryId(null)},n.prototype.getFormData=function(){return this.getForm().serialize()},n.prototype.save=function(){var b=this.saveButton.find(m.LOADING_ICON_CONTAINER);b.removeClass("hidden"),this.disableButtons();var c=this.getFormData();return k.submitCreateUpdateForm(c).then(function(b){return b.validationerror?void this.reloadBodyContent(c):(this.hide(),void(this.hasEventId()?a("body").trigger(j.updated,[b.event]):a("body").trigger(j.created,[b.event])))}.bind(this)).always(function(){b.addClass("hidden"),this.enableButtons()}.bind(this)).fail(d.exception)},n.prototype.registerEventListeners=function(){g.prototype.registerEventListeners.call(this),this.getModal().on(f.events.activate,m.SAVE_BUTTON,function(a,b){this.getForm().submit(),b.originalEvent.preventDefault(),a.stopPropagation()}.bind(this)),this.getModal().on("submit",function(a){this.save(),a.preventDefault(),a.stopPropagation()}.bind(this))},l||(h.register(n.TYPE,n,"calendar/modal_event_form"),l=!0),n});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define([],function(){return{eventFilterItem:"[data-action='filter-event-type']",eventType:{site:"[data-eventtype-site]",category:"[data-eventtype-category]",course:"[data-eventtype-course]",group:"[data-eventtype-group]",user:"[data-eventtype-user]"},popoverType:{site:"[data-popover-eventtype-site]",category:"[data-popover-eventtype-category]",course:"[data-popover-eventtype-course]",group:"[data-popover-eventtype-group]",user:"[data-popover-eventtype-user]"},calendarPeriods:{month:"[data-period='month']"},editLink:'a[data-action="edit"]',deleteLink:'a[data-action="delete"]',courseSelector:'select[name="course"]',newEventButton:'button[data-action="new-event-button"]',actions:{edit:'[data-action="edit"]',remove:'[data-action="delete"]'}}});
|
||||
define([],function(){return{eventFilterItem:"[data-action='filter-event-type']",eventType:{site:"[data-eventtype-site]",category:"[data-eventtype-category]",course:"[data-eventtype-course]",group:"[data-eventtype-group]",user:"[data-eventtype-user]"},popoverType:{site:"[data-popover-eventtype-site]",category:"[data-popover-eventtype-category]",course:"[data-popover-eventtype-course]",group:"[data-popover-eventtype-group]",user:"[data-popover-eventtype-user]"},calendarPeriods:{month:"[data-period='month']"},courseSelector:'select[name="course"]',actions:{create:'[data-action="new-event-button"]',edit:'[data-action="edit"]',remove:'[data-action="delete"]'},today:".today",day:'[data-region="day"]',wrapper:".calendarwrapper",eventItem:'[data-type="event"]'}});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/repository","core_calendar/events","core_calendar/crud"],function(a,b,c,d,e,f,g,h,i,j,k){var l=!1,m={ROOT:"[data-region='summary-modal-container']",EDIT_BUTTON:'[data-action="edit"]',DELETE_BUTTON:'[data-action="delete"]'},n=function(a){e.call(this,a)};return n.TYPE="core_calendar-event_summary",n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.getEditButton=function(){return"undefined"==typeof this.editButton&&(this.editButton=this.getFooter().find(m.EDIT_BUTTON)),this.editButton},n.prototype.getDeleteButton=function(){return"undefined"==typeof this.deleteButton&&(this.deleteButton=this.getFooter().find(m.DELETE_BUTTON)),this.deleteButton},n.prototype.getEventId=function(){return this.getBody().find(m.ROOT).attr("data-event-id")},n.prototype.getEventTitle=function(){return this.getBody().find(m.ROOT).attr("data-event-title")},n.prototype.getEventCount=function(){return this.getBody().find(m.ROOT).attr("data-event-event-count")},n.prototype.getEditUrl=function(){return this.getBody().find(m.ROOT).attr("data-edit-url")},n.prototype.isActionEvent=function(){return"true"==this.getBody().find(m.ROOT).attr("data-action-event")},n.prototype.registerEventListeners=function(){e.prototype.registerEventListeners.call(this),this.getRoot().on(h.bodyRendered,function(){this.getDeleteButton().data({eventTitle:this.getEventTitle(),eventId:this.getEventId(),eventCount:this.getEventCount()}),k.registerRemove(this.getModal(),m.ROOT)}.bind(this)),a("body").on(j.deleted,function(){this.hide()}.bind(this)),d.define(this.getEditButton(),[d.events.activate]),this.getEditButton().on(d.events.activate,function(b,c){this.isActionEvent()?a("body").trigger(j.editActionEvent,[this.getEditUrl()]):a("body").trigger(j.editEvent,[this.getEventId()]),this.hide(),b.preventDefault(),b.stopPropagation(),c.originalEvent.preventDefault(),c.originalEvent.stopPropagation()}.bind(this))},l||(f.register(n.TYPE,n,"core_calendar/event_summary_modal"),l=!0),n});
|
||||
define(["jquery","core/str","core/notification","core/custom_interaction_events","core/modal","core/modal_registry","core/modal_factory","core/modal_events","core_calendar/repository","core_calendar/events","core_calendar/crud"],function(a,b,c,d,e,f,g,h,i,j,k){var l=!1,m={ROOT:"[data-region='summary-modal-container']",EDIT_BUTTON:'[data-action="edit"]',DELETE_BUTTON:'[data-action="delete"]'},n=function(a){e.call(this,a)};return n.TYPE="core_calendar-event_summary",n.prototype=Object.create(e.prototype),n.prototype.constructor=n,n.prototype.getEditButton=function(){return"undefined"==typeof this.editButton&&(this.editButton=this.getFooter().find(m.EDIT_BUTTON)),this.editButton},n.prototype.getDeleteButton=function(){return"undefined"==typeof this.deleteButton&&(this.deleteButton=this.getFooter().find(m.DELETE_BUTTON)),this.deleteButton},n.prototype.getEventId=function(){return this.getBody().find(m.ROOT).attr("data-event-id")},n.prototype.getEventTitle=function(){return this.getBody().find(m.ROOT).attr("data-event-title")},n.prototype.getEventCount=function(){return this.getBody().find(m.ROOT).attr("data-event-count")},n.prototype.getEditUrl=function(){return this.getBody().find(m.ROOT).attr("data-edit-url")},n.prototype.isActionEvent=function(){return"true"==this.getBody().find(m.ROOT).attr("data-action-event")},n.prototype.registerEventListeners=function(){e.prototype.registerEventListeners.call(this),this.getRoot().on(h.bodyRendered,function(){this.getModal().data({eventTitle:this.getEventTitle(),eventId:this.getEventId(),eventCount:this.getEventCount()}).attr("data-type","event"),k.registerRemove(this.getModal())}.bind(this)),a("body").on(j.deleted,function(){this.hide()}.bind(this)),d.define(this.getEditButton(),[d.events.activate]),this.getEditButton().on(d.events.activate,function(b,c){this.isActionEvent()?a("body").trigger(j.editActionEvent,[this.getEditUrl()]):a("body").trigger(j.editEvent,[this.getEventId()]),this.hide(),b.preventDefault(),b.stopPropagation(),c.originalEvent.preventDefault(),c.originalEvent.stopPropagation()}.bind(this))},l||(f.register(n.TYPE,n,"core_calendar/event_summary_modal"),l=!0),n});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=b.find(f.CALENDAR_MONTH_WRAPPER),e=d.data("courseid"),g=d.data("categoryid"),h=a(c.currentTarget);i(b,h.attr("href"),h.data("year"),h.data("month"),e,g),c.preventDefault()})},h=function(g,h,i,j,m,n){k(g),n=n||g.find(f.CALENDAR_MONTH_WRAPPER),M.util.js_pending([g.get("id"),h,i,j].join("-"));var o=g.data("includenavigation");return d.getCalendarMonthData(h,i,j,m,o).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(n,a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return M.util.js_complete([g.get("id"),h,i,j].join("-")),l(g)}).fail(c.exception)},i=function(b,c,d,f,g,i){return h(b,d,f,g,i).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f,g,i]),arguments})},j=function(a,b,c){var d=a.find(f.CALENDAR_MONTH_WRAPPER).data("year"),e=a.find(f.CALENDAR_MONTH_WRAPPER).data("month");return"undefined"==typeof b&&(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),"undefined"==typeof c&&(c=a.find(f.CALENDAR_MONTH_WRAPPER).data("categoryid")),h(a,d,e,b,c)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")},m=function(g,h){k(g);var i=g.find(f.CALENDAR_MONTH_WRAPPER);return d.getCalendarUpcomingData(h).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return window.history.replaceState(null,null,"?view=upcoming&course="+h),b.replaceNode(i,a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h,reloadCurrentUpcoming:m}});
|
||||
define(["jquery","core/templates","core/notification","core_calendar/repository","core_calendar/events"],function(a,b,c,d,e){var f={ROOT:"[data-region='calendar']",CALENDAR_NAV_LINK:".calendarwrapper .arrow_link",CALENDAR_MONTH_WRAPPER:".calendarwrapper",LOADING_ICON_CONTAINER:'[data-region="overlay-icon-container"]'},g=function(b){b=a(b),b.on("click",f.CALENDAR_NAV_LINK,function(c){var d=b.find(f.CALENDAR_MONTH_WRAPPER),e=d.data("courseid"),g=d.data("categoryid"),h=a(c.currentTarget);i(b,h.attr("href"),h.data("year"),h.data("month"),e,g),c.preventDefault()})},h=function(g,h,i,j,m,n){k(g),n=n||g.find(f.CALENDAR_MONTH_WRAPPER),M.util.js_pending([g.get("id"),h,i,j].join("-"));var o=g.data("includenavigation");return d.getCalendarMonthData(h,i,j,m,o).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return b.replaceNode(n,a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return M.util.js_complete([g.get("id"),h,i,j].join("-")),l(g)}).fail(c.exception)},i=function(b,c,d,f,g,i){return h(b,d,f,g,i).then(function(){return c.length&&"#"!==c&&window.history.pushState({},"",c),arguments}).then(function(){return a("body").trigger(e.monthChanged,[d,f,g,i]),arguments})},j=function(a,b,c){var d=a.find(f.CALENDAR_MONTH_WRAPPER).data("year"),e=a.find(f.CALENDAR_MONTH_WRAPPER).data("month");return"undefined"==typeof b&&(b=a.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),"undefined"==typeof c&&(c=a.find(f.CALENDAR_MONTH_WRAPPER).data("categoryid")),h(a,d,e,b,c)},k=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.removeClass("hidden")},l=function(a){var b=a.find(f.LOADING_ICON_CONTAINER);b.addClass("hidden")},m=function(g,h){k(g);var i=g.find(f.CALENDAR_MONTH_WRAPPER);return h||(h=g.find(f.CALENDAR_MONTH_WRAPPER).data("courseid")),d.getCalendarUpcomingData(h).then(function(a){return b.render(g.attr("data-template"),a)}).then(function(a,c){return window.history.replaceState(null,null,"?view=upcoming&course="+h),b.replaceNode(i,a,c)}).then(function(){a("body").trigger(e.viewUpdated)}).always(function(){return l(g)}).fail(c.exception)};return{init:function(a){g(a)},reloadCurrentMonth:j,changeMonth:i,refreshMonthContent:h,reloadCurrentUpcoming:m}});
|
||||
@@ -231,7 +231,9 @@ define([
|
||||
// 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;
|
||||
@@ -275,44 +277,18 @@ define([
|
||||
.fail(Notification.exception);
|
||||
});
|
||||
|
||||
var eventFormPromise = CalendarCrud.registerEventFormModal(root, CalendarSelectors.newEventButton);
|
||||
var eventFormPromise = CalendarCrud.registerEventFormModal(root);
|
||||
registerCalendarEventListeners(root, eventFormPromise);
|
||||
|
||||
// Bind click event on the new event button.
|
||||
CustomEvents.define(root, [CustomEvents.events.activate]);
|
||||
root.on('click', SELECTORS.NEW_EVENT_BUTTON, function(e) {
|
||||
eventFormPromise.then(function(modal) {
|
||||
var wrapper = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER);
|
||||
modal.setCourseId(wrapper.data('courseid'));
|
||||
var categoryId = wrapper.data('categoryid');
|
||||
if (typeof categoryId !== 'undefined') {
|
||||
modal.setCategoryId(categoryId);
|
||||
}
|
||||
|
||||
// Attempt to find the cell for today.
|
||||
// If it can't be found, then use the start time of the first day on the calendar.
|
||||
var today = root.find(SELECTORS.TODAY);
|
||||
if (!today.length) {
|
||||
modal.setStartTime(root.find(SELECTORS.DAY).attr('data-new-event-timestamp'));
|
||||
}
|
||||
|
||||
modal.show();
|
||||
return;
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Bind click events to calendar days.
|
||||
root.on('click', SELECTORS.DAY, function(e) {
|
||||
|
||||
var target = $(e.target);
|
||||
|
||||
if (!target.is(SELECTORS.VIEW_DAY_LINK)) {
|
||||
var startTime = $(this).attr('data-new-event-timestamp');
|
||||
eventFormPromise.then(function(modal) {
|
||||
var wrapper = target.closest(SELECTORS.CALENDAR_MONTH_WRAPPER);
|
||||
|
||||
var wrapper = target.closest(CalendarSelectors.wrapper);
|
||||
modal.setCourseId(wrapper.data('courseid'));
|
||||
|
||||
var categoryId = wrapper.data('categoryid');
|
||||
@@ -320,6 +296,7 @@ define([
|
||||
modal.setCategoryId(categoryId);
|
||||
}
|
||||
|
||||
modal.setContextId(wrapper.data('contextId'));
|
||||
modal.setStartTime(startTime);
|
||||
modal.show();
|
||||
return;
|
||||
@@ -334,7 +311,6 @@ define([
|
||||
return {
|
||||
init: function(root) {
|
||||
root = $(root);
|
||||
CalendarCrud.init(root);
|
||||
CalendarViewManager.init(root);
|
||||
registerEventListeners(root);
|
||||
}
|
||||
|
||||
@@ -48,53 +48,28 @@ define([
|
||||
CalendarCrud
|
||||
) {
|
||||
|
||||
var registerEventListeners = function(root) {
|
||||
var body = $('body'),
|
||||
deleteLink = $(CalendarSelectors.deleteLink),
|
||||
newEventButton = $(CalendarSelectors.newEventButton),
|
||||
courseId = root.data('courseid');
|
||||
var registerEventListeners = function(root, type) {
|
||||
var body = $('body');
|
||||
|
||||
var eventFormPromise = CalendarCrud.registerEventFormModal(root, newEventButton);
|
||||
CalendarCrud.registerEventFormModal(root);
|
||||
CalendarCrud.registerRemove(root);
|
||||
|
||||
CalendarCrud.registerRemove(deleteLink);
|
||||
var reloadFunction = 'reloadCurrent' + type.charAt(0).toUpperCase() + type.slice(1);
|
||||
|
||||
root.on('click', CalendarSelectors.deleteLink, function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var target = $(e.currentTarget),
|
||||
eventId = target.data('event-id'),
|
||||
eventTitle = target.data('title'),
|
||||
eventCount = target.data('event-event-count');
|
||||
|
||||
CalendarCrud.confirmDeletion(eventId, eventTitle, eventCount).then(function(deleteModalPromise) {
|
||||
body.on(CalendarEvents.deleted, function() {
|
||||
// Close the dialogue on delete.
|
||||
deleteModalPromise.hide();
|
||||
CalendarViewManager.reloadCurrentUpcoming(root, courseId);
|
||||
}.bind(this));
|
||||
});
|
||||
body.on(CalendarEvents.created, function() {
|
||||
CalendarViewManager[reloadFunction](root);
|
||||
});
|
||||
|
||||
root.on('click', CalendarSelectors.editLink, function(e) {
|
||||
e.preventDefault();
|
||||
var target = $(e.currentTarget);
|
||||
|
||||
eventFormPromise.then(function(modal) {
|
||||
// When something within the calendar tells us the user wants
|
||||
// to edit an event then show the event form modal.
|
||||
var eventId = target.data('event-id');
|
||||
if (eventId) {
|
||||
modal.setEventId(eventId);
|
||||
}
|
||||
modal.show();
|
||||
return;
|
||||
}).fail(Notification.exception);
|
||||
body.on(CalendarEvents.deleted, function() {
|
||||
CalendarViewManager[reloadFunction](root);
|
||||
});
|
||||
body.on(CalendarEvents.updated, function() {
|
||||
CalendarViewManager[reloadFunction](root);
|
||||
});
|
||||
|
||||
root.on('change', CalendarSelectors.courseSelector, function() {
|
||||
var selectElement = $(this);
|
||||
var courseId = selectElement.val();
|
||||
CalendarViewManager.reloadCurrentUpcoming(root, courseId)
|
||||
CalendarViewManager[reloadFunction](root, courseId)
|
||||
.then(function() {
|
||||
// We need to get the selector again because the content has changed.
|
||||
return root.find(CalendarSelectors.courseSelector).val(courseId);
|
||||
@@ -113,11 +88,11 @@ define([
|
||||
};
|
||||
|
||||
return {
|
||||
init: function(root) {
|
||||
init: function(root, type) {
|
||||
root = $(root);
|
||||
|
||||
CalendarViewManager.init(root);
|
||||
registerEventListeners(root);
|
||||
CalendarViewManager.init(root, type);
|
||||
registerEventListeners(root, type);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
+51
-16
@@ -149,22 +149,61 @@ function(
|
||||
*
|
||||
* @method registerEventFormModal
|
||||
* @param {object} root The calendar root element
|
||||
* @param {object} newEventButton The new event button element
|
||||
* @return {object} The create modal promise
|
||||
*/
|
||||
var registerEventFormModal = function(root, newEventButton) {
|
||||
var registerEventFormModal = function(root) {
|
||||
var eventFormPromise = ModalFactory.create({
|
||||
type: ModalEventForm.TYPE,
|
||||
large: true
|
||||
});
|
||||
|
||||
var contextId = newEventButton.data('context-id');
|
||||
// Bind click event on the new event button.
|
||||
root.on('click', CalendarSelectors.actions.create, function(e) {
|
||||
eventFormPromise.then(function(modal) {
|
||||
var wrapper = root.find(CalendarSelectors.wrapper);
|
||||
|
||||
return ModalFactory.create(
|
||||
{
|
||||
type: ModalEventForm.TYPE,
|
||||
large: true,
|
||||
templateContext: {
|
||||
contextid: contextId
|
||||
var categoryId = wrapper.data('categoryid');
|
||||
if (typeof categoryId !== 'undefined') {
|
||||
modal.setCategoryId(categoryId);
|
||||
}
|
||||
}, [root, CalendarSelectors.newEventButton]
|
||||
);
|
||||
|
||||
// Attempt to find the cell for today.
|
||||
// If it can't be found, then use the start time of the first day on the calendar.
|
||||
var today = root.find(CalendarSelectors.today);
|
||||
var firstDay = root.find(CalendarSelectors.day);
|
||||
if (!today.length && firstDay.length) {
|
||||
modal.setStartTime(firstDay.data('newEventTimestamp'));
|
||||
}
|
||||
|
||||
modal.setContextId(wrapper.data('contextId'));
|
||||
modal.setCourseId(wrapper.data('courseid'));
|
||||
modal.show();
|
||||
return;
|
||||
})
|
||||
.fail(Notification.exception);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
root.on('click', CalendarSelectors.actions.edit, function(e) {
|
||||
e.preventDefault();
|
||||
var target = $(e.currentTarget),
|
||||
calendarWrapper = target.closest(CalendarSelectors.wrapper),
|
||||
eventWrapper = target.closest(CalendarSelectors.eventItem);
|
||||
|
||||
eventFormPromise.then(function(modal) {
|
||||
// When something within the calendar tells us the user wants
|
||||
// to edit an event then show the event form modal.
|
||||
modal.setEventId(eventWrapper.data('eventId'));
|
||||
|
||||
modal.setContextId(calendarWrapper.data('contextId'));
|
||||
modal.show();
|
||||
return;
|
||||
}).fail(Notification.exception);
|
||||
});
|
||||
|
||||
|
||||
return eventFormPromise;
|
||||
};
|
||||
/**
|
||||
* Register the listeners required to remove the event.
|
||||
@@ -174,7 +213,7 @@ function(
|
||||
function registerRemove(root) {
|
||||
root.on('click', CalendarSelectors.actions.remove, function(e) {
|
||||
// Fetch the event title, count, and pass them into the new dialogue.
|
||||
var eventSource = $(this);
|
||||
var eventSource = $(this).closest(CalendarSelectors.eventItem);
|
||||
var eventId = eventSource.data('eventId'),
|
||||
eventTitle = eventSource.data('eventTitle'),
|
||||
eventCount = eventSource.data('eventCount');
|
||||
@@ -185,11 +224,7 @@ function(
|
||||
}
|
||||
|
||||
return {
|
||||
init: function(root) {
|
||||
registerEventFormModal(root, $(CalendarSelectors.newEventButton));
|
||||
},
|
||||
registerRemove: registerRemove,
|
||||
confirmDeletion: confirmDeletion,
|
||||
registerEventFormModal: registerEventFormModal
|
||||
};
|
||||
});
|
||||
|
||||
@@ -66,6 +66,7 @@ define([
|
||||
this.startTime = null;
|
||||
this.courseId = null;
|
||||
this.categoryId = null;
|
||||
this.contextId = null;
|
||||
this.reloadingBody = false;
|
||||
this.reloadingTitle = false;
|
||||
this.saveButton = this.getFooter().find(SELECTORS.SAVE_BUTTON);
|
||||
@@ -75,6 +76,26 @@ define([
|
||||
ModalEventForm.prototype = Object.create(Modal.prototype);
|
||||
ModalEventForm.prototype.constructor = ModalEventForm;
|
||||
|
||||
/**
|
||||
* Set the context id to the given value.
|
||||
*
|
||||
* @method setContextId
|
||||
* @param {Number} id The event id
|
||||
*/
|
||||
ModalEventForm.prototype.setContextId = function(id) {
|
||||
this.contextId = id;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve the current context id, if any.
|
||||
*
|
||||
* @method getContextId
|
||||
* @return {Number|null} The event id
|
||||
*/
|
||||
ModalEventForm.prototype.getContextId = function() {
|
||||
return this.contextId;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the course id to the given value.
|
||||
*
|
||||
@@ -278,7 +299,6 @@ define([
|
||||
this.reloadingBody = true;
|
||||
this.disableButtons();
|
||||
|
||||
var contextId = this.saveButton.attr('data-context-id');
|
||||
var args = {};
|
||||
|
||||
if (this.hasEventId()) {
|
||||
@@ -301,7 +321,7 @@ define([
|
||||
args.formdata = formData;
|
||||
}
|
||||
|
||||
this.bodyPromise = Fragment.loadFragment('calendar', 'event_form', contextId, args);
|
||||
this.bodyPromise = Fragment.loadFragment('calendar', 'event_form', this.getContextId(), args);
|
||||
|
||||
this.setBody(this.bodyPromise);
|
||||
|
||||
|
||||
@@ -41,13 +41,15 @@ define([], function() {
|
||||
calendarPeriods: {
|
||||
month: "[data-period='month']",
|
||||
},
|
||||
editLink: 'a[data-action="edit"]',
|
||||
deleteLink: 'a[data-action="delete"]',
|
||||
courseSelector: 'select[name="course"]',
|
||||
newEventButton: 'button[data-action="new-event-button"]',
|
||||
actions: {
|
||||
create: '[data-action="new-event-button"]',
|
||||
edit: '[data-action="edit"]',
|
||||
remove: '[data-action="delete"]',
|
||||
},
|
||||
today: '.today',
|
||||
day: '[data-region="day"]',
|
||||
wrapper: '.calendarwrapper',
|
||||
eventItem: '[data-type="event"]',
|
||||
};
|
||||
});
|
||||
|
||||
@@ -131,7 +131,7 @@ function(
|
||||
* @return {int}
|
||||
*/
|
||||
ModalEventSummary.prototype.getEventCount = function() {
|
||||
return this.getBody().find(SELECTORS.ROOT).attr('data-event-event-count');
|
||||
return this.getBody().find(SELECTORS.ROOT).attr('data-event-count');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -166,12 +166,13 @@ function(
|
||||
// We have to wait for the modal to finish rendering in order to ensure that
|
||||
// the data-event-title property is available to use as the modal title.
|
||||
this.getRoot().on(ModalEvents.bodyRendered, function() {
|
||||
this.getDeleteButton().data({
|
||||
this.getModal().data({
|
||||
eventTitle: this.getEventTitle(),
|
||||
eventId: this.getEventId(),
|
||||
eventCount: this.getEventCount(),
|
||||
});
|
||||
CalendarCrud.registerRemove(this.getModal(), SELECTORS.ROOT);
|
||||
})
|
||||
.attr('data-type', 'event');
|
||||
CalendarCrud.registerRemove(this.getModal());
|
||||
|
||||
}.bind(this));
|
||||
|
||||
|
||||
@@ -171,6 +171,10 @@ define(['jquery', 'core/templates', 'core/notification', 'core_calendar/reposito
|
||||
|
||||
var target = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER);
|
||||
|
||||
if (!courseId) {
|
||||
courseId = root.find(SELECTORS.CALENDAR_MONTH_WRAPPER).data('courseid');
|
||||
}
|
||||
|
||||
return CalendarRepository.getCalendarUpcomingData(courseId)
|
||||
.then(function(context) {
|
||||
return Templates.render(root.attr('data-template'), context);
|
||||
|
||||
@@ -36,6 +36,6 @@
|
||||
</div>
|
||||
{{#js}}
|
||||
require(['jquery', 'core_calendar/calendar_view'], function($, CalendarView) {
|
||||
CalendarView.init($("#calendar-upcoming-{{uniqid}}"));
|
||||
CalendarView.init($("#calendar-upcoming-{{uniqid}}"), 'upcoming');
|
||||
});
|
||||
{{/js}}
|
||||
|
||||
@@ -31,17 +31,25 @@
|
||||
{
|
||||
}
|
||||
}}
|
||||
<div class="event" data-eventtype-{{calendareventtype}}="1" data-event-event-count="{{eventcount}}">
|
||||
<div{{!
|
||||
}} data-type="event"{{!
|
||||
}} data-course-id="{{course.id}}"{{!
|
||||
}} data-event-id="{{id}}"{{!
|
||||
}} class="event"{{!
|
||||
}} data-eventtype-{{calendareventtype}}="1"{{!
|
||||
}} data-event-title="{{name}}"{{!
|
||||
}} data-event-count="{{eventcount}}"{{!
|
||||
}}>
|
||||
<div class="card">
|
||||
<div class="box card-header clearfix p-y-1">
|
||||
<div class="commands pull-xs-right">
|
||||
{{#canedit}}
|
||||
{{#candelete}}
|
||||
<a href="{{deleteurl}}" data-event-id="{{id}}" data-action="delete" data-event-id="{{id}}" data-title="{{name}}" data-event-event-count="{{eventcount}}">
|
||||
<a href="{{deleteurl}}" data-action="delete">
|
||||
{{#pix}}t/delete, core, {{#str}}delete{{/str}}{{/pix}}
|
||||
</a>
|
||||
{{/candelete}}
|
||||
<a href="{{editurl}}" data-event-id="{{id}}" data-action="edit" data-event-id="{{id}}" data-title="{{name}}">
|
||||
<a href="{{editurl}}" data-action="edit">
|
||||
{{#pix}}t/edit, core, {{#str}}edit{{/str}}{{/pix}}
|
||||
</a>
|
||||
{{/canedit}}
|
||||
@@ -65,4 +73,4 @@
|
||||
{{/groupname}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
}} data-region="summary-modal-container"{{!
|
||||
}} data-event-id="{{id}}"{{!
|
||||
}} data-event-title="{{name}}"{{!
|
||||
}} data-event-event-count="{{eventcount}}"{{!
|
||||
}} data-event-count="{{eventcount}}"{{!
|
||||
}} data-event-="{{repeatid}}"{{!
|
||||
}} data-action-event="{{isactionevent}}"{{!
|
||||
}} data-edit-url="{{editurl}}"{{!
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
}} class="calendarwrapper"{{!
|
||||
}}{{#courseid}} data-courseid="{{courseid}}"{{/courseid}}{{!
|
||||
}}{{#categoryid}} data-categoryid="{{categoryid}}"{{/categoryid}}{{!
|
||||
}} data-context-id="{{defaulteventcontext}}"{{!
|
||||
}} data-month="{{date.mon}}"{{!
|
||||
}} data-year="{{date.year}}"{{!
|
||||
}}>
|
||||
|
||||
Reference in New Issue
Block a user