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

Change subject: Replying to reply sends notification to the wrong target
......................................................................


Replying to reply sends notification to the wrong target

I am really not sure about this implementation, this seems like a hack 
but I couldn't find an easy solution, suggestion/comment are welcome, :)

Basically the problem is that when a user replies to a reply, the 
application is showing the reply form to the parent of the reply and 
hence send notification to the parent post author.  The patch tries to 
alter the property of the form on the fly.

There is still one problem with this patch.  After a reply, it appends
 the new post to the end of parent container; however, when you refresh 
the page, the new post is right below the reply.


bug: 56224
Change-Id: Ife8c17b5f6ab96c0d78ffa46466b28b736e59e4b
---
M modules/discussion/forms.js
M modules/discussion/ui.js
M templates/post.html.php
3 files changed, 26 insertions(+), 5 deletions(-)

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



diff --git a/modules/discussion/forms.js b/modules/discussion/forms.js
index 53267d0..22b7810 100644
--- a/modules/discussion/forms.js
+++ b/modules/discussion/forms.js
@@ -53,9 +53,7 @@
                function() {
                        var $form = $( this ).closest( '.flow-reply-form' ),
                                workflowId = $( this ).flow( 
'getTopicWorkflowId' ),
-                               replyToId = $( this )
-                                       .closest( '.flow-post-container' )
-                                       .data( 'post-id' ),
+                               replyToId = $form.find( 
'input[name="topic[replyTo]"]' ).val(),
                                content = mw.flow.editor.getContent( 
$form.find( '.flow-reply-content' ) );
 
                        return [ workflowId, replyToId, content ];
diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js
index 5222f6c..3578db4 100644
--- a/modules/discussion/ui.js
+++ b/modules/discussion/ui.js
@@ -50,9 +50,24 @@
                                var $form,
                                        $viewport = $('main, html');
 
+                               /**
+                                * Internal helper function for adjusting the 
ReplyTo target
+                                * @param $btn the reply button jquery object
+                                * @param $targetFrom the form juqery object to 
submit post reply
+                                */
+                               function adjustReplyTarget( $btn, $targetForm ) 
{
+                                       var replyTo = $btn.closest( 
'.flow-post' ).attr( 'data-post-id' );
+                                       var replyDefaultText = $btn.closest( 
'.flow-post' )
+                                               .siblings( 
'form.flow-reply-form' )
+                                               .find( 
'input[name="placeholder"]' ).val();
+                                       $targetForm.find( 
'input[name="topic[replyTo]"]' ).val( replyTo );
+                                       $targetForm.find( 'textarea' ).attr( 
'placeholder',  replyDefaultText );
+                               }
+
                                if ( $(this).is( '.flow-post-container 
.flow-post-container *' ) ) {
                                        // We're in a tangent
-                                       $form = $( this ).closest( 
'.flow-post-replies' ).siblings( 'form.flow-reply-form' );
+                                       $form = $( this ).parents( 
'.flow-post-container' ).last().children( 'form.flow-reply-form' );
+                                       adjustReplyTarget( $( this ), $form );
                                        $( this ).closest( 
'.flow-topic-container' ).find( '.flow-topic-reply-container' ).hide();
                                } else if ( $(this).is( '.flow-topic-comments 
.flow-reply-link' ) ) {
                                        // We're in the topic title
@@ -60,6 +75,7 @@
                                } else {
                                        // Not in a tangent
                                        $form = $( this ).closest( '.flow-post' 
).siblings( 'form.flow-reply-form' );
+                                       adjustReplyTarget( $( this ), $form );
                                }
 
                                $textarea = $form.find( 'textarea' );
diff --git a/templates/post.html.php b/templates/post.html.php
index 7e611d8..0f1eb31 100644
--- a/templates/post.html.php
+++ b/templates/post.html.php
@@ -15,14 +15,21 @@
                        $replyForm .= $error->text() . '<br>'; // the pain ...
                }
        }
+
+       $placeHolder = $postView->replyPlaceholder( $post );
        $replyForm .=
                Html::element( 'input', array(
                        'type' => 'hidden',
                        'name' => $block->getName() . '[replyTo]',
                        'value' => $post->getPostId()->getHex(),
                ) ) .
+               Html::element( 'input', array(
+                       'type' => 'hidden',
+                       'name' => 'placeholder',
+                       'value' => $placeHolder,
+               ) ) .
                Html::textarea( $block->getName() . '[content]', '', array(
-                       'placeholder' => $postView->replyPlaceholder( $post ),
+                       'placeholder' => $placeHolder,
                        'class' => 'flow-reply-content flow-input mw-ui-input',
                ) ) .
                // NOTE: cancel button will be added via JS, makes no sense in 
non-JS context

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ife8c17b5f6ab96c0d78ffa46466b28b736e59e4b
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Bsitu <[email protected]>
Gerrit-Reviewer: Bsitu <[email protected]>
Gerrit-Reviewer: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: Werdna <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to