1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-07-04 18:57:50 +00:00
seahub/static/scripts/app/views/group-members.js

87 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-12-11 12:41:16 +00:00
define([
'jquery',
'underscore',
'backbone',
'common',
'app/collections/group-members',
'app/views/group-member',
'app/views/widgets/popover'
], function($, _, Backbone, Common, GroupMembers, ItemView, PopoverView) {
2015-12-11 12:41:16 +00:00
'use strict';
var View = PopoverView.extend({
id: 'group-members',
2016-04-27 06:48:25 +00:00
className: 'sf-popover',
template: _.template($('#group-members-tmpl').html()),
2015-12-11 12:41:16 +00:00
initialize: function(options) {
PopoverView.prototype.initialize.call(this);
this.groupView = options.groupView;
2015-12-11 12:41:16 +00:00
this.collection = new GroupMembers();
this.listenTo(this.collection, 'add', this.addOne);
this.listenTo(this.collection, 'reset', this.reset);
this.render();
2015-12-11 12:41:16 +00:00
},
events: {
2015-12-11 12:41:16 +00:00
},
addOne: function(item, collection, options) {
var view = new ItemView({
model: item
});
this.$listContainer.append(view.render().el);
},
reset: function() {
this.$error.hide();
this.$loadingTip.hide();
this.$listContainer.empty();
this.collection.each(this.addOne, this);
this.$listContainer.show();
},
render: function() {
this.$el.html(this.template());
this.$loadingTip = this.$('.loading-tip');
this.$listContainer = this.$('#group-member-list');
this.$error = this.$('.error');
},
showContent: function() {
2015-12-11 12:41:16 +00:00
this.$listContainer.hide();
this.$loadingTip.show();
var _this = this;
this.collection.setGroupId(this.groupView.group.id);
2015-12-11 12:41:16 +00:00
this.collection.fetch({
cache: false,
reset: true,
data: {'avatar_size': 64},
2015-12-15 03:33:07 +00:00
success: function(collection, response, opts) {
},
2015-12-15 03:33:07 +00:00
error: function(collection, response, opts) {
2015-12-11 12:41:16 +00:00
_this.$loadingTip.hide();
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();
}
});
$("#group").append(this.$el);
2015-12-11 12:41:16 +00:00
}
});
return View;
});