mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 02:48:51 +00:00
Enable create repo at myhome and group pages
This commit is contained in:
@@ -4,62 +4,23 @@ define([
|
||||
'underscore',
|
||||
'backbone',
|
||||
'common',
|
||||
'app/collections/group-repos',
|
||||
'text!' + app.config._tmplRoot + 'create-repo.html',
|
||||
], function($, simplemodal, _, Backbone, Common, GroupRepos, CreateRepoTemplate) {
|
||||
'app/views/add-repo',
|
||||
'text!' + app.config._tmplRoot + 'create-repo.html'
|
||||
], function($, simplemodal, _, Backbone, Common, AddRepoView, CreateRepoTemplate) {
|
||||
'use strict';
|
||||
|
||||
var AddGroupRepoView = Backbone.View.extend({
|
||||
|
||||
tagName: 'div',
|
||||
|
||||
template: _.template(CreateRepoTemplate),
|
||||
|
||||
events: {
|
||||
"submit": "addGroupRepo"
|
||||
},
|
||||
|
||||
initialize: function(repos) {
|
||||
this.repos = repos;
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.$el.html(this.template({}));
|
||||
this.$el.modal();
|
||||
},
|
||||
|
||||
// Generate the attributes for a new GroupRepo item.
|
||||
newAttributes: function() {
|
||||
var AddGroupRepoView = AddRepoView.extend({
|
||||
templateData: function() {
|
||||
return {
|
||||
name: $('input[name=repo_name]', this.$el).val().trim(),
|
||||
desc: $('textarea[name=repo_desc]', this.$el).val().trim(),
|
||||
permission: $('select[name=permission]', this.$el).val(),
|
||||
|
||||
// TODO: encrypted repo
|
||||
// encrypted: $('#encrypt-switch', this.$el).attr('checked'),
|
||||
// passwd1: $('input[name=passwd]', this.$el).val(),
|
||||
// passwd2: $('input[name=passwd_again]', this.$el).val()
|
||||
showSharePerm: true
|
||||
};
|
||||
},
|
||||
|
||||
addGroupRepo: function(e) {
|
||||
e.preventDefault();
|
||||
newAttributes: function() {
|
||||
var baseAttrs = AddRepoView.prototype.newAttributes.apply(this);
|
||||
|
||||
Common.feedback('Loading...', 'info', Common.INFO_TIMEOUT);
|
||||
this.repos.create(this.newAttributes(), {
|
||||
wait: true,
|
||||
prepend: true, // show newly created repo at first line
|
||||
success: function() {
|
||||
Common.feedback('Success', 'success', Common.SUCCESS_TIMEOUT);
|
||||
},
|
||||
error: function() {
|
||||
Common.feedback('Error', 'error', Common.ERROR_TIMEOUT);
|
||||
},
|
||||
complete: function() {
|
||||
Common.closeModal();
|
||||
}
|
||||
});
|
||||
}
|
||||
return _.extend(baseAttrs, $('select[name=permission]', this.$el).val());
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user