Esanders has uploaded a new change for review.
https://gerrit.wikimedia.org/r/226705
Change subject: Make missingref references uneditable, not uninspectable
......................................................................
Make missingref references uneditable, not uninspectable
Depends on I1ba8978dd in core.
Bonus: remove not-allowed-cursor & highlight title (which was
broken) now that we can display this information properly.
Bug: T106810
Change-Id: I1800490ba1b8e10ff54b26372a8a78661c1c7d68
---
M VisualEditor.hooks.php
M modules/ve-mw/ce/nodes/ve.ce.MWReferenceNode.js
M modules/ve-mw/ce/styles/nodes/ve.ce.MWReferenceNode.css
M modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
M modules/ve-mw/ui/contextitems/ve.ui.MWReferenceContextItem.js
5 files changed, 19 insertions(+), 31 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/05/226705/1
diff --git a/VisualEditor.hooks.php b/VisualEditor.hooks.php
index 76dec04..91ce928 100644
--- a/VisualEditor.hooks.php
+++ b/VisualEditor.hooks.php
@@ -491,6 +491,7 @@
'modules/ve-mw/ui/actions/ve.ui.MWCitationAction.js',
),
'styles' => array(
+
'modules/ve-mw/ui/styles/contextitems/ve.ui.MWReferenceContextItem.css',
'modules/ve-mw/ui/styles/widgets/ve.ui.MWReferenceGroupInputWidget.css',
'modules/ve-mw/ui/styles/widgets/ve.ui.MWReferenceResultWidget.css',
'modules/ve-mw/ui/styles/widgets/ve.ui.MWReferenceSearchWidget.css',
diff --git a/modules/ve-mw/ce/nodes/ve.ce.MWReferenceNode.js
b/modules/ve-mw/ce/nodes/ve.ce.MWReferenceNode.js
index aacd4b8..7c21e48 100644
--- a/modules/ve-mw/ce/nodes/ve.ce.MWReferenceNode.js
+++ b/modules/ve-mw/ce/nodes/ve.ce.MWReferenceNode.js
@@ -112,22 +112,6 @@
}
};
-/** */
-ve.ce.MWReferenceNode.prototype.createHighlights = function () {
- // Mixin method
- ve.ce.FocusableNode.prototype.createHighlights.call( this );
-
- if ( !this.getModel().isInspectable() ) {
- // TODO: Move this into one of the classes mixin or inherit from
- // as any focusable node that isn't inspectable should have this
- // as it would be bad UX to have a focusable nodes where one of
the
- // same type doesn't show an inspector.
- this.$highlights
- .addClass( 've-ce-mwReferenceNode-missingref' )
- .attr( 'title', ve.msg(
'visualeditor-referenceslist-missingref' ) );
- }
-};
-
/* Registration */
ve.ce.nodeFactory.register( ve.ce.MWReferenceNode );
diff --git a/modules/ve-mw/ce/styles/nodes/ve.ce.MWReferenceNode.css
b/modules/ve-mw/ce/styles/nodes/ve.ce.MWReferenceNode.css
index 42d049c..fe52ab5 100644
--- a/modules/ve-mw/ce/styles/nodes/ve.ce.MWReferenceNode.css
+++ b/modules/ve-mw/ce/styles/nodes/ve.ce.MWReferenceNode.css
@@ -5,10 +5,6 @@
* @license The MIT License (MIT); see LICENSE.txt
*/
-.ve-ce-mwReferenceNode-missingref {
- cursor: not-allowed;
-}
-
/* HACK: Hide Ref errors in templates */
.mw-ext-cite-error {
display: none;
diff --git a/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
b/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
index 9454947..ce045bf 100644
--- a/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
+++ b/modules/ve-mw/dm/nodes/ve.dm.MWReferenceNode.js
@@ -288,11 +288,11 @@
/* Methods */
/**
- * Don't allow reference nodes to be inspected if we can't find their contents.
+ * Don't allow reference nodes to be edited if we can't find their contents.
*
* @inheritdoc
*/
-ve.dm.MWReferenceNode.prototype.isInspectable = function () {
+ve.dm.MWReferenceNode.prototype.isEditable = function () {
var internalItem = this.getInternalItem();
return internalItem && internalItem.getLength() > 0;
};
diff --git a/modules/ve-mw/ui/contextitems/ve.ui.MWReferenceContextItem.js
b/modules/ve-mw/ui/contextitems/ve.ui.MWReferenceContextItem.js
index f8e414c..94790fe 100644
--- a/modules/ve-mw/ui/contextitems/ve.ui.MWReferenceContextItem.js
+++ b/modules/ve-mw/ui/contextitems/ve.ui.MWReferenceContextItem.js
@@ -48,23 +48,30 @@
* @return {jQuery} DOM rendering of reference
*/
ve.ui.MWReferenceContextItem.prototype.getRendering = function () {
- var refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode(
this.model );
- this.view = new ve.ui.PreviewWidget(
- refModel.getDocument().getInternalList().getItemNode(
refModel.getListIndex() )
- );
+ var refModel;
+ if ( this.model.isEditable() ) {
+ refModel = ve.dm.MWReferenceModel.static.newFromReferenceNode(
this.model );
+ this.view = new ve.ui.PreviewWidget(
+ refModel.getDocument().getInternalList().getItemNode(
refModel.getListIndex() )
+ );
- // The $element property may be rendered into asynchronously, update
the context's size when the
- // rendering is complete if that's the case
- this.view.once( 'render', this.context.updateDimensions.bind(
this.context ) );
+ // The $element property may be rendered into asynchronously,
update the context's size when the
+ // rendering is complete if that's the case
+ this.view.once( 'render', this.context.updateDimensions.bind(
this.context ) );
- return this.view.$element;
+ return this.view.$element;
+ } else {
+ return $( '<div>' )
+ .addClass( 've-ui-mwReferenceContextItem-muted' )
+ .text( ve.msg( 'visualeditor-referenceslist-missingref'
) );
+ }
};
/**
* @inheritdoc
*/
ve.ui.MWReferenceContextItem.prototype.getDescription = function () {
- return this.getRendering().text();
+ return this.model.isEditable() ? this.getRendering().text() : ve.msg(
'visualeditor-referenceslist-missingref' );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/226705
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1800490ba1b8e10ff54b26372a8a78661c1c7d68
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits