File: grid_layout.js

package info (click to toggle)
odoo 18.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 878,716 kB
  • sloc: javascript: 927,937; python: 685,670; xml: 388,524; sh: 1,033; sql: 415; makefile: 26
file content (95 lines) | stat: -rw-r--r-- 3,066 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/** @odoo-module **/

import {
    changeOption,
    clickOnSave,
    clickOnSnippet,
    insertSnippet,
    registerWebsitePreviewTour,
} from '@website/js/tours/tour_utils';

const snippet = {
    id: 's_text_image',
    name: 'Text - Image',
    groupName: "Content",
};

registerWebsitePreviewTour('website_replace_grid_image', {
    url: '/',
    edition: true,
}, () => [
    ...insertSnippet(snippet),
    ...clickOnSnippet(snippet),
    {
        content: "Toggle to grid mode",
        trigger: '.o_we_user_value_widget[data-name="grid_mode"]',
        run: "click",
    },
    {
        content: "Replace image",
        trigger: ':iframe .s_text_image img',
        run: 'dblclick',
    },
    {
        content: "Pick new image",
        trigger: '.o_select_media_dialog img[title="s_banner_default_image.jpg"]',
        run: "click",
    },
    {
        content: "Add new image column",
        trigger: '.o_we_user_value_widget[data-add-element="image"]',
        run: "click",
    },
    {
        content: "Pick new image",
        trigger: '.o_select_media_dialog img[title="s_banner_default_image2.jpg"]',
        run: "click",
    },
    {
        content: "Replace new image",
        trigger: ':iframe .s_text_image img[src*="s_banner_default_image2.jpg"]',
        run: 'dblclick',
    },
    {
        content: "Pick new image",
        trigger: '.o_select_media_dialog img[title="s_banner_default_image.jpg"]',
        run: "click",
    },
    ...clickOnSave()
]);

registerWebsitePreviewTour("scroll_to_new_grid_item", {
    url: "/",
    edition: true,
}, () => [
    // Drop enough snippets to scroll.
    ...insertSnippet({id: "s_text_image", name: "Text - Image", groupName: "Content"}),
    ...insertSnippet({id: "s_image_text", name: "Image - Text", groupName: "Content"}),
    ...insertSnippet({id: "s_image_text", name: "Image - Text", groupName: "Content"}),
    // Toggle the first snippet to grid mode.
    ...clickOnSnippet({id: "s_text_image", name: "Text - Image"}),
    changeOption("layout_column", 'we-button[data-name="grid_mode"]'),
    // Add a new grid item.
    changeOption("layout_column", 'we-button[data-add-element="image"]'),
    {
        content: "Select the new image in the media dialog",
        trigger: '.o_select_media_dialog img[title="s_banner_default_image.jpg"]',
        run: "click",
    }, {
        content: "Check that the page scrolled to the new grid item",
        trigger: ":iframe .s_text_image .o_grid_item:nth-child(3)",
        async run() {
            // Leave some time to the page to scroll.
            await new Promise((r) => setTimeout(r, 500));
            const newItemPosition = this.anchor.getBoundingClientRect();
            if (newItemPosition.top < 0) {
                throw new Error("The page did not scroll to the new grid item.");
            }
            document.body.classList.add("o_scrolled_to_grid_item");
        },
    }, {
        content: "Make sure the scroll check is done",
        trigger: ".o_scrolled_to_grid_item",
    },
    ...clickOnSave(),
]);