mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-24 08:23:52 +00:00
Merge "Show edit notices in the new discussion tool"
This commit is contained in:
commit
1f9d96d81a
|
@ -5,10 +5,13 @@
|
|||
* @constructor
|
||||
* @param {string} pageName Page name the reply is being saved to
|
||||
* @param {number} oldId Revision ID of page at time of editing
|
||||
* @param {Object.<string,string>} notices Edit notices for the page where the reply is being saved.
|
||||
* Keys are message names; values are HTML to display.
|
||||
*/
|
||||
function CommentDetails( pageName, oldId ) {
|
||||
function CommentDetails( pageName, oldId, notices ) {
|
||||
this.pageName = pageName;
|
||||
this.oldId = oldId;
|
||||
this.notices = notices;
|
||||
}
|
||||
|
||||
OO.initClass( CommentDetails );
|
||||
|
|
|
@ -9,6 +9,7 @@ function NewTopicController( $pageContainer, $replyLink, parser ) {
|
|||
padded: true,
|
||||
framed: true
|
||||
} );
|
||||
this.$notices = $( '<div>' ).addClass( 'ext-discussiontools-ui-newTopic-notices' );
|
||||
|
||||
this.sectionTitle = new OO.ui.TextInputWidget( {
|
||||
// Wrap in a <h2> element to inherit heading font styles
|
||||
|
@ -23,7 +24,7 @@ function NewTopicController( $pageContainer, $replyLink, parser ) {
|
|||
} );
|
||||
this.prevTitleText = '';
|
||||
|
||||
this.container.$element.append( this.sectionTitleField.$element );
|
||||
this.container.$element.append( this.$notices, this.sectionTitleField.$element );
|
||||
|
||||
// HeadingItem representing the heading being added, so that we can pretend we're replying to it
|
||||
var comment = new HeadingItem( {
|
||||
|
@ -67,6 +68,24 @@ NewTopicController.prototype.setup = function ( mode ) {
|
|||
NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) {
|
||||
NewTopicController.super.prototype.setupReplyWidget.call( this, replyWidget, data );
|
||||
|
||||
this.$notices.empty();
|
||||
for ( var noticeName in this.replyWidget.commentDetails.notices ) {
|
||||
if (
|
||||
// Ignored because we have a custom warning for non-logged-in users.
|
||||
noticeName === 'anoneditwarning' ||
|
||||
// Ignored because it contains mostly instructions for signing comments using tildes.
|
||||
// (Does not appear in VE notices right now, but just in case.)
|
||||
noticeName === 'talkpagetext'
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
var noticeItem = this.replyWidget.commentDetails.notices[ noticeName ];
|
||||
var $noticeElement = $( '<div>' )
|
||||
.addClass( 'ext-discussiontools-ui-replyWidget-notice' )
|
||||
.html( typeof noticeItem === 'string' ? noticeItem : noticeItem.message );
|
||||
this.$notices.append( $noticeElement );
|
||||
}
|
||||
|
||||
var title = this.replyWidget.storage.get( this.replyWidget.storagePrefix + '/title' );
|
||||
if ( title && !this.sectionTitle.getValue() ) {
|
||||
// Don't overwrite if the user has already typed something in while the widget was loading.
|
||||
|
|
|
@ -208,7 +208,7 @@ function checkCommentOnPage( pageName, oldId, comment ) {
|
|||
} ] } ).promise();
|
||||
}
|
||||
|
||||
return new CommentDetails( pageName, oldId );
|
||||
return new CommentDetails( pageName, oldId, metadata.notices );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,16 @@
|
|||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.ext-discussiontools-ui-newTopic-notices {
|
||||
// Ensure that the form is visible below the notice in case of large notices and small screens
|
||||
max-height: 75vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.ext-discussiontools-ui-newTopic-notices + .oo-ui-fieldLayout {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
h2&-sectionTitle {
|
||||
max-width: none;
|
||||
// This element is a <h2> - override unwanted heading styles
|
||||
|
|
Loading…
Reference in a new issue