*: website, test_website Before this commit, the LinkPopoverWidget element was not positioned correctly in mobile edition. With [1] that introduced the website edition using an iframe, the element was appended on the global document, outside of the iframe, so that it was not overlapped by the snippets manipulators (that were also in the global document). But Bootstrap popovers are not meant to be used "on top" of iframes. Bootstrap uses the container's ownerDocument to compute placements, and does not take into account whether or not the target is located inside an iframe (therefore, skipping the iframe's offset and dimensions in the placements computations). This was leading to a visual bug in mobile edition: the iframe top, left values were not computed by the popover, and it was not positioned correctly. Since [2] moved the manipulators inside the iframe, the popover can be initialised using its target ownerDocument body, without being overlapped by the manipulators. Styles are adapted so that the popover stays consistent in the frontend and the backend, and a container option is added to the widget so that the element can be placed with other snippets manipulators from the website builder. [1]: https://github.com/odoo/odoo/commit/31cc10b91dc7762e23b4bde9b945be0c4ce3fe3b [2]: https://github.com/odoo/odoo/commit/872bb20b3ac08cf82613e15e6634a2e7593ccf7a task-2687506 closes odoo/odoo#103562 X-original-commit: 931d488af0d4dce529e4ea4ab3c8b827bda0d699 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Signed-off-by: Younn Olivier (yol) <yol@odoo.com>
189 lines
6.1 KiB
JavaScript
189 lines
6.1 KiB
JavaScript
odoo.define("website.tour.edit_link_popover", function (require) {
|
|
"use strict";
|
|
|
|
const wTourUtils = require('website.tour_utils');
|
|
|
|
const FIRST_PARAGRAPH = 'iframe #wrap .s_text_image p:nth-child(2)';
|
|
|
|
const clickFooter = [{
|
|
content: "Save the link by clicking outside the URL input (not on a link element)",
|
|
trigger: 'iframe footer h5:first',
|
|
}, {
|
|
content: "Wait delayed click on footer",
|
|
trigger: '.o_we_customize_panel we-title:contains("Footer")',
|
|
run: function () {}, // it's a check
|
|
}];
|
|
|
|
const clickEditLink = [{
|
|
content: "Click on Edit Link in Popover",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_edit_link',
|
|
}, {
|
|
content: "Ensure popover is closed",
|
|
trigger: 'iframe html:not(:has(.o_edit_menu_popover))', // popover should be closed
|
|
run: function () {}, // it's a check
|
|
in_modal: false,
|
|
}];
|
|
|
|
wTourUtils.registerWebsitePreviewTour('edit_link_popover', {
|
|
test: true,
|
|
url: '/',
|
|
edition: true,
|
|
}, [
|
|
// 1. Test links in page content (web_editor)
|
|
wTourUtils.dragNDrop({
|
|
id: 's_text_image',
|
|
name: 'Text - Image',
|
|
}),
|
|
{
|
|
content: "Click on a paragraph",
|
|
trigger: FIRST_PARAGRAPH,
|
|
run: 'text Paragraph', // Make sure the selection is set in the paragraph
|
|
},
|
|
{
|
|
content: "Click on 'Link' to open Link Dialog",
|
|
trigger: "#toolbar #create-link",
|
|
},
|
|
{
|
|
content: "Type the link URL /contactus",
|
|
trigger: '#o_link_dialog_url_input',
|
|
run: 'text /contactus'
|
|
},
|
|
...clickFooter,
|
|
{
|
|
content: "Click on newly created link",
|
|
trigger: `${FIRST_PARAGRAPH} a`,
|
|
},
|
|
{
|
|
content: "Popover should be shown",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Contact Us")', // At this point preview is loaded
|
|
run: function () {}, // it's a check
|
|
},
|
|
...clickEditLink,
|
|
{
|
|
content: "Type the link URL /",
|
|
trigger: '#o_link_dialog_url_input',
|
|
run: "text /"
|
|
},
|
|
...clickFooter,
|
|
{
|
|
content: "Click on link",
|
|
trigger: `${FIRST_PARAGRAPH} a`,
|
|
},
|
|
{
|
|
content: "Popover should be shown with updated preview data",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Home")',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Click on Remove Link in Popover",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_remove_link',
|
|
},
|
|
{
|
|
content: "Link should be removed",
|
|
trigger: `${FIRST_PARAGRAPH}:not(:has(a))`,
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Ensure popover is closed",
|
|
trigger: 'iframe html:not(:has(.o_edit_menu_popover))', // popover should be closed
|
|
run: function () {}, // it's a check
|
|
},
|
|
// 2. Test links in navbar (website)
|
|
{
|
|
content: "Click navbar menu Home",
|
|
trigger: 'iframe #top_menu a:contains("Home")',
|
|
},
|
|
{
|
|
content: "Popover should be shown (2)",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Home")',
|
|
run: function () {}, // it's a check
|
|
},
|
|
...clickEditLink,
|
|
{
|
|
content: "Change the URL",
|
|
trigger: '#url_input',
|
|
run: "text /contactus"
|
|
},
|
|
{
|
|
content: "Save the Edit Menu modal",
|
|
trigger: '.modal-footer .btn-primary',
|
|
},
|
|
{
|
|
content: "Click on the Home menu again",
|
|
extra_trigger: 'div:not(.o_loading_dummy) > #oe_snippets',
|
|
trigger: 'iframe #top_menu a:contains("Home")[href="/contactus"]',
|
|
},
|
|
{
|
|
content: "Popover should be shown with updated preview data (2)",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Contact Us")',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Click on Edit Menu in Popover",
|
|
trigger: 'iframe .o_edit_menu_popover .js_edit_menu',
|
|
},
|
|
{
|
|
content: "Edit Menu (tree) should open",
|
|
trigger: '.o_website_dialog .oe_menu_editor',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Close modal",
|
|
trigger: '.modal-footer .btn-secondary',
|
|
},
|
|
// 3. Test other links (CTA in navbar & links in footer)
|
|
{
|
|
content: "Click CTA in navbar",
|
|
trigger: 'iframe #top_menu_container a.btn-primary[href="/contactus"]',
|
|
},
|
|
{
|
|
content: "Popover should be shown (3)",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Contact Us")',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Toolbar should be shown (3)",
|
|
trigger: '#toolbar:has(#o_link_dialog_url_input:propValue(/contactus))',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Click 'Home' link in footer",
|
|
trigger: 'iframe footer a[href="/"]',
|
|
},
|
|
{
|
|
content: "Popover should be shown (4)",
|
|
trigger: 'iframe .o_edit_menu_popover .o_we_url_link:contains("Home")',
|
|
run: function () {}, // it's a check
|
|
},
|
|
{
|
|
content: "Toolbar should be shown (4)",
|
|
trigger: '#toolbar:has(#o_link_dialog_url_input:propValue(/))',
|
|
run: function () {}, // it's a check
|
|
},
|
|
// 4. Popover should close when clicking non-link element
|
|
...clickFooter,
|
|
// 5. Double click should not open popover but should open toolbar link
|
|
{
|
|
content: "Double click on link",
|
|
extra_trigger: 'iframe html:not(:has(.o_edit_menu_popover))', // popover should be closed
|
|
trigger: 'iframe footer a[href="/"]',
|
|
run: function (actions) {
|
|
// Create range to simulate real double click, see pull request
|
|
const range = document.createRange();
|
|
range.selectNodeContents(this.$anchor[0]);
|
|
const sel = window.getSelection();
|
|
sel.removeAllRanges();
|
|
sel.addRange(range);
|
|
actions.click();
|
|
actions.dblclick();
|
|
},
|
|
},
|
|
{
|
|
content: "Ensure popover is opened on double click, and so is right panel edit link",
|
|
trigger: 'html:has(#o_link_dialog_url_input)',
|
|
extra_trigger: 'iframe html:has(.o_edit_menu_popover)',
|
|
run: function () {}, // it's a check
|
|
},
|
|
]);
|
|
});
|