From 36d33daa03a63be88fcc049c622b3aaf517380d1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 16 Apr 2019 01:53:55 +0200 Subject: [PATCH] HTMLForm: Improve method interface for collapsible forms Also minor tweaks: * Fix @since tags, this did not make it into 1.33 * Fix usage of FieldsetLayout 'group' in OOUIHTMLForm * Documentation changes Follow-up to 2896e87a1007202f5416fe506c691652b27c4ac9, per my post-merge review on that commit. Change-Id: Ib93375cde19730a46e4929878d6e472d3ac8f631 --- includes/actions/HistoryAction.php | 2 +- includes/htmlform/HTMLForm.php | 21 +++++++++++---------- includes/htmlform/OOUIHTMLForm.php | 12 ++++++------ 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index fc42be4612..658ee48081 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -267,7 +267,7 @@ class HistoryAction extends FormlessAction { $htmlForm ->setMethod( 'get' ) ->setAction( wfScript() ) - ->setCollapsible( true ) + ->setCollapsibleOptions( true ) ->setId( 'mw-history-searchform' ) ->setSubmitText( $this->msg( 'historyaction-submit' )->text() ) ->setWrapperAttributes( [ 'id' => 'mw-history-search' ] ) diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index aeeb934f93..99671c0cfc 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -222,15 +222,15 @@ class HTMLForm extends ContextSource { protected $mAction = false; /** - * Whether the HTML form can be collapsed - * @since 1.33 + * Whether the form can be collapsed + * @since 1.34 * @var bool */ protected $mCollapsible = false; /** - * Whether the HTML form IS collapsed by default - * @since 1.33 + * Whether the form is collapsed by default + * @since 1.34 * @var bool */ protected $mCollapsed = false; @@ -1062,14 +1062,15 @@ class HTMLForm extends ContextSource { } /** - * Make the form collapsible - * @since 1.33 - * @param bool $collapsed whether it should be by default - * @return HTMLForm $this for chaining calls (since 1.20) + * Set whether the HTML form can be collapsed. + * + * @since 1.34 + * @param bool $collapsedByDefault (optional) whether the form is collapsed by default + * @return HTMLForm $this for chaining calls */ - public function setCollapsible( $collapsed = false ) { + public function setCollapsibleOptions( $collapsedByDefault = false ) { $this->mCollapsible = true; - $this->mCollapsed = $collapsed; + $this->mCollapsed = $collapsedByDefault; return $this; } diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index 22ece4c58e..baafa5e721 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -290,13 +290,13 @@ class OOUIHTMLForm extends HTMLForm { 'classes' => $classes, 'group' => new OOUI\StackLayout( [ 'expanded' => false, - 'classes' => [ 'oo-ui-fieldsetLayout-group mw-collapsible-content' ], - 'items' => [ - new OOUI\Widget( [ - 'content' => new OOUI\HtmlSnippet( $html ) - ] ), - ], + 'classes' => [ 'mw-collapsible-content' ], ] ), + 'items' => [ + new OOUI\Widget( [ + 'content' => new OOUI\HtmlSnippet( $html ) + ] ), + ], ] + OOUI\Element::configFromHtmlAttributes( $this->mWrapperAttributes ) ); } else { $content = new OOUI\HtmlSnippet( $html ); -- 2.20.1