diff options
| author | Christophe Simonis <chs@odoo.com> | 2016-02-02 14:52:15 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2016-02-02 14:52:15 +0100 |
| commit | 469e04e97c2aa60d9d41bd430e0aeba77ee6f9dd (patch) | |
| tree | 0119f59009274d2c569920432c9a7fabafde0974 /addons/project/static | |
| parent | 78d20b552b4374b94aec7097c0e6a48a3dd2d961 (diff) | |
| parent | 2611a8198eaac60cf424742e4dc411700e439352 (diff) | |
[MERGE] forward port of branch saas-8 up to 2611a81
Diffstat (limited to 'addons/project/static')
| -rw-r--r-- | addons/project/static/src/js/project.js | 58 | ||||
| -rw-r--r-- | addons/project/static/src/less/project_dashboard.less | 14 | ||||
| -rw-r--r-- | addons/project/static/src/xml/project.xml | 31 |
3 files changed, 55 insertions, 48 deletions
diff --git a/addons/project/static/src/js/project.js b/addons/project/static/src/js/project.js index 0695a3a4a2f..5072c144b44 100644 --- a/addons/project/static/src/js/project.js +++ b/addons/project/static/src/js/project.js @@ -1,7 +1,9 @@ odoo.define('project.update_kanban', function (require) { +'use strict'; var core = require('web.core'); var data = require('web.data'); +var Dialog = require('web.Dialog'); var Model = require('web.Model'); var session = require('web.session'); @@ -9,45 +11,57 @@ var KanbanView = require('web_kanban.KanbanView'); var KanbanRecord = require('web_kanban.Record'); var QWeb = core.qweb; - +var _t = core._t; KanbanRecord.include({ - on_card_clicked: function() { + on_card_clicked: function () { if (this.model === 'project.project') { this.$('.o_project_kanban_boxes a').first().click(); } else { this._super.apply(this, arguments); } }, - on_kanban_action_clicked: function(ev) { + on_kanban_action_clicked: function (ev) { var self = this; if (this.model === 'project.task' && $(ev.currentTarget).data('type') === 'set_cover') { ev.preventDefault(); new Model('ir.attachment').query(['id', 'name']) .filter([['res_model', '=', 'project.task'], ['res_id', '=', this.id], ['mimetype', 'ilike', 'image']]) - .all().then(function (attachment_ids) { - - var $cover_modal = $(QWeb.render("project.SetCoverModal", { - widget: self, - attachment_ids: attachment_ids, - })); - - $cover_modal.appendTo($('body')); - $cover_modal.modal('toggle'); - $cover_modal.on('click', 'img', function(ev){ - self.update_record({ - data : { - displayed_image_id: $(ev.currentTarget).data('id'), - } - }); - $cover_modal.modal('toggle'); - $cover_modal.remove(); - }); - }); + .all().then(open_cover_images_dialog); } else { this._super.apply(this, arguments, ev); } + + function open_cover_images_dialog(attachment_ids) { + var cover_id = self.record.displayed_image_id.raw_value[0]; + var $content = $(QWeb.render("project.SetCoverModal", { + cover_id: cover_id, + 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.update_record({data: {displayed_image_id: $imgs.filter('.o_selected').data('id')}}); + }}, {text: _t("Remove Cover Image"), close: true, click: function () { + self.update_record({data: {displayed_image_id: 0}}); + }}, {text: _t("Discard"), close: true}], + $content: $content, + }).open(); + + var $selectBtn = dialog.$footer.find('.btn-primary'); + $content.on('click', 'img', function (ev) { + $imgs.not(ev.currentTarget).removeClass('o_selected'); + $selectBtn.prop('disabled', !$(ev.currentTarget).toggleClass('o_selected').hasClass('o_selected')); + }); + + $content.on('dblclick', 'img', function (ev) { + self.update_record({data: {displayed_image_id: $(ev.currentTarget).data('id')}}); + dialog.close(); + }); + } }, }); }); diff --git a/addons/project/static/src/less/project_dashboard.less b/addons/project/static/src/less/project_dashboard.less index 54b4087c974..36c48bb9cca 100644 --- a/addons/project/static/src/less/project_dashboard.less +++ b/addons/project/static/src/less/project_dashboard.less @@ -82,3 +82,17 @@ } } } + +.o_kanban_task_cover_image { + .o-columns(200px, 4); + > img { + cursor: pointer; + margin-bottom: 1em; + border: 1px solid transparent; + + &.o_selected { + border-color: @odoo-brand-secondary; + box-shadow: 0px 0px 2px 2px @odoo-brand-secondary; + } + } +} diff --git a/addons/project/static/src/xml/project.xml b/addons/project/static/src/xml/project.xml index f27c8fd4c5b..d9c4f3fa675 100644 --- a/addons/project/static/src/xml/project.xml +++ b/addons/project/static/src/xml/project.xml @@ -1,30 +1,9 @@ <?xml version="1.0" encoding="UTF-8"?> <templates id="template" xml:space="preserve"> - -<div t-name="project.SetCoverModal" class="modal" tabindex="-1" data-backdrop="static" role="dialog" aria-hidden="true"> - <div class="modal-dialog modal-lg"> - <div class="modal-content"> - <div class="modal-header"> - <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> - <h4 class="modal-title">Set a Cover Image</h4> - </div> - <div class="modal-body"> - <div class="container-fluid"> - <div t-if="attachment_ids.length > 0" class="row"> - <t t-foreach="attachment_ids" t-as="attachment"> - <div class="col-sm-3 o_image" style="height: 100%"> - <img style="cursor: pointer; width: 100%" t-att-src="'/web/image/' + attachment['id'] + '?unique=1'" t-att-data-id="attachment['id']"/> - </div> - </t> - </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> - </div> - </div> - <div class="modal-footer"><button type="button" class="btn btn-primary" data-dismiss="modal">Close</button></div> + <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']"/> </div> - </div> -</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> </templates> |
