Skip to content

Commit f383b2a

Browse files
Merge pull request #1469 from nextcloud/hide-empty-tag-input
Hide collaborative tag input when empty
2 parents d24e78d + dd74627 commit f383b2a

File tree

5 files changed

+46
-3
lines changed

5 files changed

+46
-3
lines changed

apps/systemtags/css/systemtagsfilelist.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,13 @@
2727
.nav-icon-systemtagsfilter {
2828
background-image: url('../img/tag.svg');
2929
}
30+
31+
#app-sidebar .mainFileInfoView .tag-label {
32+
cursor: pointer;
33+
padding: 13px;
34+
}
35+
36+
#app-sidebar .mainFileInfoView .icon-tag {
37+
opacity: .5;
38+
vertical-align: middle;
39+
}

apps/systemtags/img/tag.svg

Lines changed: 1 addition & 1 deletion
Loading

apps/systemtags/js/systemtagsinfoview.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
*/
3838
_inputView: null,
3939

40+
_toggleHandle: null,
41+
4042
initialize: function(options) {
4143
var self = this;
4244
options = options || {};
@@ -58,6 +60,9 @@
5860

5961
this._inputView.on('select', this._onSelectTag, this);
6062
this._inputView.on('deselect', this._onDeselectTag, this);
63+
64+
this._toggleHandle = $('<span>').addClass('tag-label').text(t('systemtags', 'Tags'));
65+
this._toggleHandle.prepend($('<span>').addClass('icon icon-tag'));
6166
},
6267

6368
/**
@@ -118,24 +123,43 @@
118123
this.selectedTagsCollection.fetch({
119124
success: function(collection) {
120125
collection.fetched = true;
121-
self._inputView.setData(collection.map(modelToSelection));
122-
self.$el.removeClass('hidden');
126+
127+
var appliedTags = collection.map(modelToSelection);
128+
self._inputView.setData(appliedTags);
129+
130+
if (appliedTags.length !== 0) {
131+
self.$el.removeClass('hidden');
132+
} else {
133+
self.$el.addClass('hidden');
134+
}
123135
}
124136
});
125137
}
138+
126139
this.$el.addClass('hidden');
127140
},
128141

129142
/**
130143
* Renders this details view
131144
*/
132145
render: function() {
146+
var self = this;
147+
133148
this.$el.append(this._inputView.$el);
134149
this._inputView.render();
150+
151+
$('#app-sidebar').find('.mainFileInfoView .file-details').append(this._toggleHandle);
152+
this._toggleHandle.off('click');
153+
this._toggleHandle.on('click', function () {
154+
console.log('toggle');
155+
console.log(self.$el);
156+
self.$el.toggleClass('hidden');
157+
});
135158
},
136159

137160
remove: function() {
138161
this._inputView.remove();
162+
this._toggleHandle.remove();
139163
}
140164
});
141165

core/css/icons.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ img.icon-loading-small-dark, object.icon-loading-small-dark, video.icon-loading-
291291
background-image: url('../img/actions/starred.svg?v=1');
292292
}
293293

294+
.icon-tag {
295+
background-image: url('../img/actions/tag.svg?v=1');
296+
}
297+
294298
.icon-toggle {
295299
background-image: url('../img/actions/toggle.svg?v=1');
296300
}

core/img/actions/tag.svg

Lines changed: 5 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)