jenkins-bot has submitted this change and it was merged.
Change subject: Use checkboxes instead of multiselect to edit badges
......................................................................
Use checkboxes instead of multiselect to edit badges
Bug: 70333
Change-Id: I7093c95fec6405b9930eeb6f63d7db2c4f023b93
---
M repo/includes/specials/SpecialSetSiteLink.php
M repo/tests/phpunit/includes/specials/SpecialSetSitelinkTest.php
2 files changed, 41 insertions(+), 37 deletions(-)
Approvals:
Henning Snater: Checked; Looks good to me, but someone else must approve
JanZerebecki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/specials/SpecialSetSiteLink.php
b/repo/includes/specials/SpecialSetSiteLink.php
index 3386c01..83deb8f 100644
--- a/repo/includes/specials/SpecialSetSiteLink.php
+++ b/repo/includes/specials/SpecialSetSiteLink.php
@@ -121,7 +121,12 @@
$this->page = $request->getVal( 'page' );
- $this->badges = $request->getArray( 'badges', array() );
+ $this->badges = array();
+ foreach ( $this->badgeItems as $badgeId => $value ) {
+ if ( $request->getVal( 'badge-' . $badgeId ) ) {
+ $this->badges[] = $badgeId;
+ }
+ }
}
/**
@@ -240,22 +245,11 @@
. Html::element(
'label',
array(
- 'for' => 'wb-setsitelink-badges',
'class' => 'wb-label'
),
$this->msg( 'wikibase-setsitelink-badges'
)->text()
)
- . Html::openElement(
- 'select',
- array(
- 'name' => 'badges[]',
- 'class' => 'wb-input',
- 'id' => 'wb-setsitelink-badges',
- 'multiple' => true
- )
- )
- . $this->getBadgesOptionsHtml()
- . Html::closeElement( 'select' );
+ . $this->getHtmlForBadges();
}
$site = $this->siteStore->getSite( $this->site );
@@ -311,23 +305,36 @@
}
/**
- * Returns the HTML containing an option tag for each badge.
+ * Returns the HTML containing a checkbox for each badge.
*
* @return string
*/
- private function getBadgesOptionsHtml() {
+ private function getHtmlForBadges() {
$options = '';
foreach ( $this->badgeItems as $badgeId => $value ) {
- $attrs = array( 'value' => $badgeId );
- if ( in_array( $badgeId, $this->badges ) ) {
- $attrs['selected'] = true;
- }
+ $name = 'badge-' . $badgeId;
+ $title = $this->getTitleForBadge( new ItemId( $badgeId
) );
- $options .= Html::element(
- 'option',
- $attrs,
- $this->getTitleForBadge( new ItemId( $badgeId )
)
+ $options .= Html::rawElement(
+ 'div',
+ array(
+ 'class' => 'wb-label'
+ ),
+ Html::check(
+ $name,
+ in_array( $badgeId, $this->badges ),
+ array(
+ 'id' => $name
+ )
+ )
+ . Html::element(
+ 'label',
+ array(
+ 'for' => $name
+ ),
+ $title
+ )
);
}
diff --git a/repo/tests/phpunit/includes/specials/SpecialSetSitelinkTest.php
b/repo/tests/phpunit/includes/specials/SpecialSetSitelinkTest.php
index 6b69f1a..54ebc88 100644
--- a/repo/tests/phpunit/includes/specials/SpecialSetSitelinkTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialSetSitelinkTest.php
@@ -126,25 +126,22 @@
}
private function addBadgeMatcher() {
- $badgeMatcher = array(
- 'tag' => 'option',
- 'content' => 'Good article',
+ $name = 'badge-' . self::$badgeId;
+ self::$matchers['badgeinput'] = array(
+ 'tag' => 'input',
'attributes' => array(
- 'value' => self::$badgeId
+ 'name' => $name,
+ 'id' => $name,
+ 'type' => 'checkbox'
) );
- self::$matchers['badges'] = array(
- 'tag' => 'select',
+ self::$matchers['badgelabel'] = array(
+ 'tag' => 'label',
'attributes' => array(
- 'id' => 'wb-setsitelink-badges',
- 'class' => 'wb-input',
- 'name' => 'badges[]',
- 'multiple' => ''
+ 'for' => $name
),
- 'children' => array(
- 'count' => 1,
- 'only' => $badgeMatcher
- ) );
+ 'content' => 'Good article'
+ );
}
public function testExecuteEmptyForm() {
--
To view, visit https://gerrit.wikimedia.org/r/159103
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7093c95fec6405b9930eeb6f63d7db2c4f023b93
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Bene <[email protected]>
Gerrit-Reviewer: Addshore <[email protected]>
Gerrit-Reviewer: Aude <[email protected]>
Gerrit-Reviewer: Daniel Kinzler <[email protected]>
Gerrit-Reviewer: Henning Snater <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: JanZerebecki <[email protected]>
Gerrit-Reviewer: Jeroen De Dauw <[email protected]>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits