]> git.mxchange.org Git - friendica.git/commitdiff
add link to parent of comment
authorJakobus Schürz <jakobus.schuerz@home.arpa>
Thu, 5 Oct 2023 10:39:31 +0000 (12:39 +0200)
committerJakobus Schürz <jakobus.schuerz@home.arpa>
Fri, 6 Oct 2023 22:09:06 +0000 (00:09 +0200)
src/Object/Post.php
view/theme/frio/js/theme.js
view/theme/frio/templates/wall_thread.tpl

index dd3074cfa32a0e06d4ac785b35e4b10c5f93cc03..77912c7b85c5e046a70e24f276c4d057f9493de7 100644 (file)
@@ -164,7 +164,7 @@ class Post
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         * @throws \ImagickException
         */
-       public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1)
+       public function getTemplateData(array $conv_responses, string $formSecurityToken, int $thread_level = 1, string $parent_guid = "", string $parent_username = "")
        {
                $item = $this->getData();
                $edited = false;
@@ -497,6 +497,8 @@ class Post
                }
 
                $tmp_item = [
+                       'parentguid'      => $parent_guid,
+                       'isanswerto'      => DI::l10n()->t('is answer to %s', $parent_username),
                        'template'        => $this->getTemplate(),
                        'type'            => implode('', array_slice(explode('/', $item['verb']), -1)),
                        'comment_firstcollapsed' => false,
@@ -610,7 +612,7 @@ class Post
                $nb_children = count($children);
                if ($nb_children > 0) {
                        foreach ($children as $child) {
-                               $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1);
+                               $result['children'][] = $child->getTemplateData($conv_responses, $formSecurityToken, $thread_level + 1, $tmp_item['guid'], $tmp_item['name']);
                        }
 
                        // Collapse
index ef71b8c1d0339be304ca7e6b4fafa31375ff2a82..733752cfd9669e89d3ed731f27f64bd4ae0e35ac 100644 (file)
@@ -184,6 +184,7 @@ $(document).ready(function () {
                if (typeof searchValue !== "undefined") {
                        $("#nav-search-input-field").val(searchValue);
                }
+
        }
 
        // move the "Save the search" button to the second navbar
@@ -941,4 +942,13 @@ function toggleDropdownText(elm) {
 function hasClass(elem, cls) {
        return (" " + elem.className + " ").indexOf(" " + cls + " ") > -1;
 }
+
+// Go to parent for "is answer to <user>" link in comments below username
+function goToParentItem(plink, pguid) {
+       history.pushState({},"",plink);
+       var loc = plink.split("/");
+       loc.pop();
+       loc.push(pguid);
+       location.href = loc.join("/");
+}
 // @license-end
index b3ade5fe04991341ae4ec8527f7d82f5236e893d..14240659d2a150d4acaf47edeeba790b5d61981f 100644 (file)
@@ -214,6 +214,10 @@ as the value of $top_child_total (this is done at the end of this file)
                                        <span class="text-muted">
                                </h5>
                                <small>
+                                       {{if !$item.parentguid==""}}
+                                               <a id="btn-{{$item.id}}" class="time" href="javascript:;" onclick="goToParentItem('{{$item.plink.orig}}', '{{$item.parentguid}}');">{{$item.isanswerto}}</a>
+                                               &#x2022;
+                                       {{/if}}
                                        <a href="{{$item.plink.orig}}">
                                                <time class="time" title="{{$item.localtime}}" data-toggle="tooltip" datetime="{{$item.utc}}">{{$item.ago}}</time>
                                        </a>