mirror of https://github.com/OCA/web.git
[MIG] web_drop_target : Migration to 11.0
parent
93f60ddc3e
commit
2491b71139
|
@ -22,7 +22,7 @@ To use this module, you need to:
|
||||||
|
|
||||||
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
|
||||||
:alt: Try me on Runbot
|
:alt: Try me on Runbot
|
||||||
:target: https://runbot.odoo-community.org/runbot/162/10.0
|
:target: https://runbot.odoo-community.org/runbot/162/11.0
|
||||||
|
|
||||||
Known issues / Roadmap
|
Known issues / Roadmap
|
||||||
======================
|
======================
|
||||||
|
@ -31,6 +31,7 @@ Known issues / Roadmap
|
||||||
* handle multiple files
|
* handle multiple files
|
||||||
* add an upload progress meter for huge files
|
* add an upload progress meter for huge files
|
||||||
* trigger custom events about different stages of the drop operation for other addons to hook in
|
* trigger custom events about different stages of the drop operation for other addons to hook in
|
||||||
|
* Install document module to display attachments in the sidebar
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
@ -57,6 +58,7 @@ Contributors
|
||||||
------------
|
------------
|
||||||
|
|
||||||
* Holger Brunn <hbrunn@therp.nl>
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
||||||
|
|
||||||
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
|
Do not contact contributors directly about help with questions or problems concerning this addon, but use the `community mailing list <mailto:community@mail.odoo.com>`_ or the `appropriate specialized mailinglist <https://odoo-community.org/groups>`_ for help, and the bug tracker linked in `Bug Tracker`_ above for technical issues.
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,2 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2018 Therp BV <https://therp.nl>
|
# Copyright 2018 Therp BV <https://therp.nl>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Copyright 2018 Therp BV <https://therp.nl>
|
# Copyright 2018 Therp BV <https://therp.nl>
|
||||||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
{
|
{
|
||||||
"name": "Drop target support",
|
"name": "Drop target support",
|
||||||
"version": "10.0.1.0.0",
|
"version": "11.0.1.0.0",
|
||||||
"author": "Therp BV,Odoo Community Association (OCA)",
|
"author": "Therp BV,Odoo Community Association (OCA)",
|
||||||
"website": "https://github.com/OCA/web",
|
"website": "https://github.com/OCA/web",
|
||||||
"license": "AGPL-3",
|
"license": "AGPL-3",
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
* Holger Brunn <hbrunn@therp.nl>
|
||||||
|
* Akim Juillerat <akim.juillerat@camptocamp.com>
|
|
@ -0,0 +1,5 @@
|
||||||
|
This module extends the functionality of the web client to support dropping local files into the web client.
|
||||||
|
|
||||||
|
By default, an attachment will be created when dropping a file on a form.
|
||||||
|
|
||||||
|
Further, this module is meant as a base drag&drop module supporting other actions after some file is dropped so that other modules can add more features.
|
|
@ -0,0 +1,4 @@
|
||||||
|
Libraries
|
||||||
|
---------
|
||||||
|
|
||||||
|
* `base64js <https://raw.githubusercontent.com/beatgammit/base64-js>`_.
|
|
@ -0,0 +1,5 @@
|
||||||
|
* dropping on list or kanban views would be nice too
|
||||||
|
* handle multiple files
|
||||||
|
* add an upload progress meter for huge files
|
||||||
|
* trigger custom events about different stages of the drop operation for other addons to hook in
|
||||||
|
* Install document module to display attachments in the sidebar
|
|
@ -0,0 +1,4 @@
|
||||||
|
To use this module, you need to:
|
||||||
|
|
||||||
|
#. drag a file from your local computer onto an Odoo form view
|
||||||
|
#. it should become an attachment of the currently opened record
|
|
@ -1,11 +1,9 @@
|
||||||
//-*- coding: utf-8 -*-
|
|
||||||
//Copyright 2018 Therp BV <https://therp.nl>
|
//Copyright 2018 Therp BV <https://therp.nl>
|
||||||
//License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
//License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
|
||||||
/*global Uint8Array base64js*/
|
/*global Uint8Array base64js*/
|
||||||
|
|
||||||
odoo.define('web_drop_target', function(require) {
|
odoo.define('web_drop_target', function(require) {
|
||||||
var Model = require('web.Model'),
|
var FormController = require('web.FormController');
|
||||||
FormView = require('web.FormView');
|
|
||||||
|
|
||||||
// this is the main contribution of this addon: A mixin you can use
|
// this is the main contribution of this addon: A mixin you can use
|
||||||
// to make some widget a drop target. Read on how to use this yourself
|
// to make some widget a drop target. Read on how to use this yourself
|
||||||
|
@ -79,20 +77,19 @@ odoo.define('web_drop_target', function(require) {
|
||||||
) {
|
) {
|
||||||
// helper to upload an attachment and update the sidebar
|
// helper to upload an attachment and update the sidebar
|
||||||
var self = this;
|
var self = this;
|
||||||
return new Model('ir.attachment').call(
|
return this._rpc({
|
||||||
'create',
|
model: 'ir.attachment',
|
||||||
[
|
method: 'create',
|
||||||
_.extend({
|
args: [{
|
||||||
name: drop_file.name,
|
'name': drop_file.name,
|
||||||
datas: base64js.fromByteArray(
|
'datas': base64js.fromByteArray(
|
||||||
new Uint8Array(e.target.result)
|
new Uint8Array(e.target.result)
|
||||||
),
|
),
|
||||||
datas_fname: drop_file.name,
|
'datas_fname': drop_file.name,
|
||||||
res_model: res_model,
|
'res_model': res_model,
|
||||||
res_id: res_id,
|
'res_id': res_id,
|
||||||
}, extra_data || {})
|
}],
|
||||||
]
|
})
|
||||||
)
|
|
||||||
.then(function() {
|
.then(function() {
|
||||||
// try to find a sidebar and update it if we found one
|
// try to find a sidebar and update it if we found one
|
||||||
var p = self;
|
var p = self;
|
||||||
|
@ -101,9 +98,9 @@ odoo.define('web_drop_target', function(require) {
|
||||||
}
|
}
|
||||||
if(p) {
|
if(p) {
|
||||||
var sidebar = p.sidebar;
|
var sidebar = p.sidebar;
|
||||||
sidebar.do_attachement_update(
|
if(sidebar && _.isFunction(sidebar._onFileUploaded)) {
|
||||||
sidebar.dataset, sidebar.model_id
|
sidebar._onFileUploaded();
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -111,7 +108,7 @@ odoo.define('web_drop_target', function(require) {
|
||||||
|
|
||||||
// and here we apply the mixin to form views, allowing any files and
|
// and here we apply the mixin to form views, allowing any files and
|
||||||
// adding them as attachment
|
// adding them as attachment
|
||||||
FormView.include(_.extend(DropTargetMixin, {
|
FormController.include(_.extend(DropTargetMixin, {
|
||||||
_get_drop_file: function() {
|
_get_drop_file: function() {
|
||||||
// disable drag&drop when we're on an unsaved record
|
// disable drag&drop when we're on an unsaved record
|
||||||
if(!this.datarecord.id) {
|
if(!this.datarecord.id) {
|
||||||
|
@ -121,7 +118,7 @@ odoo.define('web_drop_target', function(require) {
|
||||||
},
|
},
|
||||||
_handle_file_drop: function(drop_file, e) {
|
_handle_file_drop: function(drop_file, e) {
|
||||||
return this._handle_file_drop_attach(
|
return this._handle_file_drop_attach(
|
||||||
drop_file, e, this.dataset.model, this.datarecord.id
|
drop_file, e, this.renderer.state.model, this.renderer.state.res_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<openerp>
|
<odoo>
|
||||||
<data>
|
<template id="assets_backend" name="web_drop_target assets" inherit_id="web.assets_backend">
|
||||||
<template id="assets_backend" name="web_drop_target assets" inherit_id="web.assets_backend">
|
<xpath expr="." position="inside">
|
||||||
<xpath expr="." position="inside">
|
<script type="text/javascript" src="/web_drop_target/static/lib/base64js.min.js"></script>
|
||||||
<script type="text/javascript" src="/web_drop_target/static/lib/base64js.min.js"></script>
|
<script type="text/javascript" src="/web_drop_target/static/src/js/web_drop_target.js"></script>
|
||||||
<script type="text/javascript" src="/web_drop_target/static/src/js/web_drop_target.js"></script>
|
<link rel="stylesheet" href="/web_drop_target/static/src/css/web_drop_target.css"/>
|
||||||
<link rel="stylesheet" href="/web_drop_target/static/src/css/web_drop_target.css"/>
|
</xpath>
|
||||||
</xpath>
|
</template>
|
||||||
</template>
|
</odoo>
|
||||||
</data>
|
|
||||||
</openerp>
|
|
||||||
|
|
Loading…
Reference in New Issue