1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-29 08:27:55 +00:00
seahub/static/scripts/app/views/group-item.js

52 lines
1.5 KiB
JavaScript
Raw Normal View History

2015-11-30 07:02:03 +00:00
define([
'jquery',
'underscore',
'backbone',
'common',
'app/collections/group-repos',
'app/views/group-repo'
], function($, _, Backbone, Common, GroupRepos, GroupRepoView) {
'use strict';
var GroupItemView = Backbone.View.extend({
template: _.template($('#group-item-tmpl').html()),
events: {
},
initialize: function() {
},
render: function() {
this.$el.html(this.template(this.model.attributes));
var repos = this.model.get('repos');
if (repos.length) {
this.renderRepoList(repos);
}
return this;
},
renderRepoList: function (repos) {
repos.sort(function(a, b) {
return Common.compareTwoWord(a.name, b.name);
});
var group_id = this.model.get('id'),
2015-12-02 03:25:11 +00:00
is_staff = $.inArray(app.pageOptions.username, this.model.get('admins')) != -1 ? true : false,
2015-11-30 07:02:03 +00:00
$listContainer = this.$('tbody');
var groupRepos = new GroupRepos();
groupRepos.setGroupID(group_id);
$(repos).each(function(index, item) {
var view = new GroupRepoView({
model: new Backbone.Model(item, {collection: groupRepos}),
group_id: group_id,
is_staff: is_staff
});
$listContainer.append(view.render().el);
});
}
});
return GroupItemView;
});