jenkins-bot has submitted this change and it was merged.

Change subject: Summarize Topic js interaction
......................................................................


Summarize Topic js interaction

Change-Id: I1abe19785581ae429ffb2526192a7b92bc42ee68
---
M Resources.php
M handlebars/compiled/flow_block_topic.handlebars.php
M handlebars/compiled/flow_block_topic_edit_post.handlebars.php
M handlebars/compiled/flow_block_topiclist.handlebars.php
M handlebars/flow_block_topicsummary_edit.handlebars
M handlebars/flow_topic.handlebars
M modules/new/components/flow-board.js
M modules/new/flow-api.js
8 files changed, 97 insertions(+), 16 deletions(-)

Approvals:
  EBernhardson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Resources.php b/Resources.php
index 4ec5784..1b9ec32 100644
--- a/Resources.php
+++ b/Resources.php
@@ -80,6 +80,8 @@
                        'flow-terms-of-use-edit',
                        'flow-terms-of-use-new-topic',
                        'flow-terms-of-use-reply',
+                       'flow-terms-of-use-summarize',
+                       'flow-summarize-topic-submit',
                        'flow-toggle-topics',
                        'flow-topic-action-close-topic',
                        'flow-topic-action-edit-title',
diff --git a/handlebars/compiled/flow_block_topic.handlebars.php 
b/handlebars/compiled/flow_block_topic.handlebars.php
index 4af869c..650874c 100644
--- a/handlebars/compiled/flow_block_topic.handlebars.php
+++ b/handlebars/compiled/flow_block_topic.handlebars.php
@@ -191,6 +191,8 @@
                                '.((LCRun3::ifvar($cx, 
((is_array($in['actions']) && isset($in['actions']['summarize'])) ? 
$in['actions']['summarize'] : null))) ? '
                                        <li>
                                                <a class="flow-ui-button 
flow-ui-progressive flow-ui-quiet flow-ui-thin"
+                                                  
data-flow-interactive-handler="apiRequest"
+                                                   
data-flow-api-handler="activateSummarizeTopic"
                                                   
href="'.htmlentities(((is_array($in['actions']['summarize']) && 
isset($in['actions']['summarize']['url'])) ? $in['actions']['summarize']['url'] 
: null), ENT_QUOTES, 'UTF-8').'"
                                                   
title="'.htmlentities(((is_array($in['actions']['summarize']) && 
isset($in['actions']['summarize']['title'])) ? 
$in['actions']['summarize']['title'] : null), ENT_QUOTES, 'UTF-8').'">
                                                        <span class="wikiglyph 
wikiglyph-flag"></span>
@@ -204,11 +206,11 @@
                                ' : '').'
                        </ul>
                </div>
-               '.((LCRun3::ifvar($cx, ((is_array($in) && 
isset($in['summary'])) ? $in['summary'] : null))) ? '
-                       <div class="flow-topic-summary">
+               <div class="flow-topic-summary">
+                       '.((LCRun3::ifvar($cx, ((is_array($in) && 
isset($in['summary'])) ? $in['summary'] : null))) ? '
                                '.LCRun3::ch($cx, 'html', Array(((is_array($in) 
&& isset($in['summary'])) ? $in['summary'] : null)), 'encq').'
-                       </div>
-               ' : '').'
+                       ' : '').'
+               </div>
        </div>
 
        '.LCRun3::sec($cx, ((is_array($in) && isset($in['replies'])) ? 
$in['replies'] : null), $in, true, function($cx, $in) {return '
diff --git a/handlebars/compiled/flow_block_topic_edit_post.handlebars.php 
b/handlebars/compiled/flow_block_topic_edit_post.handlebars.php
index 9e6bc26..7a83f6c 100644
--- a/handlebars/compiled/flow_block_topic_edit_post.handlebars.php
+++ b/handlebars/compiled/flow_block_topic_edit_post.handlebars.php
@@ -29,7 +29,7 @@
 ' : '').'
 
 
-       
+
 
        '.LCRun3::sec($cx, ((is_array($in) && isset($in['roots'])) ? 
$in['roots'] : null), $in, true, function($cx, $in) {return '
                '.LCRun3::hbch($cx, 'eachPost', Array($cx['scopes'][0],$in), 
$in, function($cx, $in) {return '
@@ -47,7 +47,7 @@
        ' : '').'
 </div>
        <input type="hidden" name="wpEditToken" 
value="'.htmlentities(((is_array($cx['scopes'][0]) && 
isset($cx['scopes'][0]['editToken'])) ? $cx['scopes'][0]['editToken'] : null), 
ENT_QUOTES, 'UTF-8').'" />
-       
+
        <input type="hidden" name="topic_prev_revision" 
value="'.htmlentities(((is_array($in) && isset($in['revisionId'])) ? 
$in['revisionId'] : null), ENT_QUOTES, 'UTF-8').'" />
        '.LCRun3::hbch($cx, 'ifAnonymous', Array(), $in, function($cx, $in) 
{return '
                <div class="flow-anon-warning flow-ui-tooltip 
flow-ui-progressive flow-ui-tooltip-down flow-form-collapsible plainlinks">
diff --git a/handlebars/compiled/flow_block_topiclist.handlebars.php 
b/handlebars/compiled/flow_block_topiclist.handlebars.php
index 33fb654..b534fa5 100644
--- a/handlebars/compiled/flow_block_topiclist.handlebars.php
+++ b/handlebars/compiled/flow_block_topiclist.handlebars.php
@@ -261,6 +261,8 @@
                                '.((LCRun3::ifvar($cx, 
((is_array($in['actions']) && isset($in['actions']['summarize'])) ? 
$in['actions']['summarize'] : null))) ? '
                                        <li>
                                                <a class="flow-ui-button 
flow-ui-progressive flow-ui-quiet flow-ui-thin"
+                                                  
data-flow-interactive-handler="apiRequest"
+                                                   
data-flow-api-handler="activateSummarizeTopic"
                                                   
href="'.htmlentities(((is_array($in['actions']['summarize']) && 
isset($in['actions']['summarize']['url'])) ? $in['actions']['summarize']['url'] 
: null), ENT_QUOTES, 'UTF-8').'"
                                                   
title="'.htmlentities(((is_array($in['actions']['summarize']) && 
isset($in['actions']['summarize']['title'])) ? 
$in['actions']['summarize']['title'] : null), ENT_QUOTES, 'UTF-8').'">
                                                        <span class="wikiglyph 
wikiglyph-flag"></span>
@@ -274,11 +276,11 @@
                                ' : '').'
                        </ul>
                </div>
-               '.((LCRun3::ifvar($cx, ((is_array($in) && 
isset($in['summary'])) ? $in['summary'] : null))) ? '
-                       <div class="flow-topic-summary">
+               <div class="flow-topic-summary">
+                       '.((LCRun3::ifvar($cx, ((is_array($in) && 
isset($in['summary'])) ? $in['summary'] : null))) ? '
                                '.LCRun3::ch($cx, 'html', Array(((is_array($in) 
&& isset($in['summary'])) ? $in['summary'] : null)), 'encq').'
-                       </div>
-               ' : '').'
+                       ' : '').'
+               </div>
        </div>
 
        '.LCRun3::sec($cx, ((is_array($in) && isset($in['replies'])) ? 
$in['replies'] : null), $in, true, function($cx, $in) {return '
diff --git a/handlebars/flow_block_topicsummary_edit.handlebars 
b/handlebars/flow_block_topicsummary_edit.handlebars
index 2d77104..0295be1 100644
--- a/handlebars/flow_block_topicsummary_edit.handlebars
+++ b/handlebars/flow_block_topicsummary_edit.handlebars
@@ -17,7 +17,13 @@
                        {{~/if~}}
                </textarea>
                <div class="flow-form-actions flow-form-collapsible">
-                       <button data-role="submit" class="flow-ui-button 
flow-ui-constructive">{{l10n "flow-topic-action-summarize-topic"}}</button>
+                       <button
+                               data-role="submit"
+                               class="flow-ui-button flow-ui-constructive"
+                               data-flow-interactive-handler="apiRequest"
+                               data-flow-api-handler="summarizeTopic">
+                                       {{l10n 
"flow-topic-action-summarize-topic"}}
+                       </button>
                        <button data-role="action" class="flow-ui-button 
flow-ui-progressive flow-ui-quiet" data-flow-api-handler="preview" 
name="preview">
                                {{l10n "flow-preview"}}
                        </button>
diff --git a/handlebars/flow_topic.handlebars b/handlebars/flow_topic.handlebars
index d0574e6..2859e85 100644
--- a/handlebars/flow_topic.handlebars
+++ b/handlebars/flow_topic.handlebars
@@ -145,6 +145,8 @@
                                {{#if actions.summarize}}
                                        <li>
                                                <a class="flow-ui-button 
flow-ui-progressive flow-ui-quiet flow-ui-thin"
+                                                  
data-flow-interactive-handler="apiRequest"
+                                                   
data-flow-api-handler="activateSummarizeTopic"
                                                   
href="{{actions.summarize.url}}"
                                                   
title="{{actions.summarize.title}}">
                                                        <span class="wikiglyph 
wikiglyph-flag"></span>
@@ -158,11 +160,11 @@
                                {{/if}}
                        </ul>
                </div>
-               {{#if summary}}
-                       <div class="flow-topic-summary">
+               <div class="flow-topic-summary">
+                       {{#if summary}}
                                {{html summary}}
-                       </div>
-               {{/if}}
+                       {{/if}}
+               </div>
        </div>
 
        {{#each replies}}
diff --git a/modules/new/components/flow-board.js 
b/modules/new/components/flow-board.js
index b98a506..29759d5 100644
--- a/modules/new/components/flow-board.js
+++ b/modules/new/components/flow-board.js
@@ -205,6 +205,21 @@
                        };
                };
 
+               /**
+                * Before activating summarize topic, sends an overrideObject 
to the
+                * API to modify the request params.
+                * @param {Event} event
+                * @return {Object}
+                */
+               
FlowBoardComponent.UI.events.apiPreHandlers.activateSummarizeTopic = function ( 
event ) {
+                       return {
+                               // href submodule is edit-topic-summary
+                               submodule: 'topic-summary-view',
+                               // href does not have this param
+                               vtscontentFormat: 'wikitext'
+                       };
+               };
+
                ////////////////////////////////////////////////////////////
                // FlowBoardComponent.UI api callback handlers
                ////////////////////
@@ -495,6 +510,57 @@
                        }
                };
 
+               /**
+                * Activate the editable summarize topic form with given api 
request
+                * @param {String} status
+                * @param {Object} data
+                * @param {jqXHR} jqxhr
+                */
+               FlowBoardComponent.UI.events.apiHandlers.activateSummarizeTopic 
= function ( status, data, jqxhr ) {
+                       var html,
+                               $node = $( this ).closest( 
'.flow-topic-titlebar' ).find( '.flow-topic-summary' ),
+                               old = $node.html(),
+                               flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $( this ) );
+                       $( this ).closest( '.flow-menu' ).removeClass( 'focus' 
);
+
+                       // @todo This is using the old fashion way to re-render 
new content in the board
+                       // need to use the proper way that flow is using, eg: 
reinitializeBoard() etc
+                       if ( status === 'done' ) {
+                               html = flowBoard.TemplateEngine.processTemplate(
+                                       'flow_block_topicsummary_edit',
+                                       data.flow[ 'topic-summary-view' 
].result.topicsummary
+                               );
+                               $node.html(
+                                       $( html ).html()
+                               );
+                               $node.find( 'form' ).data( 
'flow-cancel-callback', function() {
+                                       $node.html( old );
+                               } );
+                       } else {
+                               // @todo fail
+                               alert('fail');
+                       }
+               };
+
+               /**
+                * After submit of the summarize topic edit form, process the 
new topic summary data.
+                * @param {String} status
+                * @param {Object} data
+                * @param {jqXHR} jqxhr
+                */
+               FlowBoardComponent.UI.events.apiHandlers.summarizeTopic = 
function ( status, data, jqxhr ) {
+                       var flowBoard = 
FlowBoardComponent.prototype.getInstanceByElement( $( this ) ),
+                               $node = $( this ).closest( 
'.flow-topic-titlebar' ).find( '.flow-topic-summary' );
+
+                       if ( status === 'done' ) {
+                               // There is no template to render
+                               $node.html( data.flow[ 'edit-topic-summary' 
].result.topicsummary.revision.content );
+                       } else {
+                               // @todo fail
+                               alert('fail');
+                       }
+               };
+
                ////////////////////////////////////////////////////////////
                // FlowBoardComponent.UI on-element-load handlers
                ////////////////////
diff --git a/modules/new/flow-api.js b/modules/new/flow-api.js
index c634969..26f3166 100644
--- a/modules/new/flow-api.js
+++ b/modules/new/flow-api.js
@@ -21,7 +21,8 @@
                'post-view': [ 'topic', 'vp' ],
                'topic-view': [ 'topic', 'vt' ],
                'header-view': [ 'header_', 'vh' ],
-               'topic-summary-view': [ 'topicsummary_', 'vts' ]
+               'topic-summary-view': [ 'topicsummary_', 'vts' ],
+               'edit-topic-summary': [ 'topicsummary_', 'ets' ]
        };
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1abe19785581ae429ffb2526192a7b92bc42ee68
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: frontend-rewrite
Gerrit-Owner: Bsitu <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: SG <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to