From 3c5194a00b3c0525dfd84552233e9c8f85a150f4 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Fri, 22 Nov 2019 11:37:09 +0000 Subject: [PATCH] [ADD] web: Custom File Input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New component: the custom file input. Its purpose is to define a input of type file with a custom trigger (button, link, etc.). Its construction is the following: - attributes: behaviour of the actual input (route to call, multifile, allowed extensions etc.) - inner template: the trigger that will fire the upload prompt when clicked Once a file has been uploaded, the component will emit a 'uploaded' custom event containing the files. closes odoo/odoo#38423 Related: odoo/enterprise#6031 Signed-off-by: Géry Debongnie (ged) --- addons/web/controllers/main.py | 8 +- .../src/js/components/custom_file_input.js | 88 +++++++++++++++ addons/web/static/src/xml/base.xml | 15 +++ .../components/custom_file_input_tests.js | 103 ++++++++++++++++++ addons/web/views/webclient_templates.xml | 3 + 5 files changed, 213 insertions(+), 4 deletions(-) create mode 100644 addons/web/static/src/js/components/custom_file_input.js create mode 100644 addons/web/static/tests/components/custom_file_input_tests.js diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index b1e86ff2643..90657b2e764 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1469,7 +1469,7 @@ class Binary(http.Controller): @http.route('/web/binary/upload', type='http', auth="user") @serialize_exception - def upload(self, callback, ufile): + def upload(self, ufile, callback=None): # TODO: might be useful to have a configuration flag for max-length file uploads out = """ + @@ -715,6 +716,8 @@ + +