jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/364768 )
Change subject: Change Form's statements header text ...................................................................... Change Form's statements header text Bug: T170388 Depends-On: Ic522ad291c299a4c60993c304f340a10f625fb9b Change-Id: I76f6152c2544af75cf716d9342c9e5f44d2639a4 --- M extension.json M i18n/en.json M i18n/qqq.json M resources/jquery.wikibase.lexemeformview.js M src/View/LexemeFormsView.php M src/View/LexemeViewFactory.php M tests/phpunit/mediawiki/View/LexemeFormsViewTest.php 7 files changed, 48 insertions(+), 17 deletions(-) Approvals: WMDE-leszek: Looks good to me, approved jenkins-bot: Verified diff --git a/extension.json b/extension.json index 3b6b2ab..ac879ba 100644 --- a/extension.json +++ b/extension.json @@ -84,7 +84,7 @@ "messages": [ "wikibase-lexeme-empty-form-representation", "wikibase-lexeme-enter-form-representation", - "wikibase-statementsection-statements" + "wikibase-lexeme-statementsection-statements-about-form" ] }, "jquery.wikibase.grammaticalfeatureview": { diff --git a/i18n/en.json b/i18n/en.json index 7e9fce5..3d49f8a 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -11,6 +11,7 @@ "wikibase-newlexeme-lexicalcategory": "Lexical category", "wikibase-newlexeme-language": "Language of lexeme", "wikibase-lexeme-view-language-lexical-category": "$1 in $2", + "wikibase-lexeme-statementsection-statements-about-form": "Statements about $1", "wikibase-lexeme-view-forms": "Forms", "wikibase-lexeme-enter-form-representation": "Enter new form representation", "wikibase-lexeme-empty-form-representation": "No form representation defined", diff --git a/i18n/qqq.json b/i18n/qqq.json index 22b35bc..ed23ba0 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -16,6 +16,7 @@ "wikibase-newlexeme-lexicalcategory": "Name for \"lexical category\"", "wikibase-newlexeme-language": "Label for field in the lexeme creation form.", "wikibase-lexeme-view-language-lexical-category": "Description when both lexical category and language are present\n{{Identical|In}}", + "wikibase-lexeme-statementsection-statements-about-form": "Heading for the list of statements giving specific information about the currently viewed Form of a Lexeme.\n\nParameters:\n* $1 - Form ID.\n{{Identical|Statements}}", "wikibase-lexeme-view-forms": "Subheading for the forms section on a lexeme page.\n{{Identical|Form}}", "wikibase-lexeme-enter-form-representation": "Placeholder for the lexeme form representation input field.", "wikibase-lexeme-empty-form-representation": "Placeholder message displayed instead of the lexeme form representation in case no representation has been specified yet.", diff --git a/resources/jquery.wikibase.lexemeformview.js b/resources/jquery.wikibase.lexemeformview.js index b057626..c8ad5b7 100644 --- a/resources/jquery.wikibase.lexemeformview.js +++ b/resources/jquery.wikibase.lexemeformview.js @@ -51,10 +51,11 @@ function () { var $container = $( '<div/>' ); this.deferredFormWithId.promise().then( function ( form ) { + var messageKey = 'wikibase-lexeme-statementsection-statements-about-form'; var $header = $( '<h2/>' ).applyTemplate( 'wb-section-heading', [ - mw.message( 'wikibase-statementsection-statements' ).escaped(), + mw.message( messageKey, form.getId() ).escaped(), '', 'wikibase-statements' ] diff --git a/src/View/LexemeFormsView.php b/src/View/LexemeFormsView.php index 20d119b..1431eac 100644 --- a/src/View/LexemeFormsView.php +++ b/src/View/LexemeFormsView.php @@ -8,7 +8,7 @@ use Wikibase\Lexeme\View\Template\LexemeTemplateFactory; use Wikibase\Lib\EntityIdHtmlLinkFormatter; use Wikibase\View\LocalizedTextProvider; -use Wikibase\View\StatementSectionsView; +use Wikibase\View\StatementGroupListView; use WMDE\VueJsTemplating\Templating; /** @@ -33,9 +33,9 @@ private $entityIdHtmlFormatter; /** - * @var StatementSectionsView + * @var StatementGroupListView */ - private $statementSectionView; + private $statementGroupListView; /** * @var string @@ -46,12 +46,12 @@ LocalizedTextProvider $textProvider, LexemeTemplateFactory $templateFactory, EntityIdHtmlLinkFormatter $entityIdHtmlFormatter, - StatementSectionsView $statementSectionView + StatementGroupListView $statementGroupListView ) { $this->textProvider = $textProvider; $this->templateFactory = $templateFactory; $this->entityIdHtmlFormatter = $entityIdHtmlFormatter; - $this->statementSectionView = $statementSectionView; + $this->statementGroupListView = $statementGroupListView; } /** @@ -101,7 +101,7 @@ htmlspecialchars( $form->getId()->getSerialization() ), $this->renderRepresentationWidget( $form ), $grammaticalFeaturesHtml, - $this->statementSectionView->getHtml( $form->getStatements() ), + $this->getStatementSectionHtml( $form ), //Anchor separated from ID to avoid issue with front-end rendering htmlspecialchars( $form->getId()->getSerialization() ) ] ); @@ -191,4 +191,28 @@ HTML; } + /** + * @param Form $form + * @return string + */ + private function getStatementSectionHtml( Form $form ) { + $headerText = htmlspecialchars( + $this->textProvider->get( + 'wikibase-lexeme-statementsection-statements-about-form', + [ $form->getId()->getSerialization() ] + ) + ); + + $statementHeader = <<<HTML +<h2 class="wb-section-heading section-heading wikibase-statements" dir="auto"> + <span class="mw-headline">{$headerText}</span> +</h2> +HTML; + + $statementSection = $this->statementGroupListView->getHtml( + $form->getStatements()->toArray() + ); + return $statementHeader . $statementSection; + } + } diff --git a/src/View/LexemeViewFactory.php b/src/View/LexemeViewFactory.php index 4e9e258..cc444b2 100644 --- a/src/View/LexemeViewFactory.php +++ b/src/View/LexemeViewFactory.php @@ -90,6 +90,13 @@ $this->editSectionGenerator ); + $statementGroupListView = $wikibaseRepo->getViewFactory()->newStatementGroupListView( + $this->languageCode, + $this->labelDescriptionLookup, + $this->fallbackChain, + $this->editSectionGenerator + ); + $htmlTermRenderer = new FallbackHintHtmlTermRenderer( $languageDirectionalityLookup, new LanguageNameLookup( $this->languageCode ) @@ -108,7 +115,7 @@ $templateFactory, $this->entityIdHtmlLinkFormatterFactory ->getEntityIdFormatter( $retrievingLabelDescriptionLookup ), - $statementSectionsView + $statementGroupListView ); $sensesView = new SensesView( diff --git a/tests/phpunit/mediawiki/View/LexemeFormsViewTest.php b/tests/phpunit/mediawiki/View/LexemeFormsViewTest.php index 8c94a21..3a80a4b 100644 --- a/tests/phpunit/mediawiki/View/LexemeFormsViewTest.php +++ b/tests/phpunit/mediawiki/View/LexemeFormsViewTest.php @@ -4,10 +4,7 @@ use PHPUnit_Framework_TestCase; use Prophecy\Argument; -use Wikibase\DataModel\Entity\ItemId; use Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup; -use Wikibase\Lexeme\DataModel\Form; -use Wikibase\Lexeme\DataModel\FormId; use Wikibase\Lexeme\Tests\DataModel\NewForm; use Wikibase\Lexeme\View\LexemeFormsView; use Wikibase\Lexeme\View\Template\LexemeTemplateFactory; @@ -15,7 +12,7 @@ use Wikibase\Lib\LanguageNameLookup; use Wikibase\Lib\Store\EntityTitleLookup; use Wikibase\View\DummyLocalizedTextProvider; -use Wikibase\View\StatementSectionsView; +use Wikibase\View\StatementGroupListView; /** * @covers Wikibase\Lexeme\View\LexemeFormsView @@ -27,7 +24,7 @@ */ class LexemeFormsViewTest extends PHPUnit_Framework_TestCase { - const STATEMENT_SECTION_HTML = '<div class="statement-section"></div>'; + const STATEMENT_LIST_HTML = '<div class="statement-list"></div>'; public function testHtmlContainsTheFormsHeadline() { $view = $this->newFormsView(); @@ -118,13 +115,13 @@ assertThat( $html, - is( htmlPiece( havingChild( tagMatchingOutline( self::STATEMENT_SECTION_HTML ) ) ) ) + is( htmlPiece( havingChild( tagMatchingOutline( self::STATEMENT_LIST_HTML ) ) ) ) ); } private function newFormsView() { - $statementSectionView = $this->prophesize( StatementSectionsView::class ); - $statementSectionView->getHtml( Argument::any() )->willReturn( self::STATEMENT_SECTION_HTML ); + $statementSectionView = $this->prophesize( StatementGroupListView::class ); + $statementSectionView->getHtml( Argument::any() )->willReturn( self::STATEMENT_LIST_HTML ); return new LexemeFormsView( new DummyLocalizedTextProvider(), -- To view, visit https://gerrit.wikimedia.org/r/364768 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I76f6152c2544af75cf716d9342c9e5f44d2639a4 Gerrit-PatchSet: 8 Gerrit-Project: mediawiki/extensions/WikibaseLexeme Gerrit-Branch: master Gerrit-Owner: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de> Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits