mirror of
https://github.com/OCA/knowledge.git
synced 2025-07-13 15:34:49 -06:00
[MIG] attachment_preview: Migration to 12.0
[REM] Old files [ADD] Magic to travis file [FIX] Nagivation refresh widget
This commit is contained in:
parent
004fb26e65
commit
063c58e25a
@ -30,6 +30,7 @@ env:
|
||||
install:
|
||||
- git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools
|
||||
- export PATH=${HOME}/maintainer-quality-tools/travis:${PATH}
|
||||
- pip install --upgrade python-magic
|
||||
- travis_install_nightly
|
||||
|
||||
|
||||
|
@ -14,13 +14,13 @@ Preview attachments
|
||||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
|
||||
:alt: License: AGPL-3
|
||||
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github
|
||||
:target: https://github.com/OCA/knowledge/tree/11.0/attachment_preview
|
||||
:target: https://github.com/OCA/knowledge/tree/12.0/attachment_preview
|
||||
:alt: OCA/knowledge
|
||||
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
|
||||
:target: https://translation.odoo-community.org/projects/knowledge-11-0/knowledge-11-0-attachment_preview
|
||||
:target: https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview
|
||||
:alt: Translate me on Weblate
|
||||
.. |badge5| image:: https://img.shields.io/badge/runbot-Try%20me-875A7B.png
|
||||
:target: https://runbot.odoo-community.org/runbot/118/11.0
|
||||
:target: https://runbot.odoo-community.org/runbot/118/12.0
|
||||
:alt: Try me on Runbot
|
||||
|
||||
|badge1| |badge2| |badge3| |badge4| |badge5|
|
||||
@ -64,7 +64,7 @@ Bug Tracker
|
||||
Bugs are tracked on `GitHub Issues <https://github.com/OCA/knowledge/issues>`_.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
`feedback <https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
|
||||
|
||||
Do not contact contributors directly about support or help with technical issues.
|
||||
|
||||
@ -104,6 +104,6 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.
|
||||
|
||||
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/11.0/attachment_preview>`_ project on GitHub.
|
||||
This module is part of the `OCA/knowledge <https://github.com/OCA/knowledge/tree/12.0/attachment_preview>`_ project on GitHub.
|
||||
|
||||
You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
"name": "Preview attachments",
|
||||
"version": "11.0.1.3.0",
|
||||
"version": "12.0.1.0.0",
|
||||
"author": "Therp BV,"
|
||||
"Onestein,"
|
||||
"Odoo Community Association (OCA)",
|
||||
@ -12,6 +12,7 @@
|
||||
"category": "Knowledge Management",
|
||||
"depends": [
|
||||
'web',
|
||||
'mail'
|
||||
],
|
||||
"data": [
|
||||
"templates/assets.xml",
|
||||
|
@ -3,7 +3,7 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="generator" content="Docutils 0.15.1: http://docutils.sourceforge.net/" />
|
||||
<meta name="generator" content="Docutils 0.14: http://docutils.sourceforge.net/" />
|
||||
<title>Preview attachments</title>
|
||||
<style type="text/css">
|
||||
|
||||
@ -367,7 +367,7 @@ ul.auto-toc {
|
||||
!! This file is generated by oca-gen-addon-readme !!
|
||||
!! changes will be overwritten. !!
|
||||
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/11.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-11-0/knowledge-11-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/11.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p><a class="reference external" href="https://odoo-community.org/page/development-status"><img alt="Beta" src="https://img.shields.io/badge/maturity-Beta-yellow.png" /></a> <a class="reference external" href="http://www.gnu.org/licenses/agpl-3.0-standalone.html"><img alt="License: AGPL-3" src="https://img.shields.io/badge/licence-AGPL--3-blue.png" /></a> <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview"><img alt="OCA/knowledge" src="https://img.shields.io/badge/github-OCA%2Fknowledge-lightgray.png?logo=github" /></a> <a class="reference external" href="https://translation.odoo-community.org/projects/knowledge-12-0/knowledge-12-0-attachment_preview"><img alt="Translate me on Weblate" src="https://img.shields.io/badge/weblate-Translate%20me-F47D42.png" /></a> <a class="reference external" href="https://runbot.odoo-community.org/runbot/118/12.0"><img alt="Try me on Runbot" src="https://img.shields.io/badge/runbot-Try%20me-875A7B.png" /></a></p>
|
||||
<p>This addon allows to preview attachments supported by <a class="reference external" href="http://viewerjs.org">http://viewerjs.org</a>.</p>
|
||||
<p>Currently, that’s most Libreoffice files and PDFs.</p>
|
||||
<img alt="Screenshot of split form view" src="https://raw.githubusercontent.com/attachment_preview/static/description/screenshot-split.png" style="width: 100%;" />
|
||||
@ -409,7 +409,7 @@ next to the navigational buttons you can open the preview in a separate window.<
|
||||
<p>Bugs are tracked on <a class="reference external" href="https://github.com/OCA/knowledge/issues">GitHub Issues</a>.
|
||||
In case of trouble, please check there if your issue has already been reported.
|
||||
If you spotted it first, help us smashing it by providing a detailed and welcomed
|
||||
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2011.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<a class="reference external" href="https://github.com/OCA/knowledge/issues/new?body=module:%20attachment_preview%0Aversion:%2012.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**">feedback</a>.</p>
|
||||
<p>Do not contact contributors directly about support or help with technical issues.</p>
|
||||
</div>
|
||||
<div class="section" id="credits">
|
||||
@ -444,7 +444,7 @@ If you spotted it first, help us smashing it by providing a detailed and welcome
|
||||
<p>OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||
mission is to support the collaborative development of Odoo features and
|
||||
promote its widespread use.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/11.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p>
|
||||
<p>This module is part of the <a class="reference external" href="https://github.com/OCA/knowledge/tree/12.0/attachment_preview">OCA/knowledge</a> project on GitHub.</p>
|
||||
<p>You are welcome to contribute. To learn how please visit <a class="reference external" href="https://odoo-community.org/page/Contribute">https://odoo-community.org/page/Contribute</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -7,7 +7,7 @@ odoo.define('attachment_preview', function (require) {
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
var qweb = core.qweb;
|
||||
var Sidebar = require('web.Sidebar');
|
||||
var Chatter = require('mail.Chatter');
|
||||
var basic_fields = require('web.basic_fields');
|
||||
var FormRenderer = require('web.FormRenderer');
|
||||
var FormController = require('web.FormController');
|
||||
@ -42,21 +42,40 @@ odoo.define('attachment_preview', function (require) {
|
||||
},
|
||||
};
|
||||
|
||||
Sidebar.include(AttachmentPreviewMixin);
|
||||
Sidebar.include({
|
||||
events: _.extend({}, Sidebar.prototype.events, {
|
||||
'click .o_sidebar_preview_attachment': '_onPreviewAttachment',
|
||||
Chatter.include(AttachmentPreviewMixin);
|
||||
Chatter.include({
|
||||
events: _.extend({}, Chatter.prototype.events, {
|
||||
'click .o_attachment_preview': '_onPreviewAttachment',
|
||||
}),
|
||||
|
||||
previewableAttachments: null,
|
||||
|
||||
_redraw: function () {
|
||||
this._super.apply(this, arguments);
|
||||
_openAttachmentBox: function () {
|
||||
var res = this._super.apply(this, arguments);
|
||||
|
||||
this.getPreviewableAttachments().done(function (atts) {
|
||||
this.previewableAttachments = atts;
|
||||
this.updatePreviewButtons(atts);
|
||||
this.trigger_up('setPreviewableAttachments', {attachments: atts});
|
||||
this.getParent().attachmentPreviewWidget.setAttachments(atts);
|
||||
}.bind(this));
|
||||
|
||||
return res;
|
||||
},
|
||||
|
||||
update: function () {
|
||||
var res = this._super.apply(this, arguments);
|
||||
var self = this;
|
||||
if (this.getParent().$el.hasClass('attachment_preview')) {
|
||||
this._fetchAttachments().done(function () {
|
||||
self._openAttachmentBox();
|
||||
self.getPreviewableAttachments().done(function (atts) {
|
||||
self.updatePreviewButtons(self.previewableAttachments);
|
||||
self.previewableAttachments = atts;
|
||||
self.getParent().attachmentPreviewWidget.setAttachments(atts);
|
||||
});
|
||||
});
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
_onPreviewAttachment: function (event) {
|
||||
@ -86,7 +105,7 @@ odoo.define('attachment_preview', function (require) {
|
||||
var self = this;
|
||||
var deferred = $.Deferred();
|
||||
|
||||
var $items = this.$el.find('.o_sidebar_preview_attachment');
|
||||
var $items = this.$el.find('.o_attachment_preview');
|
||||
var attachments = _.object($items.map(function () {
|
||||
return parseInt($(this).attr('data-id'), 10);
|
||||
}), $items.map(function () {
|
||||
@ -111,14 +130,14 @@ odoo.define('attachment_preview', function (require) {
|
||||
})), function (id) {
|
||||
return {
|
||||
id: id,
|
||||
url: attachments[id]['url'],
|
||||
url: attachments[id].url,
|
||||
extension: extensions[id],
|
||||
title: attachments[id]['title'],
|
||||
title: attachments[id].title,
|
||||
previewUrl: self.getUrl(
|
||||
id,
|
||||
attachments[id]['url'],
|
||||
attachments[id].url,
|
||||
extensions[id],
|
||||
id + ' - ' + attachments[id]['title']
|
||||
id + ' - ' + attachments[id].title
|
||||
),
|
||||
};
|
||||
});
|
||||
@ -130,7 +149,7 @@ odoo.define('attachment_preview', function (require) {
|
||||
},
|
||||
|
||||
updatePreviewButtons: function (previewableAttachments) {
|
||||
this.$el.find('.o_sidebar_preview_attachment').each(function () {
|
||||
this.$el.find('.o_attachment_preview').each(function () {
|
||||
var $this = $(this);
|
||||
var id = $this.attr('data-id');
|
||||
var att = _.findWhere(previewableAttachments, {id: id});
|
||||
@ -152,19 +171,23 @@ odoo.define('attachment_preview', function (require) {
|
||||
_renderReadonly: function () {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments);
|
||||
this._getBinaryExtension().done(function (extension) {
|
||||
if (self.canPreview(extension)) {
|
||||
self._renderPreviewButton(extension);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.recordData.id) {
|
||||
this._getBinaryExtension().done(function (extension) {
|
||||
if (self.canPreview(extension)) {
|
||||
self._renderPreviewButton(extension);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_renderPreviewButton: function (extension) {
|
||||
this.$previewBtn = $("<span/>");
|
||||
this.$previewBtn.addClass('fa fa-search');
|
||||
this.$previewBtn = $("<a/>");
|
||||
this.$previewBtn.addClass('fa fa-search mr-2');
|
||||
this.$previewBtn.attr('href', 'javascript:void(0)');
|
||||
this.$previewBtn.attr('title', _.str.sprintf(_t('Preview %s'), this.field.string));
|
||||
this.$previewBtn.attr('data-extension', extension);
|
||||
this.$el.find('.fa-download').after(this.$previewBtn);
|
||||
this.$el.find('.fa-download').before(this.$previewBtn);
|
||||
},
|
||||
|
||||
_getBinaryExtension: function () {
|
||||
@ -193,6 +216,7 @@ odoo.define('attachment_preview', function (require) {
|
||||
_.str.sprintf(_t('Preview %s'), this.field.string),
|
||||
false
|
||||
);
|
||||
event.stopPropagation();
|
||||
},
|
||||
});
|
||||
|
||||
@ -257,12 +281,12 @@ odoo.define('attachment_preview', function (require) {
|
||||
},
|
||||
|
||||
show: function () {
|
||||
this.$el.removeClass('hidden');
|
||||
this.$el.removeClass('d-none');
|
||||
this.trigger('shown');
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
this.$el.addClass('hidden');
|
||||
this.$el.addClass('d-none');
|
||||
this.trigger('hidden');
|
||||
},
|
||||
|
||||
@ -290,6 +314,10 @@ odoo.define('attachment_preview', function (require) {
|
||||
});
|
||||
|
||||
FormRenderer.include({
|
||||
custom_events: _.extend({}, FormRenderer.prototype.custom_events, {
|
||||
onAttachmentPreview: '_onAttachmentPreview',
|
||||
}),
|
||||
|
||||
attachmentPreviewWidget: null,
|
||||
|
||||
init: function () {
|
||||
@ -310,8 +338,9 @@ odoo.define('attachment_preview', function (require) {
|
||||
|
||||
showAttachmentPreviewWidget: function () {
|
||||
this.$el.addClass('attachment_preview');
|
||||
|
||||
this.attachmentPreviewWidget.setAttachments(
|
||||
this.getParent().sidebar.previewableAttachments
|
||||
this.chatter.previewableAttachments
|
||||
);
|
||||
this.attachmentPreviewWidget.show();
|
||||
},
|
||||
@ -321,25 +350,12 @@ odoo.define('attachment_preview', function (require) {
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
FormController.include({
|
||||
custom_events: _.extend({}, FormController.prototype.custom_events, {
|
||||
onAttachmentPreview: '_onAttachmentPreview',
|
||||
setPreviewableAttachments: '_setPreviewableAttachments',
|
||||
}),
|
||||
|
||||
_onAttachmentPreview: function (event) {
|
||||
this.renderer.showAttachmentPreviewWidget();
|
||||
},
|
||||
|
||||
_setPreviewableAttachments: function (event) {
|
||||
this.renderer.attachmentPreviewWidget.setAttachments(
|
||||
event.data.attachments
|
||||
);
|
||||
this.showAttachmentPreviewWidget();
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
return {
|
||||
AttachmentPreviewMixin: AttachmentPreviewMixin,
|
||||
AttachmentPreviewWidget: AttachmentPreviewWidget,
|
||||
|
@ -1,11 +1,11 @@
|
||||
.o_cp_sidebar {
|
||||
li .o_sidebar_preview_attachment {
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
right: 26px;
|
||||
background-color: #FFF;
|
||||
.o_attachments_list .o_attachment_wrap {
|
||||
.o_attachment_preview {
|
||||
cursor: pointer;
|
||||
float: right;
|
||||
padding-top: 1px;
|
||||
padding-bottom: 1px;
|
||||
|
||||
&.o_sidebar_preview_attachment_new_tab {
|
||||
&.o_attachment_preview_new_tab {
|
||||
right: 43px;
|
||||
}
|
||||
}
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
> .attachment_preview_iframe {
|
||||
width: 100%;
|
||||
height: calc(~"100% - 30px");
|
||||
height: calc(100% - 30px);
|
||||
float: left;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@
|
||||
float: left;
|
||||
width: 100%;
|
||||
background-color: #FFF;
|
||||
border-left: 1px solid @gray-lighter-dark;
|
||||
border-left: 1px solid $gray-800;
|
||||
|
||||
button {
|
||||
min-width: 25px;
|
@ -1,33 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates>
|
||||
<t t-extend="Sidebar">
|
||||
<t t-jquery="span.o_sidebar_delete_attachment" t-operation="before">
|
||||
<span t-if="section.name == 'files' and widget.options.editable and !item.callback and item.url"
|
||||
class="fa fa-search o_sidebar_preview_attachment"
|
||||
t-att-data-id="item.id"
|
||||
t-att-data-url="item.url"
|
||||
t-attf-title="Preview #{item.name}"/>
|
||||
<t t-extend="mail.Attachment">
|
||||
<t t-jquery=".o_attachment_download" t-operation="after">
|
||||
<span t-if="!attachment.callback and attachment.url"
|
||||
class="fa fa-search ml4 o_attachment_preview"
|
||||
t-att-data-id="attachment.id"
|
||||
t-att-data-url="attachment.url"
|
||||
t-attf-title="Preview #{attachment.name} in side panel"/>
|
||||
|
||||
<span t-if="section.name == 'files' and widget.options.editable and !item.callback and item.url"
|
||||
class="fa fa-external-link o_sidebar_preview_attachment o_sidebar_preview_attachment_new_tab"
|
||||
<span t-if="!attachment.callback and attachment.url"
|
||||
class="fa fa-external-link ml4 o_attachment_preview o_attachment_preview_new_tab"
|
||||
data-target="new"
|
||||
t-att-data-id="item.id"
|
||||
t-att-data-url="item.url"
|
||||
t-attf-title="Open preview #{item.name} in a new tab"/>
|
||||
t-att-data-id="attachment.id"
|
||||
t-att-data-url="attachment.url"
|
||||
t-attf-title="Open preview #{attachment.name} in a new tab"/>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="attachment_preview.AttachmentPreviewWidget">
|
||||
<div class="attachment_preview_widget hidden">
|
||||
<div class="attachment_preview_widget d-none">
|
||||
<div class="attachment_preview_buttons">
|
||||
<div class="button-group pull-left">
|
||||
<button class="btn btn-sm btn-default attachment_preview_previous"><i class="fa fa-chevron-left"/></button>
|
||||
<button class="btn btn-sm btn-default disabled attachment_preview_current">1 / 5</button>
|
||||
<button class="btn btn-sm btn-default attachment_preview_next"><i class="fa fa-chevron-right"/></button>
|
||||
<button class="btn btn-sm btn-secondary attachment_preview_previous"><i class="fa fa-chevron-left"/></button>
|
||||
<button class="btn btn-sm btn-secondary disabled attachment_preview_current">1 / 5</button>
|
||||
<button class="btn btn-sm btn-secondary attachment_preview_next"><i class="fa fa-chevron-right"/></button>
|
||||
</div>
|
||||
<button class="btn btn-sm btn-default pull-left ml8 attachment_preview_popout"><i class="fa fa-external-link"/></button>
|
||||
<button class="btn btn-sm btn-secondary pull-left ml8 attachment_preview_popout"><i class="fa fa-external-link"/></button>
|
||||
|
||||
<button class="btn btn-sm btn-default pull-right attachment_preview_close"><i class="fa fa-times"/></button>
|
||||
<button class="btn btn-sm btn-secondary pull-right attachment_preview_close"><i class="fa fa-times"/></button>
|
||||
</div>
|
||||
<iframe class="attachment_preview_iframe"></iframe>
|
||||
</div>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<template id="assets_backend" name="attachment_preview assets" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/attachment_preview/static/src/js/attachment_preview.js"></script>
|
||||
<link rel="stylesheet" type="text/less" href="/attachment_preview/static/src/less/attachment_preview.less" />
|
||||
<link rel="stylesheet" type="text/scss" href="/attachment_preview/static/src/scss/attachment_preview.scss" />
|
||||
</xpath>
|
||||
</template>
|
||||
</odoo>
|
||||
|
Loading…
Reference in New Issue
Block a user