1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 19:08:21 +00:00

[backbone] Add dirView for organizational libs

This commit is contained in:
Daniel Pan
2015-03-07 16:40:30 +08:00
parent 0a32d98f20
commit 4d471c0c24
7 changed files with 84 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
define([ define([
'app/routers/organization' 'app/routers/organization'
], function(Router){ ], function(Router){
new Router(); app.router = new Router();
Backbone.history.start(); Backbone.history.start();
}); });

View File

@@ -8,21 +8,26 @@ define([
var OrganizationRouter = Backbone.Router.extend({ var OrganizationRouter = Backbone.Router.extend({
routes: { routes: {
'libs/:id(/*path)': 'showDir', 'lib/:repo_id(/*path)': 'showDir',
// Default // Default
'*actions': 'defaultAction' '*actions': 'defaultAction'
}, },
initialize: function() { initialize: function() {
this.organizationView = new OrganizationView(); this.orgView = new OrganizationView();
}, },
showDir: function() { showDir: function(repo_id, path) {
alert('todo'); if (path) {
path = '/' + path;
} else {
path = '/';
}
this.orgView.showDir(repo_id, path);
}, },
defaultAction: function(){ defaultAction: function(){
this.organizationView.showPublicRepos(); this.orgView.showPublicRepos();
} }
}); });

View File

@@ -16,7 +16,6 @@ define([
el: '#main', el: '#main',
initialize: function() { initialize: function() {
console.log('init MyHomePage');
Common.prepareApiCsrf(); Common.prepareApiCsrf();
//_.bindAll(this, 'ajaxLoadingShow', 'ajaxLoadingHide'); //_.bindAll(this, 'ajaxLoadingShow', 'ajaxLoadingHide');

View File

@@ -3,7 +3,7 @@ define([
'underscore', 'underscore',
'backbone', 'backbone',
'common', 'common',
'text!' + app.config._tmplRoot + 'organization-repos.html' 'text!' + app.config._tmplRoot + 'organization-repo.html'
], function($, _, Backbone, Common, reposTemplate) { ], function($, _, Backbone, Common, reposTemplate) {
'use strict'; 'use strict';

View File

@@ -4,15 +4,17 @@ define([
'backbone', 'backbone',
'common', 'common',
'app/collections/repos', 'app/collections/repos',
'app/views/organization-repo' 'app/views/organization-repo',
], function($, _, Backbone, Common, RepoCollection, OrganizationRepoView) { 'app/views/dir',
], function($, _, Backbone, Common, RepoCollection, OrganizationRepoView,
DirView) {
'use strict'; 'use strict';
var OrganizationView = Backbone.View.extend({ var OrganizationView = Backbone.View.extend({
el: '#main', el: '#main',
initialize: function() { initialize: function() {
this.$reposDiv = $('#organization-repos');
this.$table = $('#organization-repos table'); this.$table = $('#organization-repos table');
this.$tableBody = $('tbody', this.$table); this.$tableBody = $('tbody', this.$table);
this.$loadingTip = $('#organization-repos .loading-tip'); this.$loadingTip = $('#organization-repos .loading-tip');
@@ -21,6 +23,8 @@ define([
this.repos = new RepoCollection({type: 'org'}); this.repos = new RepoCollection({type: 'org'});
this.listenTo(this.repos, 'add', this.addOne); this.listenTo(this.repos, 'add', this.addOne);
this.listenTo(this.repos, 'reset', this.reset); this.listenTo(this.repos, 'reset', this.reset);
this.dirView = new DirView();
}, },
events: { events: {
@@ -54,7 +58,23 @@ define([
}, },
showPublicRepos: function() { showPublicRepos: function() {
this.dirView.hide();
this.$reposDiv.show();
this.repos.fetch({reset: true}); 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);
} }
}); });

View File

@@ -10,8 +10,7 @@
<% } %> <% } %>
<% } %> <% } %>
</td> </td>
{# TODO #} <td><a href="#/lib/<%= id %>"><%- name %></a></td>
<td><a href="#/libs/<%= id %>"><%- name %></a></td>
<td><%- desc %></td> <td><%- desc %></td>
<td><%- mtime_relative %></td> <td><%- mtime_relative %></td>
<td><%- share_from %></td> <td><%- share_from %></td>
@@ -20,4 +19,3 @@
<img src="<%= app.config.mediaUrl%>img/rm.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" /> <img src="<%= app.config.mediaUrl%>img/rm.png" alt="" class="cancel-share op-icon vh" title="{% trans "Unshare" %}" />
<% } %> <% } %>
</td> </td>

View File

@@ -4,6 +4,24 @@
{% block sub_title %}{% trans "Organization" %} - {% endblock %} {% block sub_title %}{% trans "Organization" %} - {% endblock %}
{% block extra_style %}
<style type="text/css">
/* lib view */
.repo-file-list .dirent-name {
width:260px;
}
.repo-file-list .dirent-size {
width:114px;
}
.repo-file-list .dirent-update {
width:123px;
}
.repo-file-list .dirent-op {
width:110px;
}
</style>
{% endblock %}
{% block left_panel %} {% block left_panel %}
<div class="side-tabnav"> <div class="side-tabnav">
<h3 class="hd">{% trans "Organization" %}</h3> <h3 class="hd">{% trans "Organization" %}</h3>
@@ -16,12 +34,12 @@
{% endblock %} {% endblock %}
{% block right_panel %} {% block right_panel %}
<div id="organization-repos">
<div class="hd ovhd"> <div class="hd ovhd">
<h3 class="fleft">{% trans "Libraries" %}</h3> <h3 class="fleft">{% trans "Libraries" %}</h3>
<button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library"%}</span></button> <button id="repo-create" class="fright"><img src="{{ MEDIA_URL }}img/add.png" alt="" class="add vam" /><span class="vam">{% trans "New Library"%}</span></button>
</div> </div>
<div id="organization-repos">
<table class="repo-list hide"> <table class="repo-list hide">
<thead> <thead>
<tr> <tr>
@@ -43,10 +61,35 @@
</div> </div>
</div> </div>
<div id="dir-view" class="hide">
<div class="repo-file-list-topbar">
<p class="path"></p>
<div class="repo-op"></div>
</div>
<table class="repo-file-list">
<thead>
<tr>
<th class="select">
<span class="checkbox"><input type="checkbox" class="checkbox-orig" /></span>
</th>
<th class="star"></th>
<th class="dirent-icon"></th>
<th><span class="dirent-name">{% trans "Name"%} <span id="by-name" class="icon-caret-up cspt"></span></span></th>
<th class="dirent-size">{% trans "Size"%}</th>
<th class="dirent-update">{% trans "Last Update" %} <span id="by-time" class="icon-caret-down cspt"></span></th>
<th class="dirent-op">{% trans "Operations"%}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
<img class="loading-tip" src="{{MEDIA_URL}}img/loading-icon.gif" alt="{% trans 'Loading...' %}" />
</div>
{% endblock %} {% endblock %}
{% block extra_script %} {% block extra_script %}
{% include "js/lib-op-popups.html" %}
<script> <script>
app["pageOptions"] = { app["pageOptions"] = {
base_url: "{{ SITE_ROOT }}" + "home/my/", base_url: "{{ SITE_ROOT }}" + "home/my/",