Alex Monk has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/169270

Change subject: Show warning on reference dialog when editing a reference used 
in more than one place
......................................................................

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

Bug: 52792
Change-Id: I2b183c3867ddb601041f9989964aa6f78b5f37e4
---
M VisualEditor.php
M modules/ve-mw/i18n/en.json
M modules/ve-mw/i18n/qqq.json
M modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
4 files changed, 22 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/70/169270/1

diff --git a/VisualEditor.php b/VisualEditor.php
index bc2c6c4..02e2f08 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -1130,6 +1130,7 @@
                        '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',
diff --git a/modules/ve-mw/i18n/en.json b/modules/ve-mw/i18n/en.json
index fa7a320..9bf690f 100644
--- a/modules/ve-mw/i18n/en.json
+++ b/modules/ve-mw/i18n/en.json
@@ -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": "Note that this reference 
is used $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",
diff --git a/modules/ve-mw/i18n/qqq.json b/modules/ve-mw/i18n/qqq.json
index 202e2df..70a6918 100644
--- a/modules/ve-mw/i18n/qqq.json
+++ b/modules/ve-mw/i18n/qqq.json
@@ -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.",
        "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",
diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js 
b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
index fe3c0ac..f1f17c1 100644
--- a/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
+++ b/modules/ve-mw/ui/dialogs/ve.ui.MWReferenceDialog.js
@@ -233,6 +233,7 @@
  * @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 @@
        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 @@
                $: 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 @@
 
        // 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 );

-- 
To view, visit https://gerrit.wikimedia.org/r/169270
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2b183c3867ddb601041f9989964aa6f78b5f37e4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to