diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index 915c037431dd2..20add2b5719c8 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -1127,3 +1127,15 @@ table.dragshadow td.size { #gallery-button { display: none; } + +#tag_multiple_files_container { + overflow: hidden; + background-color: #fff; + border-radius: 3px; + position: relative; + + td { + padding: 0 0.5em 0 0.5em; + } +} + diff --git a/apps/files/js/app.js b/apps/files/js/app.js index 20da85f0f927b..d6b5f4756da91 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -102,6 +102,11 @@ displayName: t('files', 'Delete'), iconClass: 'icon-delete', }, + { name: 'tags', + displayName: 'Tags', + iconClass: 'icon-tag' + + } ], sorting: { mode: $('#defaultFileSorting').val(), diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index d2a23283f12bc..788cf0189a5bf 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -508,6 +508,9 @@ case 'restore': this._onClickRestoreSelected(ev); break; + case 'tags': + this._onClickTagSelected(ev); + break; } }, /** @@ -1063,6 +1066,112 @@ event.preventDefault(); }, + /** + * CUSTOM CODE + * Event handler for when clicking on "Tags" for the selected files + */ + _onClickTagSelected: function(event) { + var self = this; + event.preventDefault(); + var commonTags = []; + + var selectedFiles = _.pluck(this.getSelectedFiles(),'id') + var tagCollections=[]; + var fetchTagPromises = []; + + + selectedFiles.forEach(function(fileId) { + var deferred = new $.Deferred(); + var tagCollection = new OC.SystemTags.SystemTagsMappingCollection([], { + objectType: 'files', + objectId: fileId}); + tagCollections.push(tagCollection); + tagCollection.fetch({ + success: function(){ + deferred.resolve('success'); + }, + error: function() {deferred.resolve('failed');} + }) + fetchTagPromises.push(deferred); + }); + if (!self._inputView) { + self._inputView = new OC.SystemTags.SystemTagsInputField({ + multiple: true, + allowActions: true, + allowCreate: true, + isAdmin: OC.isUserAdmin(), + }); + self._inputView.on('select', self._onSelectTag, self); + self._inputView.on('deselect', self._onDeselectTag, self); + self._inputView.render(); + self.tagsContainer = $('