(
#[prop()] key: String,
#[prop()] title: K,
#[prop()] tooltip: K1,
#[prop()] items: Vec<CheckboxItems>,
#[prop()] single: bool,
#[prop()] mobile: bool,
)
| 268 | #[tracing::instrument(level = "debug", skip(key, title, tooltip, items, single))] |
| 269 | #[component()] |
| 270 | pub fn CheckboxPref<K, H, K1, H1>( |
| 271 | #[prop()] key: String, |
| 272 | #[prop()] title: K, |
| 273 | #[prop()] tooltip: K1, |
| 274 | #[prop()] items: Vec<CheckboxItems>, |
| 275 | #[prop()] single: bool, |
| 276 | #[prop()] mobile: bool, |
| 277 | ) -> impl IntoView |
| 278 | where |
| 279 | K: Fn() -> H + Send + Sync + 'static, |
| 280 | H: IntoView + Copy + 'static, |
| 281 | K1: Fn() -> H1 + Send + Sync + 'static, |
| 282 | H1: IntoView + Copy + 'static, |
| 283 | { |
| 284 | let ui_store = expect_context::<RwSignal<UiStore>>(); |
| 285 | let is_mobile = create_read_slice(ui_store, |u| u.get_is_mobile()).get(); |
| 286 | if is_mobile && !mobile { |
| 287 | return ().into_any(); |
| 288 | } |
| 289 | |
| 290 | let should_write = RwSignal::new(false); |
| 291 | let pref_value = RwSignal::<Vec<CheckboxPreference>>::new(Default::default()); |
| 292 | let pref_key = key; |
| 293 | let pref_key_clone = pref_key.clone(); |
| 294 | load_selective(pref_key.clone(), pref_value.write_only()); |
| 295 | let last_enabled = RwSignal::new(String::new()); |
| 296 | Effect::new(move || { |
| 297 | let value = pref_value.get(); |
| 298 | if !should_write.get_untracked() { |
| 299 | should_write.update_untracked(|v| { |
| 300 | *v = true; |
| 301 | }); |
| 302 | return; |
| 303 | } |
| 304 | |
| 305 | save_selective(pref_key.clone(), value.clone()); |
| 306 | }); |
| 307 | view! { |
| 308 | <div class="container-fluid mt-4"> |
| 309 | <div class="row no-gutters"> |
| 310 | <div class="col-auto align-self-center title d-flex preference-title"> |
| 311 | {title()} |
| 312 | </div> |
| 313 | <div class="col-auto ml-2"> |
| 314 | <Tooltip>{tooltip()}</Tooltip> |
| 315 | </div> |
| 316 | </div> |
| 317 | |
| 318 | <For |
| 319 | each=move || items.clone() |
| 320 | key=|p| p.key.clone() |
| 321 | children=move |item| { |
| 322 | let item_key_clone = item.key.clone(); |
| 323 | let item_key_clone_1 = item_key_clone.clone(); |
| 324 | let pref_key = pref_key_clone.clone(); |
| 325 | view! { |
| 326 | <div class="row no-gutters item w-100 flex-nowrap"> |
| 327 | <div class="col-auto align-self-center"> |
nothing calls this directly
no test coverage detected