Sunday, October 15, 2023
2 changes · master
New functionality added to Odoo
Website editors can now add buttons, images, and videos as simple building blocks. This makes page creation faster and keeps the resulting content clean and easy to edit later.
Original PR description
This commit introduces 3 new inner snippets: button, image, and video. What sets these snippets apart is that, once dropped onto the page, they transform into basic HTML code, just like if they were created using the editor. task-3248881
Enhancements to existing features
Website editors can now adjust spacing between grid rows and columns and set padding on individual grid items, giving more control over page layouts. The update also prevents editing previews from being copied when snippets are duplicated and fixes visual issues in Banner and Text Cover snippets.
Original PR description
[IMP] web_editor: clean the snippet UI before cloning it When cloning a snippet, if it had some previews displayed, the previews may be cloned with it. This is not a good behavior because the clone…
[IMP] web_editor: clean the snippet UI before cloning it When cloning a snippet, if it had some previews displayed, the previews may be cloned with it. This is not a good behavior because the clone is a new snippet so it should not have all the preview classes that were added when editing. Moreover, these previews could also cause bugs. To solve this, an idea could be to call the `cleanForSave` function of all its options before cloning the snippet. But the problem is that in some options, the `cleanForSave` function does more than simply clean the UI (as it was originally supposed to) and so it cannot be used for that purpose only. As a solution, this commit adds a new function called `cleanUI` whose exclusive purpose will be to clean the snippet UI. In the future, it will replace the `cleanForSave` function. task-3369695 --- [IMP] web_editor: add support for data-min/max to InputUserValueWidget Before this commit, when using a `we-input`, there was no way to easily specify the min and max values that could be entered in the input, which could be useful when too low/high values could break some behaviors, for example. This commit adds the support for the `data-min` and `data-max` data- attributes in `InputUserValueWidget`. More precisely, when these attributes are added on a `we-input`, if the user writes a value smaller than the `data-min` or bigger than the `data-max`, the value snaps to these bounds. When using the arrows, the value cannot be decreased/ increased beyond them either. task-3369695 --- [REF] web_editor: refactor some grid code In the grid mode code, the code managing the transformation of a grid item into a normal column (when it is dropped or when we toggle the normal mode) is repeated at several places. This commits fixes that by creating a function doing this conversion instead. task-3369695 --- [IMP] web_editor, website: add individual Padding option for grid items Before this commit, the "Padding" grid mode option, added in commit [1], was impacting all the grid items at the same time, which was not convenient since all these elements would have the same padding and could not be styled individually. This commit improves this option in order to modify the padding of the grid items individually. The highlight effect, added in commit [2], when changing the padding is still added. [1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec [2]: https://github.com/odoo/odoo/commit/f3f2c4c73ce08d3898b8c88e1ef045f7bbd1f624 task-3369695 --- [REF] web_editor, website: remove duplicated grid/column options When adding the grid options in commits [1] and [6], some of them have been duplicated in order to cover the different use cases: grid-only, columns-only and grid + columns. However, they should have been declared only once and then called when needed. This commit extracts the common options into views, to avoid duplicating them. [1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec [6]: https://github.com/odoo/odoo/commit/85b352af319edec84407f2046cf795b4e5503460 task-3369695 --- [IMP] web_editor, website: add a Spacing option to modify the grid gaps The `display: grid` property allows to modify the spacing (or gaps) between the rows and columns of the grid with the `row-gap` and `column- gap` CSS properties. When the grid mode was added with [1], these properties were deliberately ignored and the gaps were forced to 0px. This commit adds the "Spacing (Y, X)" option that allows to modify these grid gaps. A grid preview is also added when using this option, in order to visualize what is being changed in the grid. [1]: https://github.com/odoo/odoo/commit/cc406afcea7bf5846233a9f97a4a8ac5f618f3ec task-3369695 --- [FIX] web_editor: make background grid more visible on dark backgrounds When redesigning the grid layout and handles, commit [3] removed the filter that allowed the grid to be clearly visible on dark backgrounds (added in commit [4]). Without this, the background grid when dragging/ resizing and the highlight effect when changing the gaps are difficult to see. This commit adds this filter back, but with a lowered opacity in order to not obstruct the view too much. [3]: https://github.com/odoo/odoo/commit/70f723a9f78c406746f5409f6a89cbe93ad21580 [4]: https://github.com/odoo/odoo/commit/1aa81243b7c80069c576381e2f3b04281455794f task-3369695 --- [FIX] website: make the "Text Cover" snippet look good in grid mode Before this commit, toggling the "Text Cover" snippet to grid mode did not produce a good-looking result: the column containing the background image loses all its padding and therefore appears smaller and shifted compared to the normal mode. This commit adds a background color to the image column. Indeed, with a background color, and more precisely thanks to the `o_cc` class, the padding is taken into account when computing the grid items size, making them look similar to how they were in normal mode. task-3369695 --- [FIX] website: fix the new design of the Banner snippet In commit [5], the Banner snippet has been redesigned in order to be in grid mode by default, to highlight some cool features of the editor. However, some grid classes and attributes are missing or not well set: - the first column has a `g-height-4` class despite having 8 rows: this causes the vertical resize to not work correctly. - the row does not have the `data-row-count` attribute, which is needed to display the background grid correctly. This commit fixes this by replacing the class by `g-height-8` and adding the `data-row-count` attribute, which is set to 11 rows. [5]: https://github.com/odoo/odoo/commit/3cbdf754ff8fac8a77887c4307b658cb86b0be1d task-3369695