Browse Source

Update

pull/5/head
Mathias Markl 7 years ago
parent
commit
4114f2821e
  1. 5
      muk_web_preview_attachment/__manifest__.py
  2. BIN
      muk_web_preview_attachment/static/description/screenshot.png
  3. BIN
      muk_web_preview_attachment/static/src/img/eye.png
  4. 62
      muk_web_preview_attachment/static/src/js/attachment_preview.js
  5. 88
      muk_web_preview_attachment/static/src/js/chatter_preview.js
  6. 3
      muk_web_preview_attachment/static/src/js/sidebar_preview.js
  7. 39
      muk_web_preview_attachment/static/src/less/attachment_preview.less
  8. 59
      muk_web_preview_attachment/static/src/less/chatter_preview.less
  9. 28
      muk_web_preview_attachment/static/src/xml/chatter_preview.xml
  10. 5
      muk_web_preview_attachment/template/assets.xml
  11. 13
      muk_web_preview_attachment/views/ir_attachment_view.xml

5
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 <mathias.markl@mukit.at>",
],
"depends": [
"mail",
"document",
"muk_web_preview",
],
"data": [
"template/assets.xml",
"views/ir_attachment_view.xml",
],
"demo": [
],

BIN
muk_web_preview_attachment/static/description/screenshot.png

Before

Width: 520  |  Height: 185  |  Size: 8.6 KiB

After

Width: 803  |  Height: 288  |  Size: 58 KiB

BIN
muk_web_preview_attachment/static/src/img/eye.png

After

Width: 64  |  Height: 64  |  Size: 1.1 KiB

62
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 <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
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);
});
},
});
});

88
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 <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
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);
});
},
});
});

3
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);
});
},
});

39
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 <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
.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');
}
}

59
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 <http://www.gnu.org/licenses/>.
*
**********************************************************************************/
.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');
}
}

28
muk_web_preview_attachment/static/src/xml/chatter_preview.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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/>.
-->
<templates>
<t t-extend="mail.Attachment">
<t t-jquery=".o_image" t-operation="append">
<span class="o_attachment_id hidden" t-attf-data-id="#{attachment.id}" />
</t>
</t>
</templates>

5
muk_web_preview_attachment/template/assets.xml

@ -20,7 +20,12 @@
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<link rel="stylesheet" href="/muk_web_preview_attachment/static/src/less/attachment_preview.less" />
<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/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"/>
</xpath>
</template>

13
muk_web_preview_attachment/views/ir_attachment_view.xml

@ -30,4 +30,17 @@
</field>
</record>
<record id="view_document_file_kanban" model="ir.ui.view">
<field name="name">Adding an ID to the o_image</field>
<field name="model">ir.attachment</field>
<field name="inherit_id" ref="mail.view_document_file_kanban"/>
<field name="arch" type="xml">
<xpath expr="//div[@class='o_image']" position="attributes">
<attribute name="t-att-data-id">record.id.value</attribute>
</xpath>
</field>
</record>
</odoo>
Loading…
Cancel
Save