MDL-66770 mod_forum: rename modern display mode to nested v2

This commit is contained in:
Ryan Wyllie
2019-11-01 13:17:24 +08:00
parent 787762b17a
commit 2602c7bfb5
24 changed files with 312 additions and 312 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,2 +1,2 @@
define ("mod_forum/inpage_reply",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,f){var g={MODERN:4,THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},h={POST_CREATED:"mod_forum-post-created"},i={MOODLE:0},j=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer),d=a.outerWidth();a.css("width",d);b.addClass("hidden");c.removeClass("hidden")},k=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer);a.css("width","");b.removeClass("hidden");c.addClass("hidden")},l=function(l){l.on("click",f.post.inpageSubmitBtn,function(m){m.preventDefault();var e=a(m.currentTarget),n=e.parent().find(f.post.inpageReplyButton),o=e.parents(f.post.inpageReplyForm).get(0),p=o.elements.post.value.trim(),q=i.MOODLE,r=o.elements.reply.value,s=o.elements.subject.value,t=e.closest(f.post.post),u=o.elements.privatereply!=void 0?o.elements.privatereply.checked:!1,v=l.find(f.post.modeSelect),w=v.length?parseInt(v.get(0).value):null,x;if(p.length){j(e);n.prop("disabled",!0);d.addDiscussionPost(r,s,p,q,u,!0).then(function(a){var b=a.messages.reduce(function(a,b){if("success"==b.type){a+="<p>"+b.message+"</p>"}return a},"");c.addNotification({message:b,type:"success"});return a}).then(function(a){o.reset();var c=a.post;x=c.id;switch(w){case g.MODERN:var d=c.capabilities,e=t.children().not(f.post.repliesContainer).find(f.post.authorName).text();c.parentauthorname=e;c.showactionmenu=d.view||d.controlreadstatus||d.edit||d.split||d.delete||d.export||c.urls.viewparent;return b.render("mod_forum/forum_discussion_modern_post_reply",c);case g.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case g.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c);}}).then(function(a,c){var d=t.find(f.post.repliesContainer).first();if(w==g.FLAT_NEWEST_FIRST){return b.prependNodeContents(d,a,c)}else{return b.appendNodeContents(d,a,c)}}).then(function(){e.trigger(h.POST_CREATED,x);k(e);n.prop("disabled",!1);return t.find(f.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+x}).catch(function(a){k(e);n.prop("disabled",!1);return c.exception(a)})}})};return{init:function init(a){l(a)},CONTENT_FORMATS:i,EVENTS:h}});
define ("mod_forum/inpage_reply",["jquery","core/templates","core/notification","mod_forum/repository","mod_forum/selectors"],function(a,b,c,d,f){var g={NESTED_V2:4,THREADED:2,NESTED:3,FLAT_OLDEST_FIRST:1,FLAT_NEWEST_FIRST:-1},h={POST_CREATED:"mod_forum-post-created"},i={MOODLE:0},j=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer),d=a.outerWidth();a.css("width",d);b.addClass("hidden");c.removeClass("hidden")},k=function(a){var b=a.find(f.post.inpageSubmitBtnText),c=a.find(f.post.loadingIconContainer);a.css("width","");b.removeClass("hidden");c.addClass("hidden")},l=function(l){l.on("click",f.post.inpageSubmitBtn,function(m){m.preventDefault();var e=a(m.currentTarget),n=e.parent().find(f.post.inpageReplyButton),o=e.parents(f.post.inpageReplyForm).get(0),p=o.elements.post.value.trim(),q=i.MOODLE,r=o.elements.reply.value,s=o.elements.subject.value,t=e.closest(f.post.post),u=o.elements.privatereply!=void 0?o.elements.privatereply.checked:!1,v=l.find(f.post.modeSelect),w=v.length?parseInt(v.get(0).value):null,x;if(p.length){j(e);n.prop("disabled",!0);d.addDiscussionPost(r,s,p,q,u,!0).then(function(a){var b=a.messages.reduce(function(a,b){if("success"==b.type){a+="<p>"+b.message+"</p>"}return a},"");c.addNotification({message:b,type:"success"});return a}).then(function(a){o.reset();var c=a.post;x=c.id;switch(w){case g.NESTED_V2:var d=c.capabilities,e=t.children().not(f.post.repliesContainer).find(f.post.authorName).text();c.parentauthorname=e;c.showactionmenu=d.view||d.controlreadstatus||d.edit||d.split||d.delete||d.export||c.urls.viewparent;return b.render("mod_forum/forum_discussion_nested_v2_post_reply",c);case g.THREADED:return b.render("mod_forum/forum_discussion_threaded_post",c);case g.NESTED:return b.render("mod_forum/forum_discussion_nested_post",c);default:return b.render("mod_forum/forum_discussion_post",c);}}).then(function(a,c){var d=t.find(f.post.repliesContainer).first();if(w==g.FLAT_NEWEST_FIRST){return b.prependNodeContents(d,a,c)}else{return b.appendNodeContents(d,a,c)}}).then(function(){e.trigger(h.POST_CREATED,x);k(e);n.prop("disabled",!1);return t.find(f.post.inpageReplyContent).hide()}).then(function(){location.href="#p"+x}).catch(function(a){k(e);n.prop("disabled",!1);return c.exception(a)})}})};return{init:function init(a){l(a)},CONTENT_FORMATS:i,EVENTS:h}});
//# sourceMappingURL=inpage_reply.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/>.
/**
* Module for viewing a discussion in modern view.
* Module for viewing a discussion in nested v2 view.
*
* @copyright 2019 Ryan Wyllie <ryan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -326,7 +326,7 @@ const renderInPageReplyTemplate = (additionalTemplateContext, button, postContai
...additionalTemplateContext
};
return Templates.render('mod_forum/inpage_reply_modern', context);
return Templates.render('mod_forum/inpage_reply_v2', context);
};
/**
@@ -393,7 +393,7 @@ const registerEventListeners = (root) => {
};
/**
* Initialise the javascript for the discussion in modern display mode.
* Initialise the javascript for the discussion in nested v2 display mode.
*
* @param {Object} root jQuery element for the discussion container
* @param {Object} context Additional render context for the in page reply template
+3 -3
View File
@@ -36,7 +36,7 @@ define([
) {
var DISPLAYCONSTANTS = {
MODERN: 4,
NESTED_V2: 4,
THREADED: 2,
NESTED: 3,
FLAT_OLDEST_FIRST: 1,
@@ -133,7 +133,7 @@ define([
newid = post.id;
switch (mode) {
case DISPLAYCONSTANTS.MODERN:
case DISPLAYCONSTANTS.NESTED_V2:
var capabilities = post.capabilities;
var currentAuthorName = currentRoot.children()
.not(Selectors.post.repliesContainer)
@@ -147,7 +147,7 @@ define([
capabilities.delete ||
capabilities.export ||
post.urls.viewparent;
return Templates.render('mod_forum/forum_discussion_modern_post_reply', post);
return Templates.render('mod_forum/forum_discussion_nested_v2_post_reply', post);
case DISPLAYCONSTANTS.THREADED:
return Templates.render('mod_forum/forum_discussion_threaded_post', post);
case DISPLAYCONSTANTS.NESTED:
@@ -183,8 +183,8 @@ class renderer {
case FORUM_MODE_NESTED:
$template = 'mod_forum/forum_discussion_nested_posts';
break;
case FORUM_MODE_MODERN:
$template = 'mod_forum/forum_discussion_modern_posts';
case FORUM_MODE_NESTED_V2:
$template = 'mod_forum/forum_discussion_nested_v2_posts';
break;
default;
$template = 'mod_forum/forum_discussion_posts';
@@ -228,7 +228,7 @@ class renderer {
$seenfirstunread = true;
}
if ($displaymode === FORUM_MODE_MODERN) {
if ($displaymode === FORUM_MODE_NESTED_V2) {
$exportedpost->showactionmenu = $exportedpost->capabilities['view'] ||
$exportedpost->capabilities['controlreadstatus'] ||
$exportedpost->capabilities['edit'] ||
@@ -246,7 +246,7 @@ class renderer {
if (
$displaymode === FORUM_MODE_NESTED ||
$displaymode === FORUM_MODE_THREADED ||
$displaymode === FORUM_MODE_MODERN
$displaymode === FORUM_MODE_NESTED_V2
) {
$sortedposts = $exportedpostssorter->sort_into_children($exportedposts);
$sortintoreplies = function($nestedposts) use (&$sortintoreplies) {
@@ -232,8 +232,8 @@ class discussion {
];
}
if ($this->displaymode === FORUM_MODE_MODERN) {
$template = 'mod_forum/forum_discussion_modern';
if ($this->displaymode === FORUM_MODE_NESTED_V2) {
$template = 'mod_forum/forum_discussion_nested_v2';
} else {
$template = 'mod_forum/forum_discussion';
}
@@ -332,7 +332,7 @@ class discussion {
$html = '<div class="movediscussionoption">';
$movebutton = get_string('move');
if ($this->displaymode === FORUM_MODE_MODERN) {
if ($this->displaymode === FORUM_MODE_NESTED_V2) {
// Move discussion selector will be rendered on the settings drawer. We won't output the button in this mode.
$movebutton = null;
}
+4 -4
View File
@@ -291,11 +291,11 @@ if ($node && $post->get_id() != $discussion->get_first_post_id()) {
$node->add(format_string($post->get_subject()), $PAGE->url);
}
$ismoderndisplaymode = $displaymode == FORUM_MODE_MODERN;
$isnestedv2displaymode = $displaymode == FORUM_MODE_NESTED_V2;
$PAGE->set_title("$course->shortname: " . format_string($discussion->get_name()));
$PAGE->set_heading($course->fullname);
if ($ismoderndisplaymode) {
$PAGE->add_body_class('modern-display-mode reset-style');
if ($isnestedv2displaymode) {
$PAGE->add_body_class('nested-v2-display-mode reset-style');
$PAGE->set_include_region_main_settings_in_header_actions(true);
$settingstrigger = $OUTPUT->render_from_template('mod_forum/settings_drawer_trigger', null);
$PAGE->add_header_action($settingstrigger);
@@ -304,7 +304,7 @@ if ($ismoderndisplaymode) {
}
echo $OUTPUT->header();
if (!$ismoderndisplaymode) {
if (!$isnestedv2displaymode) {
echo $OUTPUT->heading(format_string($forum->get_name()), 2);
echo $OUTPUT->heading(format_string($discussion->get_name()), 3, 'discussionname');
}
+1 -1
View File
@@ -394,8 +394,8 @@ $string['messageprovider:posts'] = 'Subscribed forum posts';
$string['missingsearchterms'] = 'The following search terms occur only in the HTML markup of this message:';
$string['modeflatnewestfirst'] = 'Display replies flat, with newest first';
$string['modeflatoldestfirst'] = 'Display replies flat, with oldest first';
$string['modemodern'] = 'Display replies in modern form';
$string['modenested'] = 'Display replies in nested form';
$string['modenestedv2'] = 'Display replies in experimental nested form';
$string['modethreaded'] = 'Display replies in threaded form';
$string['modulename'] = 'Forum';
$string['modulename_help'] = 'The forum activity module enables participants to have asynchronous discussions i.e. discussions that take place over an extended period of time.
+2 -2
View File
@@ -32,7 +32,7 @@ define('FORUM_MODE_FLATOLDEST', 1);
define('FORUM_MODE_FLATNEWEST', -1);
define('FORUM_MODE_THREADED', 2);
define('FORUM_MODE_NESTED', 3);
define('FORUM_MODE_MODERN', 4);
define('FORUM_MODE_NESTED_V2', 4);
define('FORUM_CHOOSESUBSCRIBE', 0);
define('FORUM_FORCESUBSCRIBE', 1);
@@ -5308,7 +5308,7 @@ function forum_get_layout_modes() {
FORUM_MODE_FLATNEWEST => get_string('modeflatnewestfirst', 'forum'),
FORUM_MODE_THREADED => get_string('modethreaded', 'forum'),
FORUM_MODE_NESTED => get_string('modenested', 'forum'),
FORUM_MODE_MODERN => get_string('modemodern', 'forum'));
FORUM_MODE_NESTED_V2 => get_string('modenestedv2', 'forum'));
}
/**
@@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_discussion_modern
@template mod_forum/forum_discussion_nested_v2
Template for displaying a single forum discussion.
@@ -44,7 +44,7 @@
{{{html.posts}}}
</div>
{{#js}}
require(['jquery', 'mod_forum/discussion_modern'], function($, Discussion) {
require(['jquery', 'mod_forum/discussion_nested_v2'], function($, Discussion) {
var root = $('#discussion-container-{{uniqid}}');
Discussion.init(root, {
{{#loggedinuser}}
@@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_discussion_modern_first_post
@template mod_forum/forum_discussion_nested_v2_first_post
Template to render a single post from a discussion.
@@ -353,7 +353,7 @@
<div class="indent replies-container" data-region="replies-container">
{{#hasreplies}}
{{#replies}}
{{> mod_forum/forum_discussion_modern_post_reply }}
{{> mod_forum/forum_discussion_nested_v2_post_reply }}
{{/replies}}
{{/hasreplies}}
</div>
@@ -29,7 +29,7 @@
{
}
}}
{{< mod_forum/forum_discussion_modern_first_post }}
{{< mod_forum/forum_discussion_nested_v2_first_post }}
{{$subject}}
<h3
{{#isdeleted}}class="h6 font-weight-bold"{{/isdeleted}}
@@ -76,10 +76,10 @@
<div class="indent replies-container" data-region="replies-container">
{{#hasreplies}}
{{#replies}}
{{> mod_forum/forum_discussion_modern_post_reply }}
{{> mod_forum/forum_discussion_nested_v2_post_reply }}
{{/replies}}
{{/hasreplies}}
</div>
<div class="indent inline-reply-container" data-region="inpage-reply-container"></div>
{{/replies}}
{{/ mod_forum/forum_discussion_modern_first_post }}
{{/ mod_forum/forum_discussion_nested_v2_first_post }}
@@ -15,7 +15,7 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/forum_discussion_modern_posts
@template mod_forum/forum_discussion_nested_v2_posts
Template to render a list of posts for a discussion.
@@ -30,5 +30,5 @@
}
}}
{{#posts}}
{{> mod_forum/forum_discussion_modern_first_post }}
{{> mod_forum/forum_discussion_nested_v2_first_post }}
{{/posts}}
@@ -31,6 +31,6 @@
}}
<div data-region="posts-modal">
{{#.}}
{{> mod_forum/forum_discussion_modern_post_reply }}
{{> mod_forum/forum_discussion_nested_v2_post_reply }}
{{/.}}
</div>
@@ -34,10 +34,10 @@
<div class="hr-sect mt-0">{{name}}</div>
{{#posts}}
{{#parent}}
{{> mod_forum/forum_discussion_modern_post_reply }}
{{> mod_forum/forum_discussion_nested_v2_post_reply }}
{{/parent}}
{{#starter}}
{{> mod_forum/forum_discussion_modern_first_post }}
{{> mod_forum/forum_discussion_nested_v2_first_post }}
<a class="btn btn-outline-dark"
role="button"
data-action="view-context"
@@ -52,7 +52,7 @@
<div class="forum-post-container" data-region="replies-container">
<div class="indent replies-container" data-region="replies-container">
<div class="indent replies-container" data-region="replies-container">
{{> mod_forum/forum_discussion_modern_post_reply }}
{{> mod_forum/forum_discussion_nested_v2_post_reply }}
<a class="btn btn-outline-dark"
role="button"
data-action="view-context"
@@ -15,9 +15,9 @@
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template mod_forum/inpage_reply_modern
@template mod_forum/inpage_reply_v2
In page reply HTML for the "modern" discussion display mode.
In page reply HTML for the nested v2 discussion display mode.
Classes required for JS:
* none
+2 -2
View File
@@ -110,8 +110,8 @@ if ($capabilitymanager->can_grade($USER)) {
$buttons[] = forum_search_form($course, $search);
$PAGE->set_button(implode('', $buttons));
if ($istypesingle && $displaymode == FORUM_MODE_MODERN) {
$PAGE->add_body_class('modern-display-mode reset-style');
if ($istypesingle && $displaymode == FORUM_MODE_NESTED_V2) {
$PAGE->add_body_class('nested-v2-display-mode reset-style');
}
if (empty($cm->visible) && !has_capability('moodle/course:viewhiddenactivities', $forum->get_context())) {
+2 -2
View File
@@ -219,7 +219,7 @@ $author-image-margin-sm: 8px;
}
#page-mod-forum-view [data-region="unified-grader"],
.path-mod-forum.modern-display-mode {
.path-mod-forum.nested-v2-display-mode {
.discussionsubscription {
margin-top: 0;
text-align: inherit;
@@ -384,7 +384,7 @@ $author-image-margin-sm: 8px;
/** Extra small devices (portrait phones, less than 576px). */
@include media-breakpoint-down(sm) {
#page-mod-forum-discuss.modern-display-mode {
#page-mod-forum-discuss.nested-v2-display-mode {
.forum-post-container {
.author-image-container {
width: $author-image-width-sm;
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long