diff options
| author | Harshad Modi <hmo@odoo.com> | 2017-06-07 13:45:04 +0530 |
|---|---|---|
| committer | ged-odoo <ged@odoo.com> | 2017-06-07 10:15:04 +0200 |
| commit | 922a04dbd2acbd547c0279b046099647c5f9eb3f (patch) | |
| tree | f146f7283ef685c67d56042dfd0a19bf563cd540 /addons/project/static/src | |
| parent | ac1fad575e8e6b668e4fb7d42340af8b0058b952 (diff) | |
[FIX] project: fix traceback while setting cover image
from project task kanban view (PR #17165)
Diffstat (limited to 'addons/project/static/src')
| -rw-r--r-- | addons/project/static/src/js/project.js | 23 | ||||
| -rw-r--r-- | addons/project/static/src/xml/project.xml | 2 |
2 files changed, 17 insertions, 8 deletions
diff --git a/addons/project/static/src/js/project.js b/addons/project/static/src/js/project.js index 5da3151aa68..a1ca1a60302 100644 --- a/addons/project/static/src/js/project.js +++ b/addons/project/static/src/js/project.js @@ -51,19 +51,23 @@ KanbanRecord.include({ } function open_cover_images_dialog(attachment_ids) { - var cover_id = self.record.displayed_image_id.raw_value[0]; + var coverID = self.record.displayed_image_id && self.record.displayed_image_id.raw_value[0]; var $content = $(QWeb.render("project.SetCoverModal", { - cover_id: cover_id, + cover_id: coverID, attachment_ids: attachment_ids, })); var $imgs = $content.find('img'); - var dialog = new Dialog(self, { title: _t("Set a Cover Image"), - buttons: [{text: _t("Select"), classes: 'btn-primary', close: true, disabled: !cover_id, click: function () { - self._updateRecord({displayed_image_id: $imgs.filter('.o_selected').data('id')}); + buttons: [{text: _t("Select"), classes: 'btn-primary', close: true, disabled: !coverID, click: function () { + var $img = $imgs.filter('.o_selected'); + var data = { + id: $img.data('id'), + display_name: $img.data('name') + }; + self._updateRecord({displayed_image_id: data}); }}, {text: _t("Remove Cover Image"), close: true, click: function () { - self._updateRecord({displayed_image_id: 0}); + self._updateRecord({displayed_image_id: false}); }}, {text: _t("Discard"), close: true}], $content: $content, }).open(); @@ -75,7 +79,12 @@ KanbanRecord.include({ }); $content.on('dblclick', 'img', function (ev) { - self._updateRecord({displayed_image_id: $(ev.currentTarget).data('id')}); + var $img = $(ev.currentTarget); + var data = { + id: $img.data('id'), + display_name: $img.data('name') + }; + self._updateRecord({displayed_image_id: data}); dialog.close(); }); } diff --git a/addons/project/static/src/xml/project.xml b/addons/project/static/src/xml/project.xml index d9c4f3fa675..a2d222784b9 100644 --- a/addons/project/static/src/xml/project.xml +++ b/addons/project/static/src/xml/project.xml @@ -2,7 +2,7 @@ <templates id="template" xml:space="preserve"> <t t-name="project.SetCoverModal"> <div t-if="attachment_ids.length > 0" class="o_kanban_task_cover_image"> - <img t-foreach="attachment_ids" t-as="attachment" t-attf-class="img-responsive#{cover_id == attachment['id'] ? ' o_selected' : ''}" t-attf-src="/web/image/#{attachment['id']}?unique=1" t-att-data-id="attachment['id']"/> + <img t-foreach="attachment_ids" t-as="attachment" t-attf-class="img-responsive#{cover_id == attachment['id'] ? ' o_selected' : ''}" t-attf-src="/web/image/#{attachment['id']}?unique=1" t-att-data-id="attachment['id']" t-att-data-name="attachment['name']"/> </div> <div t-if="attachment_ids.length == 0">There is no available image to be set as cover. Send a message on the task with an attached image.</div> </t> |
