mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 10:26:17 +00:00
[group discussion] added 'load more'
This commit is contained in:
@@ -1267,6 +1267,11 @@ textarea:-moz-placeholder {/* for FF */
|
|||||||
text-align:center;
|
text-align:center;
|
||||||
margin:10px 0;
|
margin:10px 0;
|
||||||
}
|
}
|
||||||
|
.load-more-discussion {
|
||||||
|
color:#eb8205;
|
||||||
|
cursor:pointer;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
/********** container ***********/
|
/********** container ***********/
|
||||||
#main, #footer {
|
#main, #footer {
|
||||||
width:950px;
|
width:950px;
|
||||||
|
@@ -75,8 +75,11 @@ class GroupDiscussions(APIView):
|
|||||||
"created_at": isoformat_timestr
|
"created_at": isoformat_timestr
|
||||||
})
|
})
|
||||||
|
|
||||||
return HttpResponse(json.dumps(msgs), status=200,
|
return HttpResponse(json.dumps({
|
||||||
content_type=json_content_type)
|
"msgs": msgs,
|
||||||
|
"current_page": page,
|
||||||
|
"page_num": paginator.num_pages,
|
||||||
|
}), status=200, content_type=json_content_type)
|
||||||
|
|
||||||
@api_check_group
|
@api_check_group
|
||||||
def post(self, request, group_id, format=None):
|
def post(self, request, group_id, format=None):
|
||||||
|
@@ -159,6 +159,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="popover-con">
|
<div class="popover-con">
|
||||||
<span class="loading-icon loading-tip"></span>
|
<span class="loading-icon loading-tip"></span>
|
||||||
|
<p class="load-more-discussion hide js-load-more">{% trans "More..." %}</p>
|
||||||
<ul id="group-discussion-list" class="hide"></ul>
|
<ul id="group-discussion-list" class="hide"></ul>
|
||||||
<p class="no-discussion-tip hide">{% trans "No discussion in this group yet." %}</p>
|
<p class="no-discussion-tip hide">{% trans "No discussion in this group yet." %}</p>
|
||||||
<p class="error hide"></p>
|
<p class="error hide"></p>
|
||||||
|
@@ -15,6 +15,13 @@ define([
|
|||||||
|
|
||||||
url: function() {
|
url: function() {
|
||||||
return Common.getUrl({name: 'group_discussions', group_id: this.group_id});
|
return Common.getUrl({name: 'group_discussions', group_id: this.group_id});
|
||||||
|
},
|
||||||
|
|
||||||
|
parse: function(data) {
|
||||||
|
this.current_page = data.current_page;
|
||||||
|
this.page_num = data.page_num;
|
||||||
|
|
||||||
|
return data.msgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@@ -22,6 +22,7 @@ define([
|
|||||||
this.$listContainer = this.$('#group-discussion-list');
|
this.$listContainer = this.$('#group-discussion-list');
|
||||||
this.$emptyTip = this.$('.no-discussion-tip');
|
this.$emptyTip = this.$('.no-discussion-tip');
|
||||||
this.$error = this.$('.error');
|
this.$error = this.$('.error');
|
||||||
|
this.$loadMore = this.$('.js-load-more');
|
||||||
|
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$(window).resize(function() {
|
$(window).resize(function() {
|
||||||
@@ -44,6 +45,7 @@ define([
|
|||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .close': 'hide',
|
'click .close': 'hide',
|
||||||
|
'click .js-load-more': 'loadMore',
|
||||||
'submit form': 'formSubmit'
|
'submit form': 'formSubmit'
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -70,9 +72,15 @@ define([
|
|||||||
this.collection.each(this.addOne, this);
|
this.collection.each(this.addOne, this);
|
||||||
this.$listContainer.show();
|
this.$listContainer.show();
|
||||||
this.scrollConToBottom();
|
this.scrollConToBottom();
|
||||||
|
if (this.collection.current_page < this.collection.page_num) {
|
||||||
|
this.$loadMore.show();
|
||||||
|
} else {
|
||||||
|
this.$loadMore.hide();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$emptyTip.show();
|
this.$emptyTip.show();
|
||||||
this.$listContainer.hide();
|
this.$listContainer.hide();
|
||||||
|
this.$loadMore.hide();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -146,6 +154,45 @@ define([
|
|||||||
$input.focus();
|
$input.focus();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
loadMore: function() {
|
||||||
|
var _this = this;
|
||||||
|
|
||||||
|
this.$loadMore.hide();
|
||||||
|
this.$loadingTip.show();
|
||||||
|
|
||||||
|
this.collection.fetch({
|
||||||
|
cache: false,
|
||||||
|
remove: false,
|
||||||
|
data: {
|
||||||
|
'avatar_size': 64,
|
||||||
|
'page': this.collection.current_page + 1
|
||||||
|
},
|
||||||
|
success: function(collection, response, opts) {
|
||||||
|
},
|
||||||
|
error: function(collection, response, opts) {
|
||||||
|
var err_msg;
|
||||||
|
if (response.responseText) {
|
||||||
|
if (response['status'] == 401 || response['status'] == 403) {
|
||||||
|
err_msg = gettext("Permission error");
|
||||||
|
} else {
|
||||||
|
err_msg = gettext("Error");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
err_msg = gettext('Please check the network.');
|
||||||
|
}
|
||||||
|
_this.$error.html(err_msg).show();
|
||||||
|
},
|
||||||
|
complete: function() {
|
||||||
|
_this.$loadingTip.hide();
|
||||||
|
if (_this.collection.current_page < _this.collection.page_num) {
|
||||||
|
_this.$loadMore.show();
|
||||||
|
} else {
|
||||||
|
_this.$loadMore.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
formSubmit: function() {
|
formSubmit: function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
var content = $.trim(this.$('[name="message"]').val());
|
var content = $.trim(this.$('[name="message"]').val());
|
||||||
|
Reference in New Issue
Block a user