From ba292d21fba26d364d0e05cb54bd2910767e58ea Mon Sep 17 00:00:00 2001 From: manu Date: Mon, 29 Jul 2024 11:10:06 +0200 Subject: [PATCH] [MIG]web_widget_image_download: Migration to 16.0 --- web_widget_image_download/README.rst | 14 +++---- web_widget_image_download/__manifest__.py | 9 ++--- .../i18n/web_widget_image_download.pot | 4 +- web_widget_image_download/readme/USAGE.rst | 2 +- .../static/description/index.html | 22 ++++++----- .../static/src/components/image_field.esm.js | 21 ++++++++++ .../src/js/web_widget_image_download.js | 30 --------------- .../src/scss/web_widget_image_download.scss | 38 ------------------- .../src/xml/web_widget_image_download.xml | 31 ++++++++++----- 9 files changed, 67 insertions(+), 104 deletions(-) create mode 100644 web_widget_image_download/static/src/components/image_field.esm.js delete mode 100644 web_widget_image_download/static/src/js/web_widget_image_download.js delete mode 100644 web_widget_image_download/static/src/scss/web_widget_image_download.scss diff --git a/web_widget_image_download/README.rst b/web_widget_image_download/README.rst index 34038352d..5cdfd6b33 100644 --- a/web_widget_image_download/README.rst +++ b/web_widget_image_download/README.rst @@ -7,7 +7,7 @@ Web Widget - Image Download !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - !! source digest: sha256:01e27e70406c021c12f0ccba353c64aea71f52d5f06cd7eee48668ad281a029d + !! source digest: sha256:fbbaac2dd53338854af6551564ac3c565458b7a3a430c38d5a5d593e54332607 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! .. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png @@ -17,13 +17,13 @@ Web Widget - Image Download :target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html :alt: License: LGPL-3 .. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fweb-lightgray.png?logo=github - :target: https://github.com/OCA/web/tree/15.0/web_widget_image_download + :target: https://github.com/OCA/web/tree/16.0/web_widget_image_download :alt: OCA/web .. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png - :target: https://translation.odoo-community.org/projects/web-15-0/web-15-0-web_widget_image_download + :target: https://translation.odoo-community.org/projects/web-16-0/web-16-0-web_widget_image_download :alt: Translate me on Weblate .. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png - :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=15.0 + :target: https://runboat.odoo-community.org/builds?repo=OCA/web&target_branch=16.0 :alt: Try me on Runboat |badge1| |badge2| |badge3| |badge4| |badge5| @@ -44,7 +44,7 @@ To use this module, an example path is: #. Go to the section `Contacts`. #. Click on a contact. #. Edit the contact. -#. Click the `Download` button (between `Edit` and `Clear`). +#. Click the `Download` button (on the top left corner). Bug Tracker =========== @@ -52,7 +52,7 @@ Bug Tracker Bugs are tracked on `GitHub Issues `_. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -`feedback `_. +`feedback `_. Do not contact contributors directly about support or help with technical issues. @@ -93,6 +93,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/web `_ project on GitHub. +This module is part of the `OCA/web `_ project on GitHub. You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute. diff --git a/web_widget_image_download/__manifest__.py b/web_widget_image_download/__manifest__.py index 9ed52dbc1..dfecfebb3 100644 --- a/web_widget_image_download/__manifest__.py +++ b/web_widget_image_download/__manifest__.py @@ -3,7 +3,7 @@ { "name": "Web Widget - Image Download", "summary": "Allows to download any image from its widget", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "category": "web", "website": "https://github.com/OCA/web", "author": "Tecnativa, Odoo Community Association (OCA), Kaushal Prajapati", @@ -13,11 +13,8 @@ "depends": ["web"], "assets": { "web.assets_backend": [ - "web_widget_image_download/static/src/js/**/*", - "web_widget_image_download/static/src/scss/**/*", - ], - "web.assets_qweb": [ - "web_widget_image_download/static/src/xml/**/*", + "web_widget_image_download/static/src/components/*", + "web_widget_image_download/static/src/xml/*", ], }, } diff --git a/web_widget_image_download/i18n/web_widget_image_download.pot b/web_widget_image_download/i18n/web_widget_image_download.pot index 6b64daaa0..16a5fb35d 100644 --- a/web_widget_image_download/i18n/web_widget_image_download.pot +++ b/web_widget_image_download/i18n/web_widget_image_download.pot @@ -4,7 +4,7 @@ # msgid "" msgstr "" -"Project-Id-Version: Odoo Server 15.0\n" +"Project-Id-Version: Odoo Server 16.0\n" "Report-Msgid-Bugs-To: \n" "Last-Translator: \n" "Language-Team: \n" @@ -14,7 +14,7 @@ msgstr "" "Plural-Forms: \n" #. module: web_widget_image_download -#. openerp-web +#. odoo-javascript #: code:addons/web_widget_image_download/static/src/xml/web_widget_image_download.xml:0 #: code:addons/web_widget_image_download/static/src/xml/web_widget_image_download.xml:0 #, python-format diff --git a/web_widget_image_download/readme/USAGE.rst b/web_widget_image_download/readme/USAGE.rst index f1685b6a0..e4cccdbd2 100644 --- a/web_widget_image_download/readme/USAGE.rst +++ b/web_widget_image_download/readme/USAGE.rst @@ -3,4 +3,4 @@ To use this module, an example path is: #. Go to the section `Contacts`. #. Click on a contact. #. Edit the contact. -#. Click the `Download` button (between `Edit` and `Clear`). +#. Click the `Download` button (on the top left corner). diff --git a/web_widget_image_download/static/description/index.html b/web_widget_image_download/static/description/index.html index 4bddbe6ec..a2cd61561 100644 --- a/web_widget_image_download/static/description/index.html +++ b/web_widget_image_download/static/description/index.html @@ -1,4 +1,3 @@ - @@ -9,10 +8,11 @@ /* :Author: David Goodger (goodger@python.org) -:Id: $Id: html4css1.css 8954 2022-01-20 10:10:25Z milde $ +:Id: $Id: html4css1.css 9511 2024-01-13 09:50:07Z milde $ :Copyright: This stylesheet has been placed in the public domain. Default cascading style sheet for the HTML output of Docutils. +Despite the name, some widely supported CSS2 features are used. See https://docutils.sourceforge.io/docs/howto/html-stylesheets.html for how to customize this style sheet. @@ -275,7 +275,7 @@ pre.literal-block, pre.doctest-block, pre.math, pre.code { margin-left: 2em ; margin-right: 2em } -pre.code .ln { color: grey; } /* line numbers */ +pre.code .ln { color: gray; } /* line numbers */ pre.code, code { background-color: #eeeeee } pre.code .comment, code .comment { color: #5C6576 } pre.code .keyword, code .keyword { color: #3B0D06; font-weight: bold } @@ -301,7 +301,7 @@ span.option { span.pre { white-space: pre } -span.problematic { +span.problematic, pre.problematic { color: red } span.section-subtitle { @@ -367,9 +367,9 @@ ul.auto-toc { !! This file is generated by oca-gen-addon-readme !! !! changes will be overwritten. !! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -!! source digest: sha256:01e27e70406c021c12f0ccba353c64aea71f52d5f06cd7eee48668ad281a029d +!! source digest: sha256:fbbaac2dd53338854af6551564ac3c565458b7a3a430c38d5a5d593e54332607 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

Beta License: LGPL-3 OCA/web Translate me on Weblate Try me on Runboat

+

Beta License: LGPL-3 OCA/web Translate me on Weblate Try me on Runboat

This module was written to extend the functionality of the image widget and allows to download it.

Table of contents

@@ -392,7 +392,7 @@ allows to download it.

  • Go to the section Contacts.
  • Click on a contact.
  • Edit the contact.
  • -
  • Click the Download button (between Edit and Clear).
  • +
  • Click the Download button (on the top left corner).
  • @@ -400,7 +400,7 @@ allows to download it.

    Bugs are tracked on GitHub Issues. In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed -feedback.

    +feedback.

    Do not contact contributors directly about support or help with technical issues.

    @@ -431,11 +431,13 @@ If you spotted it first, help us to smash it by providing a detailed and welcome

    Maintainers

    This module is maintained by the OCA.

    -Odoo Community Association + +Odoo Community Association +

    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/web project on GitHub.

    +

    This module is part of the OCA/web project on GitHub.

    You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.

    diff --git a/web_widget_image_download/static/src/components/image_field.esm.js b/web_widget_image_download/static/src/components/image_field.esm.js new file mode 100644 index 000000000..c1d0816a7 --- /dev/null +++ b/web_widget_image_download/static/src/components/image_field.esm.js @@ -0,0 +1,21 @@ +/** @odoo-module **/ + +/* Copyright 2016 Flavio Corpa + * Copyright 2016 Jairo Llopis + * Copyright 2024 Manuel Regidor + * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ + +import {patch} from "@web/core/utils/patch"; +import {ImageField} from "@web/views/fields/image/image_field"; + +patch(ImageField.prototype, "web_widget_image_download", { + download() { + const downloadLink = document.createElement("a"); + downloadLink.setAttribute("href", this.getUrl(this.props.name)); + downloadLink.setAttribute("download", ""); + downloadLink.click(); + }, + onFileDownload() { + this.download(); + }, +}); diff --git a/web_widget_image_download/static/src/js/web_widget_image_download.js b/web_widget_image_download/static/src/js/web_widget_image_download.js deleted file mode 100644 index d78a3d4ff..000000000 --- a/web_widget_image_download/static/src/js/web_widget_image_download.js +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright 2016 Flavio Corpa - * Copyright 2016 Jairo Llopis - * License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */ -odoo.define("web_widget_image_download.widget", function (require) { - "use strict"; - - var FieldBinaryImage = require("web.basic_fields").FieldBinaryImage; - - FieldBinaryImage.include({ - _render: function () { - this._super(); - var $widget = this.$el.find(".o_form_binary_file_download"); - this.imgSrc = this.$el.find('img[name="' + this.name + '"]').attr("src"); - - $.ajax({ - // Avoid downloading full image, just headers - type: "HEAD", - url: this.imgSrc, - complete: function (xhr) { - $widget.attr( - "download", - xhr.getResponseHeader("Content-Type").replace("/", ".") - ); - }, - }); - - $widget.attr("href", this.imgSrc); - }, - }); -}); diff --git a/web_widget_image_download/static/src/scss/web_widget_image_download.scss b/web_widget_image_download/static/src/scss/web_widget_image_download.scss deleted file mode 100644 index 134419bfe..000000000 --- a/web_widget_image_download/static/src/scss/web_widget_image_download.scss +++ /dev/null @@ -1,38 +0,0 @@ -.o_field_widget { - &.o_field_image { - .o_form_image_controls { - > .fa, - .o_form_binary_file_download { - margin: 5px 0; - padding: 1px 0; - width: 33.333333%; - } - .o_form_binary_file_download { - border: none; - background-color: transparent; - line-height: 0px; - - > button.fa { - width: 100%; - height: 100%; - margin: 0px; - border: none; - background-color: transparent; - cursor: pointer; - } - } - } - @include media-breakpoint-down(xs, $o-extra-grid-breakpoints) { - .o_form_image_controls { - .o_form_binary_file_download { - display: none; - } - > .fa { - width: 50%; - padding: 6px; - margin: 0px; - } - } - } - } -} diff --git a/web_widget_image_download/static/src/xml/web_widget_image_download.xml b/web_widget_image_download/static/src/xml/web_widget_image_download.xml index f27db538b..1f030b1b1 100644 --- a/web_widget_image_download/static/src/xml/web_widget_image_download.xml +++ b/web_widget_image_download/static/src/xml/web_widget_image_download.xml @@ -2,17 +2,28 @@