Browse Source

Merge pull request #389 from Tecnativa/8.0-web_widget_image_download

[8.0][ADD] web_widget_image_download
pull/391/head
Sylvain LE GAL 8 years ago
committed by GitHub
parent
commit
b78144e507
  1. 59
      web_widget_image_download/README.rst
  2. 0
      web_widget_image_download/__init__.py
  3. 23
      web_widget_image_download/__openerp__.py
  4. BIN
      web_widget_image_download/static/description/icon.png
  5. 6
      web_widget_image_download/static/src/css/web_widget_image_download.css
  6. 16
      web_widget_image_download/static/src/js/web_widget_image_download.js
  7. 14
      web_widget_image_download/static/src/xml/web_widget_image_download.xml
  8. 18
      web_widget_image_download/views/assets.xml

59
web_widget_image_download/README.rst

@ -0,0 +1,59 @@
.. image:: https://img.shields.io/badge/licence-LGPL--3-blue.svg
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
:alt: License: LGPL-3
===========================
Web Widget - Image Download
===========================
This module was written to extend the functionality of the image widget and allows to download it.
Usage
=====
To use this module, you need to:
#. Go to the section `Contacts`.
#. Click on a contact.
#. Edit the contact.
#. Click the `Download` button (between `Edit` and `Clear`).
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/162/8.0
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/web/issues>`_. In case of trouble, please
check there if your issue has already been reported. If you spotted it first,
help us smashing it by providing a detailed and welcomed feedback.
Credits
=======
Images
------
* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.
Contributors
------------
* Flavio Corpa <flavio.corpa@tecnativa.com>
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit https://odoo-community.org.

0
web_widget_image_download/__init__.py

23
web_widget_image_download/__openerp__.py

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
{
"name": "Web Widget - Image Download",
"summary": "Allows to download the avatar for the contact",
"version": "8.0.1.0.0",
"category": "web",
"website": "https://www.tecnativa.com",
"author": "Tecnativa, Odoo Community Association (OCA)",
"license": "LGPL-3",
"application": False,
"installable": True,
"data": [
"views/assets.xml",
],
"depends": [
"web",
],
"qweb": [
"static/src/xml/web_widget_image_download.xml",
]
}

BIN
web_widget_image_download/static/description/icon.png

After

Width: 128  |  Height: 128  |  Size: 17 KiB

6
web_widget_image_download/static/src/css/web_widget_image_download.css

@ -0,0 +1,6 @@
/* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). */
.openerp .oe_application a.oe_form_binary_file_download {
color: #eee;
}

16
web_widget_image_download/static/src/js/web_widget_image_download.js

@ -0,0 +1,16 @@
/*
* Copyright 2016 Flavio Corpa <flavio.corpa@tecnativa.com>
* License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
*/
openerp.web_widget_image_download = function(instance) {
'use strict';
instance.web.form.web_widget_image_download = instance.web.form.FieldBinaryImage.include({
render_value() {
this._super();
// take image URI from preceding <img> tag
this.$el.find('.oe_form_binary_file_download').attr('href', $('img[name="image"]').attr('src'));
}
});
}

14
web_widget_image_download/static/src/xml/web_widget_image_download.xml

@ -0,0 +1,14 @@
<?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=".oe_form_binary_file_edit" t-operation="after">
<a class="fa fa-download fa-1g col-md-4 oe_form_binary_file_download" title="Download" download="image.png"></a>
</t>
<t t-jquery=".oe_form_binary_file_clear" t-operation="replace">
<i class="fa fa-trash-o fa-1g oe_form_binary_file_clear" title="Clear"/>
</t>
</t>
</template>

18
web_widget_image_download/views/assets.xml

@ -0,0 +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). -->
<openerp>
<data>
<template id="assets_backend" inherit_id="web.assets_backend">
<xpath expr=".">
<link rel="stylesheet"
href="/web_widget_image_download/static/src/css/web_widget_image_download.css"/>
<script type="text/javascript"
src="/web_widget_image_download/static/src/js/web_widget_image_download.js"/>
</xpath>
</template>
</data>
</openerp>
Loading…
Cancel
Save