diff --git a/app/assets/javascripts/angularjs/controllers/git_tree_controller.js b/app/assets/javascripts/angularjs/controllers/git_tree_controller.js index ff98722da..46cae3787 100644 --- a/app/assets/javascripts/angularjs/controllers/git_tree_controller.js +++ b/app/assets/javascripts/angularjs/controllers/git_tree_controller.js @@ -13,12 +13,14 @@ RosaABF.controller('GitTreeCtrl', ['$scope', '$http', '$location', function($sco }; $scope.refresh = function(more) { - $scope.processing = true; - var params = { format: 'json', path: $scope.path }; if(more) { - params.page = $scope.next_page; + params.page = $scope.next_page; + $scope.load_more = true; + } + else { + $scope.processing = true; } $http.get(Routes.tree_path($scope.project, $scope.treeish, params)).then(function(res) { @@ -28,11 +30,12 @@ RosaABF.controller('GitTreeCtrl', ['$scope', '$http', '$location', function($sco $scope.next_page = res.data.next_page; if(more) { $scope.tree.push.apply($scope.tree, res.data.tree); + $scope.load_more = false; } else { - $scope.tree = res.data.tree; + $scope.tree = res.data.tree; + $scope.processing = false; } - $scope.processing = false; }); }; diff --git a/app/views/projects/git/trees/_show.html.haml b/app/views/projects/git/trees/_show.html.haml index 3077097e4..24ca88890 100644 --- a/app/views/projects/git/trees/_show.html.haml +++ b/app/views/projects/git/trees/_show.html.haml @@ -59,6 +59,6 @@ %td{ 'ng-hide' => 'el.commit' } %hr - %btn.center-block.btn.btn-primary{ 'ng-show' => 'next_page', 'ng-disabled' => 'processing', + %btn.center-block.btn.btn-primary{ 'ng-show' => 'next_page', 'ng-disabled' => 'load_more || processing', 'ng-click' => 'getTree($event, null, true)' } = t 'layout.activity_feed.load_more' diff --git a/app/views/projects/git/trees/show.json.jbuilder b/app/views/projects/git/trees/show.json.jbuilder index db8bafde7..4d36e1d0b 100644 --- a/app/views/projects/git/trees/show.json.jbuilder +++ b/app/views/projects/git/trees/show.json.jbuilder @@ -64,6 +64,5 @@ else json.path @path json.root_path @path.present? ? @path.split('/')[0...-1].join('/') : nil - params[:page].to_i json.next_page page.next if @tree && @tree.contents.count >= Project::CONTENT_LIMIT*(page+1) end