MDL-59383 core_calendar: change modal body rendering

This commit is contained in:
Simey Lameze 2017-07-12 13:53:16 +08:00
parent 8a5c06b705
commit e1c811609b
2 changed files with 8 additions and 2 deletions

View File

@ -1 +1 @@
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_factory","core_calendar/summary_modal","core_calendar/calendar_repository"],function(a,b,c,d,e,f,g,h,i){var j={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']"},k=null,l=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a}).fail(e.exception)},m=function(a){var b=i.getEventById(a);return b.then(function(a){return a.event?a.event:void b.fail(e.exception)}).then(function(a){return l(a.eventtype).then(function(b){return a.eventtype=b,a})}).then(function(a){return k.done(function(b){b.setTitle(a.name),b.setBody(d.render("core_calendar/event_summary_body",a)),0==a.caneditevent&&b.setFooter(""),b.show()})})},n=function(b){b=a(b);var c=!1;b.on("click",j.EVENT_LINK,function(b){if(!c){c=!0,b.preventDefault();var d=a(b.target).closest(j.EVENT_LINK),e=d.attr("data-event-id");m(e).done(function(){c=!1})}})};return{init:function(){k=g.create({type:h.TYPE}),n(j.ROOT)}}});
define(["jquery","core/ajax","core/str","core/templates","core/notification","core/custom_interaction_events","core/modal_factory","core_calendar/summary_modal","core_calendar/calendar_repository"],function(a,b,c,d,e,f,g,h,i){var j={ROOT:"[data-region='calendar']",EVENT_LINK:"[data-action='view-event']"},k=null,l=function(a){var b="type"+a;return c.get_string(b,"core_calendar").then(function(a){return a}).fail(e.exception)},m=function(a){var b=i.getEventById(a);return b.then(function(a){return a.event?a.event:void b.fail(e.exception)}).then(function(a){return l(a.eventtype).then(function(b){return a.eventtype=b,a})}).then(function(a){return k.done(function(b){b.setTitle(a.name),d.render("core_calendar/event_summary_body",a).done(function(a,c){d.replaceNodeContents(b.getBody(),a,c)}),0==a.caneditevent&&b.setFooter(""),b.show()})})},n=function(b){b=a(b);var c=!1;b.on("click",j.EVENT_LINK,function(b){if(!c){c=!0,b.preventDefault();var d=a(b.target).closest(j.EVENT_LINK),e=d.attr("data-event-id");m(e).done(function(){c=!1})}})};return{init:function(){k=g.create({type:h.TYPE}),n(j.ROOT)}}});

View File

@ -69,7 +69,13 @@ define(['jquery', 'core/ajax', 'core/str', 'core/templates', 'core/notification'
}).then(function(eventdata) {
return modalPromise.done(function(modal) {
modal.setTitle(eventdata.name);
modal.setBody(Templates.render('core_calendar/event_summary_body', eventdata));
Templates.render(
'core_calendar/event_summary_body',
eventdata
).done(function(html, js) {
Templates.replaceNodeContents(modal.getBody(), html, js);
});
// Hide edit and delete buttons if I don't have permission.
if (eventdata.caneditevent == false) {