mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
mw.ViewPageTarget: When saving a page as a redirect, update contentSub text
Or vice versa. Per my comment on bug 65621. Change-Id: Ic51745103446dda8ea8ff901c4f211c30c39e45c
This commit is contained in:
parent
4be0218bbb
commit
c18fb662aa
|
@ -114,6 +114,7 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
|
|||
if ( $result === false ) {
|
||||
$this->dieUsage( 'Error contacting the Parsoid server', 'parsoidserver' );
|
||||
}
|
||||
$result['isRedirect'] = $page->isRedirect();
|
||||
|
||||
if ( isset( $saveresult['edit']['newrevid'] ) ) {
|
||||
$result['newrevid'] = intval( $saveresult['edit']['newrevid'] );
|
||||
|
|
|
@ -190,6 +190,7 @@ $wgResourceModules += array(
|
|||
'spamprotectiontext',
|
||||
'summary-preview',
|
||||
'parentheses',
|
||||
'redirectpagesub',
|
||||
|
||||
// Messages needed by VE in init phase only (rest go below)
|
||||
'visualeditor-loadwarning',
|
||||
|
|
|
@ -423,7 +423,7 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () {
|
|||
* @param {string} categoriesHtml Rendered categories HTML from server
|
||||
* @param {number} [newid] New revision id, undefined if unchanged
|
||||
*/
|
||||
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid ) {
|
||||
ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, newid, isRedirect ) {
|
||||
if ( !this.pageExists || this.restoring ) {
|
||||
// This is a page creation or restoration, refresh the page
|
||||
this.tearDownBeforeUnloadHandler();
|
||||
|
@ -461,7 +461,7 @@ ve.init.mw.ViewPageTarget.prototype.onSave = function ( html, categoriesHtml, ne
|
|||
}
|
||||
this.saveDialog.close();
|
||||
this.saveDialog.reset();
|
||||
this.replacePageContent( html, categoriesHtml );
|
||||
this.replacePageContent( html, categoriesHtml, isRedirect );
|
||||
this.setupSectionEditLinks();
|
||||
this.tearDownBeforeUnloadHandler();
|
||||
this.deactivate( true );
|
||||
|
@ -1531,7 +1531,7 @@ ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function ( e ) {
|
|||
* @param {string} html Rendered HTML from server
|
||||
* @param {string} categoriesHtml Rendered categories HTML from server
|
||||
*/
|
||||
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml ) {
|
||||
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, categoriesHtml, isRedirect ) {
|
||||
var $content = $( $.parseHTML( html ) ), $editableContent;
|
||||
|
||||
if ( $( '#mw-imagepage-content' ).length ) {
|
||||
|
@ -1552,6 +1552,11 @@ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function ( html, catego
|
|||
|
||||
mw.hook( 'wikipage.content' ).fire( $editableContent.empty().append( $content ) );
|
||||
$( '#catlinks' ).replaceWith( categoriesHtml );
|
||||
if ( isRedirect ) {
|
||||
$( '#contentSub' ).text( ve.msg( 'redirectpagesub' ) );
|
||||
} else {
|
||||
$( '#contentSub' ).text( '' );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -74,6 +74,7 @@ OO.inheritClass( ve.init.mw.Target, ve.init.Target );
|
|||
* @param {string} html Rendered page HTML from server
|
||||
* @param {string} categoriesHtml Rendered categories HTML from server
|
||||
* @param {number} [newid] New revision id, undefined if unchanged
|
||||
* @param {boolean} isRedirect Whether this page is now a redirect or not.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -542,7 +543,7 @@ ve.init.mw.Target.onSave = function ( doc, saveData, response ) {
|
|||
} else if ( typeof data.content !== 'string' ) {
|
||||
this.onSaveError( doc, saveData, null, 'Invalid HTML content in response from server', response );
|
||||
} else {
|
||||
this.emit( 'save', data.content, data.categorieshtml, data.newrevid );
|
||||
this.emit( 'save', data.content, data.categorieshtml, data.newrevid, data.isRedirect );
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue