Alex Monk has uploaded a new change for review.

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

Change subject: Disable re-use citation tool if there are no references in the 
document
......................................................................

Disable re-use citation tool if there are no references in the document

Bug: 70640
Change-Id: I727857281644dffd23605d7792a3f71ee7c5b751
---
M modules/ve-mw/ui/tools/ve.ui.MWReferenceDialogTool.js
1 file changed, 20 insertions(+), 0 deletions(-)


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

diff --git a/modules/ve-mw/ui/tools/ve.ui.MWReferenceDialogTool.js 
b/modules/ve-mw/ui/tools/ve.ui.MWReferenceDialogTool.js
index ea0bbc7..dab1e11 100644
--- a/modules/ve-mw/ui/tools/ve.ui.MWReferenceDialogTool.js
+++ b/modules/ve-mw/ui/tools/ve.ui.MWReferenceDialogTool.js
@@ -51,6 +51,26 @@
 ve.ui.MWUseExistingReferenceDialogTool.static.requiresRange = true;
 ve.ui.MWUseExistingReferenceDialogTool.static.autoAddToGroup = false;
 ve.ui.MWUseExistingReferenceDialogTool.static.autoAddToCatchall = false;
+/**
+ * @inheritdoc
+ */
+ve.ui.MWUseExistingReferenceDialogTool.prototype.onUpdateState = function ( 
fragment ) {
+       var groups = fragment.getDocument().getInternalList().getNodeGroups(), 
empty = true;
+
+       // Parent method
+       ve.ui.Tool.prototype.onUpdateState.apply( this, arguments );
+
+       $.each( groups, function ( groupName, group ) {
+               if ( groupName.lastIndexOf( 'mwReference/' ) !== 0 ) {
+                       return;
+               }
+               if ( group.indexOrder.length ) {
+                       empty = false;
+                       return false;
+               }
+       } );
+       this.setDisabled( empty );
+};
 ve.ui.toolFactory.register( ve.ui.MWUseExistingReferenceDialogTool );
 
 /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I727857281644dffd23605d7792a3f71ee7c5b751
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