1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 23:29:49 +00:00

update activity page

This commit is contained in:
lian
2015-07-28 19:54:57 +08:00
parent dfc7f1856f
commit d889f3bafe
10 changed files with 55 additions and 70 deletions

View File

@@ -27,7 +27,7 @@ define([
'org/lib/:repo_id(/*path)': 'showOrgRepoDir',
'common/lib/:repo_id(/*path)': 'showCommonDir',
'starred/': 'showStarredFile',
'activities/': 'showEvent',
'activities/': 'showActivities',
// Default
'*actions': 'showRepos'
},
@@ -91,9 +91,9 @@ define([
this.myHomeView.showStarredFile();
},
showEvent: function() {
showActivities: function() {
this.switchCurrentView(this.myHomeView);
this.myHomeView.showActivity();
this.myHomeView.showActivities();
},
showMyRepoDir: function(repo_id, path) {

View File

@@ -8,29 +8,30 @@ define([
], function($, _, Backbone, Common, ActivityCollection, ActivityItemView) {
'use strict';
var EventView = Backbone.View.extend({
var ActivitiesView = Backbone.View.extend({
el: $('#events'),
el: $('#activities'),
template: _.template($('#activities-date-tmpl').html()),
activityGroupTemplate: _.template($('#activity-group-tmpl').html()),
events: {
'click #events-more': 'getMoreActivites'
'click #activities-more': 'getMoreActivities'
},
initialize: function () {
this.activities = new ActivityCollection();
this.$eventsBody = this.$('#events-body');
this.$eventsMore = this.$('#events-more');
this.$activitiesBody = this.$('#activities-body');
this.$activitiesMore = this.$('#activities-more');
this.$loadingTip = this.$('.loading-tip');
this.moreOffset = 0;
},
getMoreActivites: function () {
getMoreActivities: function () {
var _this = this;
this.$loadingTip.show();
this.$activitiesMore.hide();
this.activities.fetch({
remove: false,
data: {'start': _this.moreOffset},
@@ -47,9 +48,9 @@ define([
allActivities = [];
this.$loadingTip.hide();
this.$eventsMore.hide();
this.$activitiesMore.hide();
this.moreOffset = activitiesJson[len-1]['more_offset'];
this.$eventsBody.empty().show();
this.$activitiesBody.empty().show();
for (var i = 0; i < len; i++) {
allActivities = allActivities.concat(activitiesJson[i]['events']);
@@ -58,19 +59,19 @@ define([
var groupedActivities = _.groupBy(allActivities, 'date');
for (var date in groupedActivities) {
var $activitiesDate = $(this.template({'date': date})),
var $activityGroup = $(this.activityGroupTemplate({'date': date})),
activityList = groupedActivities[date];
this.$eventsBody.append($activitiesDate);
this.$activitiesBody.append($activityGroup);
_.each(activityList, function (activity) {
var view = new ActivityItemView(activity);
$activitiesDate.children('ol').append(view.render().el);
$activityGroup.children('ol').append(view.render().el);
});
}
if (more) {
this.$eventsMore.show();
this.$activitiesMore.show();
}
},
@@ -81,6 +82,8 @@ define([
show: function () {
this.$el.show();
this.$activitiesBody.hide();
this.$activitiesMore.hide();
this.$loadingTip.show();
var _this = this;
@@ -95,5 +98,5 @@ define([
});
return EventView;
return ActivitiesView;
});

View File

@@ -1,27 +0,0 @@
define([
'jquery',
'underscore',
'backbone',
'common'
], function($, _, Backbone, Common) {
'use strict';
var DetailsItemView = Backbone.View.extend({
template: _.template($('#details-item-tmpl').html()),
initialize: function(options) {
this.details_title = options.details_title;
this.details = options.details;
},
render: function () {
var data = {'details_title': this.details_title, 'details': this.details}
this.$el.html(this.template(data));
return this;
}
});
return DetailsItemView;
});

View File

@@ -2,9 +2,8 @@ define([
'jquery',
'underscore',
'backbone',
'common',
'app/views/details-item'
], function($, _, Backbone, Common, DetailsItemView) {
'common'
], function($, _, Backbone, Common) {
'use strict';
var DetailsView = Backbone.View.extend({
@@ -12,6 +11,7 @@ define([
id: 'ls-ch',
template: _.template($('#details-popup-tmpl').html()),
detailItemTemplate: _.template($('#detail-item-tmpl').html()),
initialize: function (options) {
this.repo_id = options['repo_id'];
@@ -24,9 +24,8 @@ define([
},
getDetails: function () {
var repo_id = this.repo_id,
cmmt_id = this.cmmt_id,
details_title,
var repo_id = this.repo_id, cmmt_id = this.cmmt_id,
details_title, item_data, item_html,
_this = this;
Common.ajaxGet({
@@ -37,7 +36,9 @@ define([
_this.$('.commit-time').html(data['date_time']);
for (var item in data) {
if (data[item].length > 0 && item != 'date_time') {
if (item == "cmt_desc") {
_this.$el.append(data[item]);
} else if (data[item].length > 0 && item != 'date_time') {
if (item == "new") { details_title = gettext("New files") }
if (item == "removed") { details_title = gettext("Deleted files") }
if (item == "renamed") { details_title = gettext("Renamed or Moved files") }
@@ -45,14 +46,16 @@ define([
if (item == "newdir") { details_title = gettext("New directories") }
if (item == "deldir") { details_title = gettext("Deleted directories") }
var view = new DetailsItemView({details_title: details_title, details: data[item]});
_this.$el.append(view.render().el);
item_data = {"details_title": details_title, "details": data[item]};
item_html = _this.detailItemTemplate(item_data);
_this.$el.append(item_html);
}
}
$(window).resize();
},
after_op_error: function(xhr) {
Common.ajaxErrorHandler(xhr);
after_op_error: function() {
$('#ls-ch').html(gettext("Unknown error"));
setTimeout(function() { $.modal.close(); }, 2500);
}
});
}

View File

@@ -7,10 +7,10 @@ define([
'app/views/myhome-sub-repos',
'app/views/myhome-shared-repos',
'app/views/starred-file',
'app/views/activity',
'app/views/activities',
'app/views/myhome-side-nav'
], function($, _, Backbone, Common, ReposView, SubReposView,
SharedReposView, StarredFileView, ActivityView, MyhomeSideNavView) {
SharedReposView, StarredFileView, ActivitiesView, MyhomeSideNavView) {
'use strict';
var MyHomeView = Backbone.View.extend({
@@ -22,7 +22,7 @@ define([
this.subReposView = new SubReposView();
this.sharedReposView = new SharedReposView();
this.starredFileView = new StarredFileView();
this.activityView = new ActivityView();
this.activitiesView = new ActivitiesView();
this.dirView = options.dirView;
@@ -59,11 +59,11 @@ define([
this.currentView = this.starredFileView;
},
showActivity: function() {
showActivities: function() {
this.sideNavView.show({'cur_tab': 'activities'});
this.currentView.hide();
this.activityView.show();
this.currentView = this.activityView;
this.activitiesView.show();
this.currentView = this.activitiesView;
},
showDir: function(category, repo_id, path) {