Debian Codegraph @

addons/website_sale/static/src/js/notification/cart_notification/cart_notification.js

raw symbols SCIP
1 import { Component, onMounted } from "@odoo/owl";
2 import { AddToCartNotification } from "../add_to_cart_notification/add_to_cart_notification";
3 import { WarningNotification } from "../warning_notification/warning_notification";
4
5 const AUTOCLOSE_DELAY = 4000;
6
7 export class CartNotification extends Component {
8 static components = { AddToCartNotification, WarningNotification };
9 static template = "website_sale.cartNotification";
10 static props = {
11 message: [String, { toString: Function }],
12 warning: {type : [String, { toString: Function }], optional: true},
13 lines: {
14 type: Array,
15 optional: true,
16 element: {
17 type: Object,
18 shape: {
19 id: Number,
20 linked_line_id: { type: Number, optional: true },
21 image_url: String,
22 quantity: Number,
23 uom_name: { type: String, optional: true },
24 name: String,
25 combination_name: { type: String, optional: true },
26 description: { type: String, optional: true },
27 price_total: Number,
28 },
29 },
30 },
31 currency_id: {type: Number, optional: true},
32 className: String,
33 close: Function,
34 }
35
36 setup() {
37 onMounted(() => setTimeout(this.props.close, AUTOCLOSE_DELAY));
38 }
39
40 /**
41 * Get the top position (in px) of the notification based on the navbar height.
42 *
43 * This prevents the notification from being shown in front of the navbar.
44 */
45 get positionOffset() {
46 return (document.querySelector('header.o_top_fixed_element')?.offsetHeight || 0) + 'px';
47 }
48 }