* website, website_mass_mailing
Now, when any option method is called (editor left panel), the widgets
related to the targeted DOM is automatically updated. This is possible
to disable for a specific widget with `data-no-widget-refresh="true"`.
This commit also makes the `_refreshPublicWidget` method better handle
its async component: it is now "fully async" so the caller should wait
for its resolution before executing some other related code.
In this commit:
- transformed test_utils helpers to always trigger native events
- introduced new test_utils_create helper: prepareTarget
- updated qunit asserts to support Owl Components
- updated all misused helpers that would crash with the updated test_utils
Co-authored-by: Julien Mougenot <jum@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: Pierre Rousseau <pro@odoo.com>
* website, website_mass_mailing
We only have one invisible snippet (newsletter popup) which is handled
by adding a yellow alert in the DOM in edit mode to be able to click
somewhere to open the snippet options.
As we will add some new invisible snippet (generic popup, cookies bar,
and probably more) this needed to be improved.
Now, any snippet having the `o_snippet_invisible` class will have an
entry in the left panel in a dedicated zone to edit itself. This also
allows to get rid of the yellow alert, making sure that "what you see
is what you get" in the editor zone.
task-2150966
closesodoo/odoo#41420
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Introducing a new snippet called Chart.
This snippet uses the lib https://www.chartjs.org/
6 types of graph are possible:
Bar vertical
Bar horizontal
Line
Pie
Doughnut
Radar
task-2092267
closesodoo/odoo#40051
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
This commit introduces a new snippet: Countdown.
The countdown snippet is composed of 4 circle countdown, one for every time
unit: seconds, minutes, hours and days.
When countdown ends, the user can chose between 3 possible actions:
1. Nothing
2. Show message: show a message once the countdown ends.
The message will be displayed bellow the countdown (stopped on 0) or will
replace the countdown depending on the option selected.
The message can be edited through the website builder.
3. Redirect: redirect the user to the chosen URL. If the user is on the page at
the exact moment the countdown reach 0, the user will be redirected
automatically. If the user lands on the page after the countdown has reached
0, there will be no redirection and the link will be shown bellow the
countdown (stopped on 0) or will replace the countdown depending on the
option selected.
The countdown layout can be customized in multiple ways:
1. By choosing to hide some time units. For instance, seconds can be hidden or
only days shown.
2. By changing its size between small/medium/large.
3. By changing its basic design (circle, boxes, clean).
4. By changing its advanced design (shape, background, progress bar..)
task-2093081
closesodoo/odoo#39773
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Before this commit, inputs were always a title followed by the <input/>
on the same line.
Now it follows the same logic as we-row elements: title on a line,
<input/> on a new line, except if the 'o_we_inline' class is used.
Part of https://github.com/odoo/odoo/pull/41402
Add the ability for a snippet option's method to target multiple
subelements of the option's $target using the data-apply-to attribute
with a jQuery selector. This is achieved by calling the method on a
proxy of the object where accesses to the $target are redirected to a
different object.
While it may seem preferable to just set the $target before calling the
method and restoring it after the call, as this would be much simpler
code, it is not possible as this breaks down under asynchronous
conditions, hence the need to operate on a proxy such that all
concurrent asynchronous operations have their own independent $target
available for their entire time of execution.
Part of https://github.com/odoo/odoo/pull/41402
- Some layout broken when a scrollbar appeared
- The edit icon of background disappeared when the filename was too long
X-original-commit: d3419fed27147c92e673fb367657db8865a0d538
In a normal flux, this happen when an option is hovered and left:
1) Hover event -> the widget goes in 'preview' state and notifies a
preview to the option
2) The preview is received by the option and, after an internal mutex
resolution, the option enables its methods with the widget values.
3) Leave event -> same as (1), except leaving 'preview' state
4) same as (2), except receiving a 'reset'
Everything is fine and correctly managed... except if a JS code triggers
both hover and leave events in the same execution... and this is what
tests are doing. In this case, as (2) executes after an internal mutex
resolution, the points (2) and (3) were inverted, so the widget left the
'preview' state before (2) got the widget values.
Maybe the test system has to be improved, but this commit solves the
problem for this case explicitely.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
* website, website_blog, website_sale
Some snippet option already needed to implement this by themself and now
that they use custom widget, this is even more needed. The long-term
goal is that developers should not have to override the onFocus method
or the updateUI method but only the _computeWidgetState method.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
* web, mass_mailing, website
Introduced a new sub-widget for snippet options: we-colorpicker. This
allows to retrieve a color value (either a normalized css color or a
theme color name) to be used for a snippet option method.
This commit replaces the old 'colorpicker' snippet option whose behavior
is now simply achieved by defining an xml option using a we-colorpicker
widget in combination with the 'selectStyle' standard method.
This commit also adds the possibility to control the border-color of
elements alongside their border-width. Again, just a we-colorpicker
widget in combination with the 'selectStyle' standard method.
Note: this commit reviewed what the colorpalette palette widget
notifies. This is not a cssColor and a 'isClass' flag to say if it is
a css class or not. The colorpalette always returns a color string which
can be the name of a color like 'alpha'. This is up to the caller to
check if the color string is a css color or not with isCSSColor. In the
case it is not, the related code can read the actual color by reading
the related css variable.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
* website
Review colorpicker methods to always allow to use normalized colors.
Also factorize some code in the color palette widget.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
Before this commit, the rendering of inner content of the left panel
options was handled through _buildXXXElement methods in the options
widgets. Now they are handled through sub-widgets which also handle
the user events.
Each sub-widget is notified with the string value it should hold
according to the snippet option target and methods. Each sub-widget
notifies a string value following user interactions, which snippet
options can use to adapt their target through their option methods.
The current sub-widgets introduced by this commit are (others will
follow):
1) we-button
2) we-checkbox
3) we-input
4) we-select (typically containing multiple we-button widgets)
5) we-multi (typically containing multiple we-input widget)
Following this commit only 3 standard option methods remain, which can
be used with any meaningful widget:
1) selectClass
-> Same as before + handle the old 'toggleClass' method when used with
a checkbox-like widget.
2) selectStyle
-> Same as old setStyle, introduced recently (simply renamed)
3) selectDataAttribute
-> Handle both old selectDataAttribute and setDataAttribute, introduced
recently
The parameters these methods received are now:
- previewMode: same as before
- widgetValue: the string value the widget currently holds
- params: additional parameters (mainly dataset of the related xml)
+ params.possibleValues (all the possible values for the method,
meaninful for a select or a checkbox)
+ params.defaultValue (the value that the widget would give if it
even holds no value)
When defining a method in XML, the given value is the default value.
e.g. data-select-style="34px" data-css-property="margin-top"
-> if set on any widget, allows to retrieve a value from the user to
customize the margin-top, the default value being 34px.
-> if used with a we-input, allow to retrieve any value and an empty
value will be equal to 34px
-> if used on a checkbox, allow to toggle between no value and 34px.
-> ...
Hopefully, detailed documentation about all of this will follow. Code
documentation should already be helpful.
Last note: the _updateUI method (replacing the old _setActive) is now
async (so does all the functions calling it). In particular, the _select
method is now async.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
* website, website_sale
Also make the "isTopOption" method a property.
This is done in preparation of better code for coupling sub-widgets used
to retrieve user value (button, input, colorpicker, ...) to actual
change in the edited DOM through snippet options methods.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
Now, the editor UI can suggest options the same way as select-class but
for editing a data attribute.
Note: the public widgets are now refreshed on data attribute changes
through the select-data-attribute and set-data-attribute methods.
Part of https://github.com/odoo/odoo/pull/40282
In preparation of task-2122935 and other tasks
In most use case, when we edit the website we have a situation such as:
```
<div id="wrap" branding-attributes="...">
<section class="mycontent">hi!</section>
</div>
```
When we modify a part, we replace all child nodes of the branded
element.
But if we had more complex content such as:
```
<div id="wrap">
<section class="mycontent" branding-attributes="...">ho!</section>
<t t-call-assets="web.assets_common" t-js="false" t-css="false"/>
</div>
```
we have a t-call inside the div#wrap, so branding is distributed to
child that could have attribute modified (eg. changing background).
Then if `<section/>` node is saved, the possibly modified attributes
are lost.
Without the change, the added test fails with:
'<div class="nice">hoi</div>' not found in '...<div>hoi</div>...' :
saved element attributes are saved excluding branding ones
opw-2122947
closes#40345closesodoo/odoo#40830
X-original-commit: 71b20a24c40ae9daa10076ab0fd656b043819cff
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
before this commit: when creating a product from frontend and editing
the product and delete image and save edition, it throws traceback,
because ir.qweb.field.image doesn't get any url and due to which it
throws traceback.
after this commit: if url is not defined in ir.qweb.field.image field
converter then return None
task-2063293
closesodoo/odoo#40638
X-original-commit: 896127a6528fa59f7f385019e296acd5db585321
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
In e29c08969 source mode was reintroduced. Since complex template seemed
broken when it was edited, the feature of forcing source mode when there
is a `% if ` or `% set` template directive of 12.3 was reintroduced.
Since the direct breaking of the template was mostly solved with the
added line:
`options.prettifyHtml = false;`
the force source mode is not so much necessary and there was report that
it was not very clear.
In this commit it is removed, and if necessary could be reintroduced
later with clearer implementation.
opw-2123730
fix#40410closes#40421closesodoo/odoo#40458
X-original-commit: be30a3ba431cf24a5fcfdfedd0f9d9f73163c717
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Open Mass Mailing in debug mode, create a new mass mailing,
choose a template for the body, check with the inspector the iframe.
The head of the iframe does not have the debug assets. This is because
the global variable relative to the debug mode gets temporary
overwritten before solving the promise.
For Gorash this has been done for:
* Performance as all the editor assets must be inserted into the iframe
assets
* As an indication to bugfixers that the fix must not be done in this
bundle as it is the exact same content as outside of the iframe and the
exact same content as previous Odoo versions.
Removing the override given that:
* If someone enable debug=assets he/she is aware of the performance hit
* A ticket has been opened because the iframe is hard to debug
without debug assets.
opw-2117649
closesodoo/odoo#40417
X-original-commit: 17c6952af3242c22bae2596f64b0addd04b9f9e0
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
Reproduce the issue
- Install Events
- Set the english default format date to %d/%m/%Y
- Create an event & edit the date
The date is set correctly in the backend
- Edit the date of an event on the website directly
The date format is still the old one
Cause
The `from_html` method of DateTime was using `parser.parse` and
ignore the user's date format.
This commit changes `parser.parse` into `datetime.strptime` taking
into consideration the user's date format.
closesodoo/odoo#40415
X-original-commit: d00c0e317f8affbe8bea231972c2b6da70b9f240
Signed-off-by: Jason Van Malder <jasonvanmalder@users.noreply.github.com>
Now, we should either use:
- A we-select (in the end, same as collapse except it does not push the
elements in the UI)
- A simple div to always display the elements
Part of https://github.com/odoo/odoo/pull/38959
task-2066614
closesodoo/odoo#38959
Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Previously, background size and position for snippets was configured in
a modal, the user could choose a "focus point", which is rather
unintuitive. They could also choose to use the "contain" background
mode, with or without repeat, or a third option, where they could
customize everything, from the background size in both directions to
whether to repeat the background in only one or in both directions.
This commit streamlines the background-sizing options, only the "cover"
and "repeat pattern" options have been kept, as they cover almost every
use case. Their configuration has been moved into the options menu for
consistency with the rest of the editor, and the background's position
is now chosen by clicking on the corresponding menu option, and dragging
the background to the desired place.
Part of https://github.com/odoo/odoo/pull/38959
maintask-2066614
task-2088304
This will allow to do the following:
1) Show a preview overlay over an element
2) Block preview overlays -> the overlay at step 1 stays no matter what
3) Encourage the user to do something that edits what the preview
overlay is currently showing.
4) The edition is finished, go back to normal by unblocking preview
overlays.
Part of https://github.com/odoo/odoo/pull/38959
task-2066614
* web_editor
This commit adds a slide counter in carousel snippets option menu, as
well as left and right buttons, this way the user can manage their
slides entirely from the options, instead of having to go to the block
itself to navigate to where they want before going back to the option
menu to add or remove a slide.
Part of https://github.com/odoo/odoo/pull/38959
maintask-2066614
task-2088291
Co-authored-by: Samuel Degueldre <sad@odoo.com>
Currently we have:
- a colorpicker for background color of snippets
- a colorpicker for foreground and background text (topbar)
- a colorpicker for menu/footer/navbar/etc
These 3 are separate colorpickers with different options.
After this Commit
All 3 will use the same color palette wich allow you to select
theme color, common colors, custom color and transparent filter.
Part of https://github.com/odoo/odoo/pull/38959
maintask-2066614
task-2087383
* web_editor
Previously, the user could choose their anchor names using a modal
window, anchor names also have weird rules, this was not a great user
experience.
This commit makes the anchor button generate anchors automatically based
on the first title in a section, or the snippet name if there are none.
If the anchor name is already taken, it is suffixed by a number. After
it has been generated, it is also copied to the clipboard and the user
is shown a toast to tell them the anchor has been generated and copied.
The anchor is displayed in the toast along with an edit button that will
open the same edition modal as previously, but it is now less
restrictive.
Part of https://github.com/odoo/odoo/pull/38959
maintask-2066614
task-2088270
* website
Now snippet options can be defined as a button which can be placed next
to the clone and delete buttons, through a new "isTopOption" method.
This commit also review the buttons and title design and take advantage
of the feature to review the way snippets options are added in their
container (that code indeed contained useless part since 13.0).
Part of https://github.com/odoo/odoo/pull/38959
task-2066614
* web_editor, website_blog, mass_mailing
In preparation of the new left panel UI, remove all snippet options UI
icons as we do not want them anymore to simplify the UI.
Part of https://github.com/odoo/odoo/pull/38959
task-2066614