1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

modified 'repo create' for myhome/group/org

This commit is contained in:
llj
2015-04-22 18:45:28 +08:00
parent b00d29c8e2
commit 5c75344bfa
5 changed files with 20 additions and 15 deletions

View File

@@ -15,17 +15,17 @@ define([
initialize: function(repos) {
this.repos = repos;
this.listenTo(repos, 'invalid', this.displayValidationErrors);
},
events: {
"submit": "addRepo",
"click #encrypt-switch": "togglePasswdInput"
this.render();
this.$el.modal();
$("#simplemodal-container").css({'height':'auto'});
this.listenTo(repos, 'invalid', this.displayValidationErrors);
},
render: function() {
this.$el.html(this.template(this.templateData()));
this.$el.modal();
return this;
},
templateData: function() {
@@ -34,6 +34,11 @@ define([
};
},
events: {
"submit": "addRepo",
"click #encrypt-switch": "togglePasswdInput"
},
// Generate the attributes for a new GroupRepo item.
newAttributes: function() {
return {
@@ -48,19 +53,20 @@ define([
// TODO: move to common
displayValidationErrors: function(model, error, options) {
this.$('.error').html(error).show();
$("#simplemodal-container").css({'height':'auto'});
},
addRepo: function(e) {
e.preventDefault();
this.repos.create(this.newAttributes(), {
var repos = this.repos;
repos.create(this.newAttributes(), {
wait: true,
validate: true,
prepend: true, // show newly created repo at first line
success: function() {
// No need to show feedback
// Common.feedback('Success', 'success', Common.SUCCESS_TIMEOUT);
if (repos.length == 1) {
repos.fetch({reset: true});
}
},
error: function(xhr, textStatus, errorThrown) {
// TODO: handle error gracefully