Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] web,web_editor: make image upload work without iframe #31208

Open
wants to merge 8 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@seb-odoo
Copy link
Contributor

seb-odoo commented Feb 18, 2019

This makes the code easier to understand and to maintain.

Part of task 1930726

@seb-odoo seb-odoo self-assigned this Feb 18, 2019

@robodoo robodoo added the seen 🙂 label Feb 18, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:master-filesize-seb branch 2 times, most recently Feb 18, 2019

@seb-odoo seb-odoo changed the title [IMP] web,web_editor: make image upload works without iframe [IMP] web,web_editor: make image upload work without iframe Feb 18, 2019

@seb-odoo seb-odoo requested a review from qsm-odoo Feb 18, 2019

@seb-odoo

This comment has been minimized.

Copy link
Contributor Author

seb-odoo commented Feb 18, 2019

As discussed with @JKE-be

@seb-odoo seb-odoo force-pushed the odoo-dev:master-filesize-seb branch to 11a9f77 Feb 19, 2019

@seb-odoo

This comment has been minimized.

Copy link
Contributor Author

seb-odoo commented Feb 19, 2019

  • I renamed the method.
  • I double checked the xhr progress, it works nicely with the code I used. (we can consider showing a progress bar to the user if that's something we want functionally)
  • I added a note about older browser support in the commit.
  • I checked for the http route returning a json, and there is no easy way.

According to this answer: https://stackoverflow.com/a/4083908

You basically have three choices:

  • Base64 encode the file, at the expense of increasing the data size by around 33%.
  • Send the file first in a multipart/form-data POST, and return an ID to the client. The client then sends the metadata with the ID, and the server re-associates the file and the metadata.
  • Send the metadata first, and return an ID to the client. The client then sends the file with the ID, and the server re-associates the file and the metadata.

So either we keep the current solution: we send the multipart/form-data to our 'html' route and return a json.

Or we absolutely want to use RPC + json route for the data, then we need to do either of the above: base64 encode or create 2 routes.

@qsm-odoo
Copy link
Contributor

qsm-odoo left a comment

If it works, it seems ok to me.
@robodoo delegate+

action="/web_editor/attachment/add"
enctype="multipart/form-data"
t-att-target="iframeName">
<form>

This comment has been minimized.

@qsm-odoo

qsm-odoo Feb 19, 2019

Contributor

I would have left the action attribute here and read it in JS, but it is the same.

@seb-odoo seb-odoo force-pushed the odoo-dev:master-filesize-seb branch 2 times, most recently Feb 22, 2019

@seb-odoo seb-odoo force-pushed the odoo-dev:master-filesize-seb branch to 43bd973 Mar 4, 2019

@@ -2,16 +2,16 @@ odoo.define('wysiwyg.widgets.AltDialog', function (require) {
'use strict';

var core = require('web.core');
var Dialog = require('wysiwyg.widgets.Dialog');
var SummernoteDialog = require('wysiwyg.widgets.Dialog');

This comment has been minimized.

@JKE-be

JKE-be Mar 8, 2019

Contributor

purpose is to remove summernote ;)
so avoid reference to ;)

seb-odoo added some commits Feb 22, 2019

wip
wip
wip

@seb-odoo seb-odoo force-pushed the odoo-dev:master-filesize-seb branch from bb4ecd9 to ee40ce2 Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.