diff options
| author | ThanhDodeurOdoo <tso@odoo.com> | 2018-11-07 14:52:33 +0000 |
|---|---|---|
| committer | ThanhDodeurOdoo <tso@odoo.com> | 2018-12-06 19:09:33 +0000 |
| commit | 89f20d2c297d99d4eb0ded8be78fbf86b8ec45d3 (patch) | |
| tree | c86e3d9085425ef7aa9ddf4dcdd453b766a0b90f /addons/mail/static/src | |
| parent | 72905feee0b5393f8872e51b33a10e4ec7978085 (diff) | |
[REF] base, mail: splits the documents feature from ir attachment
Moved the field 'active', 'res_model_name' and 'thumbnail' from
ir.attachment to enterprise's documents.document.
Moved the pdf split feature to enterprise's Documents module.
task: #1908896
Diffstat (limited to 'addons/mail/static/src')
| -rw-r--r-- | addons/mail/static/src/js/document_viewer.js | 22 | ||||
| -rw-r--r-- | addons/mail/static/src/scss/composer.scss | 21 | ||||
| -rw-r--r-- | addons/mail/static/src/xml/thread.xml | 18 |
3 files changed, 9 insertions, 52 deletions
diff --git a/addons/mail/static/src/js/document_viewer.js b/addons/mail/static/src/js/document_viewer.js index e2c03e24d6a..9affc3f41cf 100644 --- a/addons/mail/static/src/js/document_viewer.js +++ b/addons/mail/static/src/js/document_viewer.js @@ -13,7 +13,6 @@ var DocumentViewer = Widget.extend({ template: "DocumentViewer", events: { 'click .o_download_btn': '_onDownload', - 'click .o_split_btn': '_onSplitPDF', 'click .o_viewer_img': '_onImageClicked', 'click .o_viewer_video': '_onVideoClicked', 'click .move_next': '_onNext', @@ -44,7 +43,7 @@ var DocumentViewer = Widget.extend({ init: function (parent, attachments, activeAttachmentID) { this._super.apply(this, arguments); this.attachment = _.filter(attachments, function (attachment) { - var match = attachment.type == 'url' ? attachment.url.match("(youtu|.png|.jpg|.gif)") : attachment.mimetype.match("(image|video|application/pdf|text)"); + var match = attachment.type === 'url' ? attachment.url.match("(youtu|.png|.jpg|.gif)") : attachment.mimetype.match("(image|video|application/pdf|text)"); if (match) { attachment.type = match[1]; @@ -67,6 +66,7 @@ var DocumentViewer = Widget.extend({ } }); this.activeAttachment = _.findWhere(attachments, {id: activeAttachmentID}); + this.modelName = 'ir.attachment'; this._reset(); }, /** @@ -329,24 +329,6 @@ var DocumentViewer = Widget.extend({ * @private * @param {MouseEvent} e */ - _onSplitPDF: function (e) { - e.stopPropagation(); - var self = this; - var indices = $("input[name=Indices]").val(); - var remainder = $("input[type=checkbox][name=remainder]").is(":checked"); - this._rpc({ - model: 'ir.attachment', - method: 'split_pdf', - args: [this.activeAttachment.id, indices, remainder], - }).always(function () { - self.trigger_up('document_viewer_attachment_changed'); - self.destroy(); - }); - }, - /** - * @private - * @param {MouseEvent} e - */ _onStartDrag: function (e) { e.preventDefault(); this.enableDrag = true; diff --git a/addons/mail/static/src/scss/composer.scss b/addons/mail/static/src/scss/composer.scss index bd9307bdd2f..aa5131b0de5 100644 --- a/addons/mail/static/src/scss/composer.scss +++ b/addons/mail/static/src/scss/composer.scss @@ -485,27 +485,6 @@ $o-mail-attachment-margin: 5px; .o_image_caption { bottom: 20%; position: absolute; - - .o_split_pdf_area { - background-color: #3a3a3a; - margin: 5px; - padding: 6px; - margin-left: 50px; - - .o_split_btn { - vertical-align: baseline; - } - - .o_page_number_input { - width: 13%; - color: black; - display: inline; - } - - .o_remainder_input { - vertical-align: middle; - } - } } } diff --git a/addons/mail/static/src/xml/thread.xml b/addons/mail/static/src/xml/thread.xml index fcfe8ba7de2..914168306b8 100644 --- a/addons/mail/static/src/xml/thread.xml +++ b/addons/mail/static/src/xml/thread.xml @@ -35,6 +35,7 @@ --> <t t-name="DocumentViewer.Content"> <div class="o_viewer_content"> + <t t-set="model" t-value="widget.modelName"/> <div class="o_viewer-header"> <span class="o_image_caption"> <i class="fa fa-picture-o mr8" t-if="widget.activeAttachment.type == 'image'" role="img" aria-label="Image" title="Image"/> @@ -42,11 +43,6 @@ <i class="fa fa-video-camera mr8" t-if="widget.activeAttachment.type == 'video'" role="img" aria-label="Video" title="Video"/> <t t-esc="widget.activeAttachment.name"/> <a role="button" href="#" class="o_download_btn ml8 small" data-toggle="tooltip" data-placement="right" title="Download"><i class="fa fa-fw fa-download" role="img" aria-label="Download"/></a> - <span t-if="widget.activeAttachment.type == 'application/pdf'" class="o_split_pdf_area"> - <label for="Indices">Extract pages:&nbsp;</label><input class="o_page_number_input" name="Indices" placeholder="e.g. 1-5, 7, 8-9"/> - <label for="remainder">All pages:&nbsp;</label><input class="o_remainder_input" type="checkbox" name="remainder" value="remainder"/> - <button class="btn btn-sm btn-primary o_split_btn" data-toggle="tooltip" title="Split">Split</button> - </span> </span> <a role="button" class="o_close_btn float-right" href="#" aria-label="Close" title="Close">×</a> </div> @@ -55,12 +51,12 @@ <div t-if="widget.activeAttachment.type == 'image'" class="o_loading_img text-center"> <i class="fa fa-circle-o-notch fa-spin text-gray-light fa-3x fa-fw" role="img" aria-label="Loading" title="Loading"/> </div> - <img t-if="widget.activeAttachment.type == 'image'" class="o_viewer_img" t-attf-src="/web/image/#{widget.activeAttachment.id}?unique=1&signature=#{widget.activeAttachment.checksum}" alt="Viewer"/> - <iframe class="mt32 o_viewer_pdf" t-if="widget.activeAttachment.type == 'application/pdf'" t-attf-src="/web/static/lib/pdfjs/web/viewer.html?file=/web/content/#{widget.activeAttachment.id}" /> - <iframe class="mt32 o_viewer_text" t-if="(widget.activeAttachment.type || '').indexOf('text') !== -1" t-attf-src="/web/content/#{widget.activeAttachment.id}" /> - <iframe class="mt32 o_viewer_text" t-if="widget.activeAttachment.type == 'youtu'" allow="autoplay; encrypted-media" width="560" height="315" t-attf-src="https://www.youtube.com/embed/#{widget.activeAttachment.youtube}"/> + <img t-if="widget.activeAttachment.type === 'image'" class="o_viewer_img" t-attf-src="/web/image/#{widget.activeAttachment.id}?unique=1&signature=#{widget.activeAttachment.checksum}&model=#{model}" alt="Viewer"/> + <iframe t-if="widget.activeAttachment.type == 'application/pdf'" class="mt32 o_viewer_pdf" t-attf-src="/web/static/lib/pdfjs/web/viewer.html?file=/web/content/#{widget.activeAttachment.id}?model%3D#{model}" /> + <iframe t-if="(widget.activeAttachment.type || '').indexOf('text') !== -1" class="mt32 o_viewer_text" t-attf-src="/web/content/#{widget.activeAttachment.id}?model%3D#{model}" /> + <iframe t-if="widget.activeAttachment.type == 'youtu'" class="mt32 o_viewer_text" allow="autoplay; encrypted-media" width="560" height="315" t-attf-src="https://www.youtube.com/embed/#{widget.activeAttachment.youtube}"/> <video t-if="widget.activeAttachment.type == 'video'" class="o_viewer_video" controls="controls"> - <source t-attf-src="/web/image/#{widget.activeAttachment.id}" t-att-data-type="widget.activeAttachment.mimetype"/> + <source t-attf-src="/web/image/#{widget.activeAttachment.id}?model=#{model}" t-att-data-type="widget.activeAttachment.mimetype"/> </video> </div> </div> @@ -86,7 +82,7 @@ --> <t t-name="DocumentViewer"> <div class="modal o_modal_fullscreen" tabindex="-1" data-keyboard="false" role="dialog"> - <t t-call="DocumentViewer.Content"/> + <t class="o_document_viewer_content_call" t-call="DocumentViewer.Content"/> <t t-if="widget.attachment.length !== 1"> <a class="arrow arrow-left move_previous" href="#"> |
