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

89 lines
2.6 KiB
JavaScript
Raw Normal View History

2015-03-07 07:56:10 +00:00
define([
'jquery',
'underscore',
'backbone',
'common',
'app/collections/repos',
'app/views/organization-repo',
'app/views/dir',
2015-03-08 12:47:42 +00:00
'app/views/group-nav',
], function($, _, Backbone, Common, RepoCollection, OrganizationRepoView,
2015-03-08 12:47:42 +00:00
DirView, GroupNavView) {
2015-03-07 07:56:10 +00:00
'use strict';
var OrganizationView = Backbone.View.extend({
el: '#main',
initialize: function() {
this.$reposDiv = $('#organization-repos');
2015-03-07 07:56:10 +00:00
this.$table = $('#organization-repos table');
this.$tableBody = $('tbody', this.$table);
this.$loadingTip = $('#organization-repos .loading-tip');
this.$emptyTip = $('#organization-repos .empty-tips');
this.repos = new RepoCollection({type: 'org'});
this.listenTo(this.repos, 'add', this.addOne);
this.listenTo(this.repos, 'reset', this.reset);
this.dirView = new DirView();
2015-03-08 12:47:42 +00:00
this.groupView = new GroupNavView();
Common.initAccountPopup();
2015-03-20 05:55:50 +00:00
Common.initNoticePopup();
2015-03-07 07:56:10 +00:00
},
events: {
'click #repo-create': 'createRepo'
},
createRepo: function() {
alert('todo');
},
addOne: function(repo, collection, options) {
var view = new OrganizationRepoView({model: repo, collection: this.repos});
if (options.prepend) {
this.$tableBody.prepend(view.render().el);
} else {
this.$tableBody.append(view.render().el);
}
},
reset: function() {
this.$tableBody.empty();
this.repos.each(this.addOne, this);
if (this.repos.length) {
this.$emptyTip.hide();
this.$table.show();
} else {
this.$emptyTip.show();
this.$table.hide();
}
this.$loadingTip.hide();
},
showPublicRepos: function() {
this.dirView.hide();
this.$reposDiv.show();
2015-03-07 07:56:10 +00:00
this.repos.fetch({reset: true});
this.$loadingTip.show();
},
hideRepos: function() {
this.$reposDiv.hide();
},
showDir: function(repo_id, path) {
var path = path || '/';
this.hideRepos();
this.dirView.showDir('', repo_id, path);
// this.dirent_list = new app.DirentListView({id: id, path: path});
// $('#my-own-repos table').children().remove();
// $('#my-own-repos table').append(this.dirent_list.render().el);
2015-03-07 07:56:10 +00:00
}
});
return OrganizationView;
});