[#369] add activity tabs

This commit is contained in:
Alexander Machehin 2014-04-21 21:04:23 +06:00
parent 67031c06f8
commit 9ea2677319
2 changed files with 29 additions and 16 deletions

View File

@ -5,15 +5,12 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte
$scope.tracker_tab = { title: 'activity_menu.tracker', content: [] , active: false };
$scope.pull_requests_tab = { title: 'activity_menu.pull_requests', content: [] , active: false };
$scope.getContent=function(tab){
$scope.getContent=function(tab){
var cur_tab = $scope.$eval(tab+'_tab');
/* make request for data */
var path = Routes.root_path({ filter: cur_tab.filter, format: 'json' });
$http.get(path).then(function(res){
cur_tab[cur_tab.filter].feed = res.data.feed;
cur_tab[cur_tab.filter].next_page_link = res.data.next_page_link;
});
}
if (tab === 'activity') {
$scope.getActivityContent();
}
};
$scope.getTimeLinefaClass = function(content) {
var template = 'btn-warning fa-question';
@ -42,16 +39,15 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte
};
$scope.needShowTimeLabel = function(index) {
var cur_date = $filter('amDateFormat')($scope.getCurActivity().feed[index].date, 'll');
var prev_date = index == 0 || $filter('amDateFormat')($scope.getCurActivity().feed[index-1].date, 'll');
var feed = $scope.getCurActivity().feed;
if (feed === undefined) {
return false;
};
var cur_date = $filter('amDateFormat')(feed[index].date, 'll');
var prev_date = index == 0 || $filter('amDateFormat')(feed[index-1].date, 'll');
return cur_date !== prev_date;
};
$scope.isComment = function(content) {
return content.kind === 'new_comment_notification' ||
content.kind === 'new_comment_commit_notification';
};
$scope.getTemplate = function(content) {
return content.kind + '.html';
};
@ -67,4 +63,18 @@ RosaABF.controller('ActivityCtrl', ['$scope', '$http', '$timeout', '$q', '$filte
cur_tab.next_page_link = res.data.next_page_link;
});
};
$scope.changeActivityFilter = function(filter) {
$scope.activity_tab.filter = filter;
$scope.getActivityContent();
};
$scope.getActivityContent = function() {
var path = Routes.root_path({ filter: $scope.activity_tab.filter, format: 'json' });
$http.get(path).then(function(res) {
$scope.getCurActivity().feed = res.data.feed;
$scope.getCurActivity().next_page_link = res.data.next_page_link;
});
};
}]);

View File

@ -34,8 +34,11 @@
%h3
= t("layout.activity_feed.header")
= link_to image_tag("rss.ico", width: '15px', height: '15px', class: 'atom_icon'), atom_activity_feeds_path(format: 'atom', token: current_user.authentication_token)
%tabset
- (collection = t 'feed_menu').each do |base, title|
%tab{ heading: title, active: (@filter == base), select: "changeActivityFilter('#{base}')" }
/ The time line
.row
.row.offset20
.col-md-12.col-sm-12
%ul.timeline
/ timeline time label