Commit Graph
95 Commits
Author SHA1 Message Date
Thanh Dodeur c212cfe899 [REF] *: removes datas_fname from ir.attachment
This commit removes the field `datas_fname` from `ir.attachment` as
it was unnecessary and most of the time the duplicate of `name` or
`url`.

Task #1909865

closes odoo/odoo#32976

Signed-off-by: Martin Geubelle (mge) <mge@openerp.com>
2019-06-05 09:12:13 +00:00
Sébastien Theys 87a35d4263 [IMP] web, web_editor, *: add media image optimize dialog
* = website, website_blog

The goal is to give the user an opportunity to optimize his images before using
them.

For this we introduce a preview/configuration dialog after every image upload,
where appropriate default values are filled for the quality and resolution,
based on where the image is going to be used. Since this is not going to be
perfect all the time, we still allow the user to configure them, and we display
a preview to ease this process.

Indeed it is important for SEO and for usability in general that the images are
as light as possible in size.

Technically the original image is uploaded and saved first, and then it can be
optimized. This way the upload only happens once, and the preview can be
computed from the already saved image.

task-1930726
PR: #31208
2019-06-04 22:14:13 +02:00
Sébastien Theys 76cf2ae82a [IMP] web_editor, *: improve media dialog attachment upload
* = web_unsplash, website

Remove iframe upload and replace it with a proper RPC. The route is now only
accepting one file at a time, which makes it easier to maintain, and allows to
process the first file as soon as it is ready, instead of having to wait on
everything.

Also fix a bug where a document could not be uploaded because it would try to
parse it as an image.

Remove filter after search result from the JS and add the corresponding
conditions in the domain to avoid processing and returning unnecessary records.

If multiple attachments exist with the same URL, now display them all to avoid
confusion.

Compute all the necessary values in the python model instead of in the JS.

Allow SVG in the widget (the server already accepted them before).

Disable multiple image upload when not in multiImages mode.

task-1930726
PR: #31208
2019-06-04 22:14:13 +02:00
Sébastien Theys 191c556d6b [IMP] web_editor, *: improve file media widget views & selection
* = web_unsplash, website_blog

Rename "image" to "attachment" when appropriate in FileWidget

Improve image selection / highlight code (now based on attachment id)

Improve image grid view:
 - Remove the row mechanism and replace it by a single loop over the images.
 - Take advantage of row wrap for a responsive display.
 - Uniformize the height (prevent tall images from moving down everything).
 - Load a miniature of the images when possible, remove the loading placeholder.
 	This should significantly reduce the download size when opening the dialog,
 	at the cost of CPU usage on the server.
 - Split the existing image view into one view for the loop and one view for the
 	image itself. This way in a following commit we can reuse the image view
 	when adding a new one, instead of having to render everything again.

task-1930726
PR: #31208
2019-06-04 22:14:13 +02:00
Martin Trigaux 5a6a414e2c [MERGE] Forward port of saas-12.4 to master up to aadc4a9f0b 2019-07-22 14:47:52 +02:00
Martin Trigaux 5d57e1862f [MERGE] Forward port of saas-12.4 to master up to beba36416f
closes odoo/odoo#34924

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-16 15:45:24 +00:00
Yannick Tivisse 14067543d0 [IMP] uom: Remove parentheses on uom names
Purpose
=======

Parentheses in the label of units of measure sometimes make
reading needlessly uncomfortable.

Specification
=============

Remove parentheses in the name of every standard uom.uom and hardcoded
occurence on views/field names.

TaskID: 2030444

closes odoo/odoo#34492

Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
2019-07-15 12:57:34 +00:00
Christophe Simonis a97037c6d4 [MERGE] forward port branch saas-12.2 up to 78b3b650b0 2019-05-06 12:27:51 +02:00
Antoine Guenet 706bf85512 [FIX] web_editor: disable tooltips in keyboard tests and on option off
The link and media tooltips were not taking Summernote's `tooltip`
option into account. That option ensures that tooltips are disabled if
the option is off (which is for instance the case on mobile).
This fix ensures that these tooltips are disabled when the option is
set to `false`.
It also disables tooltips in the keyboard tests. They are not relevant
to the keyboard tests and occasionally caused the DOM to not be properly
cleaned after the tests were run (most likely due to their 2000ms
`setTimeout`).
2019-04-19 10:23:21 +00:00
Gorash 9fd27ff101 [FIX] web_editor: indent multiple lines at a time with editable as parent 2019-05-13 07:40:36 +00:00
Antoine Guenet 6951521278 [FIX] web_editor: properly unformat text at the start of the DOM
When trying to remove a format (bold, italic, underline), collapsed at
the start of the DOM, an error occurred because of a wrong range.
Ex.: `<p><b>Odoo</b></p>` -> when clicking before the word "Odoo", then
clicking the "bold" button, we expect to be able to start writing in
plain (not bold) text (for that, the DOM has to look like this:
`<p>\u200B<b>Odoo</b></p>`). We now have that proper behavior without
the accompanying error message and loss of selection.

Task ID: 1978515

closes odoo/odoo#33038

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-04-30 08:45:05 +00:00
Sébastien Theys b0acd056e9 [IMP] web_editor: clean up media file widget selectors
Avoid selectors based on DOM structure, use classes whenever possible.
Register all the selectors in start to avoid searching the DOM multiple times.
No functional change.

PR: #33509
2019-05-27 16:32:52 +00:00
Sébastien Theys 277c30e7e6 [IMP] web_editor, website: clean up media dialog
Restructure the code in a more logical manner. No functional change.

PR: #33509
2019-05-27 16:32:52 +00:00
Sébastien Theys 8ab696dc82 [IMP] web_editor, web_unsplash: split media widget (image & document)
The common code is kept in a generic File widget, while the split allows for
easier customization.

PR: #33509
2019-05-27 16:32:52 +00:00
Christophe Simonis 8dd5a85267 [MERGE] forward port branch saas-12.3 up to 60e71302a3 2019-05-13 15:26:12 +02:00
Antoine Guenet 27eb8ba617 [FIX] web_editor, website: never indent/outdent list groups
The "comparisons" website snippet uses a list group with the class set
on a UL. In consequence, the web editor considers it as a regular list
and may try to outdent it, which is not the expected behavior with a
list group. This fix ensures that ULs with the `list-group` class cannot
be in/outdented.

closes odoo/odoo#32709

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-04-25 10:03:14 +00:00
Antoine Guenet cb9263a823 [FIX] web_editor: properly merge a LI with text with a LI with text in P
A list item with text can be written as <li>text</li> or as
<li><p>text</p></li>. Issues occurred when both syntaxes need to be
merged together. Namely, the <p>text</p> was being appended to the other
list item, thereby creating a visible new line.
2019-04-25 10:03:05 +00:00
Antoine Guenet 41088bb311 [FIX] web_editor: properly handle delete in nested lists of all syntaxes
This addresses various bugs that occured with nested lists - including
lists that are nested with a UL within a LI (as opposed to a UL directly
within another UL).
2019-04-25 10:03:00 +00:00
Antoine Guenet 8e89ffb175 [FIX] web_editor: properly convert a checklist to an ordered list
The `o_checklist` class was preserved when converting a checklist to an
ordered list.
2019-04-25 10:00:43 +00:00
Antoine Guenet 17aff7b59b [FIX] web_editor: uncheck new checklist item on split
On ENTER in a checklist item, a new checklist item is created. The new
one should never be checked. This ensures that ENTER in a checked
checklist item never creates a checked checklist item but instead cleans
the class.

closes odoo/odoo#32684

Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-04-15 11:40:05 +00:00
mgh-odoo f217aa528f [FIX]web_editor: Fixed traceback due to 'field_html' widget while saving record
Previously, when user edited record having 'field_html' widget and
tried to save the record immediately, a traceback was faced sometimes
because content was not loaded yet. This commit fixes the issue
by calling super method if the content is not loaded yet properly.

Task: #1932687
Closes: #30833

closes odoo/odoo#31581

Signed-off-by: VincentSchippefilt <VincentSchippefilt@users.noreply.github.com>
2019-03-05 09:09:33 +00:00
Antoine Guenet 4339101afe [IMP] web_editor: add tests for deleting all contents of format block
Implementing new behavior on delete all contents of a format block
revealed insufficient testing, which is now covered.

closes odoo/odoo#31277
2019-02-21 09:13:32 +00:00
Antoine Guenet 2a010c38f3 [FIX] web_editor: remove broken and unnecessary test
The next test was identical to the removed one, with the exception that
it inserts a character at the end, which really is the behavior we want
to test. The removed test was broken because it expected the range on
the parent, which is anyway equivalent in this case. This is confirmed
by the fact that inserting a character at either ranges indeed inserts
the character where it is expected to do so.
2019-02-21 09:13:31 +00:00
Raphael Collet 1ced3bfca4 [FIX] *: pass context in kwargs in rpc calls 2019-03-22 16:42:08 +00:00
Christophe Simonis 44515bc7be [MERGE] forward port branch saas-12.2 up to c9f832d9f0
closes odoo/odoo#31790

Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-13 14:24:51 +00:00
David Monjoie 455a9c9d58 [FIX] web_editor: fix non-deterministic tests
Those tests were skipped because they were failing
non-deterministically.

This commit aims to make them deterministic by putting back some
guard promises that were lost during the jquery update adaptation.

This commit also fixes a lingering issue with one of the asserts.
We observed that sometimes, the "alt" and "title" attributes where
both present on the element but displayed in different order in
the string returned by wysiwyg.getValue(). This is because there
is no set order in the attribute returned by jQuery.html().
Because of that, I replaced the simple sring test by a thorough
manual comparison of the result that is expected to be equivalent.

closes odoo/odoo#31671

Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
2019-03-08 09:00:31 +00:00
Vincent Schippefilt 7a665ca92a [FIX] web_editor: temporarily skip two tests
Those two tests non deterministically fail on the jQuery branch.
We'll fix them after the merge.
2019-03-06 20:07:17 +01:00
2e8222dee7 [REF] web_editor: adapt code after jQuery update
Part of task 1896658

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-03-06 20:07:17 +01:00
Christophe Matthieu b49745e52d [IMP] web_editor: lazy load the wysiwyg
Issue: wysiwyg asset slow down the loading of the website, error
inadvertently introduced: https://github.com/odoo/odoo/pull/29775

The assets are now loaded assynchroneously, when the editor is needed,
its assets will be loaded.

closes odoo/odoo#30700
2019-02-14 15:11:19 +00:00
Antoine Guenet eea58a3cf8 [FIX] web_editor: on anchor split, rerange and clean data on getValue
Due to a wrong order of operations, after splitting an anchor (press
ENTER), the range was setting on the first anchor. Now it sets on the
second one (as the code - but not the tests - suggests was supposed to
happen). Tests were adapted to reflect that change.

In tests, after splitting the anchor, `Wysiwyg.getValue` didn't always
properly clean up `data-original-title`. Targetting empty
`data-original-title` attribute instead of `aria-describedby` attribute
should fix that issue.

closes odoo/odoo#30923
2019-02-07 10:20:57 +00:00
Antoine Guenet 48cb3c71d1 [IMP] web_editor: handle CTRL+A (and then DELETE) locally
This fixes issues with CTRL+A then delete.
Now CTRL+A selects all the contents of the unbreakable node in
which the range is contained. Deleting it all will replace the contents
with `<p><br></p>` so the user can start editing afresh.

Note: Only CTRL+A is handled: ``select all`` in contextual and edit
menus are still handled by the browser.

closes odoo/odoo#30648
2019-02-04 09:44:18 +00:00
Antoine Guenet a27837a000 [FIX] web_editor: properly disable the toolbar on snippet removal
Update editor toolbar on each change to properly disable it when needed

closes odoo/odoo#30594
2019-01-29 07:54:58 +00:00
Antoine GuenetandGorash eb0ea8efbe [ADD] web_editor,*: Tests for new structure of web editor
The refactoring also had to be done in order to create a set of unit
tests.
Each behavior can be tested, including the behaviors performed as a
consequence of keyboard interactions (for instance: Enter, Tab...).
This commit also contains some changes to test_utils that were
necessary given the new structure of the wysiwyg editor.

Co-authored-by: Gorash <chm@odoo.com>
2019-01-17 08:40:21 +00:00
Christophe Matthieu de444335b7 [REF] web_editor,*: Move and rename files to prepare refactoring
The refactoring of the wysiwyg editor and 'html' field allows us to
move some of the code that was in web_editor but only used in website or
in mass_mailing. Some parts are still in web_editor but will be
moved at a later time.
2019-01-17 08:40:21 +00:00
40dd121938 [REF] web: move ControlPanel inside controllers/actions
This branch introduces a large-scale reorganization of the
component tree generated by the web client.  The short version is
that now, the control panel is a child of the view controller and
no longer a sibling. Graphically (and simplified), we go from
this:

                  webClient
                 /    |    \
               ...   ...  actionManager
                           /         \
                   controlPanel   viewController
                                    /       \

to this:

           	  webClient
                 /    |    \
               ...   ...  actionManager
                               |
                          viewController
                            /   |   \
          ControlPanelController
              /           \
         CPRenderer     CPModel

The motivation is that this work moves the code where it should be.
Before this commit, it was kind of weird to have code in the
controllers to render buttons outside of their root node (in
renderButtons).  Also, the action manager had to take care of
coordinating search view states between view transitions.

So, this work simplifies the code.  It also makes it easier to
extend. We see day after day that Odoo needs to take care of more
complex UI needs, and in many cases, these needs were quite
difficult to implement (we prefer spaghettis in our plates, not in
our code).  The changes in this branch should open the way to
implement these features.

For example,
- it will now be easy to add the possibility of views (for example,
  the search view or a new ControlPanel view) to add custom buttons
  (of type action or object) in the control panel.
- Another need will be to serialize/ restore the state of the
  search view across action boundaries (needed by the dashboard).
- Another example is the possibility for views to customize easily
  the presence/absence of sub menus (filters/groupbys/favorites/
  time range/...)
- Another need is an easier way for views/client action to customize
  their control panel.

This commit also contains a large rewrite of the search view (so it
is more inline with our architecture and easier to maintain).

Part of task 1893568

Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
2018-12-07 13:16:06 +00:00
Géry Debongnie abf32b8b21 [REF] *: update js test suite to use helpers
This rev. introduces robust helpers to use in the JS tests suite to
interact with DOM and components, and starts using them (almost)
everywhere.

All the helpers are exposed though testUtils.js.

There are 2 kinds of helpers:

1. Assertions
-------------
 * assert.containsNone, containsN, containsOnce check that the DOM
   (or a specific part of the DOM) contains a `selector`. It
   generates a correct error message automatically.
    ex: assert.strictEqual(form.$('.o_form_editable'), 1, "msg");
        -> assert.containsOnce(form, '.o_form_editable');
 * assert.isVisible, isNotVisible check that the DOM has an element
   visible or not. They also check that the element is actually in
   the DOM (before most tests didn't verify this).
 * assert.hasClass, doesNotHaveClass, hasAttrVAlue, check specific
   properties of a DOM element, and also validate that it is
   applied on a single existing DOM element (before most tests
   didn't verify this).
    ex: assert.notOk(form.$('button').hasClass('btn-primary'));
       -> assert.doesNotHaveClass(form.$('button'), 'btn-primary');

2. Utilities
------------
The goal of the utilities is to centralize the definition of many
standard components and interactions, ensuring that when we
refactor the JS framework, we do not need to change all the tests.

Existing mock utilities (addMockEnvironment, intercept, path,
patchDate, unpatch and fieldsViewGet) are moved to
'testUtils.mock.*'.
Existing DOM utilities are moved to 'testUtils.dom.*'.
New dom utilities are created for opendDatePicker, click,
clickFirst and clickLast. Helper `click` verifies that there is
exactly 1 element visible in the DOM you click on, `clickFirst`
and `clickLast` verify that there are more than one element on the
DOM.
 ex: form.$('button').click();
     -> testUtils.dom.click(form.$('button'));

New Form utilities: (testUtils.form.*)
 clickEdit, clickSave, clickCreate, clickDiscard, all clicks on
 the control panel buttons of the form.
 `reload` reloads the form data.

New modal, graph, kanban and pivot utils (testUtils.pivot.*,
testUtils.kanban.*, etc.).

New fields utils: (testUtils.fields.*)
 * editInput, editSelect: allow to change the value of a field,
   using a selector to identify it. They validate that the input
   exists and trigger the change event automatically.
 * editAndTrigger: allow to modify a field and trigger specific
   events after the value change
 * many2one (testUtils.fields.many2one.*)
   clickOpenDropdown, clickHighlightedItem, clickItem,
   searchAndClickItem: use a field name instead of a selector and
   do all the complex mechanism to open, filter and highlight
   many2one fields.

Joint work with aab, dam, ged, mge, svs and vsc.
2018-11-19 11:24:28 +00:00
mgh-odoo 1f57d4a34c [FIX] web_editor: FieldHtml commitChanges called too soon
The original issue appeared in mass_mailing where triggering the mail
template preview throws a client error.

This commit prevents commitChanges() from being called before the
element is rendered.

Task-ID: 1950784
2019-04-17 09:30:38 +00:00
Jeremy Kersten 8a1cb4758d [FIX] web_editor: avoid useless 404 during test
removeSrcAttribute should avoid these rpc, but for some
unknown reasons, on firefox it works but not with chrome.

Because the purpose of the test is to check the url and
not the content, that works to use an existing route.

Courtesy of @kangol for the fix
2018-02-01 14:13:32 +01:00
Alexandre Kühn 6632822d14 [FIX] web_editor: html field commitchanges fully loaded
Fix over this one: https://github.com/odoo/odoo/commit/cae188514fa8b0a7c785a630ac4aff677b2071fa

The intent was to disable buttons in form views until html fields are fully loaded,
but it was not disabling the buttons for the following reasons:

   1. It is looking for buttons in the DOM, although they
      are not already attached into the body at this moment.
   2. It was disabling the buttons only at widget start(),
      so only once after "Empty Cache and Hard Reload".

We propose a better solution than disabling the buttons in the control panel:
when we click on "Save", the html field ensures that it is fully loaded while commiting the changes.
2017-12-18 11:27:11 +01:00
Aaron Bohy deba788b4c [FIX] web_editor: html_frame: saving in readonly
A form view record may be saved even if the record is displayed in
readonly (e.g. when a button in the form view is clicked). When
this happened, if there were an html field with html_frame widget
in the form, it crashed (e.g. in Email Marketing > Mass Mailings >
open one > click on Test Mailing).
2017-08-10 13:56:22 +02:00
Darshan Kalola 7ada921e67 [FIX] web_editor: make html widget translatable
The translate feature of widgets html and html_frame had been
broken by the new views refactoring. This commit restores it for
the html widget, and removes it completely for html_frame as it
wasn't working correctly before the new views anyway (moreover,
it had already been disabled for mass_mailing: de403dc1ab).

This commit also ensures that the changes are correctly saved for
the html_frame widget. Note that this widget still needs to be
converted to our new coding guidelines.
2017-06-28 12:41:35 +02:00
Géry Debongnie cad943d035 [FIX] web_editor: prevent crash with FieldTextHtmlSimple
If the method commitChange from the widget FieldTextHtmlSimple was
called in mode=readonly, a traceback was displayed.  This is not very
common, because most save operations are done in mode=edit, but it can
happen in readonly mode: when the user clicks on an action button, then
the form view is saved, if necessary.

To reproduce this bug, just open a form view for res.users, and click on
the Change Password button.
2017-05-29 12:12:44 +02:00
Aaron Bohy ec988d4121 [FIX] web(_editor): field widget html
The field widget html wasn't implemented yet in the new views. A
very basic implementation was done in addon web. It only handled
the readonly mode so that the field were displayed in studio.

This commit removes this basic implementation from web, and re-
introduced the old one, converted, in addon web_editor.
2017-04-13 14:31:24 +02:00
Aaron Bohy 2d2e9c93c3 [FIX] web_editor: various fixes and new tests
- use 'nodeOptions' instead of 'options' in FieldTextHTML as
  'options' doesn't exist, it has been renamed into nodeOptions
  in AbstractField.
- mock iframe route in test to prevent the test framework from
  displaying an error (unimplemented route), and so the test from
  being red.
- test that the url given in the node options is correctly used.
- remove useless and broken code introduced by last rebase.
2017-04-11 19:44:38 +02:00
Géry Debongnie 905e01921f [REF] web, *: redesign all JS views
This commit introduce a full redesign of all JS views.  We started
basically from scratch.  The goal was to unify all the various views
under a common framework, to make them testable, to make then usable in
different conditions (in studio, or in the frontend), and to make our
lives easier.

Some important points are:
- we introduced new coding guidelines (camelCase, 80 chars width, ...)
- we have a brand new testing framework (still QUnit based)
- kanban view moved to the web addon
- calendar view (formerly web_calender) moved to web as well
- the tree view was removed
- all new code should be documented

We hope that this code is the start of a new era for the Odoo web
client, we want to have a high quality codebase, well documented, well
tested, well designed.

Work done by the framework team: mostly aab, ged, chm, dmo, qsm
2017-04-11 19:44:38 +02:00