jenkins-bot has submitted this change and it was merged. Change subject: Simplify wb-snak template, pass template options in JS ......................................................................
Simplify wb-snak template, pass template options in JS This removes an ugly $1 class in JS-rendered claims, and the nowhere-used class wb-mainsnak. It's related to bug 62527. Change-Id: Ie030fc7e2a4ff6b840c02fe1c7ab75c65b7f13bf --- M lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js M lib/resources/templates.php M repo/includes/ClaimHtmlGenerator.php 3 files changed, 15 insertions(+), 29 deletions(-) Approvals: Tobias Gritschacher: Looks good to me, approved WikidataJenkins: Verified jenkins-bot: Verified diff --git a/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js b/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js index f084df0..dd17946 100644 --- a/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js +++ b/lib/resources/jquery.wikibase/jquery.wikibase.snakview/snakview.js @@ -56,6 +56,7 @@ */ options: { template: 'wb-snak', + templateParams: [ '', '' ], templateShortCuts: { '$property': '.wb-snak-property', '$snakValue': '.wb-snak-value', diff --git a/lib/resources/templates.php b/lib/resources/templates.php index 75d6646..3292fdb 100644 --- a/lib/resources/templates.php +++ b/lib/resources/templates.php @@ -102,17 +102,19 @@ </div> HTML; + // TODO: .wb-snakview should not be part of the template; check uses of that class and move them + // to .wb-snak $templates['wb-snak'] = // This template is not only used for PropertyValueSnak Snaks but also for other Snaks without a // value which may display some message in the value node. <<<HTML -<div class="wb-snak $1"> +<div class="wb-snak wb-snakview"> <div class="wb-snak-property-container"> - <div class="wb-snak-property" dir="auto">$2</div> + <div class="wb-snak-property" dir="auto">$1</div> </div> <div class="wb-snak-value-container" dir="auto"> - <div class="wb-snak-typeselector">$3</div> - <div class="wb-snak-value">$4</div> + <div class="wb-snak-typeselector"></div> + <div class="wb-snak-value">$2</div> </div> </div> HTML; diff --git a/repo/includes/ClaimHtmlGenerator.php b/repo/includes/ClaimHtmlGenerator.php index 6c13b76..fc3de21 100644 --- a/repo/includes/ClaimHtmlGenerator.php +++ b/repo/includes/ClaimHtmlGenerator.php @@ -59,25 +59,6 @@ } /** - * Returns the Html for the main Snak. - * - * @param string $formattedValue - * @return string - */ - protected function getMainSnakHtml( $formattedValue ) { - $mainSnakHtml = wfTemplate( 'wb-snak', - 'wb-mainsnak', - '', // Link to property. NOTE: we don't display this ever (instead, we generate it on - // Claim group level) If this was a public function, this should be generated - // anyhow since important when displaying a Claim on its own. - '', // type selector, JS only - ( $formattedValue === '' ) ? ' ' : $formattedValue - ); - - return $mainSnakHtml; - } - - /** * Builds and returns the HTML representing a single WikibaseEntity's claim. * * @since 0.4 @@ -90,9 +71,7 @@ public function getHtmlForClaim( Claim $claim, $editSectionHtml = null ) { wfProfileIn( __METHOD__ ); - $mainSnakHtml = $this->getMainSnakHtml( - $this->getFormattedSnakValue( $claim->getMainSnak() ) - ); + $mainSnakHtml = $this->getSnakHtml( $claim->getMainSnak(), false ); $rankHtml = ''; $referencesHeading = ''; @@ -249,12 +228,16 @@ ); } + $formattedValue = $this->getFormattedSnakValue( $snak ); + + if( $formattedValue === '' ) { + $formattedValue = ' '; + } + return wfTemplate( 'wb-snak', - 'wb-snakview', // Display property link only once for snaks featuring the same property: $propertyLink, - '', - ( $snak->getType() === 'value' ) ? $this->getFormattedSnakValue( $snak ) : '' + $formattedValue ); } -- To view, visit https://gerrit.wikimedia.org/r/119457 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ie030fc7e2a4ff6b840c02fe1c7ab75c65b7f13bf Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Adrian Lang <adrian.l...@wikimedia.de> Gerrit-Reviewer: Adrian Lang <adrian.l...@wikimedia.de> Gerrit-Reviewer: Aude <aude.w...@gmail.com> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Tobias Gritschacher <tobias.gritschac...@wikimedia.de> Gerrit-Reviewer: WikidataJenkins <wikidata-servi...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits