mirror of https://github.com/OCA/web.git
[IMP] web_widget_image_download: black, isort
parent
720690c22a
commit
477a88bf48
|
@ -3,20 +3,14 @@
|
||||||
{
|
{
|
||||||
"name": "Web Widget - Image Download",
|
"name": "Web Widget - Image Download",
|
||||||
"summary": "Allows to download any image from its widget",
|
"summary": "Allows to download any image from its widget",
|
||||||
"version": "12.0.1.0.0",
|
"version": "13.0.1.0.0",
|
||||||
"category": "web",
|
"category": "web",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"author": "Tecnativa, Odoo Community Association (OCA), Kaushal Prajapati",
|
"author": "Tecnativa, Odoo Community Association (OCA), Kaushal Prajapati",
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"application": False,
|
"application": False,
|
||||||
'installable': True,
|
"installable": True,
|
||||||
"data": [
|
"data": ["views/assets.xml"],
|
||||||
"views/assets.xml",
|
"depends": ["web"],
|
||||||
],
|
"qweb": ["static/src/xml/web_widget_image_download.xml"],
|
||||||
"depends": [
|
|
||||||
"web",
|
|
||||||
],
|
|
||||||
"qweb": [
|
|
||||||
"static/src/xml/web_widget_image_download.xml",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,30 @@
|
||||||
/* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
/* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
||||||
* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
|
* Copyright 2016 Jairo Llopis <jairo.llopis@tecnativa.com>
|
||||||
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
|
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
|
||||||
odoo.define('web_widget_image_download.widget', function (require) {
|
odoo.define("web_widget_image_download.widget", function(require) {
|
||||||
'use strict';
|
"use strict";
|
||||||
|
|
||||||
var FieldBinaryImage = require('web.basic_fields').FieldBinaryImage;
|
var FieldBinaryImage = require("web.basic_fields").FieldBinaryImage;
|
||||||
|
|
||||||
FieldBinaryImage.include({
|
FieldBinaryImage.include({
|
||||||
_render: function () {
|
_render: function() {
|
||||||
this._super();
|
this._super();
|
||||||
var $widget = this.$el.find('.o_form_binary_file_download');
|
var $widget = this.$el.find(".o_form_binary_file_download");
|
||||||
this.imgSrc = this.$el.find('img[name="' + this.name + '"]')
|
this.imgSrc = this.$el.find('img[name="' + this.name + '"]').attr("src");
|
||||||
.attr('src');
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'HEAD', // Avoid downloading full image, just headers
|
// Avoid downloading full image, just headers
|
||||||
|
type: "HEAD",
|
||||||
url: this.imgSrc,
|
url: this.imgSrc,
|
||||||
complete: function (xhr) {
|
complete: function(xhr) {
|
||||||
$widget.attr(
|
$widget.attr(
|
||||||
'download',
|
"download",
|
||||||
xhr.getResponseHeader("Content-Type")
|
xhr.getResponseHeader("Content-Type").replace("/", ".")
|
||||||
.replace('/', '.')
|
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
$widget.attr('href', this.imgSrc);
|
$widget.attr("href", this.imgSrc);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
.o_field_widget {
|
.o_field_widget {
|
||||||
&.o_field_image {
|
&.o_field_image {
|
||||||
.o_form_image_controls {
|
.o_form_image_controls {
|
||||||
> .fa, .o_form_binary_file_download {
|
> .fa,
|
||||||
|
.o_form_binary_file_download {
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
padding: 1px 0;
|
padding: 1px 0;
|
||||||
width: 33.333333%;
|
width: 33.333333%;
|
||||||
|
@ -23,11 +23,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@include media-breakpoint-down(xs, $o-extra-grid-breakpoints) {
|
@include media-breakpoint-down(xs, $o-extra-grid-breakpoints) {
|
||||||
.o_form_image_controls{
|
.o_form_image_controls {
|
||||||
.o_form_binary_file_download {
|
.o_form_binary_file_download {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
> .fa{
|
> .fa {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
||||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<t t-extend="FieldBinaryImage">
|
<t t-extend="FieldBinaryImage">
|
||||||
<t t-jquery=".o_select_file_button" t-operation="after">
|
<t t-jquery=".o_select_file_button" t-operation="after">
|
||||||
<t t-if="widget.value">
|
<t t-if="widget.value">
|
||||||
<a class="o_form_binary_file_download float-left" title="Download" aria-label="Download">
|
<a
|
||||||
<button class="fa fa-download fa-lg"/>
|
class="o_form_binary_file_download float-left"
|
||||||
|
title="Download"
|
||||||
|
aria-label="Download"
|
||||||
|
>
|
||||||
|
<button class="fa fa-download fa-lg" />
|
||||||
</a>
|
</a>
|
||||||
</t>
|
</t>
|
||||||
</t>
|
</t>
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
<!-- Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
|
||||||
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
|
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
|
||||||
|
|
||||||
<odoo>
|
<odoo>
|
||||||
|
|
||||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||||
<xpath expr=".">
|
<xpath expr=".">
|
||||||
<link rel="stylesheet"
|
<link
|
||||||
href="/web_widget_image_download/static/src/scss/web_widget_image_download.scss"/>
|
rel="stylesheet"
|
||||||
<script type="text/javascript"
|
href="/web_widget_image_download/static/src/scss/web_widget_image_download.scss"
|
||||||
src="/web_widget_image_download/static/src/js/web_widget_image_download.js"/>
|
/>
|
||||||
|
<script
|
||||||
|
type="text/javascript"
|
||||||
|
src="/web_widget_image_download/static/src/js/web_widget_image_download.js"
|
||||||
|
/>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue