Browse Source

Update

pull/5/head
Mathias Markl 7 years ago
parent
commit
4805698373
  1. 4
      muk_web_preview_attachment/__manifest__.py
  2. BIN
      muk_web_preview_attachment/static/description/screenshot.png
  3. 16
      muk_web_preview_attachment/static/src/js/attachment_preview.js
  4. 31
      muk_web_preview_attachment/static/src/js/chatter_preview.js
  5. 55
      muk_web_preview_attachment/static/src/js/preview_helper.js
  6. 16
      muk_web_preview_attachment/static/src/js/sidebar_preview.js
  7. 1
      muk_web_preview_attachment/template/assets.xml

4
muk_web_preview_attachment/__manifest__.py

@ -25,8 +25,10 @@
"description": """
Adds a button to the Attachment Sidebar to
preview the content directly in the browser.
The module also enables the possibility to
preview attachment in the Odoo Chat Widgets.
""",
"version": "10.0.1.0.4",
"version": "10.0.1.0.5",
"category": "Extra Tools",
"license": "AGPL-3",
"website": "http://www.mukit.at",

BIN
muk_web_preview_attachment/static/description/screenshot.png

Before

Width: 784  |  Height: 274  |  Size: 59 KiB

After

Width: 787  |  Height: 275  |  Size: 61 KiB

16
muk_web_preview_attachment/static/src/js/attachment_preview.js

@ -26,8 +26,7 @@ var Model = require("web.Model");
var KanbanView = require('web_kanban.KanbanView');
var PreviewGenerator = require('muk_preview.PreviewGenerator');
var PreviewDialog = require('muk_preview.PreviewDialog');
var PreviewHelper = require('muk_preview_attachment.PreviewHelper');
var Attachment = new Model('ir.attachment', session.user_context);
@ -44,18 +43,7 @@ KanbanView.include({
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);
});
PreviewHelper.createAttachmentPreview($(e.currentTarget).data('id'));
},
});

31
muk_web_preview_attachment/static/src/js/chatter_preview.js

@ -27,8 +27,7 @@ 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 PreviewHelper = require('muk_preview_attachment.PreviewHelper');
var Attachment = new Model('ir.attachment', session.user_context);
@ -45,18 +44,8 @@ ChatThread.include({
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);
});
PreviewHelper.createAttachmentPreview($(e.currentTarget)
.find('.o_attachment_id ').data('id'));
},
});
@ -70,18 +59,8 @@ Chatter.include({
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);
});
PreviewHelper.createAttachmentPreview($(e.currentTarget)
.find('.o_attachment_id ').data('id'));
},
});

55
muk_web_preview_attachment/static/src/js/preview_helper.js

@ -0,0 +1,55 @@
/**********************************************************************************
*
* 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 <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
odoo.define('muk_preview_attachment.PreviewHelper', function (require) {
"use strict";
var core = require('web.core');
var session = require('web.session');
var Model = require("web.Model");
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;
var PreviewHelper = core.Class.extend({
createAttachmentPreview: function(id) {
Attachment.query(['name', 'url', 'type', 'mimetype', 'extension'])
.filter([['id', '=', 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);
});
}
});
PreviewHelper.createAttachmentPreview = function(id) {
return new PreviewHelper().createAttachmentPreview(id);
};
return PreviewHelper;
});

16
muk_web_preview_attachment/static/src/js/sidebar_preview.js

@ -25,8 +25,7 @@ var session = require('web.session');
var Sidebar = require('web.Sidebar');
var Model = require("web.Model");
var PreviewGenerator = require('muk_preview.PreviewGenerator');
var PreviewDialog = require('muk_preview.PreviewDialog');
var PreviewHelper = require('muk_preview_attachment.PreviewHelper');
var Attachment = new Model('ir.attachment', session.user_context);
@ -41,18 +40,7 @@ Sidebar.include({
on_attachment_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);
});
PreviewHelper.createAttachmentPreview($(e.currentTarget).data('id'));
},
});

1
muk_web_preview_attachment/template/assets.xml

@ -24,6 +24,7 @@
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/chatter_preview.less" />
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/sidebar_preview.less" />
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/preview_helper.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/attachment_preview.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/chatter_preview.js"/>
<script type="text/javascript" src="/muk_web_preview_attachment/static/src/js/sidebar_preview.js"/>

Loading…
Cancel
Save