Matthias Mullie has uploaded a new change for review.

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

Change subject: Make newTopic use _flowBoardComponentRefreshTopic
......................................................................

Make newTopic use _flowBoardComponentRefreshTopic

Now using _flowBoardComponentRefreshTopic, which fetches render
data from read API & renders the topic. Also removes some
specific rendering code.
Flip side: it needed another hack.

Bug: T95773
Change-Id: I3c349543b526fe3afc515fe13060322b2f5bee94
---
M modules/engine/components/board/base/flow-board-api-events.js
1 file changed, 7 insertions(+), 16 deletions(-)


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

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 a07f691..b465352 100644
--- a/modules/engine/components/board/base/flow-board-api-events.js
+++ b/modules/engine/components/board/base/flow-board-api-events.js
@@ -483,10 +483,10 @@
         * @returns {$.Promise}
         */
        FlowBoardComponentApiEventsMixin.UI.events.apiHandlers.newTopic = 
function ( info, data, jqxhr ) {
-               var result, fragment,
-                       schemaName = $( this ).data( 'flow-eventlog-schema' ),
+               var schemaName = $( this ).data( 'flow-eventlog-schema' ),
                        funnelId = $( this ).data( 'flow-eventlog-funnel-id' ),
-                       flowBoard = mw.flow.getPrototypeMethod( 'board', 
'getInstanceByElement' )( $( this ) );
+                       flowBoard = mw.flow.getPrototypeMethod( 'board', 
'getInstanceByElement' )( $( this ) ),
+                       $stub;
 
                if ( info.status !== 'done' ) {
                        // Error will be displayed by default, nothing else to 
wrap up
@@ -495,26 +495,17 @@
 
                flowBoard.logEvent( schemaName, { action: 'save-success', 
funnelId: funnelId } );
 
-               result = data.flow['new-topic'].result.topiclist;
-
-               // render only the new topic
-               result.roots = [result.roots[0]];
-               fragment = mw.flow.TemplateEngine.processTemplateGetFragment( 
'flow_topiclist_loop.partial', result );
-
                flowBoard.emitWithReturn( 'cancelForm', $( this ).closest( 
'form' ) );
-
-               // Everything must be reset before re-initializing
-               // @todo un-hardcode
-               flowBoard.reinitializeContainer(
-                       flowBoard.$container.find( '.flow-topics' ).prepend( 
fragment )
-               );
 
                // remove focus - title input field may still have focus
                // (submitted via enter key), which it needs to lose:
                // the form will only re-activate if re-focused
                document.activeElement.blur();
 
-               return $.Deferred().resolve().promise();
+               // _flowBoardComponentRefreshTopic relies on finding a 
.flow-topic node
+               // to replace, so let's pretend to have one here!
+               $stub = $( '<div class="flow-topic"><div></div></div>' 
).prependTo( flowBoard.$container.find( '.flow-topics' ) );
+               return _flowBoardComponentRefreshTopic( $stub.find( 'div' ), 
data.flow['new-topic'].committed.topiclist['topic-id'] );
        };
 
        /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c349543b526fe3afc515fe13060322b2f5bee94
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <mmul...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to