mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-65033 mod_forum: Move locked functionality into action menu
Moved the lock functionality into the menu which exposes it to the discussion list
This commit is contained in:
parent
d3cac88dac
commit
cda9da9907
2
mod/forum/amd/build/discussion_list.min.js
vendored
2
mod/forum/amd/build/discussion_list.min.js
vendored
@ -1 +1 @@
|
||||
define(["jquery","mod_forum/subscription_toggle","mod_forum/selectors","mod_forum/repository"],function(a,b,c,d){var e=function(b){b.on("click",c.favourite.toggle,function(){var b=a(this),c=b.data("forumid"),e=b.data("discussionid"),f=b.data("targetstate");d.setFavouriteDiscussionState(c,e,f).then(function(){return location.reload()})["catch"](Notification.exception)}),b.on("click",c.pin.toggle,function(b){b.preventDefault();var c=a(this),e=c.data("forumid"),f=c.data("discussionid"),g=c.data("targetstate");d.setPinDiscussionState(e,f,g).then(function(){return location.reload()})["catch"](Notification.exception)})};return{init:function(a){b.init(a),e(a)}}});
|
||||
define(["jquery","core/templates","core/str","core/notification","mod_forum/subscription_toggle","mod_forum/selectors","mod_forum/repository"],function(a,b,c,d,e,f,g){var h=function(e){e.on("click",f.favourite.toggle,function(){var b=a(this),c=b.data("forumid"),e=b.data("discussionid"),f=b.data("targetstate");g.setFavouriteDiscussionState(c,e,f).then(function(){return location.reload()})["catch"](d.exception)}),e.on("click",f.pin.toggle,function(b){b.preventDefault();var c=a(this),e=c.data("forumid"),f=c.data("discussionid"),h=c.data("targetstate");g.setPinDiscussionState(e,f,h).then(function(){return location.reload()})["catch"](d.exception)}),e.on("click",f.lock.toggle,function(e){var f=a(this),h=f.data("forumid"),i=f.data("discussionid"),j=f.data("state");g.setDiscussionLockState(h,i,j).then(function(a){return a.forumid=h,b.render("mod_forum/discussion_lock_toggle",a)}).then(function(a,c){return b.replaceNode(f,a,c)}).then(function(){return c.get_string("lockupdated","forum").done(function(a){return d.addNotification({message:a,type:"info"})})})["catch"](d.exception),e.preventDefault()})};return{init:function(a){e.init(a),h(a)}}});
|
@ -23,11 +23,17 @@
|
||||
*/
|
||||
define([
|
||||
'jquery',
|
||||
'core/templates',
|
||||
'core/str',
|
||||
'core/notification',
|
||||
'mod_forum/subscription_toggle',
|
||||
'mod_forum/selectors',
|
||||
'mod_forum/repository',
|
||||
], function(
|
||||
$,
|
||||
Templates,
|
||||
String,
|
||||
Notification,
|
||||
SubscriptionToggle,
|
||||
Selectors,
|
||||
Repository
|
||||
@ -57,6 +63,34 @@ define([
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
});
|
||||
|
||||
root.on('click', Selectors.lock.toggle, function(e) {
|
||||
var toggleElement = $(this);
|
||||
var forumId = toggleElement.data('forumid');
|
||||
var discussionId = toggleElement.data('discussionid');
|
||||
var state = toggleElement.data('state');
|
||||
|
||||
Repository.setDiscussionLockState(forumId, discussionId, state)
|
||||
.then(function(context) {
|
||||
context.forumid = forumId;
|
||||
return Templates.render('mod_forum/discussion_lock_toggle', context);
|
||||
})
|
||||
.then(function(html, js) {
|
||||
return Templates.replaceNode(toggleElement, html, js);
|
||||
})
|
||||
.then(function() {
|
||||
return String.get_string('lockupdated', 'forum')
|
||||
.done(function(s) {
|
||||
return Notification.addNotification({
|
||||
message: s,
|
||||
type: "info"
|
||||
});
|
||||
});
|
||||
})
|
||||
.catch(Notification.exception);
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -1642,6 +1642,36 @@ class mod_forum_external extends external_api {
|
||||
return $exporter->export($PAGE->get_renderer('mod_forum'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
*/
|
||||
public static function set_lock_state_parameters() {
|
||||
return new external_function_parameters(
|
||||
[
|
||||
'forumid' => new external_value(PARAM_INT, 'Forum that the discussion is in'),
|
||||
'discussionid' => new external_value(PARAM_INT, 'The discussion to lock / unlock'),
|
||||
'targetstate' => new external_value(PARAM_INT, 'The timestamp for the lock state')
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value.
|
||||
*
|
||||
* @return external_description
|
||||
*/
|
||||
public static function set_lock_state_returns() {
|
||||
return new external_single_structure([
|
||||
'id' => new external_value(PARAM_INT, 'The discussion we are locking.'),
|
||||
'locked' => new external_value(PARAM_BOOL, 'The locked state of the discussion.'),
|
||||
'times' => new external_single_structure([
|
||||
'locked' => new external_value(PARAM_INT, 'The locked time of the discussion.'),
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pin state.
|
||||
*
|
||||
@ -1672,29 +1702,13 @@ class mod_forum_external extends external_api {
|
||||
}
|
||||
|
||||
$discussion->set_pinned($targetstate);
|
||||
$discussionrecord = $legacydatamapperfactory->get_discussion_data_mapper()->to_legacy_object($discussion);
|
||||
$discussionvault->update_discussion($discussionrecord);
|
||||
$discussionvault->update_discussion($discussion);
|
||||
|
||||
$exporterfactory = mod_forum\local\container::get_exporter_factory();
|
||||
$exporter = $exporterfactory->get_discussion_exporter($USER, $forum, $discussion);
|
||||
return $exporter->export($PAGE->get_renderer('mod_forum'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
* @return external_function_parameters
|
||||
*/
|
||||
public static function set_lock_state_parameters() {
|
||||
return new external_function_parameters(
|
||||
[
|
||||
'forumid' => new external_value(PARAM_INT, 'Forum that the discussion is in'),
|
||||
'discussionid' => new external_value(PARAM_INT, 'The discussion to lock / unlock'),
|
||||
'targetstate' => new external_value(PARAM_INT, 'The timestamp for the lock state')
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method parameters.
|
||||
*
|
||||
@ -1711,21 +1725,6 @@ class mod_forum_external extends external_api {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value.
|
||||
*
|
||||
* @return external_description
|
||||
*/
|
||||
public static function set_lock_state_returns() {
|
||||
return new external_single_structure([
|
||||
'id' => new external_value(PARAM_INT, 'The discussion we are locking.'),
|
||||
'locked' => new external_value(PARAM_BOOL, 'The locked state of the discussion.'),
|
||||
'times' => new external_single_structure([
|
||||
'locked' => new external_value(PARAM_INT, 'The locked time of the discussion.'),
|
||||
])
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns description of method result value.
|
||||
*
|
||||
|
@ -325,6 +325,7 @@ $string['lockdiscussionafter_help'] = 'Discussions may be automatically locked a
|
||||
Users with the capability to reply to locked discussions can unlock a discussion by replying to it.';
|
||||
$string['longpost'] = 'Long post';
|
||||
$string['locked'] = 'Locked';
|
||||
$string['lockupdated'] = 'The lock option has been updated.';
|
||||
$string['mailnow'] = 'Send forum post notifications with no editing-time delay';
|
||||
$string['manydiscussions'] = 'Discussions per page';
|
||||
$string['managesubscriptionsoff'] = 'Finish managing subscriptions';
|
||||
|
@ -302,7 +302,6 @@ span.unread {
|
||||
}
|
||||
|
||||
.path-mod-forum .discussionsubscription,
|
||||
.path-mod-forum .discussionlock,
|
||||
.path-mod-forum .discussion-settings-menu,
|
||||
.path-mod-forum .discussionsubscription {
|
||||
margin-top: -10px;
|
||||
|
@ -35,12 +35,12 @@
|
||||
}
|
||||
}}
|
||||
<a
|
||||
class="iconsmall"
|
||||
class="btn btn-link"
|
||||
data-type="lock-toggle"
|
||||
data-action="toggle"
|
||||
data-discussionid="{{id}}"
|
||||
data-forumid="{{forumid}}"
|
||||
data-state="{{locked}}"
|
||||
data-state="{{times.locked}}"
|
||||
href="#"
|
||||
{{#locked}}
|
||||
title="{{#str}}clicktounlockdiscussion, forum{{/str}}"
|
||||
@ -50,9 +50,9 @@
|
||||
{{/locked}}
|
||||
>
|
||||
{{#locked}}
|
||||
{{#pix}}t/unlock, core, {{#str}}clicktounlockdiscussion, forum{{/str}}{{/pix}}{{#str}}locked, forum{{/str}}
|
||||
{{#str}}locked, forum{{/str}}
|
||||
{{/locked}}
|
||||
{{^locked}}
|
||||
{{#pix}}t/lock, core, {{#str}}clicktolockdiscussion, forum{{/str}}{{/pix}}{{#str}}notlocked, forum{{/str}}
|
||||
{{#str}}notlocked, forum{{/str}}
|
||||
{{/locked}}
|
||||
</a>
|
@ -59,5 +59,12 @@
|
||||
{{> mod_forum/discussion_pin_toggle}}
|
||||
</div>
|
||||
{{/capabilities.pin}}
|
||||
{{#capabilities.manage}}
|
||||
{{^istimelocked}}
|
||||
<div class="dropdown-item" role="menuitem">
|
||||
{{> forum/discussion_lock_toggle }}
|
||||
</div>
|
||||
{{/istimelocked}}
|
||||
{{/capabilities.manage}}
|
||||
</div>
|
||||
</div>
|
@ -33,13 +33,7 @@
|
||||
<div id="discussion-container-{{uniqid}}" data-content="forum-discussion">
|
||||
{{#html}}
|
||||
<div class="d-flex flex-wrap flex-row-reverse m-b-1 text-right" data-container="discussion-tools">
|
||||
{{#capabilities.manage}}
|
||||
{{^istimelocked}}
|
||||
<div class="pl-1 discussionlock">
|
||||
{{> forum/discussion_lock_toggle }}
|
||||
</div>
|
||||
{{/istimelocked}}
|
||||
{{/capabilities.manage}}
|
||||
|
||||
<div class="pl-1">
|
||||
<div class="discussion-settings-menu">
|
||||
{{> mod_forum/forum_action_menu}}
|
||||
|
@ -34,11 +34,14 @@ Feature: As a teacher, you can manually lock individual discussions when viewing
|
||||
Given I log in as "admin"
|
||||
And I am on "Course 1" course homepage
|
||||
And I navigate to post "Discussion 1" in "Test forum name" forum
|
||||
And I press "Settings"
|
||||
Then "Lock" "link" should be visible
|
||||
And I follow "Lock"
|
||||
Then I should see "This discussion has been locked so you can no longer reply to it."
|
||||
And I press "Settings"
|
||||
Then "a[@title='Lock']" "css_element" should not be visible
|
||||
Then "Locked" "link" should be visible
|
||||
Then I should see "This discussion has been locked so you can no longer reply to it."
|
||||
And I press "Settings"
|
||||
And I follow "Discussion 2"
|
||||
Then I should not see "This discussion has been locked so you can no longer reply to it."
|
||||
And I log out
|
||||
|
@ -69,7 +69,6 @@ select {
|
||||
|
||||
thead .header th,
|
||||
tbody .discussion td {
|
||||
&.discussionlock,
|
||||
&.discussionsubscription {
|
||||
width: 16px;
|
||||
padding-left: 0.5em;
|
||||
@ -84,14 +83,12 @@ select {
|
||||
}
|
||||
|
||||
.discussionsubscription,
|
||||
.discussionlock,
|
||||
.replies {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.topic,
|
||||
.discussionsubscription,
|
||||
.discussionlock,
|
||||
.topic.starter,
|
||||
.replies,
|
||||
.lastpost {
|
||||
|
@ -15028,8 +15028,7 @@ select {
|
||||
.path-mod-forum .forumheaderlist thead .header.lastpost {
|
||||
text-align: right; }
|
||||
|
||||
.path-mod-forum .forumheaderlist thead .header th.discussionlock, .path-mod-forum .forumheaderlist thead .header th.discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist tbody .discussion td.discussionlock,
|
||||
.path-mod-forum .forumheaderlist thead .header th.discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist tbody .discussion td.discussionsubscription {
|
||||
width: 16px;
|
||||
padding-left: 0.5em;
|
||||
@ -15040,13 +15039,11 @@ select {
|
||||
white-space: normal; }
|
||||
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionlock,
|
||||
.path-mod-forum .forumheaderlist .discussion .replies {
|
||||
text-align: center; }
|
||||
|
||||
.path-mod-forum .forumheaderlist .discussion .topic,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionlock,
|
||||
.path-mod-forum .forumheaderlist .discussion .topic.starter,
|
||||
.path-mod-forum .forumheaderlist .discussion .replies,
|
||||
.path-mod-forum .forumheaderlist .discussion .lastpost {
|
||||
|
@ -15285,8 +15285,7 @@ select {
|
||||
.path-mod-forum .forumheaderlist thead .header.lastpost {
|
||||
text-align: right; }
|
||||
|
||||
.path-mod-forum .forumheaderlist thead .header th.discussionlock, .path-mod-forum .forumheaderlist thead .header th.discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist tbody .discussion td.discussionlock,
|
||||
.path-mod-forum .forumheaderlist thead .header th.discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist tbody .discussion td.discussionsubscription {
|
||||
width: 16px;
|
||||
padding-left: 0.5em;
|
||||
@ -15297,13 +15296,11 @@ select {
|
||||
white-space: normal; }
|
||||
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionlock,
|
||||
.path-mod-forum .forumheaderlist .discussion .replies {
|
||||
text-align: center; }
|
||||
|
||||
.path-mod-forum .forumheaderlist .discussion .topic,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionsubscription,
|
||||
.path-mod-forum .forumheaderlist .discussion .discussionlock,
|
||||
.path-mod-forum .forumheaderlist .discussion .topic.starter,
|
||||
.path-mod-forum .forumheaderlist .discussion .replies,
|
||||
.path-mod-forum .forumheaderlist .discussion .lastpost {
|
||||
|
Loading…
x
Reference in New Issue
Block a user