jenkins-bot has submitted this change and it was merged.
Change subject: Fixed initialization of site link tables
......................................................................
Fixed initialization of site link tables
For site link groups that have no site, the site link table header is not
displayed anymore.
With that done, the $.tablesorter widget does not cause an error due to being
initialized on
a table with an empty body.
Change-Id: I08d0c822b037c3c7c555d4b48deaeca7689d6861
---
M lib/resources/wikibase.ui.SiteLinksEditTool.js
M repo/includes/ItemView.php
2 files changed, 23 insertions(+), 20 deletions(-)
Approvals:
Daniel Kinzler: Checked; Looks good to me, approved
jenkins-bot: Verified
diff --git a/lib/resources/wikibase.ui.SiteLinksEditTool.js
b/lib/resources/wikibase.ui.SiteLinksEditTool.js
index 1059700..5f55eea 100644
--- a/lib/resources/wikibase.ui.SiteLinksEditTool.js
+++ b/lib/resources/wikibase.ui.SiteLinksEditTool.js
@@ -81,7 +81,7 @@
self.refreshView(); // will re-assign even/uneven
classes
} );
- if ( $( 'table.wb-sitelinks thead' ).children().length > 0 ) {
+ if ( this._subject.children( 'thead' ).children().length > 0 ) {
// initially sort on the site id column
this._subject.tablesorter( { sortList: [{1:'asc'}] } );
}
diff --git a/repo/includes/ItemView.php b/repo/includes/ItemView.php
index 9478e88..5429f14 100644
--- a/repo/includes/ItemView.php
+++ b/repo/includes/ItemView.php
@@ -68,7 +68,24 @@
/**
* @var ItemContent $itemContent
*/
- $siteLinks = $itemContent->getItem()->getSimpleSiteLinks();
+ $allSiteLinks = $itemContent->getItem()->getSimpleSiteLinks();
+
+ $siteLinks = array(); // site links of the currently handled
site group
+
+ foreach( $allSiteLinks as $siteLink ) {
+ // FIXME: depracted method usage
+ $site = \Sites::singleton()->getSite(
$siteLink->getSiteId() );
+
+ if ( $site === null ) {
+ continue;
+ }
+
+ $link = new SiteLink( $site, $siteLink->getPageName() );
+
+ if ( $site->getGroup() === $group ) {
+ $siteLinks[] = $link;
+ }
+ }
$html = $thead = $tbody = $tfoot = '';
@@ -90,14 +107,14 @@
$i = 0;
// Batch load the sites we need info about during the building
of the sitelink list.
- $sites = Sites::singleton()->getSites();
+ $sites = Sites::singleton()->getSiteGroup( $group );
// Sort the sitelinks according to their global id
$safetyCopy = $siteLinks; // keep a shallow copy;
$sortOk = usort(
$siteLinks,
- function( SimpleSiteLink $a, SimpleSiteLink $b ) {
- return strcmp( $a->getSiteId(), $b->getSiteId()
);
+ function( SiteLink $a, SiteLink $b ) {
+ return strcmp( $a->getSite()->getGlobalId(),
$b->getSite()->getGlobalId() );
}
);
@@ -109,21 +126,7 @@
$idFormatter =
WikibaseRepo::getDefaultInstance()->getIdFormatter();
$editLink = $this->getEditUrl( $idFormatter->format(
$itemContent->getEntity()->getId() ), null, 'SetSiteLink' );
- foreach( $siteLinks as $siteLink ) {
- // FIXME: depracted method usage
- $site = \Sites::singleton()->getSite(
$siteLink->getSiteId() );
-
- if ( $site === null ) {
- $site = new \Site();
- $site->setGlobalId( $siteLink->getSiteId() );
- }
-
- $link = new SiteLink( $site, $siteLink->getPageName() );
-
- if ( $link->getSite()->getGroup() !== $group ) {
- continue;
- }
-
+ foreach( $siteLinks as $link ) {
$alternatingClass = ( $i++ % 2 ) ? 'even' : 'uneven';
$site = $link->getSite();
--
To view, visit https://gerrit.wikimedia.org/r/69633
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I08d0c822b037c3c7c555d4b48deaeca7689d6861
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Henning Snater <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Tobias Gritschacher <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits