diff --git a/message/output/popup/amd/build/message_popover_controller.min.js b/message/output/popup/amd/build/message_popover_controller.min.js index b67fdc8f4bb..37fea7587b0 100644 --- a/message/output/popup/amd/build/message_popover_controller.min.js +++ b/message/output/popup/amd/build/message_popover_controller.min.js @@ -1 +1 @@ -define(["jquery","core/ajax","core/templates","core/str","core/notification","core/custom_interaction_events","core/popover_region_controller","core_message/message_repository","core/url"],function(a,b,c,d,e,f,g,h,i){var j={MARK_ALL_READ_BUTTON:'[data-action="mark-all-read"]',CONTENT:'[data-region="messages"]',CONTENT_ITEM_CONTAINER:'[data-region="message-content-item-container"]',EMPTY_MESSAGE:'[data-region="empty-message"]',COUNT_CONTAINER:'[data-region="count-container"]'},k=function(a){g.call(this,a),this.markAllReadButton=this.root.find(j.MARK_ALL_READ_BUTTON),this.content=this.root.find(j.CONTENT),this.userId=this.root.attr("data-userid"),this.limit=20,this.offset=0,this.loadedAll=!1,this.initialLoad=!1,this.loadUnreadMessageCount()};return k.prototype=Object.create(g.prototype),k.prototype.constructor=k,k.prototype.getContent=function(){return this.content},k.prototype.incrementOffset=function(){this.offset+=this.limit},k.prototype.updateButtonAriaLabel=function(){this.isMenuOpen()?d.get_string("hidemessagewindow","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):this.unreadCount?d.get_string("showmessagewindowwithcount","message",this.unreadCount).done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this)):d.get_string("showmessagewindownonew","message").done(function(a){this.menuToggle.attr("aria-label",a)}.bind(this))},k.prototype.renderUnreadCount=function(){var a=this.root.find(j.COUNT_CONTAINER);this.unreadCount?(a.text(this.unreadCount),a.removeClass("hidden")):a.addClass("hidden")},k.prototype.hideUnreadCount=function(){this.root.find(j.COUNT_CONTAINER).addClass("hidden")},k.prototype.loadUnreadMessageCount=function(){h.countUnreadConversations({useridto:this.userId}).then(function(a){this.unreadCount=a,this.renderUnreadCount(),this.updateButtonAriaLabel()}.bind(this))["catch"](e.exception)},k.prototype.renderMessages=function(b,d){var e=[];return a.each(b,function(a,b){b.contexturl=i.relativeUrl("/message/index.php",{user:this.userId,id:b.userid}),b.profileurl=i.relativeUrl("/user/profile.php",{id:b.userid});var d=c.render("message_popup/message_content_item",b).then(function(a,b){return{html:a,js:b}});e.push(d)}.bind(this)),a.when.apply(a,e).then(function(){a.each(arguments,function(a,b){d.append(b.html),c.runTemplateJS(b.js)})})},k.prototype.loadMoreMessages=function(){if(this.isLoading||this.loadedAll)return a.Deferred().resolve();this.startLoading();var b={userid:this.userId,limit:this.limit,offset:this.offset},c=this.getContent();return h.query(b).then(function(a){var b=a.contacts;return this.loadedAll=!b.length||b.length. -defined('MOODLE_INTERNAL') || die(); - /** * Contains standard functions for message_popup. * @@ -24,6 +22,8 @@ defined('MOODLE_INTERNAL') || die(); * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Renders the popup. * @@ -45,8 +45,10 @@ function message_popup_render_navbar_output(\renderer_base $renderer) { // Add the messages popover. if (!empty($CFG->messaging)) { + $unreadcount = \core_message\api::count_unread_conversations($USER); $context = [ 'userid' => $USER->id, + 'unreadcount' => $unreadcount, 'urls' => [ 'seeall' => (new moodle_url('/message/index.php'))->out(), 'writeamessage' => (new moodle_url('/message/index.php', ['contactsfirst' => 1]))->out(), @@ -59,8 +61,10 @@ function message_popup_render_navbar_output(\renderer_base $renderer) { // Add the notifications popover. $enabled = \core_message\api::is_processor_enabled("popup"); if ($enabled) { + $unreadcount = \message_popup\api::count_unread_popup_notifications($USER->id); $context = [ 'userid' => $USER->id, + 'unreadcount' => $unreadcount, 'urls' => [ 'seeall' => (new moodle_url('/message/output/popup/notifications.php'))->out(), 'preferences' => (new moodle_url('/message/notificationpreferences.php', ['userid' => $USER->id]))->out(), diff --git a/message/output/popup/templates/message_popover.mustache b/message/output/popup/templates/message_popover.mustache index 03559938f51..75b363d8fa2 100644 --- a/message/output/popup/templates/message_popover.mustache +++ b/message/output/popup/templates/message_popover.mustache @@ -45,7 +45,7 @@ {{$togglelabel}}{{#str}} showmessagewindownonew, message {{/str}}{{/togglelabel}} {{$togglecontent}} {{#pix}} t/message, core, {{#str}} togglemessagemenu, message {{/str}} {{/pix}} - +
{{unreadcount}}
{{/togglecontent}} {{$containerlabel}}{{#str}} notificationwindow, message {{/str}}{{/containerlabel}} diff --git a/message/output/popup/templates/notification_popover.mustache b/message/output/popup/templates/notification_popover.mustache index 97efbff1638..602d10643da 100644 --- a/message/output/popup/templates/notification_popover.mustache +++ b/message/output/popup/templates/notification_popover.mustache @@ -45,7 +45,7 @@ {{$togglelabel}}{{#str}} shownotificationwindownonew, message {{/str}}{{/togglelabel}} {{$togglecontent}} {{#pix}} i/notifications, core, {{#str}} togglenotificationmenu, message {{/str}} {{/pix}} - +
{{unreadcount}}
{{/togglecontent}} {{$containerlabel}}{{#str}} notificationwindow, message {{/str}}{{/containerlabel}}