mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Show warning when commit message is empty and preference is set"
This commit is contained in:
commit
22bbba249e
|
@ -40,11 +40,12 @@ class VisualEditorMessagesModule extends ResourceLoaderModule {
|
||||||
protected function getMessageInfo() {
|
protected function getMessageInfo() {
|
||||||
$msgKeys = array();
|
$msgKeys = array();
|
||||||
|
|
||||||
// Simple ones
|
// Messages that just require simple parsing
|
||||||
$msgArgs = array(
|
$msgArgs = array(
|
||||||
'minoredit' => array( 'minoredit' ),
|
'minoredit' => array( 'minoredit' ),
|
||||||
'watchthis' => array( 'watchthis' ),
|
'watchthis' => array( 'watchthis' ),
|
||||||
'visualeditor-report-notice' => array( 'visualeditor-report-notice' ),
|
'visualeditor-report-notice' => array( 'visualeditor-report-notice' ),
|
||||||
|
'missingsummary' => array( 'missingsummary' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Override message value
|
// Override message value
|
||||||
|
|
|
@ -222,6 +222,7 @@
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.ve-init-mw-viewPageTarget-saveDialog-warnings,
|
||||||
.ve-init-mw-viewPageTarget-saveDialog-conflict,
|
.ve-init-mw-viewPageTarget-saveDialog-conflict,
|
||||||
.ve-init-mw-viewPageTarget-saveDialog-nochanges {
|
.ve-init-mw-viewPageTarget-saveDialog-nochanges {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
|
|
|
@ -51,6 +51,7 @@ ve.init.mw.ViewPageTarget = function VeInitMwViewPageTarget() {
|
||||||
this.deactivating = false;
|
this.deactivating = false;
|
||||||
this.scrollTop = null;
|
this.scrollTop = null;
|
||||||
this.currentUri = currentUri;
|
this.currentUri = currentUri;
|
||||||
|
this.warnings = {};
|
||||||
this.restoring = this.oldid !== mw.config.get( 'wgCurRevisionId' );
|
this.restoring = this.oldid !== mw.config.get( 'wgCurRevisionId' );
|
||||||
this.section = currentUri.query.vesection || null;
|
this.section = currentUri.query.vesection || null;
|
||||||
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
|
this.namespaceName = mw.config.get( 'wgCanonicalNamespace' );
|
||||||
|
@ -208,6 +209,7 @@ ve.init.mw.ViewPageTarget.saveDialogTemplate = '\
|
||||||
for="ve-init-mw-viewPageTarget-saveDialog-watchList"></label>\
|
for="ve-init-mw-viewPageTarget-saveDialog-watchList"></label>\
|
||||||
<label class="ve-init-mw-viewPageTarget-saveDialog-editSummaryCount"></label>\
|
<label class="ve-init-mw-viewPageTarget-saveDialog-editSummaryCount"></label>\
|
||||||
</div>\
|
</div>\
|
||||||
|
<div class="ve-init-mw-viewPageTarget-saveDialog-warnings"></div>\
|
||||||
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
<div class="ve-init-mw-viewPageTarget-saveDialog-actions">\
|
||||||
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
<div class="ve-init-mw-viewPageTarget-saveDialog-working"></div>\
|
||||||
</div>\
|
</div>\
|
||||||
|
@ -638,13 +640,22 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceModelHistory = function () {
|
||||||
* @method
|
* @method
|
||||||
*/
|
*/
|
||||||
ve.init.mw.ViewPageTarget.prototype.onSaveDialogSaveButtonClick = function () {
|
ve.init.mw.ViewPageTarget.prototype.onSaveDialogSaveButtonClick = function () {
|
||||||
var doc = this.surface.getModel().getDocument();
|
var doc = this.surface.getModel().getDocument(),
|
||||||
this.saveDialogSaveButton.setDisabled( true );
|
saveOptions = this.getSaveOptions();
|
||||||
this.$saveDialogLoadingIcon.show();
|
if (
|
||||||
this.save(
|
+mw.user.options.get( 'forceeditsummary' ) &&
|
||||||
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ),
|
saveOptions.summary === '' &&
|
||||||
this.getSaveOptions()
|
!this.warnings.missingsummary
|
||||||
);
|
) {
|
||||||
|
this.showWarning( 'missingsummary', ve.init.platform.getParsedMessage( 'missingsummary' ) );
|
||||||
|
} else {
|
||||||
|
this.saveDialogSaveButton.setDisabled( true );
|
||||||
|
this.$saveDialogLoadingIcon.show();
|
||||||
|
this.save(
|
||||||
|
ve.dm.converter.getDomFromData( doc.getFullData(), doc.getStore(), doc.getInternalList() ),
|
||||||
|
saveOptions
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1368,6 +1379,9 @@ ve.init.mw.ViewPageTarget.prototype.swapSaveDialog = function ( slide ) {
|
||||||
this.$saveDialog.css( 'width', '' );
|
this.$saveDialog.css( 'width', '' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Warnings should not persist after slide changes
|
||||||
|
this.clearAllWarnings();
|
||||||
|
|
||||||
// Show the target slide
|
// Show the target slide
|
||||||
$slide.show();
|
$slide.show();
|
||||||
|
|
||||||
|
@ -1694,6 +1708,44 @@ ve.init.mw.ViewPageTarget.prototype.restoreEditSection = function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show an inline warning.
|
||||||
|
* @param {string} name Warning's unique name
|
||||||
|
* @param {string} messageHtml Warning message HTML
|
||||||
|
*/
|
||||||
|
ve.init.mw.ViewPageTarget.prototype.showWarning = function ( name, messageHtml ) {
|
||||||
|
if ( !this.warnings[name] ) {
|
||||||
|
var warning = $(
|
||||||
|
'<p class="ve-init-mw-viewPageTarget-saveDialog-warning">' + messageHtml + '</p>'
|
||||||
|
);
|
||||||
|
this.$saveDialog
|
||||||
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-warnings' )
|
||||||
|
.append( warning );
|
||||||
|
this.warnings[name] = warning;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove an inline warning.
|
||||||
|
* @param {string} name Warning's unique name
|
||||||
|
*/
|
||||||
|
ve.init.mw.ViewPageTarget.prototype.clearWarning = function ( name ) {
|
||||||
|
if ( this.warnings[name] ) {
|
||||||
|
this.warnings[name].remove();
|
||||||
|
delete this.warnings[name];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove all inline warnings.
|
||||||
|
*/
|
||||||
|
ve.init.mw.ViewPageTarget.prototype.clearAllWarnings = function () {
|
||||||
|
this.$saveDialog
|
||||||
|
.find( '.ve-init-mw-viewPageTarget-saveDialog-warnings' )
|
||||||
|
.empty();
|
||||||
|
this.warnings = {};
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add onbeforunload handler.
|
* Add onbeforunload handler.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue