diff --git a/web_widget_image_download/README.rst b/web_widget_image_download/README.rst index 34038352d48d..1edb0737ce0e 100644 --- a/web_widget_image_download/README.rst +++ b/web_widget_image_download/README.rst @@ -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 9ed52dbc1426..d7816a08bdb5 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", @@ -14,9 +14,6 @@ "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/**/*", ], }, diff --git a/web_widget_image_download/readme/USAGE.rst b/web_widget_image_download/readme/USAGE.rst index f1685b6a0fe8..e4cccdbd29b5 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 4bddbe6ec1bd..70ce7300bb4d 100644 --- a/web_widget_image_download/static/description/index.html +++ b/web_widget_image_download/static/description/index.html @@ -1,4 +1,3 @@ - @@ -369,7 +368,7 @@

Web Widget - Image Download

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !! source digest: sha256:01e27e70406c021c12f0ccba353c64aea71f52d5f06cd7eee48668ad281a029d !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --> -

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 +391,7 @@

Usage

  • 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 +399,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.

    @@ -435,7 +434,7 @@

    Maintainers

    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/js/web_widget_image_download.js b/web_widget_image_download/static/src/js/web_widget_image_download.js index d78a3d4ffb74..c1d0816a7e15 100644 --- 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 @@ -1,30 +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). */ -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("/", ".") - ); - }, - }); +import {patch} from "@web/core/utils/patch"; +import {ImageField} from "@web/views/fields/image/image_field"; - $widget.attr("href", this.imgSrc); - }, - }); +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/scss/web_widget_image_download.scss b/web_widget_image_download/static/src/scss/web_widget_image_download.scss deleted file mode 100644 index 134419bfed2b..000000000000 --- 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 f27db538b52c..1f030b1b1d4b 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 @@