Merge "ArticleTarget: remember whether we preloaded, so it can affect the save button"

This commit is contained in:
jenkins-bot 2017-10-30 22:07:19 +00:00 committed by Gerrit Code Review
commit 93c2da8e78
2 changed files with 15 additions and 1 deletions

View file

@ -239,6 +239,8 @@ class ApiVisualEditor extends ApiBase {
$wgTitle = $title;
RequestContext::getMain()->setTitle( $title );
$preloaded = false;
// Get information about current revision
if ( $title->exists() ) {
$latestRevision = Revision::newFromTitle( $title );
@ -287,6 +289,7 @@ class ApiVisualEditor extends ApiBase {
$params['preload'], $params['preloadparams'], $title,
$params['paction'] !== 'wikitext'
);
$preloaded = true;
}
} else {
$apiParams['rvsection'] = $section;
@ -327,6 +330,7 @@ class ApiVisualEditor extends ApiBase {
$params['preload'], $params['preloadparams'], $title,
$params['paction'] !== 'wikitext'
);
$preloaded = true;
}
$baseTimestamp = wfTimestampNow();
$oldid = 0;
@ -584,6 +588,15 @@ class ApiVisualEditor extends ApiBase {
( !empty( $params['preload'] ) && isset( $content ) )
) {
$result['content'] = $content;
if ( $preloaded ) {
// If the preload param was actually used, pass it
// back so the caller knows. (It's not obvious to the
// caller, because in some situations it'll depend on
// whether the page has been created. They can work it
// out from some of the other returns, but this is
// simpler.)
$result['preloaded'] = $params['preload'];
}
}
break;

View file

@ -283,6 +283,7 @@ ve.init.mw.ArticleTarget.prototype.loadSuccess = function ( response ) {
this.fromEditedState = data.fromEditedState;
this.switched = data.switched || 'wteswitched' in new mw.Uri( location.href ).query;
this.doc = this.constructor.static.parseDocument( this.originalHtml, this.getDefaultMode() );
this.preloaded = data.preloaded;
this.remoteNotices = ve.getObjectValues( data.notices );
this.protectedClasses = data.protectedClasses;
@ -1882,7 +1883,7 @@ ve.init.mw.ArticleTarget.prototype.updateToolbarSaveButtonState = function () {
return;
}
this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState;
this.edited = this.getSurface().getModel().hasBeenModified() || this.fromEditedState || this.preloaded;
if ( this.sectionTitle ) {
this.edited = this.edited || this.sectionTitle.getValue() !== '';
}