Mooeypoo has uploaded a new change for review.

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

Change subject: Add a link to the reference dialog in Citoid inspector
......................................................................

Add a link to the reference dialog in Citoid inspector

Link triggering the general reference dialog in the citoid
inspector.

Depends on VE-MW change I22a64265475b

Change-Id: If5ffd9c3cc022d3261e15b522dd40f5a89627a52
---
M Citoid.php
M i18n/en.json
M i18n/qqq.json
M modules/ve.ui.CiteFromIdInspector.css
M modules/ve.ui.CiteFromIdInspector.js
M modules/ve.ui.CiteFromIdInspectorTool.js
6 files changed, 65 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Citoid 
refs/changes/44/196644/1

diff --git a/Citoid.php b/Citoid.php
index 39a8871..9802551 100644
--- a/Citoid.php
+++ b/Citoid.php
@@ -52,6 +52,8 @@
                'citoid-citeFromIDDialog-lookup-button',
                'citoid-citeFromIDDialog-search',
                'citoid-citeFromIDDialog-search-label',
+               'citoid-citeFromIDDialog-use-general-dialog-message',
+               'citoid-citeFromIDDialog-use-general-dialog-button',
                'citoid-citeFromIDDialog-search-placeholder',
                'citoid-citeFromIDDialog-search-progress',
                'citoid-citeFromIDDialog-title',
diff --git a/i18n/en.json b/i18n/en.json
index 74b3b98..8c9d128 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -11,6 +11,8 @@
        "citoid-citeFromIDDialog-title": "Add a citation",
        "citoid-citeFromIDTool-title": "Cite",
        "citoid-desc": "Provides access points between the citoid service and 
MediaWiki",
+       "citoid-citeFromIDDialog-use-general-dialog-message": "Or use the $1 to 
fill in the details yourself.",
+       "citoid-citeFromIDDialog-use-general-dialog-button": "full citation 
dialog",
        "citoid-typeMap-config-error": "Mediawiki:citoid-template-type-map.json 
is improperly configured.",
        "citoid-unknown-error": "An unknown error has occured that prevented us 
from creating a citation. Please try again later."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 0e444bb..a7a0785 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -12,6 +12,8 @@
        "citoid-citeFromIDDialog-search-progress": "Message for when the search 
is in progress",
        "citoid-citeFromIDDialog-title": "The title displayed on the dialog",
        "citoid-citeFromIDTool-title": "Label for the button to add a citation 
in the toolbar",
+       "citoid-citeFromIDDialog-use-general-dialog-message": "Label for the 
user to use the full citation tool. $1 - the button to open the citation 
dialog.",
+       "citoid-citeFromIDDialog-use-general-dialog-button": "Label for the 
user to click to use the full citation tool.",
        "citoid-desc": 
"{{desc|name=Citoid|url=http://www.mediawiki.org/wiki/Citoid}}";,
        "citoid-typeMap-config-error": "Error message indicating 
Mediawiki:citoid-template-type-map.json either doesn't exist or contains 
errors.",
        "citoid-unknown-error": "Error message indicating that the service to 
create citations has returned an error or is temporarily malfunctioning, asking 
the user to try again later."
diff --git a/modules/ve.ui.CiteFromIdInspector.css 
b/modules/ve.ui.CiteFromIdInspector.css
index 971a5c7..75542c3 100644
--- a/modules/ve.ui.CiteFromIdInspector.css
+++ b/modules/ve.ui.CiteFromIdInspector.css
@@ -26,3 +26,8 @@
        background-size: 24px 24px;
        height: 2.5em;
 }
+
+.ve-ui-citeFromIdInspector-dialog-link {
+       display: inline-block;
+       margin: 0.5em 0;
+}
diff --git a/modules/ve.ui.CiteFromIdInspector.js 
b/modules/ve.ui.CiteFromIdInspector.js
index df4b690..8fa1db4 100644
--- a/modules/ve.ui.CiteFromIdInspector.js
+++ b/modules/ve.ui.CiteFromIdInspector.js
@@ -11,6 +11,8 @@
        // Parent constructor
        ve.ui.CiteFromIdInspector.super.call( this, config );
 
+       config = config || {};
+
        this.referenceModel = null;
        this.transclusionModel = null;
        this.doneStaging = false;
@@ -19,7 +21,13 @@
        this.templateTypeMap = null;
        this.lookupPromise = null;
 
-       this.$element.addClass( 've-ui-citeFromIdInspector' );
+       this.windowManager = config.dialogManager || new ve.ui.WindowManager( { 
factory: ve.ui.windowFactory, isolate: true } );
+       this.overlay = new ve.ui.Overlay( { classes: [ 've-ui-overlay-global' ] 
} );
+       this.overlay.$element.append( this.windowManager.$element );
+       $( 'body' ).append( this.overlay.$element );
+
+       this.$element
+               .addClass( 've-ui-citeFromIdInspector' );
 };
 
 /* Inheritance */
@@ -47,7 +55,7 @@
  * @inheritDoc
  */
 ve.ui.CiteFromIdInspector.prototype.initialize = function () {
-       var lookupActionFieldLayout,
+       var lookupActionFieldLayout, plainMsg, parsedMsg,
                lookupFieldset = new OO.ui.FieldsetLayout(),
                limit = ve.init.target.constructor.static.citationToolsLimit;
 
@@ -81,6 +89,25 @@
                lookupActionFieldLayout.$element
        );
 
+       // Once more, with feeling: there's a bug in mw.messages that prevents 
us from
+       // using a link in the message unless we double-parse it.
+       // See https://phabricator.wikimedia.org/T49395#490610
+       mw.messages.set( {
+               'citoid-citeFromIDDialog-temporary-message': '<a href="#">' + 
mw.message( 'citoid-citeFromIDDialog-use-general-dialog-button' ) + '</a>'
+       } );
+       plainMsg = mw.message( 'citoid-citeFromIDDialog-temporary-message' 
).plain();
+       mw.messages.set( { 'citoid-citeFromIDDialog-temporary-message-parsed': 
plainMsg } );
+       parsedMsg = mw.message( 
'citoid-citeFromIDDialog-temporary-message-parsed' );
+       // Citation dialog label
+       this.citeDialogLabel = new OO.ui.LabelWidget( {
+               // Double-parse
+               label: $( '<span>' )
+                       .addClass( 've-ui-citeFromIdInspector-dialog-link' )
+                       .append(
+                               mw.message( 
'citoid-citeFromIDDialog-use-general-dialog-message', parsedMsg ).parse()
+                       )
+       } );
+
        // Preview fieldset
        this.previewSelectWidget = new OO.ui.SelectWidget( {
                classes: [ 've-ui-citeFromIdInspector-preview' ]
@@ -97,7 +124,30 @@
        } );
 
        // Attach
-       this.form.$element.append( lookupFieldset.$element, 
this.previewSelectWidget.$element );
+       this.form.$element
+               .append(
+                       lookupFieldset.$element,
+                       this.citeDialogLabel.$element,
+                       this.previewSelectWidget.$element
+               )
+               // Connect the dialog link to the event
+               .find( '.ve-ui-citeFromIdInspector-dialog-link a' )
+                       .click( this.onOpenFullDialogLinkClick.bind( this ) );
+};
+
+/**
+ * Respond to full dialog link click
+ */
+ve.ui.CiteFromIdInspector.prototype.onOpenFullDialogLinkClick = function () {
+       var inspector = this,
+               fragment = this.getFragment();
+
+       this.close().then( function () {
+               inspector.windowManager.openWindow( 'generalreference', {
+               // inspector.getManager().openWindow( 'generalreference', {
+                       fragment: fragment
+               } );
+       } );
 };
 
 /**
diff --git a/modules/ve.ui.CiteFromIdInspectorTool.js 
b/modules/ve.ui.CiteFromIdInspectorTool.js
index d59466a..8014450 100644
--- a/modules/ve.ui.CiteFromIdInspectorTool.js
+++ b/modules/ve.ui.CiteFromIdInspectorTool.js
@@ -73,7 +73,7 @@
        OO.inheritClass( ve.ui.CiteFromIdInspectorTool, ve.ui.InspectorTool );
 
        ve.ui.CiteFromIdInspectorTool.static.name = 'citefromid';
-       ve.ui.CiteFromIdInspectorTool.static.icon = 'ref-cite-web';
+       ve.ui.CiteFromIdInspectorTool.static.icon = 'reference';
        ve.ui.CiteFromIdInspectorTool.static.title = OO.ui.deferMsg( 
'citoid-citeFromIDTool-title' );
        ve.ui.CiteFromIdInspectorTool.static.label = OO.ui.deferMsg( 
'citoid-citeFromIDTool-title' );
        ve.ui.CiteFromIdInspectorTool.static.group = 'cite';

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If5ffd9c3cc022d3261e15b522dd40f5a89627a52
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Citoid
Gerrit-Branch: master
Gerrit-Owner: Mooeypoo <mor...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to