[FIX] web_editor: avoid traceback when open img editor
In some case, (e.g.: demo data), datas_fname is undefined and match of undefined will crash and block the modal to be opened. Uncaught TypeError: r.datas_fname.match is not a function
This commit is contained in:
@@ -373,13 +373,13 @@ var ImageWidget = MediaWidget.extend({
|
||||
.sortBy(function (r) {
|
||||
if (_.any(self.firstFilters, function (filter) {
|
||||
var regex = new RegExp(filter, 'i');
|
||||
return r.name.match(regex) || r.datas_fname.match(regex);
|
||||
return r.name.match(regex) || r.datas_fname && r.datas_fname.match(regex);
|
||||
})) {
|
||||
return -1;
|
||||
}
|
||||
if (_.any(self.lastFilters, function (filter) {
|
||||
var regex = new RegExp(filter, 'i');
|
||||
return r.name.match(regex) || r.datas_fname.match(regex);
|
||||
return r.name.match(regex) || r.datas_fname && r.datas_fname.match(regex);
|
||||
})) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user