Merge pull request #18809 from owncloud/fix-tags-fileinfomodel
Tags in FileInfo map must be an array
This commit is contained in:
commit
e9e42fff61
|
@ -150,7 +150,13 @@
|
||||||
var oldElementToFile = fileList.elementToFile;
|
var oldElementToFile = fileList.elementToFile;
|
||||||
fileList.elementToFile = function($el) {
|
fileList.elementToFile = function($el) {
|
||||||
var fileInfo = oldElementToFile.apply(this, arguments);
|
var fileInfo = oldElementToFile.apply(this, arguments);
|
||||||
fileInfo.tags = $el.attr('data-tags') || [];
|
var tags = $el.attr('data-tags');
|
||||||
|
if (_.isUndefined(tags)) {
|
||||||
|
tags = '';
|
||||||
|
}
|
||||||
|
tags = tags.split('|');
|
||||||
|
tags = _.without(tags, '');
|
||||||
|
fileInfo.tags = tags;
|
||||||
return fileInfo;
|
return fileInfo;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
|
@ -112,4 +112,19 @@ describe('OCA.Files.TagsPlugin tests', function() {
|
||||||
expect($action.find('img').attr('src')).toEqual(OC.imagePath('core', 'actions/star'));
|
expect($action.find('img').attr('src')).toEqual(OC.imagePath('core', 'actions/star'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
describe('elementToFile', function() {
|
||||||
|
it('returns tags', function() {
|
||||||
|
fileList.setFiles(testFiles);
|
||||||
|
var $tr = fileList.findFileEl('One.txt');
|
||||||
|
var data = fileList.elementToFile($tr);
|
||||||
|
expect(data.tags).toEqual(['tag1', 'tag2']);
|
||||||
|
});
|
||||||
|
it('returns empty array when no tags present', function() {
|
||||||
|
delete testFiles[0].tags;
|
||||||
|
fileList.setFiles(testFiles);
|
||||||
|
var $tr = fileList.findFileEl('One.txt');
|
||||||
|
var data = fileList.elementToFile($tr);
|
||||||
|
expect(data.tags).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue