From 5c75344bfa66588b2306f74aaf9e58c6b5dd2f92 Mon Sep 17 00:00:00 2001 From: llj Date: Wed, 22 Apr 2015 18:45:28 +0800 Subject: [PATCH] modified 'repo create' for myhome/group/org --- seahub/api2/views.py | 1 + static/scripts/app/views/add-repo.js | 26 +++++++++++++++--------- static/scripts/app/views/group.js | 3 +-- static/scripts/app/views/myhome-repos.js | 3 +-- static/scripts/app/views/organization.js | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/seahub/api2/views.py b/seahub/api2/views.py index 951b343b17..0043674d90 100644 --- a/seahub/api2/views.py +++ b/seahub/api2/views.py @@ -3123,6 +3123,7 @@ class GroupRepos(APIView): "permission": 'rw', # Always have read-write permission to owned repo "owner": username, "owner_nickname": email2nickname(username), + "share_from_me": True, } return Response(group_repo, status=200) diff --git a/static/scripts/app/views/add-repo.js b/static/scripts/app/views/add-repo.js index 0ffdd2a848..44993dbe3c 100644 --- a/static/scripts/app/views/add-repo.js +++ b/static/scripts/app/views/add-repo.js @@ -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 diff --git a/static/scripts/app/views/group.js b/static/scripts/app/views/group.js index d67d70c76a..f59a51e693 100644 --- a/static/scripts/app/views/group.js +++ b/static/scripts/app/views/group.js @@ -97,8 +97,7 @@ define([ }, createRepo: function() { - var addGroupRepoView = new AddGroupRepoView(this.repos); - addGroupRepoView.render(); + new AddGroupRepoView(this.repos); }, sortByName: function() { diff --git a/static/scripts/app/views/myhome-repos.js b/static/scripts/app/views/myhome-repos.js index e9ec05cbdf..289053d292 100644 --- a/static/scripts/app/views/myhome-repos.js +++ b/static/scripts/app/views/myhome-repos.js @@ -81,8 +81,7 @@ define([ }, createRepo: function() { - var addRepoView = new AddRepoView(this.repos); - addRepoView.render(); + new AddRepoView(this.repos); }, sortByName: function() { diff --git a/static/scripts/app/views/organization.js b/static/scripts/app/views/organization.js index f29e0661df..2e8eb87059 100644 --- a/static/scripts/app/views/organization.js +++ b/static/scripts/app/views/organization.js @@ -36,7 +36,7 @@ define([ }, createRepo: function() { - new AddPubRepoView(this.repos).render(); + new AddPubRepoView(this.repos); }, addOne: function(repo, collection, options) {