[IMP] web_widget_image_download: black, isort

pull/1945/head
Alexandre Díaz 2020-01-30 17:50:13 +01:00 committed by Peerapong-Supasompob
parent 93d1417648
commit d8c09436aa
5 changed files with 39 additions and 40 deletions

View File

@ -3,20 +3,14 @@
{
"name": "Web Widget - Image Download",
"summary": "Allows to download any image from its widget",
"version": "12.0.1.0.0",
"version": "13.0.1.0.0",
"category": "web",
"website": "https://github.com/OCA/web",
"author": "Tecnativa, Odoo Community Association (OCA), Kaushal Prajapati",
"license": "LGPL-3",
"application": False,
'installable': True,
"data": [
"views/assets.xml",
],
"depends": [
"web",
],
"qweb": [
"static/src/xml/web_widget_image_download.xml",
]
"installable": True,
"data": ["views/assets.xml"],
"depends": ["web"],
"qweb": ["static/src/xml/web_widget_image_download.xml"],
}

View File

@ -1,31 +1,30 @@
/* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
odoo.define('web_widget_image_download.widget', function (require) {
'use strict';
odoo.define("web_widget_image_download.widget", function(require) {
"use strict";
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
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');
var $widget = this.$el.find(".o_form_binary_file_download");
this.imgSrc = this.$el.find('img[name="' + this.name + '"]').attr("src");
$.ajax({
type: 'HEAD', // Avoid downloading full image, just headers
// Avoid downloading full image, just headers
type: "HEAD",
url: this.imgSrc,
complete: function(xhr) {
$widget.attr(
'download',
xhr.getResponseHeader("Content-Type")
.replace('/', '.')
"download",
xhr.getResponseHeader("Content-Type").replace("/", ".")
);
}
},
});
$widget.attr('href', this.imgSrc);
}
$widget.attr("href", this.imgSrc);
},
});
});

View File

@ -1,8 +1,8 @@
.o_field_widget {
&.o_field_image {
.o_form_image_controls {
> .fa, .o_form_binary_file_download {
> .fa,
.o_form_binary_file_download {
margin: 5px 0;
padding: 1px 0;
width: 33.333333%;

View File

@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<template>
<t t-extend="FieldBinaryImage">
<t t-jquery=".o_select_file_button" t-operation="after">
<t t-if="widget.value">
<a class="o_form_binary_file_download float-left" title="Download" aria-label="Download">
<a
class="o_form_binary_file_download float-left"
title="Download"
aria-label="Download"
>
<button class="fa fa-download fa-lg" />
</a>
</t>

View File

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<link rel="stylesheet"
href="/web_widget_image_download/static/src/scss/web_widget_image_download.scss"/>
<script type="text/javascript"
src="/web_widget_image_download/static/src/js/web_widget_image_download.js"/>
<link
rel="stylesheet"
href="/web_widget_image_download/static/src/scss/web_widget_image_download.scss"
/>
<script
type="text/javascript"
src="/web_widget_image_download/static/src/js/web_widget_image_download.js"
/>
</xpath>
</template>