]> BookStack Code Mirror - bookstack/commitdiff
#47 Hides the reply button based if comments are 2 levels deep.
authorAbijeet <redacted>
Wed, 24 May 2017 01:32:11 +0000 (07:02 +0530)
committerAbijeet <redacted>
Wed, 24 May 2017 01:32:11 +0000 (07:02 +0530)
resources/assets/js/controllers.js
resources/views/comments/list-item.blade.php

index 9d5478690cdf1ab236e3aca6dec31d965dfcc121..19808905636ebf1f710c450313e61de988a5b3c7 100644 (file)
@@ -745,11 +745,11 @@ module.exports = function (ngApp, events) {
     ngApp.controller('CommentListController', ['$scope', '$http', '$timeout', function ($scope, $http, $timeout) {
         let vm = this;
         $scope.errors = {};
+        // keep track of comment levels
+        $scope.level = 1;
         $scope.defaultAvatar = defaultAvatar;
         vm.totalCommentsStr = 'Loading...';
-        $scope.editorChange = function (content) {
-            console.log(content);
-        }
+
 
         $timeout(function() {
             $http.get(window.baseUrl(`/ajax/page/${$scope.pageId}/comments/`)).then(resp => {
index 290fe4a8b03730357c48046543187bad2f4f7b9c..c267d619b25906382bdba40a6f97799b835501c8 100644 (file)
         </div>
         <div class="comment-actions">
             <ul>
-                <li><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" is-reply="true">Reply</a></li>
+                <li ng-if="level < 3"><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment" is-reply="true">Reply</a></li>
                 <li><a href="#" comment-reply-link no-comment-reply-dupe="true" comment="comment">Edit</a></li>
-                <li><a href="#">@{{::comment.created_at}}</a></li>            
-            </ul>                
+                <li><a href="#">@{{::comment.created_at}}</a></li>
+            </ul>
         </div>
         <a href="#" ng-click="vm.loadSubComments($event, comment, $index)" class="load-more-comments" ng-if="comment.cnt_sub_comments > 0 && !comment.is_loaded">
             Load @{{::comment.cnt_sub_comments}} more comment(s)
-        </a>        
-        <div class="comment-box" ng-repeat="comment in comments = comment.comments track by comment.id">        
+        </a>
+        <div class="comment-box" ng-repeat="comment in comments = comment.comments track by comment.id" ng-init="level = level + 1">
             <div ng-include src="'comment-list-item.html'">
             </div>
-        </div>        
-    </div>    
+        </div>
+    </div>
 </div>
\ No newline at end of file