Henning Snater has uploaded a new change for review.

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


Change subject: Display entity id next to entity label
......................................................................

Display entity id next to entity label

(bug 53462)
The entity id is displayed next to entity's label on each page.

Change-Id: I40972ce286f78213a3b08b5c29a4c6aee2babf89
---
M lib/resources/templates.php
M lib/resources/wikibase.css
M lib/resources/wikibase.ui.PropertyEditTool.EditableLabel.js
M lib/resources/wikibase.ui.PropertyEditTool.EditableValue.js
M lib/resources/wikibase.ui.PropertyEditTool.css
M lib/tests/qunit/wikibase.ui.PropertyEditTool.EditableValue.tests.js
M lib/tests/qunit/wikibase.ui.PropertyEditTool.tests.js
M lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
M repo/includes/EntityView.php
M selenium_cuc/features/empty_label_and_description.feature
M selenium_cuc/features/label.feature
M selenium_cuc/features/step_definitions/label_steps.rb
M selenium_cuc/features/support/modules/entity_module.rb
13 files changed, 102 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/84/84984/1

diff --git a/lib/resources/templates.php b/lib/resources/templates.php
index 1c4d014..6438090 100644
--- a/lib/resources/templates.php
+++ b/lib/resources/templates.php
@@ -155,6 +155,11 @@
 </span>
 HTML;
 
+       $templates['wb-property-value-supplement'] =
+<<<HTML
+<span class="wb-value-supplement">$1</span>
+HTML;
+
        $templates['wb-aliases-wrapper'] =
 <<<HTML
 <div class="wb-aliases $1">
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index ffe9682..fddf386 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -121,7 +121,11 @@
        display: block; /* need to force block explicitly to achieve 100% width 
*/
 }
 
-.wb-value-empty {
+.wb-value, .wb-value-supplement {
+       display: inline;
+}
+
+.wb-value-empty, .wb-value-supplement {
        color: #A1A1A1;
 }
 
@@ -186,6 +190,10 @@
        padding: 1px 0; /* even out border of input box in edit mode */
 }
 
+.wb-firstHeading .wb-value-supplement {
+       line-height: 188%;
+}
+
 .wb-firstHeading .wb-value-container {
        display: block;
        margin: .3em .3em .13em 10px; /* h1 natively has 0.17em bottom padding 
to avoid clipping */
diff --git a/lib/resources/wikibase.ui.PropertyEditTool.EditableLabel.js 
b/lib/resources/wikibase.ui.PropertyEditTool.EditableLabel.js
index 8bcc1cb..e79e130 100644
--- a/lib/resources/wikibase.ui.PropertyEditTool.EditableLabel.js
+++ b/lib/resources/wikibase.ui.PropertyEditTool.EditableLabel.js
@@ -34,6 +34,28 @@
        } ),
 
        /**
+        * see wb.ui.PropertyEditTool.EditableValue.startEditing
+        */
+       startEditing: function() {
+               var self = this;
+               return PARENT.prototype.startEditing.call( this ).done( 
function() {
+                       if( !self._interfaces[0].isEmpty() ) {
+                               self._subject.children( '.wb-value-supplement' 
).hide();
+                       }
+               }) ;
+       },
+
+       /**
+        * @see wb.ui.PropertyEditTool.EditableValue.stopEditing
+        */
+       stopEditing: function( save ) {
+               var self = this;
+               return PARENT.prototype.stopEditing.call( this, save ).done( 
function() {
+                       self._subject.children( '.wb-value-supplement' ).show();
+               } );
+       },
+
+       /**
         * @see 
wikibase.ui.PropertyEditTool.EditableValue._setRevisionIdFromApiResponse
         */
        _setRevisionIdFromApiResponse: function( response ) {
diff --git a/lib/resources/wikibase.ui.PropertyEditTool.EditableValue.js 
b/lib/resources/wikibase.ui.PropertyEditTool.EditableValue.js
index 09558a8..43a90c3 100644
--- a/lib/resources/wikibase.ui.PropertyEditTool.EditableValue.js
+++ b/lib/resources/wikibase.ui.PropertyEditTool.EditableValue.js
@@ -411,11 +411,13 @@
         * Basically this initializes the input box as sub element of the 
subject and uses the
         * elements content as initial text.
         *
-        * @return bool will return false if edit mode is active already.
+        * @return {jQuery.Promise}
         */
        startEditing: function() {
+               var promise = $.Deferred().resolve().promise();
+
                if( this.isInEditMode() ) {
-                       return false;
+                       return promise;
                }
                this._isInEditMode = true;
                this._subject.addClass( this.UI_CLASS + '-ineditmode wb-edit' );
@@ -440,7 +442,7 @@
                        $( wb ).triggerHandler( 'startItemPageEditMode', this );
                }
 
-               return true;
+               return promise;
        },
 
        /**
diff --git a/lib/resources/wikibase.ui.PropertyEditTool.css 
b/lib/resources/wikibase.ui.PropertyEditTool.css
index 6ef329a..bff2fb0 100644
--- a/lib/resources/wikibase.ui.PropertyEditTool.css
+++ b/lib/resources/wikibase.ui.PropertyEditTool.css
@@ -23,10 +23,6 @@
        font-style: italic;
 }
 
-.wb-ui-propertyedittool-editablevalue-ineditmode {
-       white-space: nowrap;
-}
-
 /* disabled input element */
 .wb-ui-propertyedittool-editablevalueinterface-disabled input {
        background-color: #F0F0F0;
diff --git 
a/lib/tests/qunit/wikibase.ui.PropertyEditTool.EditableValue.tests.js 
b/lib/tests/qunit/wikibase.ui.PropertyEditTool.EditableValue.tests.js
index c76b036..42697e3 100644
--- a/lib/tests/qunit/wikibase.ui.PropertyEditTool.EditableValue.tests.js
+++ b/lib/tests/qunit/wikibase.ui.PropertyEditTool.EditableValue.tests.js
@@ -315,12 +315,6 @@
                var ev = newTestEV( $( '<div><div class="wb-value"/></div>' ) );
 
                assert.equal(
-                       ev.startEditing(),
-                       false,
-                       'EditableValue is in edit mode initially, so 
startEditing() returns false'
-               );
-
-               assert.equal(
                        ev.isInEditMode(),
                        true,
                        'is in edit mode'
@@ -384,17 +378,33 @@
                        'changed value'
                );
 
-               assert.equal(
-                       ev.startEditing(),
-                       true,
-                       'started edit mode'
-               );
+               ev.startEditing()
+               .done( function() {
+                       assert.ok(
+                               ev.isInEditMode(),
+                               'started edit mode'
+                       );
+               } )
+               .fail( function() {
+                       assert.ok(
+                               false,
+                               'started edit mode'
+                       );
+               } );
 
-               assert.equal(
-                       ev.startEditing(),
-                       false,
-                       'try to start edit mode again'
-               );
+               ev.startEditing()
+               .done( function() {
+                       assert.ok(
+                               ev.isInEditMode(),
+                               'try to start edit mode again'
+                       );
+               } )
+               .fail( function() {
+                       assert.ok(
+                               false,
+                               'try to start edit mode again'
+                       );
+               } );
 
                assert.equal(
                        ev.validate( DATAVALUES.INVALID[0] ),
@@ -457,7 +467,7 @@
                assert.equal(
                        ev.isInEditMode(),
                        true,
-                       'started editing ans set value'
+                       'started editing and set value'
                );
 
                assert.equal(
diff --git a/lib/tests/qunit/wikibase.ui.PropertyEditTool.tests.js 
b/lib/tests/qunit/wikibase.ui.PropertyEditTool.tests.js
index 233cfb1..c2dd4b5 100644
--- a/lib/tests/qunit/wikibase.ui.PropertyEditTool.tests.js
+++ b/lib/tests/qunit/wikibase.ui.PropertyEditTool.tests.js
@@ -258,8 +258,10 @@
                        '2nd edit tool is enabled'
                );
 
+               pet1.getValues()[0].startEditing();
+
                assert.equal(
-                       pet1.getValues()[0].startEditing(),
+                       pet1.getValues()[0].isInEditMode(),
                        true,
                        'started edit mode for 1st edit tool'
                );
diff --git a/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js 
b/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
index 5017282..b00454c 100644
--- a/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
+++ b/lib/tests/qunit/wikibase.ui.SiteLinksEditTool.tests.js
@@ -309,11 +309,19 @@
                        'new value has the value set in enterNewValue( value )'
                );
 
-               assert.strictEqual(
-                       newValue.startEditing(),
-                       false,
-                       'start editing already active, call function again'
-               );
+               newValue.startEditing()
+               .done( function() {
+                       assert.ok(
+                               newValue.isInEditMode(),
+                               'start editing already active, call function 
again'
+                       );
+               } )
+               .fail( function() {
+                       assert.ok(
+                               false,
+                               'try to start edit mode again'
+                       );
+               } );
 
                assert.strictEqual(
                        newValue.stopEditing( true ).promisor.apiAction,
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 1a6a693..55f3bce 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -337,7 +337,8 @@
                        wfTemplate( 'wb-property',
                                $label === false ? 'wb-value-empty' : '',
                                htmlspecialchars( $label === false ? wfMessage( 
'wikibase-label-empty' )->text() : $label ),
-                               $this->getHtmlForEditSection( $entity, $lang, 
$editUrl )
+                               wfTemplate( 'wb-property-value-supplement', 
wfMessage( 'parentheses', $prefixedId ) )
+                                       . $this->getHtmlForEditSection( 
$entity, $lang, $editUrl )
                        )
                );
 
diff --git a/selenium_cuc/features/empty_label_and_description.feature 
b/selenium_cuc/features/empty_label_and_description.feature
index 6dca3cc..7bfcc25 100644
--- a/selenium_cuc/features/empty_label_and_description.feature
+++ b/selenium_cuc/features/empty_label_and_description.feature
@@ -41,6 +41,7 @@
       And Label edit button should not be there
       And Label cancel button should not be there
       And Label save button should not be there
+      And Entity id should be displayed next to the label
 
   @ui_only
   Scenario: Label UI behaves correctly when label is empty
diff --git a/selenium_cuc/features/label.feature 
b/selenium_cuc/features/label.feature
index 7ff1087..944a1b8 100644
--- a/selenium_cuc/features/label.feature
+++ b/selenium_cuc/features/label.feature
@@ -15,6 +15,7 @@
     Then Original label should be displayed
       And Label edit button should be there
       And Label cancel button should not be there
+      And Entity id should be displayed next to the label
 
   @ui_only
   Scenario: Click edit button
@@ -22,6 +23,7 @@
     Then Label input element should be there
       And Label input element should contain original label
       And Label cancel button should be there
+      And Entity id should not be displayed next to the label
 
   @ui_only
   Scenario: Modify the label
@@ -39,6 +41,7 @@
     Then Original label should be displayed
       And Label edit button should be there
       And Label cancel button should not be there
+      And Entity id should be displayed next to the label
 
     Examples:
       | cancel |
diff --git a/selenium_cuc/features/step_definitions/label_steps.rb 
b/selenium_cuc/features/step_definitions/label_steps.rb
index b80809d..1057545 100644
--- a/selenium_cuc/features/step_definitions/label_steps.rb
+++ b/selenium_cuc/features/step_definitions/label_steps.rb
@@ -96,3 +96,14 @@
     page.entityLabelSpan.should == value
   end
 end
+
+Then /^Entity id should be displayed next to the label$/ do
+  on(ItemPage) do |page|
+      page.entityIdSpan_element.visible?.should be_true
+      page.entityIdSpan.sub(/[()]/, '') == @entity["label"]
+    end
+end
+
+Then /^Entity id should not be displayed next to the label$/ do
+  on(ItemPage).entityIdSpan_element.visible?.should be_false
+end
\ No newline at end of file
diff --git a/selenium_cuc/features/support/modules/entity_module.rb 
b/selenium_cuc/features/support/modules/entity_module.rb
index f1a70b6..e1d6cb5 100644
--- a/selenium_cuc/features/support/modules/entity_module.rb
+++ b/selenium_cuc/features/support/modules/entity_module.rb
@@ -26,6 +26,7 @@
   h1(:firstHeading, :xpath => "//h1[contains(@class, 'wb-firstHeading')]")
   h1(:uiPropertyEdittool, :class => "wb-ui-propertyedittool")
   span(:entityLabelSpan, :xpath => "//h1[contains(@class, 
'wb-firstHeading')]/span/span")
+  span(:entityIdSpan, :xpath => "//h1[contains(@class, 
'wb-firstHeading')]/span/span[contains(@class, 'wb-value-supplement')]")
   text_field(:labelInputField, :xpath => "//h1[contains(@class, 
'wb-firstHeading')]/span/span/input")
   link(:editLabelLink, :css => "h1.wb-firstHeading 
a.wikibase-toolbareditgroup-editbutton:not(.wikibase-toolbarbutton-disabled)")
   link(:editLabelLinkDisabled, :css => "h1.wb-firstHeading 
a.wikibase-toolbareditgroup-editbutton.wikibase-toolbarbutton-disabled")

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I40972ce286f78213a3b08b5c29a4c6aee2babf89
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>

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

Reply via email to