HTMLForm: Improve method interface for collapsible forms
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 15 Apr 2019 23:53:55 +0000 (01:53 +0200)
committerjdlrobson <jdlrobson@gmail.com>
Thu, 2 May 2019 21:33:20 +0000 (14:33 -0700)
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
includes/htmlform/HTMLForm.php
includes/htmlform/OOUIHTMLForm.php

index fc42be4..658ee48 100644 (file)
@@ -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' ] )
index aeeb934..99671c0 100644 (file)
@@ -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;
        }
 
index 22ece4c..baafa5e 100644 (file)
@@ -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 );