From 21c723ecf5f588a20576f4f61ba98eeaf71a6fa7 Mon Sep 17 00:00:00 2001 From: llj Date: Mon, 13 Aug 2018 17:30:55 +0800 Subject: [PATCH] [group] fixup for adding the first owned repo when there is no repos in the group. --- static/scripts/app/views/group.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/static/scripts/app/views/group.js b/static/scripts/app/views/group.js index a6a29bf559..09d3c9600c 100644 --- a/static/scripts/app/views/group.js +++ b/static/scripts/app/views/group.js @@ -45,6 +45,8 @@ define([ this.ownedRepos = new GroupOwnedRepos(); this.listenTo(this.ownedRepos, 'add', this.addOne); + // for adding the first owned repo when there is no repos in the group. + this.listenTo(this.ownedRepos, 'reset', this.resetOwnedRepos); this.settingsView = new GroupSettingsView({groupView: this}); this.membersView = new GroupMembersView({groupView: this}); @@ -90,23 +92,27 @@ define([ this.$tableHead.html(tmpl()); }, - reset: function() { - if (this.repos.length) { + reset: function(options) { + var repos = options.repos || this.repos; + if (repos.length) { this.$emptyTip.hide(); this.renderThead(); this.$tableBody.empty(); // sort Common.updateSortIconByMode({'context': this.$el}); - Common.sortLibs({'libs': this.repos}); + Common.sortLibs({'libs': repos}); - this.repos.each(this.addOne, this); + repos.each(this.addOne, this); this.$table.show(); } else { this.showEmptyTip(); this.$table.hide(); } + }, + resetOwnedRepos: function() { + this.reset({repos: this.ownedRepos}); }, showEmptyTip: function() {