diff --git a/muk_web_preview_attachment/__manifest__.py b/muk_web_preview_attachment/__manifest__.py index d1bdb91..ad12af3 100644 --- a/muk_web_preview_attachment/__manifest__.py +++ b/muk_web_preview_attachment/__manifest__.py @@ -26,7 +26,7 @@ Adds a button to the Attachment Sidebar to preview the content directly in the browser.. """, - "version": "10.0.1.0.3", + "version": "10.0.1.0.4", "category": "Extra Tools", "license": "AGPL-3", "website": "http://www.mukit.at", @@ -35,10 +35,13 @@ "Mathias Markl ", ], "depends": [ + "mail", + "document", "muk_web_preview", ], "data": [ "template/assets.xml", + "views/ir_attachment_view.xml", ], "demo": [ ], diff --git a/muk_web_preview_attachment/static/description/screenshot.png b/muk_web_preview_attachment/static/description/screenshot.png index 01b80d6..ad35bed 100644 Binary files a/muk_web_preview_attachment/static/description/screenshot.png and b/muk_web_preview_attachment/static/description/screenshot.png differ diff --git a/muk_web_preview_attachment/static/src/img/eye.png b/muk_web_preview_attachment/static/src/img/eye.png new file mode 100644 index 0000000..27f7e2e Binary files /dev/null and b/muk_web_preview_attachment/static/src/img/eye.png differ diff --git a/muk_web_preview_attachment/static/src/js/attachment_preview.js b/muk_web_preview_attachment/static/src/js/attachment_preview.js new file mode 100644 index 0000000..0441d65 --- /dev/null +++ b/muk_web_preview_attachment/static/src/js/attachment_preview.js @@ -0,0 +1,62 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +odoo.define('muk_preview_attachment.AttachmentPreview', function (require) { +"use strict"; + +var core = require('web.core'); +var session = require('web.session'); +var Model = require("web.Model"); + +var KanbanView = require('web_kanban.KanbanView'); + +var PreviewGenerator = require('muk_preview.PreviewGenerator'); +var PreviewDialog = require('muk_preview.PreviewDialog'); + +var Attachment = new Model('ir.attachment', session.user_context); + +var QWeb = core.qweb; +var _t = core._t; + +KanbanView.include({ + init: function() { + this._super.apply(this, arguments); + this.events = _.extend(this.events, { + 'click .oe_attachment .o_image': 'preview', + }); + }, + preview: function(e) { + e.preventDefault(); + e.stopPropagation(); + var self = this; + var $target = $(e.currentTarget); + + Attachment.query(['name', 'url', 'type', 'mimetype', 'extension']) + .filter([['id', '=', $target.data('id')]]) + .first().then(function(attachment) { + if(!attachment.url && attachment.type === "binary") { + attachment.url = '/web/content/' + attachment.id + '?download=true'; + } + PreviewDialog.createPreviewDialog(self, attachment.url, attachment.mimetype, + attachment.extension, attachment.name); + }); + }, +}); + +}); \ No newline at end of file diff --git a/muk_web_preview_attachment/static/src/js/chatter_preview.js b/muk_web_preview_attachment/static/src/js/chatter_preview.js new file mode 100644 index 0000000..a7ce671 --- /dev/null +++ b/muk_web_preview_attachment/static/src/js/chatter_preview.js @@ -0,0 +1,88 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +odoo.define('muk_preview_attachment.ChatterPreview', function (require) { +"use strict"; + +var core = require('web.core'); +var session = require('web.session'); +var Model = require("web.Model"); + +var ChatThread = require('mail.ChatThread'); +var Chatter = require('mail.Chatter'); + +var PreviewGenerator = require('muk_preview.PreviewGenerator'); +var PreviewDialog = require('muk_preview.PreviewDialog'); + +var Attachment = new Model('ir.attachment', session.user_context); + +var QWeb = core.qweb; +var _t = core._t; + +ChatThread.include({ + init: function() { + this._super.apply(this, arguments); + this.events = _.extend(this.events, { + 'click .o_attachment .o_image': 'preview', + }); + }, + preview: function(e) { + e.preventDefault(); + e.stopPropagation(); + var self = this; + var $target = $(e.currentTarget); + + Attachment.query(['name', 'url', 'type', 'mimetype', 'extension']) + .filter([['id', '=', $target.find('.o_attachment_id ').data('id')]]) + .first().then(function(attachment) { + if(!attachment.url && attachment.type === "binary") { + attachment.url = '/web/content/' + attachment.id + '?download=true'; + } + PreviewDialog.createPreviewDialog(self, attachment.url, attachment.mimetype, + attachment.extension, attachment.name); + }); + }, +}); + +Chatter.include({ + init: function() { + this._super.apply(this, arguments); + this.events = _.extend(this.events, { + 'click .o_attachment .o_image': 'preview', + }); + }, + preview: function(e) { + e.preventDefault(); + e.stopPropagation(); + var self = this; + var $target = $(e.currentTarget); + + Attachment.query(['name', 'url', 'type', 'mimetype', 'extension']) + .filter([['id', '=', $target.find('.o_attachment_id ').data('id')]]) + .first().then(function(attachment) { + if(!attachment.url && attachment.type === "binary") { + attachment.url = '/web/content/' + attachment.id + '?download=true'; + } + PreviewDialog.createPreviewDialog(self, attachment.url, attachment.mimetype, + attachment.extension, attachment.name); + }); + }, +}); + +}); \ No newline at end of file diff --git a/muk_web_preview_attachment/static/src/js/sidebar_preview.js b/muk_web_preview_attachment/static/src/js/sidebar_preview.js index 09a0447..5f13d0b 100644 --- a/muk_web_preview_attachment/static/src/js/sidebar_preview.js +++ b/muk_web_preview_attachment/static/src/js/sidebar_preview.js @@ -45,7 +45,7 @@ Sidebar.include({ var $target = $(e.currentTarget); Attachment.query(['name', 'url', 'type', 'mimetype', 'extension']) - .filter([['id', '=', $target.attr('data-id')]]) + .filter([['id', '=', $target.data('id')]]) .first().then(function(attachment) { if(!attachment.url && attachment.type === "binary") { attachment.url = '/web/content/' + attachment.id + '?download=true'; @@ -53,7 +53,6 @@ Sidebar.include({ PreviewDialog.createPreviewDialog(self, attachment.url, attachment.mimetype, attachment.extension, attachment.name); }); - }, }); diff --git a/muk_web_preview_attachment/static/src/less/attachment_preview.less b/muk_web_preview_attachment/static/src/less/attachment_preview.less new file mode 100644 index 0000000..26ef41e --- /dev/null +++ b/muk_web_preview_attachment/static/src/less/attachment_preview.less @@ -0,0 +1,39 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +.o_attachment .o_image { + position: relative; + + &:hover::before { + top: 0; + left: 0; + z-index: 99; + width: 60px; + height: 60px; + opacity: 0.7; + content: " "; + position: absolute; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + background-color: #cccccc; + background-image: url('/muk_web_preview_attachment/static/src/img/eye.png'); + } +} + diff --git a/muk_web_preview_attachment/static/src/less/chatter_preview.less b/muk_web_preview_attachment/static/src/less/chatter_preview.less new file mode 100644 index 0000000..a725e60 --- /dev/null +++ b/muk_web_preview_attachment/static/src/less/chatter_preview.less @@ -0,0 +1,59 @@ +/********************************************************************************** +* +* Copyright (C) 2017 MuK IT GmbH +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU Affero General Public License as +* published by the Free Software Foundation, either version 3 of the +* License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Affero General Public License for more details. +* +* You should have received a copy of the GNU Affero General Public License +* along with this program. If not, see . +* +**********************************************************************************/ + +.oe_attachment .o_image { + position: relative; + + &:hover::before { + top: 0; + left: 0; + z-index: 99; + width: 100px; + height: 80px; + opacity: 0.7; + content: " "; + position: absolute; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + background-color: #cccccc; + background-image: url('/muk_web_preview_attachment/static/src/img/eye.png'); + } +} + +.o_attachment .o_image { + position: relative; + + &:hover::before { + top: 0; + left: 0; + z-index: 99; + width: 60px; + height: 60px; + opacity: 0.7; + content: " "; + position: absolute; + background-size: contain; + background-position: center; + background-repeat: no-repeat; + background-color: #cccccc; + background-image: url('/muk_web_preview_attachment/static/src/img/eye.png'); + } +} + diff --git a/muk_web_preview_attachment/static/src/xml/chatter_preview.xml b/muk_web_preview_attachment/static/src/xml/chatter_preview.xml new file mode 100644 index 0000000..d9a4a9f --- /dev/null +++ b/muk_web_preview_attachment/static/src/xml/chatter_preview.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + diff --git a/muk_web_preview_attachment/template/assets.xml b/muk_web_preview_attachment/template/assets.xml index 891bca0..c046b83 100644 --- a/muk_web_preview_attachment/template/assets.xml +++ b/muk_web_preview_attachment/template/assets.xml @@ -20,7 +20,12 @@