Skip to content

Commit e9e42ff

Browse files
committed
Merge pull request #18809 from owncloud/fix-tags-fileinfomodel
Tags in FileInfo map must be an array
2 parents 5234090 + 73c6194 commit e9e42ff

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

apps/files/js/tagsplugin.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@
150150
var oldElementToFile = fileList.elementToFile;
151151
fileList.elementToFile = function($el) {
152152
var fileInfo = oldElementToFile.apply(this, arguments);
153-
fileInfo.tags = $el.attr('data-tags') || [];
153+
var tags = $el.attr('data-tags');
154+
if (_.isUndefined(tags)) {
155+
tags = '';
156+
}
157+
tags = tags.split('|');
158+
tags = _.without(tags, '');
159+
fileInfo.tags = tags;
154160
return fileInfo;
155161
};
156162
},

apps/files/tests/js/tagspluginspec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,19 @@ describe('OCA.Files.TagsPlugin tests', function() {
112112
expect($action.find('img').attr('src')).toEqual(OC.imagePath('core', 'actions/star'));
113113
});
114114
});
115+
describe('elementToFile', function() {
116+
it('returns tags', function() {
117+
fileList.setFiles(testFiles);
118+
var $tr = fileList.findFileEl('One.txt');
119+
var data = fileList.elementToFile($tr);
120+
expect(data.tags).toEqual(['tag1', 'tag2']);
121+
});
122+
it('returns empty array when no tags present', function() {
123+
delete testFiles[0].tags;
124+
fileList.setFiles(testFiles);
125+
var $tr = fileList.findFileEl('One.txt');
126+
var data = fileList.elementToFile($tr);
127+
expect(data.tags).toEqual([]);
128+
});
129+
});
115130
});

0 commit comments

Comments
 (0)