MDL-66074 mod_forum: Documentation and hiding conversation elements
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
||||
define ("mod_forum/grades/expandconversation",["exports","./grader/selectors","mod_forum/repository","core/notification","core/templates","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=void 0;b=i(b);c=h(c);e=h(e);f=i(f);g=i(g);function h(a){return a&&a.__esModule?a:{default:a}}function i(a){if(a&&a.__esModule){return a}else{var b={};if(null!=a){for(var c in a){if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};if(d.get||d.set){Object.defineProperty(b,c,d)}else{b[c]=a[c]}}}}b.default=a;return b}}function j(a,b){return m(a)||l(a,b)||k()}function k(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function l(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function m(a){if(Array.isArray(a))return a}function n(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function o(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){n(h,d,e,f,g,"next",a)}function g(a){n(h,d,e,f,g,"throw",a)}f(void 0)})}}var p=function(a){return a.closest(b.expandConversation)},q=function(){var a=o(regeneratorRuntime.mark(function a(b){var d,h,i,k,l,m,n,o;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=b.dataset.postid;h=b.dataset.discussionid;i=b.dataset.name;a.next=5;return Promise.all([c.default.getDiscussionPosts(parseInt(h)),f.create({title:i,large:!0,type:f.types.CANCEL})]);case 5:k=a.sent;l=j(k,2);m=l[0];n=l[1];n.getRoot().on(g.hidden,function(){n.destroy()});n.show();o=e.default.render("mod_forum/grades/grader/discussion/post_modal",m);n.setBody(o);o.then(function(){var a=n.getRoot()[0].querySelector("#p".concat(d));if(a){a.scrollIntoView({behavior:"smooth"})}return});case 14:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.registerEventListeners=function registerEventListeners(a){a.addEventListener("click",function(a){var b=p(a.target);if(b){a.preventDefault();try{q(b)}catch(a){(0,d.exception)(a)}}})}});
|
||||
define ("mod_forum/grades/expandconversation",["exports","./grader/selectors","mod_forum/repository","core/notification","core/templates","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){"use strict";Object.defineProperty(a,"__esModule",{value:!0});a.registerEventListeners=void 0;b=i(b);c=h(c);e=h(e);f=i(f);g=i(g);function h(a){return a&&a.__esModule?a:{default:a}}function i(a){if(a&&a.__esModule){return a}else{var b={};if(null!=a){for(var c in a){if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};if(d.get||d.set){Object.defineProperty(b,c,d)}else{b[c]=a[c]}}}}b.default=a;return b}}function j(a,b){return m(a)||l(a,b)||k()}function k(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function l(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g=a[Symbol.iterator](),h;!(d=(h=g.next()).done);d=!0){c.push(h.value);if(b&&c.length===b)break}}catch(a){e=!0;f=a}finally{try{if(!d&&null!=g["return"])g["return"]()}finally{if(e)throw f}}return c}function m(a){if(Array.isArray(a))return a}function n(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){c(a);return}if(h.done){b(i)}else{Promise.resolve(i).then(d,e)}}function o(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){var h=a.apply(b,c);function f(a){n(h,d,e,f,g,"next",a)}function g(a){n(h,d,e,f,g,"throw",a)}f(void 0)})}}var p=function(a){return a.closest(b.expandConversation)},q=function(){var a=o(regeneratorRuntime.mark(function a(b){var d,h,i,k,l,m,n,o,p;return regeneratorRuntime.wrap(function(a){while(1){switch(a.prev=a.next){case 0:d=b.dataset.postid;h=b.dataset.discussionid;i=b.dataset.name;a.next=5;return Promise.all([c.default.getDiscussionPosts(parseInt(h)),f.create({title:i,large:!0,type:f.types.CANCEL})]);case 5:k=a.sent;l=j(k,2);m=l[0];n=l[1];o=m.posts.map(function(a){a.subject=null;a.readonly=!0;a.html.rating=null;return a});n.getRoot().on(g.hidden,function(){n.destroy()});n.show();p=e.default.render("mod_forum/grades/grader/discussion/post_modal",o);n.setBody(p);p.then(function(){var a=n.getRoot()[0].querySelector("#p".concat(d));if(a){a.scrollIntoView({behavior:"smooth"})}return});case 15:case"end":return a.stop();}}},a)}));return function(){return a.apply(this,arguments)}}();a.registerEventListeners=function registerEventListeners(a){a.addEventListener("click",function(a){var b=p(a.target);if(b){a.preventDefault();try{q(b)}catch(a){(0,d.exception)(a)}}})}});
|
||||
//# sourceMappingURL=expandconversation.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -14,7 +14,7 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This module will tie together all of the different calls the gradable module will make.
|
||||
* This module handles the creation of a Modal that shows the user's post in context of the entire discussion.
|
||||
*
|
||||
* @module mod_forum/grades/expandconversation
|
||||
* @package mod_forum
|
||||
@@ -39,9 +39,9 @@ const findGradableNode = node => node.closest(ForumSelectors.expandConversation)
|
||||
/**
|
||||
* Show the post in context in a modal.
|
||||
*
|
||||
* @param {HTMLElement} rootNode The button thas clicked
|
||||
* @param {HTMLElement} rootNode The button that has been clicked
|
||||
*/
|
||||
const showPostInContext = async rootNode => {
|
||||
const showPostInContext = async(rootNode) => {
|
||||
const postId = rootNode.dataset.postid;
|
||||
const discussionId = rootNode.dataset.discussionid;
|
||||
const discussionName = rootNode.dataset.name;
|
||||
@@ -58,6 +58,14 @@ const showPostInContext = async rootNode => {
|
||||
}),
|
||||
]);
|
||||
|
||||
const userPosts = allPosts.posts.map((post) => {
|
||||
post.subject = null;
|
||||
post.readonly = true;
|
||||
post.html.rating = null;
|
||||
|
||||
return post;
|
||||
});
|
||||
|
||||
// Handle hidden event.
|
||||
modal.getRoot().on(ModalEvents.hidden, function() {
|
||||
// Destroy when hidden.
|
||||
@@ -67,7 +75,7 @@ const showPostInContext = async rootNode => {
|
||||
modal.show();
|
||||
|
||||
// Note: We do not use await here because it messes with the Modal transitions.
|
||||
const templatePromise = Templates.render('mod_forum/grades/grader/discussion/post_modal', allPosts);
|
||||
const templatePromise = Templates.render('mod_forum/grades/grader/discussion/post_modal', userPosts);
|
||||
modal.setBody(templatePromise);
|
||||
// eslint-disable-next-line promise/catch-or-return
|
||||
templatePromise.then(() => {
|
||||
@@ -85,8 +93,8 @@ const showPostInContext = async rootNode => {
|
||||
*
|
||||
* @param {HTMLElement} rootNode The root to listen to.
|
||||
*/
|
||||
export const registerEventListeners = rootNode => {
|
||||
rootNode.addEventListener('click', e => {
|
||||
export const registerEventListeners = (rootNode) => {
|
||||
rootNode.addEventListener('click', (e) => {
|
||||
const rootNode = findGradableNode(e.target);
|
||||
|
||||
if (rootNode) {
|
||||
|
||||
Reference in New Issue
Block a user