Browse Source

Merge 69527f3558 into d736ee4460

pull/1181/merge
Florent de Labarre 5 years ago
committed by GitHub
parent
commit
607aec2d24
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 21
      web_widget_image_paste_clipboard/README.rst
  2. 0
      web_widget_image_paste_clipboard/__init__.py
  3. 15
      web_widget_image_paste_clipboard/__manifest__.py
  4. 1
      web_widget_image_paste_clipboard/readme/CONTRIBUTORS.rst
  5. 4
      web_widget_image_paste_clipboard/readme/DESCRIPTION.rst
  6. 14
      web_widget_image_paste_clipboard/readme/USAGE.rst
  7. BIN
      web_widget_image_paste_clipboard/static/description/icon.png
  8. 40
      web_widget_image_paste_clipboard/static/src/js/basic_fields.js
  9. 8
      web_widget_image_paste_clipboard/static/src/xml/base.xml
  10. 8
      web_widget_image_paste_clipboard/templates/assets.xml

21
web_widget_image_paste_clipboard/README.rst

@ -0,0 +1,21 @@
**This file is going to be generated by oca-gen-addon-readme.**
*Manual changes will be overwritten.*
Please provide content in the ``readme`` directory:
* **DESCRIPTION.rst** (required)
* INSTALL.rst (optional)
* CONFIGURE.rst (optional)
* **USAGE.rst** (optional, highly recommended)
* DEVELOP.rst (optional)
* ROADMAP.rst (optional)
* HISTORY.rst (optional, recommended)
* **CONTRIBUTORS.rst** (optional, highly recommended)
* CREDITS.rst (optional)
Content of this README will also be drawn from the addon manifest,
from keys such as name, authors, maintainers, development_status,
and license.
A good, one sentence summary in the manifest is also highly recommended.

0
web_widget_image_paste_clipboard/__init__.py

15
web_widget_image_paste_clipboard/__manifest__.py

@ -0,0 +1,15 @@
# Copyright 2019 Florent de Labarre
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
'name': "Web Widget Image Paste Clipboard",
'summary': "Allow to paste an image from clipboard in Image field.",
'author': "Florent de Labarre, Odoo Community Association (OCA)",
'category': 'Web',
'website': 'https://github.com/OCA/web',
'version': '11.0.1.0.0',
'depends': ['web'],
'data': ['templates/assets.xml'],
'qweb': ['static/src/xml/base.xml'],
'installable': True,
'license': 'AGPL-3',
}

1
web_widget_image_paste_clipboard/readme/CONTRIBUTORS.rst

@ -0,0 +1 @@
* Florent de Labarre <florent.mirieu@gmail.com>

4
web_widget_image_paste_clipboard/readme/DESCRIPTION.rst

@ -0,0 +1,4 @@
[ This file must be max 2-3 paragraphs, and is required. ]
This module add the possibility to paste an image in binary image field.
Works with Google Chrome

14
web_widget_image_paste_clipboard/readme/USAGE.rst

@ -0,0 +1,14 @@
[ This file must be present and contains the usage instructions
for end-users. As all other rst files included in the README,
it MUST NOT contain reStructuredText sections
only body text (paragraphs, lists, tables, etc). Should you need
a more elaborate structure to explain the addon, please create a
Sphinx documentation (which may include this file as a "quick start"
section). ]
To use this module, you need to:
#. Copy an image (from : Paint, Gimps, Google Image, ...)
#. Edit a record with image field
#. Click on the paste Icon (between Edit icon and Delete Icon)
#. Press Ctrl + V (or Cmd + V on MacOS)

BIN
web_widget_image_paste_clipboard/static/description/icon.png

After

Width: 200  |  Height: 200  |  Size: 4.6 KiB

40
web_widget_image_paste_clipboard/static/src/js/basic_fields.js

@ -0,0 +1,40 @@
odoo.define('web_widget_image_paste_clipboard.FieldBinaryImage', function(require) {
"use strict";
var basicFields = require('web.basic_fields');
basicFields.FieldBinaryImage.include({
_render: function() {
this._super.apply(this, arguments);
var self = this;
function handlePaste(event) {
if (self.mode == 'edit') {
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
var blob = null;
if (items) {
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") === 0) {
blob = items[i].getAsFile();
break;
}
}
if (blob != null) {
var filereader = new FileReader();
filereader.readAsDataURL(blob);
filereader.onloadend = function(upload) {
var data = upload.target.result;
data = data.split(',')[1];
self.on_file_uploaded(blob.size, 'paste_image', blob.type, data);
};
}
}
}
}
this.$('.o_paste_image').on("paste", handlePaste);
},
});
});

8
web_widget_image_paste_clipboard/static/src/xml/base.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="FieldBinaryImage">
<t t-jquery=".o_clear_file_button" t-operation="after">
<span class="fa fa-clipboard o_paste_image" title="Click here and Paste"/>
</t>
</t>
</templates>

8
web_widget_image_paste_clipboard/templates/assets.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="assets_backend" name="web_paste_image_assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<script type="text/javascript" src="/web_widget_image_paste_clipboard/static/src/js/basic_fields.js"></script>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save