From f60db9b93a64bff51bdf961ecd8366c8c1e169df Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 2 Sep 2019 13:24:51 +0000 Subject: [FIX] web: kanban: global click and 'image' widget Let's assume a kanban view with oe_kanban_global_click className (i.e. clicks on the card open the record in a form view), and an image with the 'image' widget. This is for instance the case of the hr.employee kanban view. Before this rev., clicking on the image didn't open the record in form view. --- addons/web/static/src/js/fields/basic_fields.js | 14 +++++++++++++- addons/web/static/src/js/fields/field_registry.js | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src') diff --git a/addons/web/static/src/js/fields/basic_fields.js b/addons/web/static/src/js/fields/basic_fields.js index 8ec2ad142a6..350ce9fa767 100644 --- a/addons/web/static/src/js/fields/basic_fields.js +++ b/addons/web/static/src/js/fields/basic_fields.js @@ -1867,6 +1867,17 @@ var FieldBinaryImage = AbstractFieldBinary.extend({ }, }); +var KanbanFieldBinaryImage = FieldBinaryImage.extend({ + // In kanban views, there is a weird logic to determine whether or not a + // click on a card should open the record in a form view. This logic checks + // if the clicked element has click handlers bound on it, and if so, does + // not open the record (assuming that the click will be handle by someone + // else). In the case of this widget, there are clicks handler but they + // only apply in edit mode, which is never the case in kanban views, so we + // simply remove them. + events: {}, +}); + var FieldBinaryFile = AbstractFieldBinary.extend({ description: _lt("File"), template: 'FieldBinaryFile', @@ -3266,6 +3277,7 @@ return { FieldPdfViewer: FieldPdfViewer, AbstractFieldBinary: AbstractFieldBinary, FieldBinaryImage: FieldBinaryImage, + KanbanFieldBinaryImage: KanbanFieldBinaryImage, FieldBoolean: FieldBoolean, BooleanToggle: BooleanToggle, FieldChar: FieldChar, @@ -3278,7 +3290,7 @@ return { FieldFloatTime: FieldFloatTime, FieldFloatFactor: FieldFloatFactor, FieldFloatToggle: FieldFloatToggle, - FieldPercentage : FieldPercentage, + FieldPercentage: FieldPercentage, FieldInteger: FieldInteger, FieldMonetary: FieldMonetary, FieldPercentPie: FieldPercentPie, diff --git a/addons/web/static/src/js/fields/field_registry.js b/addons/web/static/src/js/fields/field_registry.js index 942e6fc094a..9adb578639f 100644 --- a/addons/web/static/src/js/fields/field_registry.js +++ b/addons/web/static/src/js/fields/field_registry.js @@ -39,6 +39,7 @@ registry .add('CopyClipboardText', basic_fields.TextCopyClipboard) .add('CopyClipboardChar', basic_fields.CharCopyClipboard) .add('image', basic_fields.FieldBinaryImage) + .add('kanban.image', basic_fields.KanbanFieldBinaryImage) .add('binary', basic_fields.FieldBinaryFile) .add('pdf_viewer', basic_fields.FieldPdfViewer) .add('monetary', basic_fields.FieldMonetary) -- cgit v1.2.3