feat: create reactive traits (AsReactive and ReactiveCapture)
This commit is contained in:
1 parent
d01b568f15
commit
ec26fb6fce
9 files changed
+209
-28
No files matched your search
@@ -2,10 +2,11 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::components::ActionButton;
|
||||
use leptos::prelude::*;
|
||||
use macros::Reactive;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug)]
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Reactive, Default)]
|
||||
pub struct MultiEntryData {
|
||||
pub id: Uuid,
|
||||
pub data: HashMap<String, ValueType>,
|
||||
@@ -130,27 +131,31 @@ pub fn MultiEntry(
|
||||
<div class="rounded-md bg-red-700">
|
||||
// This div MUST have the same spacing CSS as the main entry div
|
||||
<div class="flex bg-inherit p-3 m-1">
|
||||
<span class="flex-1 text-white font-bold">{name_member.get().display_name}</span>
|
||||
<span class="flex-1 text-white font-bold">{info_member.get().display_name}</span>
|
||||
<span class="flex-1 text-white font-bold">
|
||||
{name_member.get().display_name}
|
||||
</span>
|
||||
<span class="flex-1 text-white font-bold">
|
||||
{info_member.get().display_name}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
// Entry section
|
||||
<div>
|
||||
<For
|
||||
each = move || entries.get()
|
||||
key = |entry: &MultiEntryData| entry.id
|
||||
children = move |entry| view! {
|
||||
<Entry
|
||||
entry_data=entry.clone()
|
||||
name_member=name_member
|
||||
info_member=info_member
|
||||
/>
|
||||
each=move || entries.get()
|
||||
key=|entry: &MultiEntryData| entry.id
|
||||
children=move |entry| {
|
||||
view! {
|
||||
<Entry
|
||||
entry_data=entry.clone()
|
||||
name_member=name_member
|
||||
info_member=info_member
|
||||
/>
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<ActionButton on:click=create_entry>
|
||||
Add Entry
|
||||
</ActionButton>
|
||||
<ActionButton on:click=create_entry>Add Entry</ActionButton>
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use aws_sdk_dynamodb::{error::ProvideErrorMetadata, types::AttributeValue, Clien
|
||||
use serde_dynamo::{from_item, to_item};
|
||||
|
||||
use crate::app::Unauthenticated;
|
||||
use crate::common::{StudentInfo, StudentInfoReactive, UserClaims};
|
||||
use crate::common::{StudentInfo, UserClaims};
|
||||
use crate::components::{
|
||||
ActionButton, CheckboxList, Loading, OutlinedTextField, Panel, Row, Select,
|
||||
RadioList
|
||||
@@ -14,6 +14,7 @@ use crate::components::{
|
||||
use leptos::leptos_dom::logging::console_log;
|
||||
use leptos::prelude::*;
|
||||
use leptos_oidc::{Algorithm, AuthLoaded, AuthSignal, Authenticated};
|
||||
use traits::{AsReactive, ReactiveCapture};
|
||||
|
||||
#[server(GetSubmission, endpoint = "/get-submission")]
|
||||
pub async fn get_submission(id: String) -> Result<StudentInfo, ServerFnError> {
|
||||
@@ -119,7 +120,7 @@ pub fn HomePage() -> impl IntoView {
|
||||
server_resource
|
||||
.get()
|
||||
.map(|submission: StudentInfo| {
|
||||
let reactive_info = StudentInfoReactive::new(submission);
|
||||
let reactive_info = submission.as_reactive();
|
||||
let select_value = RwSignal::new(String::from("Math"));
|
||||
let chk_select = RwSignal::new(vec!["Testing 2".into()]);
|
||||
let elements_disabled = RwSignal::new(false);
|
||||
|
||||
Reference in new issue
Block a user