Henning Snater has uploaded a new change for review.

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

Change subject: Apply claimview instead of statementview to property page output
......................................................................

Apply claimview instead of statementview to property page output

The change fixes claimview and its template in order to apply it to the static 
output
of claims that are not statements. (bug 63069)

Change-Id: Iceaf390a2d9861990ba6086ece36e6e4475bb7e5
---
M lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
M lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
M lib/resources/templates.php
M lib/resources/wikibase.css
M repo/includes/ClaimHtmlGenerator.php
5 files changed, 35 insertions(+), 29 deletions(-)


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

diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
index dc1a76b..6889481 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.claimview.js
@@ -63,7 +63,6 @@
  *            the current error state is resolved.
  */
 $.widget( 'wikibase.claimview', PARENT, {
-       widgetName: 'wikibase-claimview',
        widgetBaseClass: 'wb-claimview',
 
        /**
@@ -156,6 +155,8 @@
 
                // call template creation, this will require this._claim in 
template params callback!
                PARENT.prototype._create.call( this );
+
+               this.element.addClass( 'wb-claimview' );
 
                // set up event listeners:
                this.$mainSnak
@@ -621,7 +622,7 @@
         */
        _instantiateClaim: function( guid ) {
                var qualifiers = new wb.SnakList(),
-                       snaklistviews = this._qualifiers.value();
+                       snaklistviews = this._qualifiers ? 
this._qualifiers.value() : [];
 
                // Combine qualifiers grouped by property to a single SnakList:
                for( var i = 0; i < snaklistviews.length; i++ ) {
diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js 
b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
index b9ce7d4..dfe08e8 100644
--- a/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
+++ b/lib/resources/jquery.wikibase/jquery.wikibase.statementview.js
@@ -57,9 +57,6 @@
         * @see jQuery.claimview._create
         */
        _create: function() {
-               // add claimview class as well, so we inherit basic CSS rules:
-               this.element.addClass( 'wb-claimview' );
-
                PARENT.prototype._create.call( this );
 
                var self = this,
diff --git a/lib/resources/templates.php b/lib/resources/templates.php
index 4b977b4..d094092 100644
--- a/lib/resources/templates.php
+++ b/lib/resources/templates.php
@@ -88,11 +88,14 @@
 
        $templates['wb-claim'] =
 <<<HTML
-<div class="wb-claim wb-claim-$1">
-       <div class="wb-claim-mainsnak" dir="auto">
-               $2 <!-- wb-snak (Main Snak) -->
+<div class="wb-claimview">
+       <div class="wb-claim wb-claim-$1">
+               <div class="wb-claim-mainsnak" dir="auto">
+                       $2 <!-- wb-snak (Main Snak) -->
+               </div>
+               <div class="wb-claim-qualifiers">$3</div>
        </div>
-       <div class="wb-claim-qualifiers">$3</div>
+       $4 <!-- wikibase-toolbar -->
 </div>
 HTML;
 
diff --git a/lib/resources/wikibase.css b/lib/resources/wikibase.css
index 655026c..fb25369 100644
--- a/lib/resources/wikibase.css
+++ b/lib/resources/wikibase.css
@@ -737,7 +737,7 @@
 /********** STATEMENTS **********/
 
 /* Container for a single statement */
-.wb-statement {
+.wb-claimview {
        border-bottom: 1px dashed #AAA;
        float: left;
        width: 100%;
@@ -745,18 +745,18 @@
        padding-bottom: 1em;
 }
 
-.wb-statement .wb-statement-rank {
+.wb-statementview .wb-statement-rank {
        position: absolute;
        margin-left: 15.2em;
        margin-top: 1em;
        z-index: 1;
 }
 
-.wb-statement > .wikibase-toolbar {
+.wb-claimview > .wikibase-toolbar {
        display: block;
 }
 
-.wb-statement .wb-editsection {
+.wb-claimview .wb-editsection {
        top: 10px; /* even out padding */
 }
 
diff --git a/repo/includes/ClaimHtmlGenerator.php 
b/repo/includes/ClaimHtmlGenerator.php
index 7188c9e..fd9bb68 100644
--- a/repo/includes/ClaimHtmlGenerator.php
+++ b/repo/includes/ClaimHtmlGenerator.php
@@ -74,11 +74,18 @@
 
                $mainSnakHtml = $this->getSnakHtml( $claim->getMainSnak(), 
false );
 
-               $rankHtml = '';
-               $referencesHeading = '';
-               $referencesHtml = '';
+               $claimHtml = '';
 
-               if( is_a( $claim, 'Wikibase\Statement' ) ) {
+               if( !is_a( $claim, 'Wikibase\Statement' ) ) {
+
+                       $claimHtml = wfTemplate( 'wb-claim',
+                               $claim->getGuid(),
+                               $mainSnakHtml,
+                               $this->getHtmlForQualifiers( 
$claim->getQualifiers() ),
+                               $editSectionHtml
+                       );
+
+               } else {
                        $serializedRank = ClaimSerializer::serializeRank( 
$claim->getRank() );
 
                        // Messages: wikibase-statementview-rank-preferred, 
wikibase-statementview-rank-normal,
@@ -100,19 +107,17 @@
                        )->text();
 
                        $referencesHtml = $this->getHtmlForReferences( 
$claim->getReferences() );
-               }
 
-               // @todo: Use 'wb-claim' or 'wb-statement' template accordingly
-               // @todo: get rid of usage of global wfTemplate function
-               $claimHtml = wfTemplate( 'wb-statement',
-                       $rankHtml,
-                       $claim->getGuid(),
-                       $mainSnakHtml,
-                       $this->getHtmlForQualifiers( $claim->getQualifiers() ),
-                       $editSectionHtml,
-                       $referencesHeading,
-                       $referencesHtml
-               );
+                       $claimHtml = wfTemplate( 'wb-statement',
+                               $rankHtml,
+                               $claim->getGuid(),
+                               $mainSnakHtml,
+                               $this->getHtmlForQualifiers( 
$claim->getQualifiers() ),
+                               $editSectionHtml,
+                               $referencesHeading,
+                               $referencesHtml
+                       );
+               }
 
                wfProfileOut( __METHOD__ );
                return $claimHtml;

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

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