summaryrefslogtreecommitdiff
path: root/addons/web_editor/static/src/js/editor
AgeCommit message (Collapse)Author
2021-05-27[FIX] website, web_editor: fix colorpicker previewxO-Tx
Issue: > Set bg color combination for a snippet... > Save > Edit mode > Select the snippet > Open color palette in bg option > Hover a color option > When a color button is left, the preview is cancelled but the color combination class is not applied anymore. In '_computeWidgetState' (for 'selectStyle' method), the right value ('o_cci') is not returned because we get empty "colorNames" (the "colorPalette" is not rendered on start). The goal of this commit is to fix this behaviour by rendering the colorPalette in start for snippet options, this way, the new code won't affect the speed fix added in [1] for 'OPTIONS' tab. [1]: https://github.com/odoo/odoo/pull/65223/commits/ce54c3f21293513673cb1fc6073ada5f0a2b5641 task-2538326 closes odoo/odoo#71174 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-04-28[FIX] web_editor: add check before updateLeftPanel timeoutArthur Detroux (ard)
Added a check to make sure that we do not set a timeout to update the option panel when said option panel is already open. This could sometimes occur which could cause all openned select to close and could fail some tests if said events happened in the middle of selecting an option. task-2502297 closes odoo/odoo#69119 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-04-06[FIX] website_sale, *: make the product image container not editableYounn Olivier
*: web_editor It prevents user writing in the image preview of products. Also, the product image view now fit its container so that the user can click wherever in the frame to change the picture. Part of https://github.com/odoo/odoo/pull/65575 task-2446852 closes odoo/odoo#65575 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-03-25[FIX] web_editor: fix race condition in option selectionSamuel Degueldre
Previously, when selecting certain options, especially ones which had slow updateUI methods, the selected value was sometimes reset to its previous value. This was caused by a race condition in which, when a snippet option updated its value, it would wait for options on the parent snippet editors to update all of their options' UI, but it incorrectly only waited for *one* of the snippet editors to finish instead of waiting for all of them. This commit fixes that by stopping the event propagation and triggering a new event that will let the direct parent know when all parent editors are done updating their options' UI before signalling that the UI update is done. task-2487578 closes odoo/odoo#68238 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: Arthur Detroux <ard@odoo.com>
2021-03-18[FIX] web, web_editor, website: fix incorrectly translated template literalsSamuel Degueldre
closes odoo/odoo#68085 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2021-03-17[FIX] website_forum: show normal image modal in forumNicolas Lempereur
In #67893 the image icon was removed, but it contradicts the interface and made a feature that was working for employee less available. Since saas-12.3, we always use the full media dialog when showing the editor on the forum so we could not add an image with the image icon if were not an employee. Before saas-12.3, the original summernote image dialog was shown for everyone but website editor that saw the full media dialog (beecause we are using the same editor to do both things). With this change, we always have the original dialog in the forum message editor thanks to a new option "disableFullMediaDialog". opw-2470720 closes odoo/odoo#68018 X-original-commit: 74af23fb0be60c996503ad599eb96bc2ab4d64f9 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-05[FIX] web_editor: adapt warning when quality options are unavailableSamuel Degueldre
Previously, when quality options were not available, the option would simply not be displayed. User feedback suggests that this is confusing, as for example, in the case of modifying the image in a t-field, quality options would not be available when starting the editor, but would become available when picking the image again in the media-dialog. Some leftover code allowed to display a warning about why the quality options were not available in the case where the image is not local to the database. This warning has been adapted to display a more informative message about why quality options are not available, as well as suggest a solution: - External image => download the image and upload it in odoo - t-field => "You need to choose this image again in the media-dialog or reupload it to have access to quality options" - Images that are in an unsupported format (anything other than PNG or JPEG) => short explanation that quality options are only available on PNG and JPEG images. task-2466819 part of odoo/odoo#66732
2021-03-05[FIX] web_editor: fix parent element selectionxO-Tx
When a block is removed, the parent will be activated. If the parent element is empty and removable: 1) It will be removed too. 2) In '_activateSnippet' method, we look for the right element to be selected using the block's parent (removed from the DOM...). The goal of this commit is to fix this behaviour by computing the selected element before parent removal. task-2431506 closes odoo/odoo#65428 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-23[FIX] web_editor: bgOptimize+parallax=bg no kaputNicolas Lempereur
Scenario: - set new background image - set parallax - save => on next edition, the editor doesn't work on background anymore Why: - backgroundOptimize copy attributes of the original image to the real target element on save - parallax change the real target element to a new child => so if the original element was an editor (with data-oe-model, ...) attributes, with the combination of the two options we will save these editing attribute on the child element which is wrong (the editing attributes are added dynamically and should not be saved). With this changeset, we don't copy the editing attributes in backgroundOptimize when we copy the original target image. opw-2427560 opw-2429340 closes odoo/odoo#66665 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-22[FIX] web_editor: can set bg position on root editorNicolas Lempereur
Scenario: - go to /slides and start editing the page - change the position of background banner - save => traceback Why: The code for pan tool duplicates the target element in an overlay. In the given use case, it means a node with .o_editable class is created that will cause an error when saving because the code expect the cloned element to be an editor (in `RTEWidget.save()`) but it is not (and is eg. missing `.data('options')`). opw-2427560 closes odoo/odoo#66639 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-19[FIX] web_editor: no error background position + ctrl ZNicolas Lempereur
Scenario: - start editing background position - press TAB key - press CTRL + Z => traceback Why: Restoring a snapshot with CTRL Z can send a click event with target not wrapped in a jQuery object which was not expected by the code. reported in https://github.com/odoo/odoo/pull/66462#issuecomment-782025417 opw-2423445 closes odoo/odoo#66540 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-18[FIX] web_editor: don't save cropping tool on CTRL+ZNicolas Lempereur
Scenario: - start cropping of an image - press TAB key - do CTRL + Z => now the image cropping tool are inside the page and there is no way to remove them. Why: The image crop tool was added inside the editable elemnt, so if we did an action that changed history the cropping tools are saved in the snapshot and going back to it will add them without any code handling their removal. opw-2394877 opw-2423445 closes odoo/odoo#66462 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-02-16[FIX] web_editor: fix drag and drop when drop zones are too closeBenjamin Vray
Before this commit, the preview of the dragged snippet didn't work when moving a dragged snippet from a drop zone to an other drop zone when there was no space between those drop zones. It is because, in this case, the over event of the second drop zone is triggered before the out event of the first drop zone. task-2312878 closes odoo/odoo#66165 X-original-commit: 3ac79957d8f6948c965f76e0b5d73ba39a34c69e Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-15[IMP] web_editor: instantiate color palette only when necessaryBenoit Socias
Color palette are only visible once they are opened. However, we instantiate them a lot to build the "options" editor panel which caused the editor to appear buggy for some users... even if they would never open a colorpalette. This fixes that issue. The fix is not entirely stable but was made as stable as possible... better implementation will be done in master. task-2439295 https://github.com/odoo/odoo/pull/65223 closes odoo/odoo#65223 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: qsm-odoo <qsm@odoo.com>
2021-02-15[FIX] web, web_editor: avoid rendering color palettes more than onceBenoit Socias
Before this commit the palette was rendered each time it was opened. After this commit if the palette has already been rendered only the selected color is being updated in the palette (and its colorpicker). task-2439295 https://github.com/odoo/odoo/pull/65223 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-02-15[FIX] website, web_editor: ensure the loader appears on click optionsBenoit Socias
Before this commit the loader did not always get displayed when switching to the options tab. After this commit the loader always gets displayed ASAP when switching to the options tab until the tab is ready and displayed. task-2439295 https://github.com/odoo/odoo/pull/65223 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-02-05[FIX] web_editor: insert record name as textSamuel Degueldre
Previously, the many2one widget from the web_editor used jQuery's '.html()' method when inserting a record name into the page. The record name was not HTML-escaped before this, which may have unexpect result and break the layout. This commit fixes that by using the '.text()' method instead. This bug only affects pages containing a many2one (contact excluded) at the time of selection and not after the selection. e.g. on the /event page, changing the category of an existing event via the website editor closes odoo/odoo#65642 X-original-commit: 53aff7f07317a8261b8b9c3e462d930141c7081b Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2021-02-04[FIX] website, web_editor: fix empty parallax snippet not being removedSamuel Degueldre
Previously, when removing all the content of a snippet, that snippet would get automatically deleted. This was not the case for parallax snippets because we previously intended the user to drop the parallax snippet, empty it, and drop other content inside of it. Recently, we added the parallax option on all snippets, rendering the previous workflow obsolete. There is now no longer any reason to keep empty parallax snippets. This commit fixes that. task-2446008 closes odoo/odoo#64907 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-02-02[FIX] web_editor: fix background layers buttonsxO-Tx
Example to reproduce: Drop the "Cover" snippet and try to remove the background image. Clicking on image button has to be done 3 times to land on the correct result: - First click removes image, but not filter and leaves both buttons checked - Second click removes the filter and unchecks its button. - Third click unchecks the image button. It should be one click to remove image, filter and uncheck both buttons. The goal of this commit is to prevent _applyOptions() from setting background-image values if image is not optimizable. This filter will solve the issues since empty values (badly parsed by getBgImageURL()) won't be added as background urls. task-2312878 closes odoo/odoo#62984 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-28[FIX] web_editor: fix dropzones with invisible elementBenjamin Vray
Before this commit, dropzones were created around invisible elements (e.g. the snippet popup). So we had 2 dropzones instead of one at some locations. After this commit, we avoid creating dropzones around elements that must not have dropzones. task-2312878 closes odoo/odoo#65198 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-27[FIX] web_editor: prevent a modal from closing when dropping a snippetBenjamin Vray
Before this commit, when you dropped a snippet using the move button in a modal. The modal closed after the drop. This commit allows to define an element in which to destroy the editors. Part of https://github.com/odoo/odoo/pull/61998 task-2312878 closes odoo/odoo#61998 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-27[FIX] web_editor: fix scroll during dragging a snippet in a modalBenjamin Vray
Before this commit, it was not possible to scroll a popup with a dragged snippet. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: close open invisible elements before deleting itBenjamin Vray
Before this commit, open invisible elements were not closed before being deleted. This created issues like the 'modal-open' class wich was not removed from the body when removing a modal. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: fix drag and drop a snippet in a modalBenjamin Vray
When a modal is open, allow the drop of a snippet only in this modal. Part of https://github.com/odoo/odoo/pull/61998 task-2312878
2021-01-27[FIX] web_editor: fix scroll event on snippet popupBenjamin Vray
Before this commit, when scrolling a snippet popup, the overlay was not updating its position. So now, we use addEventListener instead of jQuery for the scroll event on the scrolling element because we need the 'capture' parameter. Setting this capture parameter to true allows us to take advantage of event bubbling for events that otherwise don’t support it. Part of https://github.com/odoo/odoo/pull/61998 task-2312878 Co-authored-by: Samuel Degueldre <sad@odoo.com>
2021-01-25[FIX] web_editor: restore website header once page content is removedqsm-odoo
The affixed header was not reappearing if page content was removed and the page thus indirectly scrolled. task-2446020 closes odoo/odoo#64990 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-22[FIX] web_editor: save custom snippets per websiteBenoit Socias
Before this commit the custom snippets were saved across websites because the RPC mechanism used by the save & reload does not include the context by default. After this commit the custom snippets are saved for the specific website as initially intended. No migration is needed: already created snippets that have been created across all sites will have the correct lifecycle because of the copy-on-unlink system: trying to delete one will make it specific on other websites. Related to task-2374802 closes odoo/odoo#64917 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-21[FIX] website, web_editor: fix drop zones when dragging a snippetBenjamin Vray
Before this commit: -when moving a snippet using the drag and drop button, two drop zones instead of one was added at the initial location of the dragged snippet. -when moving a snippet using the drag and drop button, no drop zone was added at the initial location of the dragged snippet if the snippet was alone in its parent. For example, the left jumbotron in the banner snippet. -the drop zones handled by the "children rules" were never vertical when it was necessary. This commit also refactors the code to avoid some duplicated lines. task-2312878 closes odoo/odoo#64838 X-original-commit: e637056b3b1f4129342e5c79a4d761c7aaf56a40 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-13[FIX] web_editor: solve bold command issuesqsm-odoo
Summernote uses execCommand and, worth, obsolete queryCommandState function to customize the edited content. Here we try to hack the function to solve some problems by making the DOM and style easier to understand for the base functions for the duration of their executions. This won't obviously solves all problems but this is an improvement while waiting for the new Odoo editor coming in future versions. The original problem this solves is handling bold text in blog posts. Posts are using font-weight: 300 which is enough to confuse summernote. Hitting bold on a selected paragraph wraps its content in a <b> tag but hitting bold again does nothing... having a <b> rendered as fw-400 is enough to break it. What this commit does is: before any execCommand or queryCommandState being used to modify the DOM or retrieve its state, the whole DOM is forced to fw-400 and <b> elements to fw-700. This also solves issues in some base snippets. closes odoo/odoo#64472 X-original-commit: 424d9661c5657cbcf10ce40acb94a7a200c2a48b Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2021-01-12[FIX] web_editor: fix steps snippet line removed when change icon bg-colSamuel Degueldre
Previously, when changing the background-color of an icon in the s_process_steps snippet, the line that goes through the snippet would disappear from that block. This was caused by our font-application code attempting to remove extraneous DOM nodes when changing a font color or backrgound-color, but not considering elements with a ::before or ::after pseudoelement has having content, and subsequently removing them. opw-2423785 closes odoo/odoo#64404 X-original-commit: 6b363d202d9c35e8249f7bb2b0730b995fdf4a7d Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2021-01-07[FIX] web_editor: fix replacing media leaving unexpected elementsSamuel Degueldre
Previously, changing a media from a video/icon/document to a different type would leave empty elements in the DOM, this is because summernote's range API `range.insertNode` function deletes the content but not the structure (HTML elements). This commit fixes that by using jQuery's replaceWith method instead of summernote's insertNode when a media was found, and only using summernote in case no media was found (eg. a text range). Part of: odoo/odoo#60450 X-original-commit: 63f80995a05eeab1061b769c7733a1cfa98c726e
2020-12-24[FIX] web_editor: stop suggesting shapes for model-related imagesqsm-odoo
Those kind of images use a specific route (/web_editor/shape/...) to be fetched. While waiting for a more complete solution to maybe handle them for model-related images, this commit only allows their use for images in views and HTML fields. closes odoo/odoo#63682 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-12-17[FIX] web_editor: fix permanent loading effect on option double-clickSamuel Degueldre
Previously, double clicking an arrow to change the order of images in the image-gallery snippet would cause the loading effect to permanently stay and block the snippet editor completely. This was caused by the fact that when clicking the arrow, the gallery snippet rebuilds itself from scratch. After a snippet option is used (in this case, the reordering arrow), we update the snippet overlay, and destroy snippet-editors whose target is no longer in the DOM. When double clicking, by the time we handle the second click, the target of the option has been removed from the DOM, and the widget has been destroyed. However, when we try to apply the option anyway, we trigger_up some events (eg to refresh the public widgets) and wait for the trigger_up to call back. Since the widget is already destroyed, it no longer has a parent and trigger_up fails silently, never calling us back, and blocking the mutex. This commit fixes that by checking whether the widget is destroyed before trying to apply the option, bailing immediately if it is the case, and unlocking the mutex. opw-2394953 closes odoo/odoo#63532 Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2020-12-15[FIX] web_editor: fix crash on chrome (cannot read editable of null)Samuel Degueldre
This crash is caused by some of our integration code with summernote. When clicking on a button of the toolbar, we attempt to create a range from the current selection so that we can show the image toolbar if the selection contains an image, but there was no check to see whether the current selection was actually inside of the editable part of the page. This causes issues later when we attempt to generate layoutInfo for the image, as it will look for the editable area that contains the image and fail. This commit fixes that by making sure that the current selection is inside of the editable area before adding it to the styleInfo. opw-2376794 closes odoo/odoo#63373 X-original-commit: b26c57b4ab269ca7ad3ba3fc2b4a7f4d60d995e8 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-10[FIX] web_editor: fix background position on shapesBenjamin Vray
Before this commit, the background-position was not removed from a shape when it was re-flipped to its original orientation. introduced in #61114 closes odoo/odoo#63173 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-09[FIX] web_editor, test_website: will fix the deletion of custom snippetsBenoit Socias
Before this commit the deletion of custom snippets failed because the button click event got intercepted by the drag'n'drop mechanism. The currentTarget of the event was used in an asynchronous call where it had already been replaced by the jQuery's event bubbling mechanism when invoking the other handler. After this commit the deletion of custom snippets works again and a test tour is introduced to make sure it does not get broken again task-2405854 closes odoo/odoo#62555 Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
2020-12-04[FIX] survey, web, web_editor, website, website_form: Prevent invalid date ↵Achraf (abz)
stock.picking What are the steps to reproduce your issue? 1. Install "stock" 2. Go to Inventory/Inventory Overview/Internal Transfer 3. Create new record and set manually a date with year < 1000 like "0008-10-10 18:35:00" 4. Save What is currently happening? An error arises when saving the record, and it is then no longer possible to reopen the records or any view containing it. This also prevents us from correcting the date to no longer have the error Why is this happening? The root cause is an inconsistency in `strftime` for years < 1000 [1, 2]. To take it into account, a zero-padding is needed in the DateTime parser. How to fix the bug? The missing padding is added. However, such dates lead to problematic behaviors in Python: ``` DT_FORMAT = "%Y-%m-%d %H:%M:%S" new_date = "0008-02-05 18:10:10" datetime.strptime( datetime.strptime( new_date, DT_FORMAT ).strftime(DT_FORMAT), DT_FORMAT ) ``` This raises: ``` ValueError: time data '8-02-05 18:10:10' does not match format '%Y-%m-%d %H:%M:%S' ``` As of today there was no reported business cases where dates with year < 1000 would be necessary. Therefore, we limit the range to years >= 1000. [1] https://bugs.python.org/issue13305 [2] https://docs.python.org/dev/library/datetime.html#strftime-strptime-behavior opw-2408260 closes odoo/odoo#62818 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-11-20[FIX] web_editor, website_form: speed up and robustify form editingIEL
STEPS: * open website page with a form (e.g. /contactus) * click edit * slow down connection speed * click fast between form input lines or change order of the lines BEFORE: * 7 svg files are requested every click * get_authorized_fields is called every click * random error "'classList' of undefined" in SelectUserValueWidget::close * random similar errors when a method is called before initialization AFTER: * svg and get_authorized_fields are requested once * random errors are no reproduced or it's hard to do it * performance of switching between inputs doesn't depend on connection speed (though, still not instant) WHY: * about changing in SelectUserValueWidget::close: posible reason why this.menuTogglerEl may be undefined is because method start is async * the other updates just implement caching --- opw-2368928 closes odoo/odoo#61598 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-17[FIX] web_editor: fix shape transparency color preview handlingSamuel Degueldre
Previously, the transparency color for shapes was not taken into account when handling the preview state transitions of the background shape snippet option. This caused strange behaviours where the shape transparency color would always get reset when it was a class color, either when changing to a different shape (expected, all shape colors should get reset) or when changing any other shape setting like other shape colors or flipping the shape (not expected). On the other hand, if the transparency color was not a class color, it would always remain untouched, when changing other shapes settings (expected) but also when changing shape type (eg Origins 01 -> Blocks 02, unwanted). This commit fixes that by cloning the entire shape container during preview, and restoring it on preview-reset. task-2380815 closes odoo/odoo#61710 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-13[FIX] web_editor, *: ease understanding of snippet drag, not clickqsm-odoo
*: web, website Make the empty oe_structure messages "wizz" when the user clicks on a snippet to drag instead of dragging it. Part of https://github.com/odoo/odoo/pull/60837 Related to task-2363616 closes odoo/odoo#60837 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-13[FIX] web_editor: encourage to use snippets in empty oe_structure (wizz)qsm-odoo
Make the draggable snippets "wizz" when the user clicks on an empty oe_structure. Part of https://github.com/odoo/odoo/pull/60837 Related to task-2363616
2020-11-12[FIX] web_editor: fix snippet drag and drop after scrollingBenjamin Vray
Before this commit, the positions of the drop zones were not updated after scrolling the page while dragging a snippet. It was because jQuery ignored the scroll of the scrollable element to refresh the position of the drop zones. We had to trigger the scroll on the draggable element when the scrollable element is scrolled to make it works. task-2312878 closes odoo/odoo#61334 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-12[FIX] web_editor: fix drag and drop a snippetBenjamin Vray
This commit fix the following issues: - When you move a snippet using the drag and drop button, the dropzones were not hidden during the preview of the snippet. - The out event of the droppable widget was not triggered after scrolling the page with the autoscroll. This was because we were using the d-none class on the drop zones. What was causing issues in jquery's drag and drop system. task-2312878 closes odoo/odoo#61521 X-original-commit: 31b69917639562a9b54d0e4d58d6dae1cdf90dc9 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-02[FIX] web_editor: fix gap between transformed shape and next sectionSamuel Degueldre
Previously, when flipping some shapes vertically on chrome, and vertically or horizontally on firefox, there was a gap of 1px or less at some screen widths. This is caused by the way these browsers render backgrounds on transformed elements. It seems like firefox will round the size of the element to render the background image on it if the element is transformed, while chrome will always render the background at the correct size (or render it at a larger size and clip it to the correct size after the fact), but will round the coordinates of the symmetry point, causing only the vertical flip to have this issue, and only if the background image would not extend beyond the bounds of the element (on firefox, even shapes that would extend beyond the bounds of the element would showcase a gap, eg origins 1) This commit fixes that by applying the transform to the SVG rather than to the element, by use of the shapes controller. task-2369560 closes odoo/odoo#61114 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-06[FIX] web_editor: allow single quotes in getShapeDataBenjamin Vray
Before this commit, the value of data-oe-shape-data required double quotes to be properly parsed in JSON in the getShapeData method. After this commit, we also allow single quotes to prevent issue if someone doesn't use double quotes in the the value of data-oe-shape-data. Which was precisely the case in one of the themes and this is why this commit is a fix. task-2327741 closes odoo/odoo#60835 Related: odoo/design-themes#421 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-02[FIX] web_editor: unblock the editor after dropping the "Quotes" snippetqsm-odoo
Before this commit, when the user dropped the "Quotes" snippet, the editor was not allowing to drop any more snippet (see [1]). This was because the editors initialization related to the drop of the "Quotes" snippet was not able to be fully performed. Indeed, it is composed of carousel items, themself containing images. As some of those carousel items are hidden, the images they contains are too... and some options actually wait to access their naturalWidth. As the images are lazy loaded since [2], we were thus waiting infinitely. [1]: https://github.com/odoo/odoo/commit/277f39904e7218bef2dd23b1c5b719ce8660008f [2]: https://github.com/odoo/odoo/commit/617c716aeafd7bbc776d81da134a9b25329f08c9 closes odoo/odoo#61123 Signed-off-by: Samuel Degueldre <sdegueldre@users.noreply.github.com>
2020-11-03[FIX] web_editor, website: restore footer visibility optionxO-Tx
Making the footer visible after having made it disappear was not possible anymore because of [1]. Part of https://github.com/odoo/odoo/pull/59624 task-2312878 [1]: https://github.com/odoo/odoo/commit/61ffe97d03deae0aee72568311c453d1cd3470c8 closes odoo/odoo#59624 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-02[FIX] web_editor: DOM is not cleaned before saving custom snippetsSamuel Degueldre
Previously, when saving a custom snippet, the outerHTML of the snippet was naively read directly and saved as a new custom snippet. Unfortunately this completely bypasses all cleanup mechanisms that we have before saving, such as stopping the public widgets, or creating attachments for cropped or optimized images. This would result in weird bugs, where public widgets would appear twice when dropping a custom snippet containing one, as well as the creating a new attachment for any image that was optimized or cropped before saving the custom snippet every time it was dropped in the page again. Unfortunately there is no good mechanism for an option to ask the editor to clean the DOM without actually saving it, as a temporary measure, the snippet-save option will instead save the whole page (which will clean up the DOM) and save the custom snippet after the save, before refreshing the page and reopening the editor, not unlike some theme options. task-2341612 closes odoo/odoo#61202 X-original-commit: 2fa955267a3f81495be82c4214abd8befcf1fc95 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-11-02[FIX] web_editor: avoid traceback on form inputs double-clicksBenjamin Vray
Before this commit, double clicking on the border or on the padding of a form input generated a traceback. task-2312878 closes odoo/odoo#60816 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
2020-10-29[FIX] web_editor: fix issues related to loading image infoSamuel Degueldre
In order to allow modifying background images, we need information on the image, this is done by creating a placeholder img and calling the loadImageInfo function on it. However this function did not account for the case where an image had not src attribute, which causes an unnecessary rpc. Other problems could arise from this as an attachment that doesn't have the correct mimetype but has a matching src could be returned, causing its image_src field to be false, which we would then attempt to load as a valid image, causing crashes. This commit fixes that by not trying to load image infos when the src of an image is empty, only looking for attachments of the supported mimetypes, and also checking that we actually did receive an image_src before setting it as the original src of the image, which will prevent accidentally trying to load a falsy src as an actual image. closes odoo/odoo#60953 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>