[FIX] web_editor: allow to save unchanged icons with media dialog

There was a bug with the icon edition when following these steps:
- Open the Media dialog to edit an existing icon
- Hit the "save" button in the dialog without choosing the icon
- The edited icon disappears

This happenned for icons whose original values were aliases of the
related icon. Indeed, following these steps to edit an "fa-facebook-f"
was leaving the icon unchanged as expected but doing it for a
"fa-facebook" icon made the icon disappeared. This is because the
last one is an alias of the first one and that the media dialog was
ignoring aliasies when saving the original value.

opw-725813
This commit is contained in:
qsm-odoo
2017-04-07 17:46:07 +02:00
parent 8d65763f93
commit 4aab300070
+6 -6
View File
@@ -637,9 +637,12 @@ var fontIconsDialog = Widget.extend({
},
renderElement: function () { // extract list of font (like awesome) from the cheatsheet.
this.iconsParser = fontIcons;
this.icons = _.flatten(_.map(fontIcons, function (data) {
this.icons = _.flatten(_.map(fontIcons, function (data) { // TODO maybe useless now
return data.icons;
}));
this.alias = _.flatten(_.map(fontIcons, function (data) {
return data.alias;
}));
this._super.apply(this, arguments);
},
search: function (needle) {
@@ -741,11 +744,8 @@ var fontIconsDialog = Widget.extend({
case '': continue;
default:
$(".font-icons-icon").removeClass("o_selected").filter("[data-alias*=',"+cls+",']").addClass("o_selected");
for (var k=0; k<this.icons.length; k++) {
if (this.icons.indexOf(cls) !== -1) {
this.$('#fa-icon').val(cls);
break;
}
if (this.alias.indexOf(cls) !== -1) {
this.$('#fa-icon').val(cls);
}
}
}