mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_widget_image_download: black, isort
This commit is contained in:
@@ -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 () {
|
||||
_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) {
|
||||
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);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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%;
|
||||
@@ -23,11 +23,11 @@
|
||||
}
|
||||
}
|
||||
@include media-breakpoint-down(xs, $o-extra-grid-breakpoints) {
|
||||
.o_form_image_controls{
|
||||
.o_form_image_controls {
|
||||
.o_form_binary_file_download {
|
||||
display: none;
|
||||
}
|
||||
> .fa{
|
||||
> .fa {
|
||||
width: 50%;
|
||||
padding: 6px;
|
||||
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>
|
||||
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">
|
||||
<button class="fa fa-download fa-lg"/>
|
||||
<a
|
||||
class="o_form_binary_file_download float-left"
|
||||
title="Download"
|
||||
aria-label="Download"
|
||||
>
|
||||
<button class="fa fa-download fa-lg" />
|
||||
</a>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
Reference in New Issue
Block a user