Merge "Show warning on reference dialog when editing a reference used in more than one place"

This commit is contained in:
jenkins-bot 2014-10-28 17:36:07 +00:00 committed by Gerrit Code Review
commit d73a692f57
4 changed files with 22 additions and 1 deletions

View file

@ -1134,6 +1134,7 @@ $wgResourceModules += array(
'ext.visualEditor.mwtransclusion',
),
'messages' => array(
'visualeditor-dialog-reference-editing-reused',
'visualeditor-dialog-reference-options-group-label',
'visualeditor-dialog-reference-options-group-placeholder',
'visualeditor-dialog-reference-options-name-label',

View file

@ -127,6 +127,7 @@
"visualeditor-dialog-meta-settings-toc-help": "You can force a table of contents that lists each heading on the page to appear on pages with fewer than three headings, or force it to not appear at all. By default, it will appear if the page has three or more headings.",
"visualeditor-dialog-meta-settings-toc-label": "Show the Table of Contents",
"visualeditor-dialog-meta-title": "Options",
"visualeditor-dialog-reference-editing-reused": "This reference is used $1 {{PLURAL:$1|times}} on this page.",
"visualeditor-dialog-reference-options-group-label": "Use this group",
"visualeditor-dialog-reference-options-group-placeholder": "General references",
"visualeditor-dialog-reference-options-name-label": "Re-use by this name",

View file

@ -136,6 +136,7 @@
"visualeditor-dialog-meta-settings-toc-help": "Message displayed as contextual help about the <nowiki>__FORCETOC__</nowiki> and <nowiki>__NOTOC__</nowiki> tags to editors in the page settings panel.",
"visualeditor-dialog-meta-settings-toc-label": "Prompt to let the user set the Table Of Contents (TOC) behaviour.",
"visualeditor-dialog-meta-title": "Text of the title for the meta dialog to set categories, language links and other page settings.\n{{Identical|Options}}",
"visualeditor-dialog-reference-editing-reused": "Text shown at the top of the reference dialog when editing a reference that is used multiple times.\n\nParameters:\n* $1 - Number of times used. This is always greater than 1.",
"visualeditor-dialog-reference-options-group-label": "Label for the reference group input",
"visualeditor-dialog-reference-options-group-placeholder": "Placeholder for the reference group input",
"visualeditor-dialog-reference-options-name-label": "Label for the reference name input",

View file

@ -233,6 +233,7 @@ ve.ui.MWReferenceDialog.prototype.getBodyHeight = function () {
* @chainable
*/
ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) {
var group;
// Properties
if ( ref instanceof ve.dm.MWReferenceModel ) {
// Use an existing reference
@ -276,6 +277,18 @@ ve.ui.MWReferenceDialog.prototype.useReference = function ( ref ) {
this.contentFieldset.$element.append( this.referenceSurface.$element );
this.referenceSurface.initialize();
group = this.getFragment().getDocument().getInternalList()
.getNodeGroup( this.referenceModel.getListGroup() );
if ( group && group.keyedNodes[this.referenceModel.getListKey()].length > 1 ) {
this.$reuseWarning.show();
this.$reuseWarningText.text( mw.msg(
'visualeditor-dialog-reference-editing-reused',
group.keyedNodes[this.referenceModel.getListKey()].length
) );
} else {
this.$reuseWarning.hide();
}
return this;
};
@ -292,6 +305,11 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
$: this.$, scrollable: true, padded: true
} );
this.searchPanel = new OO.ui.PanelLayout( { $: this.$ } );
this.reuseWarningIcon = new OO.ui.IconWidget( { icon: 'alert' } );
this.$reuseWarningText = this.$( '<span>' );
this.$reuseWarning = this.$( '<span>' ).append( this.reuseWarningIcon.$element, this.$reuseWarningText );
this.contentFieldset = new OO.ui.FieldsetLayout( { $: this.$ } );
this.optionsFieldset = new OO.ui.FieldsetLayout( {
$: this.$,
@ -314,7 +332,7 @@ ve.ui.MWReferenceDialog.prototype.initialize = function () {
// Initialization
this.panels.addItems( [ this.editPanel, this.searchPanel ] );
this.editPanel.$element.append( this.contentFieldset.$element, this.optionsFieldset.$element );
this.editPanel.$element.append( this.$reuseWarning, this.contentFieldset.$element, this.optionsFieldset.$element );
this.optionsFieldset.addItems( [ this.referenceGroupField ] );
this.searchPanel.$element.append( this.search.$element );
this.$body.append( this.panels.$element );