Skip to content

Commit aa12e49

Browse files
committed
Improve lateralbar files listing
1 parent ad8a535 commit aa12e49

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

client/resources/templates/lateralbar/main.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<div class="files">
1919
<%= view.component("component.lateralbar.files", {
2020
'path': "/"
21-
}, "tree") %>
21+
}, "files") %>
2222
</div>
2323
</div>
2424
<%= view.component("component.lateralbar.searchbar", {}, "search") %>

client/views/components/lateralbar/files.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,22 @@ define([
120120
tagName: "ul",
121121
className: "files-tree",
122122

123+
// Constructor
124+
initialize: function(options) {
125+
FilesTreeView.__super__.initialize.apply(this, arguments);
126+
this.countFiles = 0;
127+
return this;
128+
},
129+
123130
// Render the files tree
124131
render: function() {
125132
var that = this;
126133
this.$el.empty();
127134

128135
this.model.listdir().done(function(files) {
129136
that.empty();
137+
that.countFiles = 0;
138+
130139
_.each(files, function(file) {
131140
if (file.isHidden()) return;
132141

@@ -136,7 +145,9 @@ define([
136145
});
137146
v.render();
138147
v.$el.appendTo(that.$el);
148+
that.countFiles = that.countFiles + 1;
139149
});
150+
that.trigger("count", that.countFiles);
140151
});
141152

142153
return this.ready();

client/views/layouts/lateralbar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,17 @@ define([
7171
}
7272
});
7373

74+
// Search bar
7475
this.components.search.on("close", function() {
7576
this.toggleSearch(false);
7677
}, this);
7778

79+
// Files (count .git files)
80+
this.components.files.on("count", function() {
81+
this.toggleBar(this.components.files.countFiles > 0);
82+
}, this);
83+
this.toggleBar(this.components.files.countFiles > 0);
84+
7885
return LateralBarView.__super__.finish.apply(this, arguments);
7986
},
8087

0 commit comments

Comments
 (0)