[IMP] web: force activeActions to be boolean

The docstring says they are boolean, but they actually aren't
(e.g. edit="0" in the arch would lead to activeActions.edit=0).

This could cause issue if that value is used to toggle a class
with jQuery, as in this case the flag argument *must* be a boolean.
This commit is contained in:
Aaron Bohy
2019-02-13 12:23:28 +00:00
committed by Mathieu Duckerts-Antoine
parent ba5a2b47ac
commit 0eaee45659
3 changed files with 15 additions and 14 deletions
@@ -817,10 +817,10 @@ var FieldX2Many = AbstractField.extend({
var arch = this.view && this.view.arch;
if (arch) {
this.activeActions.create = arch.attrs.create ?
JSON.parse(arch.attrs.create) :
!!JSON.parse(arch.attrs.create) :
true;
this.activeActions.delete = arch.attrs.delete ?
JSON.parse(arch.attrs.delete) :
!!JSON.parse(arch.attrs.delete) :
true;
this.editable = arch.attrs.editable;
}
@@ -122,10 +122,10 @@ var AbstractView = Factory.extend({
this.controllerParams = {
actionViews: params.actionViews,
activeActions: {
edit: this.arch.attrs.edit ? JSON.parse(this.arch.attrs.edit) : true,
create: this.arch.attrs.create ? JSON.parse(this.arch.attrs.create) : true,
delete: this.arch.attrs.delete ? JSON.parse(this.arch.attrs.delete) : true,
duplicate: this.arch.attrs.duplicate ? JSON.parse(this.arch.attrs.duplicate) : true,
edit: this.arch.attrs.edit ? !!JSON.parse(this.arch.attrs.edit) : true,
create: this.arch.attrs.create ? !!JSON.parse(this.arch.attrs.create) : true,
delete: this.arch.attrs.delete ? !!JSON.parse(this.arch.attrs.delete) : true,
duplicate: this.arch.attrs.duplicate ? !!JSON.parse(this.arch.attrs.duplicate) : true,
},
bannerRoute: this.arch.attrs.banner_route,
controllerID: params.controllerID,
@@ -50,18 +50,19 @@ var KanbanView = BasicView.extend({
}
var activeActions = this.controllerParams.activeActions;
var archAttrs = this.arch.attrs;
activeActions = _.extend(activeActions, {
group_create: this.arch.attrs.group_create ? JSON.parse(this.arch.attrs.group_create) : true,
group_edit: this.arch.attrs.group_edit ? JSON.parse(this.arch.attrs.group_edit) : true,
group_delete: this.arch.attrs.group_delete ? JSON.parse(this.arch.attrs.group_delete) : true,
group_create: this.arch.attrs.group_create ? !!JSON.parse(archAttrs.group_create) : true,
group_edit: archAttrs.group_edit ? !!JSON.parse(archAttrs.group_edit) : true,
group_delete: archAttrs.group_delete ? !!JSON.parse(archAttrs.group_delete) : true,
});
this.rendererParams.column_options = {
editable: activeActions.group_edit,
deletable: activeActions.group_delete,
archivable: this.arch.attrs.archivable ? JSON.parse(this.arch.attrs.archivable) : true,
archivable: archAttrs.archivable ? !!JSON.parse(archAttrs.archivable) : true,
group_creatable: activeActions.group_create && !config.device.isMobile,
quickCreateView: this.arch.attrs.quick_create_view || null,
quickCreateView: archAttrs.quick_create_view || null,
hasProgressBar: !!progressBar,
};
this.rendererParams.record_options = {
@@ -70,12 +71,12 @@ var KanbanView = BasicView.extend({
read_only_mode: params.readOnlyMode,
};
this.rendererParams.quickCreateEnabled = this._isQuickCreateEnabled();
var examples = this.arch.attrs.examples;
var examples = archAttrs.examples;
if (examples) {
this.rendererParams.examples = kanbanExamplesRegistry.get(examples);
}
this.controllerParams.on_create = this.arch.attrs.on_create;
this.controllerParams.on_create = archAttrs.on_create;
this.controllerParams.readOnlyMode = false;
this.controllerParams.hasButtons = true;
this.controllerParams.quickCreateEnabled = this.rendererParams.quickCreateEnabled;
@@ -100,7 +101,7 @@ var KanbanView = BasicView.extend({
return false;
}
if (this.arch.attrs.quick_create !== undefined) {
return JSON.parse(this.arch.attrs.quick_create);
return !!JSON.parse(this.arch.attrs.quick_create);
}
return true;
},