1- < %
2- use crate::NotificationLevel;
3- use crate::components::Modal;
4- %>
1+ < % use crate::notifications::NotificationLevel; use crate::components::Modal; %>
52
6- < div class ="<%- location_id %> ">
7- < % if notification.is_some() {%>
8- < %
9- let notification = notification.unwrap();
10- let modal_id = format!("modal-{}", notification.id);
11- let show_modal = notification.trigger_modal && show_modal_on_load;
12- %>
13- < div
14- data-controller ="notifications-product-product-banner "
15- < % if show_modal {%>
16- data-action="
17- hide.bs.modal-> notifications-product-product-banner#updateModalCookie
18- turbo:load@window-> notifications-product-product-banner#showModal
19- "
20- < % } %>
21- data-notifications-product-product-banner-notification-id-value="< %- notification.id %> "
22- data-notifications-product-product-banner-modal-value="< %- modal_id %> ">
23- < %
24- let icon = {
25- if notification.level == NotificationLevel::ProductHigh {
26- "error"
27- } else if notification.level == NotificationLevel::ProductMedium {
28- "notifications"
29- } else {
30- "lightbulb"
31- }
32- };
33- %>
34- < div class ="rounded-2 W-100 <%- notification.level.to_string() %> ">
35- < div class ="banner d-flex container ">
36- < %
37- let title = if notification.title.is_some() {
38- format!(r#"< p class ="title m-0 "> {}</ p > "#, notification.title.clone().unwrap())} else {String::from("")};
39- %>
40-
41- < % let content = format!(
42- r#"
43- < {open_tag} class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-start align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
44- < div class ="px-3 py-3 py-sm-1 overflow-hidden text-container d-flex flex-row gap-2 ">
45- < span class ="material-symbols-outlined {display} preset-icon "> {icon}</ span >
46- < div >
47- {title}
48- < p class ="m-0 "> {message}</ p >
49- </ div >
50- </ div >
51- </ {close_tag}>
52- "#,
53- if notification.link.is_some() { "btn btn-tertiary p-0" } else { "" },
54- display = if notification.preset_icon { "d-block" } else { "d-none" },
55- icon = icon,
56- title = title,
57- message = notification.message,
58- open_tag = if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#, notification.link.clone().unwrap()) } else { "div".to_string() },
59- close_tag = if notification.link.is_some() { "a" } else { "div" },
60- ); %>
61-
62- < %- content %>
63-
64- < % if notification.dismissible {%>
65- < a class ="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2 "style ="height: fit-content "href ="<%- url %> ">
66- < span class ="material-symbols-outlined close ">
67- close
68- </ span >
69- </ a >
70- < % } %>
71- </ div >
72- < % if show_modal {%>
73- < %
74- let title = if notification.title.is_some() {
75- format!(r#"< h6 data-action ="click->notifications-product-product-banner#followModalLink "> {}</ h6 > "#, notification.title.unwrap())} else {String::from("")};
76- %>
3+ < div class ="<%- location_id %> ">
4+ < % if notification.is_some() {%>
5+ < % let notification=notification.unwrap(); let modal_id=format!("modal-{}", notification.id); let
6+ show_modal=notification.trigger_modal && show_modal_on_load; %>
7+ < div data-controller ="notifications-product-product-banner "< % if show_modal {%>
8+ data-action="
9+ hide.bs.modal-> notifications-product-product-banner#updateModalCookie
10+ turbo:load@window-> notifications-product-product-banner#showModal
11+ "
12+ < % } %>
13+ data-notifications-product-product-banner-notification-id-value="< %- notification.id %> "
14+ data-notifications-product-product-banner-modal-value="< %- modal_id %> ">
15+ < % let icon={ if notification.level==NotificationLevel::ProductHigh { "error" } else if
16+ notification.level==NotificationLevel::ProductMedium { "notifications" } else { "lightbulb" } }; %>
17+ < div class ="rounded-2 W-100 <%- notification.level.to_string() %> ">
18+ < div class ="banner d-flex container ">
19+ < % let title=if notification.title.is_some() { format!(r#"< p class ="title m-0 "> {}</ p > "#,
20+ notification.title.clone().unwrap())} else {String::from("")};
21+ %>
7722
78- < %+ Modal::new(format!(r#"
79- < div class ="d-flex flex-column gap-4 align-items-center text-center ">
80- < a class ="btn btn-tertiary position-absolute top-0 end-0 "data-action ="click->notifications-product-product-banner#hideModal "> < span class ="material-symbols-outlined close m-2 "> close</ span > </ a >
81- < span class ="material-symbols-outlined {display} preset-icon "style ="font-size: 44px "> {icon}</ span >
82- {title}
83- < p class ="m-0 "data-action ="click->notifications-product-product-banner#followModalLink "> {message}</ p >
23+ < % let content=format!( r#"< {open_tag}
24+ class="{} flex-grow-1 d-flex flex-column flex-md-row justify-content-start align-items-center row-gap-0 column-gap-3 fw-semibold overflow-hidden">
25+ < div class ="px-3 py-3 py-sm-1 overflow-hidden text-container d-flex flex-row gap-2 ">
26+ < span class ="material-symbols-outlined {display} preset-icon "> {icon}</ span >
27+ < div >
28+ {title}
29+ < p class ="m-0 "> {message}</ p >
30+ </ div >
31+ </ div >
32+ </ {close_tag}>
33+ "#,
34+ if notification.link.is_some() { "btn btn-tertiary p-0" } else { "" },
35+ display = if notification.preset_icon { "d-block" } else { "d-none" },
36+ icon = icon,
37+ title = title,
38+ message = notification.message,
39+ open_tag = if notification.link.is_some() { format!(r#"a href="{}" data-turbo="false" "#,
40+ notification.link.clone().unwrap()) } else { "div".to_string() },
41+ close_tag = if notification.link.is_some() { "a" } else { "div" },
42+ ); %>
43+
44+ < %- content %>
45+
46+ < % if notification.dismissible {%>
47+ < a class ="w-0 btn btn-tertiary overflow-visible d-flex align-items-start p-2 "
48+ style ="height: fit-content "href ="<%- url %> ">
49+ < span class ="material-symbols-outlined close ">
50+ close
51+ </ span >
52+ </ a >
53+ < % } %>
54+ </ div >
55+ < % if show_modal {%>
56+ < % let title=if notification.title.is_some() { format!(r#"< h6
57+ data-action ="click->notifications-product-product-banner#followModalLink "> {}</ h6 > "#,
58+ notification.title.unwrap())} else {String::from("")};
59+ %>
60+
61+ < %+ Modal::new(format!(r#"< div class ="d-flex flex-column gap-4 align-items-center text-center ">
62+ < a class ="btn btn-tertiary position-absolute top-0 end-0 "
63+ data-action ="click->notifications-product-product-banner#hideModal "> < span
64+ class ="material-symbols-outlined close m-2 "> close</ span > </ a >
65+ < span class ="material-symbols-outlined {display} preset-icon "
66+ style ="font-size: 44px "> {icon}</ span >
67+ {title}
68+ < p class ="m-0 "data-action ="click->notifications-product-product-banner#followModalLink ">
69+ {message}</ p >
70+ </ div >
71+ "#,
72+ display = if notification.preset_icon { "d-block" } else { "d-none" },
73+ icon = icon,
74+ title = title,
75+ message = notification.message
76+ )
77+ .into()).id(&modal_id)
78+ .set_static_backdrop(true) %>
79+ < % } %>
8480</ div >
85- "#,
86- display = if notification.preset_icon { "d-block" } else { "d-none" },
87- icon = icon,
88- title = title,
89- message = notification.message
90- )
91- .into()).id(&modal_id)
92- .set_static_backdrop(true) %>
93- < % } %>
94- </ div >
9581</ div >
9682
9783< % } %>
98- </ div >
84+ </ div >