Matthias Mullie has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/200150

Change subject: Get rid of hidden collapsible state
......................................................................

Get rid of hidden collapsible state

The only one using it was edit-title, which didn't need it.
I guess it was only still there for legacy reasons, from back when we didn't
do an ajax request to get the most recent title content. Nowadays, we do, then
render that into the template & append to DOM & display it. It's never in a
hidden state.

Change-Id: I14e6a9a649ab433bb104368e3ee92b0cc0c4bfa2
---
M handlebars/compiled/flow_block_topic_edit_title.handlebars.php
M handlebars/flow_edit_topic_title.partial.handlebars
M modules/engine/components/board/base/flow-board-api-events.js
M modules/engine/components/common/flow-component-events.js
4 files changed, 17 insertions(+), 32 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/50/200150/1

diff --git a/handlebars/compiled/flow_block_topic_edit_title.handlebars.php 
b/handlebars/compiled/flow_block_topic_edit_title.handlebars.php
index 279f468..540fb3d 100644
--- a/handlebars/compiled/flow_block_topic_edit_title.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_edit_title.handlebars.php
@@ -31,7 +31,7 @@
 '.LCRun3::p($cx, 'flow_errors', array(array($in),array())).'   <input 
type="hidden" name="wpEditToken" 
value="'.htmlentities((string)((isset($cx['sp_vars']['root']['editToken']) && 
is_array($cx['sp_vars']['root'])) ? $cx['sp_vars']['root']['editToken'] : 
null), ENT_QUOTES, 'UTF-8').'" />
        <input type="hidden" name="topic_prev_revision" 
value="'.htmlentities((string)((isset($in['revisionId']) && is_array($in)) ? 
$in['revisionId'] : null), ENT_QUOTES, 'UTF-8').'" />
        <input name="topic_content" class="mw-ui-input" 
value="'.((LCRun3::ifvar($cx, 
((isset($cx['sp_vars']['root']['submitted']['content']) && 
is_array($cx['sp_vars']['root']['submitted'])) ? 
$cx['sp_vars']['root']['submitted']['content'] : null))) ? 
''.htmlentities((string)((isset($cx['sp_vars']['root']['submitted']['content']) 
&& is_array($cx['sp_vars']['root']['submitted'])) ? 
$cx['sp_vars']['root']['submitted']['content'] : null), ENT_QUOTES, 'UTF-8').'' 
: ''.htmlentities((string)((isset($in['content']['content']) && 
is_array($in['content'])) ? $in['content']['content'] : null), ENT_QUOTES, 
'UTF-8').'').'" />
-       <div class="flow-form-actions flow-form-collapsible">
+       <div class="flow-form-actions">
                <button data-role="submit"
                        data-flow-api-handler="submitTopicTitle"
                        data-flow-api-target="< .flow-topic"
diff --git a/handlebars/flow_edit_topic_title.partial.handlebars 
b/handlebars/flow_edit_topic_title.partial.handlebars
index 163b32c..19516b8 100644
--- a/handlebars/flow_edit_topic_title.partial.handlebars
+++ b/handlebars/flow_edit_topic_title.partial.handlebars
@@ -10,7 +10,7 @@
                                {{~content.content~}}
                        {{~/if~}}
                " />
-       <div class="flow-form-actions flow-form-collapsible">
+       <div class="flow-form-actions">
                <button data-role="submit"
                        data-flow-api-handler="submitTopicTitle"
                        data-flow-api-target="< .flow-topic"
diff --git a/modules/engine/components/board/base/flow-board-api-events.js 
b/modules/engine/components/board/base/flow-board-api-events.js
index 7f164f4..4f0ed26 100644
--- a/modules/engine/components/board/base/flow-board-api-events.js
+++ b/modules/engine/components/board/base/flow-board-api-events.js
@@ -747,9 +747,7 @@
                        ) ).children();
 
                        flowBoard.emitWithReturn( 'addFormCancelCallback', 
$form, cancelCallback );
-                       $form
-                               .data( 'flow-initial-state', 'hidden' )
-                               .prependTo( info.$target );
+                       $form.prependTo( info.$target );
                }
 
                $form.find( '.mw-ui-input' ).focus();
diff --git a/modules/engine/components/common/flow-component-events.js 
b/modules/engine/components/common/flow-component-events.js
index f3b9770..bd78ff7 100644
--- a/modules/engine/components/common/flow-component-events.js
+++ b/modules/engine/components/common/flow-component-events.js
@@ -459,7 +459,8 @@
                // Find all the forms
                // @todo move this into a flow-load-handler
                $container.find( 'form' ).add( $container.filter( 'form' ) 
).each( function () {
-                       var $this = $( this );
+                       var $this = $( this ),
+                               initialState = $this.data( 'flow-initial-state' 
);
 
                        // Trigger for flow-actions-disabler
                        $this.find( 'input, textarea' ).trigger( 'keyup' );
@@ -474,7 +475,9 @@
                                }
                        } );
 
-                       component.emitWithReturn( 'hideForm', $this );
+                       if ( initialState === 'collapsed' ) {
+                               component.emitWithReturn( 'hideForm', $this );
+                       }
                } );
        }
        FlowComponentEventsMixin.eventHandlers.makeContentInteractive = 
flowMakeContentInteractiveCallback;
@@ -641,13 +644,12 @@
 
 
        /**
-        * Compress and hide a flow form and/or its actions, depending on 
data-flow-initial-state.
+        * Compress a flow form and/or its actions.
         * @param {jQuery} $form
         * @todo Move this to a separate file
         */
        function flowEventsMixinHideForm( $form ) {
-               var initialState = $form.data( 'flow-initial-state' ),
-                       component = mw.flow.getPrototypeMethod( 'component', 
'getInstanceByElement' )( $form );
+               var component = mw.flow.getPrototypeMethod( 'component', 
'getInstanceByElement' )( $form );
 
                // Store state
                $form.data( 'flow-state', 'hidden' );
@@ -677,15 +679,9 @@
                        }
                } );
 
-               if ( initialState === 'collapsed' ) {
-                       // Hide its actions
-                       // @todo Use TemplateEngine to find and hide actions?
-                       $form.find( '.flow-form-collapsible' ).hide();
-                       $form.data( 'flow-form-collapse-state', 'collapsed' );
-               } else if ( initialState === 'hidden' ) {
-                       // Hide the form itself
-                       $form.hide();
-               }
+               // Hide its actions
+               // @todo Use TemplateEngine to find and hide actions?
+               $form.find( '.flow-form-collapsible' ).hide();
        }
        FlowComponentEventsMixin.eventHandlers.hideForm = 
flowEventsMixinHideForm;
 
@@ -719,23 +715,14 @@
        FlowComponentEventsMixin.eventHandlers.focusField = 
flowEventsMixinFocusField;
 
        /**
-        * Expand and make visible a flow form and/or its actions, depending on 
data-flow-initial-state.
+        * Expand a flow form and/or its actions.
         * @param {jQuery} $form
         */
        function flowEventsMixinShowForm( $form ) {
-               var initialState = $form.data( 'flow-initial-state' ),
-                       self = this;
+               var self = this;
 
-               if ( initialState === 'collapsed' ) {
-                       // Show its actions
-                       if ( $form.data( 'flow-form-collapse-state' ) === 
'collapsed' ) {
-                               $form.removeData( 'flow-form-collapse-state' );
-                               $form.find( '.flow-form-collapsible' ).show();
-                       }
-               } else if ( initialState === 'hidden' ) {
-                       // Show the form itself
-                       $form.show();
-               }
+               // Show its actions
+               $form.find( '.flow-form-collapsible' ).show();
 
                // Expand all textareas if needed
                $form.find( '.flow-input-compressed' ).each( function () {

-- 
To view, visit https://gerrit.wikimedia.org/r/200150
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I14e6a9a649ab433bb104368e3ee92b0cc0c4bfa2
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to