Mattflaschen has uploaded a new change for review.

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

Change subject: Don't create duplicate edit topic forms, focus when form shown
......................................................................

Don't create duplicate edit topic forms, focus when form shown

Change-Id: I71e307c3cf9044d208a11df27586748f4b98e98d
---
M modules/new/components/flow-board.js
1 file changed, 38 insertions(+), 23 deletions(-)


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

diff --git a/modules/new/components/flow-board.js 
b/modules/new/components/flow-board.js
index 29759d5..8299936 100644
--- a/modules/new/components/flow-board.js
+++ b/modules/new/components/flow-board.js
@@ -753,39 +753,54 @@
                        event.preventDefault();
                };
 
+               /**
+                * Shows the form for editing a topic title, it's not already 
showing
+                *
+                * @param {Event} event
+                */
                FlowBoardComponent.UI.events.interactiveHandlers.editTopicTitle 
= function( event ) {
                        var $link = $( this ),
                                $topic = $link.closest( '.flow-topic' ),
-                               $title = $topic
-                                       .children( '.flow-topic-titlebar' )
-                                       .find( '.flow-topic-title' ),
-                               flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $link ),
-                               $form,
+                               $topicTitleBar = $topic
+                                       .children( '.flow-topic-titlebar' ),
+                               $title, flowBoard, $form, cancelCallback, 
linkParams;
+
+                       $form = $topicTitleBar.find( 'form' );
+
+                       if ( $form.length === 0 ) {
+                               $title = $topicTitleBar.find( 
'.flow-topic-title' );
+
+                               flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $link );
+
                                cancelCallback = function() {
                                        $form.remove();
                                        $title.show();
-                               },
+                               };
+
                                linkParams = flowBoard.API.getQueryMap( 
$link.attr( 'href' ) );
 
-                       $title.hide();
+                               $title.hide();
 
-                       $form = $( 
flowBoard.TemplateEngine.processTemplateGetFragment(
-                               'flow_edit_topic_title',
-                               {
-                                       'actions' : {
-                                               'edit' : {
-                                                       'url' : $link.attr( 
'href' )
-                                               }
-                                       },
-                                       'content' : $title.data( 'title' ),
-                                       'revisionId' : linkParams.etrevId
-                               }
-                       ) ).children();
+                               $form = $( 
flowBoard.TemplateEngine.processTemplateGetFragment(
+                                       'flow_edit_topic_title',
+                                       {
+                                               'actions' : {
+                                                       'edit' : {
+                                                               'url' : 
$link.attr( 'href' )
+                                                       }
+                                               },
+                                               'content' : $title.data( 
'title' ),
+                                               'revisionId' : 
linkParams.etrevId
+                                       }
+                               ) ).children();
 
-                       $form
-                               .data( 'flow-cancel-callback', cancelCallback )
-                               .data( 'flow-initial-state', 'hidden' )
-                               .insertAfter( $title );
+                               $form
+                                       .data( 'flow-cancel-callback', 
cancelCallback )
+                                       .data( 'flow-initial-state', 'hidden' )
+                                       .insertAfter( $title );
+                       }
+
+                       $form.find( '.mw-ui-input' ).focus();
 
                        event.preventDefault();
                };

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71e307c3cf9044d208a11df27586748f4b98e98d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: frontend-rewrite
Gerrit-Owner: Mattflaschen <[email protected]>

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

Reply via email to