Mathias Markl
8 years ago
11 changed files with 299 additions and 3 deletions
-
5muk_web_preview_attachment/__manifest__.py
-
BINmuk_web_preview_attachment/static/description/screenshot.png
-
BINmuk_web_preview_attachment/static/src/img/eye.png
-
62muk_web_preview_attachment/static/src/js/attachment_preview.js
-
88muk_web_preview_attachment/static/src/js/chatter_preview.js
-
3muk_web_preview_attachment/static/src/js/sidebar_preview.js
-
39muk_web_preview_attachment/static/src/less/attachment_preview.less
-
59muk_web_preview_attachment/static/src/less/chatter_preview.less
-
28muk_web_preview_attachment/static/src/xml/chatter_preview.xml
-
5muk_web_preview_attachment/template/assets.xml
-
13muk_web_preview_attachment/views/ir_attachment_view.xml
Before Width: 520 | Height: 185 | Size: 8.6 KiB After Width: 803 | Height: 288 | Size: 58 KiB |
After Width: 64 | Height: 64 | Size: 1.1 KiB |
@ -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); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
}); |
@ -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); |
||||
|
}); |
||||
|
}, |
||||
|
}); |
||||
|
|
||||
|
}); |
@ -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'); |
||||
|
} |
||||
|
} |
||||
|
|
@ -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'); |
||||
|
} |
||||
|
} |
||||
|
|
@ -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> |
||||
|
|
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue