style: automatic rustfmt run

This commit is contained in:
alphafetus committed 2026-01-15 07:30:32 -05:00
1 parent 9eacc9a618
commit 4e8f4a3c5e
10 files changed
+164 -155

No files matched your search

+10 -24
View File
@@ -8,9 +8,7 @@ fn render_dates(dates: DateRange) -> impl IntoView {
format!("{} - {}", start_date, end_date), format!("{} - {}", start_date, end_date),
}; };
view! { view! { <span>{move || date_text.clone()}</span> }
<span>{move || date_text.clone()}</span>
}
} }
fn render_status(status: DateStatus) -> impl IntoView { fn render_status(status: DateStatus) -> impl IntoView {
@@ -33,11 +31,7 @@ fn render_status(status: DateStatus) -> impl IntoView {
background_class background_class
); );
view! { view! { <span class=classes>{move || status_text}</span> }
<span class=classes>
{move || status_text}
</span>
}
} }
/// # Date Component /// # Date Component
@@ -72,19 +66,13 @@ fn Date(
<div class="flex-1 min-w-0"> <div class="flex-1 min-w-0">
<div class="flex items-start justify-between"> <div class="flex items-start justify-between">
<div class="flex-1"> <div class="flex-1">
<h3 class="font-bold text-md text-base"> <h3 class="font-bold text-md text-base">{info.get().title}</h3>
{info.get().title}
</h3>
<h3 class="text-md text-base mt-1"> <h3 class="text-md text-base mt-1">
{move || render_dates(info.get().date)} {move || render_dates(info.get().date)}
</h3> </h3>
<p class="text-sm text-gray-600"> <p class="text-sm text-gray-600">{info.get().description}</p>
{info.get().description}
</p>
</div>
<div class="flex-shrink-0 ml-2">
{move || render_status(info.get().status)}
</div> </div>
<div class="flex-shrink-0 ml-2">{move || render_status(info.get().status)}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -116,14 +104,12 @@ pub fn DateList(
) -> impl IntoView { ) -> impl IntoView {
view! { view! {
{move || { {move || {
dates.iter() dates
.iter()
.map(|info| { .map(|info| {
view! { view! { <Date info=info.clone() /> }
<Date })
info=info.clone() .collect_view()
/>
}
}).collect_view()
}} }}
} }
} }
+7 -6
View File
@@ -134,15 +134,13 @@ pub fn CheckboxList(
let cloned = item.clone(); let cloned = item.clone();
move || cloned.clone() move || cloned.clone()
}); });
let checked = Signal::derive(move || { let checked = Signal::derive(move || {
controller.selected_list.get().contains(&item.get()) controller.selected_list.get().contains(&item.get())
}); });
let on_change = move || { let on_change = move || {
// Update the data list by checking if the value is present in it. If so, controller
// remove it. If not, add it. .selected_list
controller.selected_list.update(|list| { .update(|list| {
let item = item.get(); let item = item.get();
if list.contains(&item) { if list.contains(&item) {
list.retain(|val| *val != item); list.retain(|val| *val != item);
@@ -153,6 +151,9 @@ pub fn CheckboxList(
controller.dirty.set(true); controller.dirty.set(true);
}; };
// Update the data list by checking if the value is present in it. If so,
// remove it. If not, add it.
view! { view! {
<Checkbox <Checkbox
checked=checked checked=checked
@@ -171,7 +172,7 @@ pub fn CheckboxList(
{move || { {move || {
match controller.error.get() { match controller.error.get() {
ValidationState::Invalid(msg) => msg, ValidationState::Invalid(msg) => msg,
_ => "There is no error - should not see this message.".to_string() _ => "There is no error - should not see this message.".to_string(),
} }
}} }}
</div> </div>
+29 -15
View File
@@ -45,7 +45,8 @@ pub fn Chip(
id=id.clone() id=id.clone()
prop:checked=checked prop:checked=checked
on:change=move |_| on_change.run(()) on:change=move |_| on_change.run(())
disabled=disabled /> disabled=disabled
/>
<div class="rounded-full p-2.5 <div class="rounded-full p-2.5
cursor-pointer text-base cursor-pointer text-base
bg-transparent border-1 border-gray-300 bg-transparent border-1 border-gray-300
@@ -98,34 +99,47 @@ pub fn ChipsList(
<div class="m-1.5 mt-0 mb-0"> <div class="m-1.5 mt-0 mb-0">
<span class="font-bold">{label}</span> <span class="font-bold">{label}</span>
<div class="flex flex-row flex-wrap gap-2 mb-1"> <div class="flex flex-row flex-wrap gap-2 mb-1">
{move || displayed_text.get().into_iter().zip(values.get()) {move || {
displayed_text
.get()
.into_iter()
.zip(values.get())
.into_iter() .into_iter()
.map(|(text, value)| { .map(|(text, value)| {
let value = RwSignal::new(value); let value = RwSignal::new(value);
let checked = Signal::derive(move || { let checked = Signal::derive(move || {
controller.selected_list.get().contains(&value.get()) controller.selected_list.get().contains(&value.get())
}); });
let on_change = move || { let on_change = move || {
// Update the data list by checking if the value is present in it. If so,
// remove it. If not, add it.
let value = value.get(); let value = value.get();
let list = controller.selected_list.get(); let list = controller.selected_list.get();
if list.contains(&value) { if list.contains(&value) {
allows_multiple.get() allows_multiple
.then(|| controller.selected_list.update(|list| list.retain(|v| v != &value))) .get()
.then(|| {
controller
.selected_list
.update(|list| list.retain(|v| v != &value))
})
.or_else(|| Some(controller.selected_list.set(Vec::new()))); .or_else(|| Some(controller.selected_list.set(Vec::new())));
} else { } else {
allows_multiple.get() allows_multiple
.then(|| controller.selected_list.update(|list| list.push(value.clone()))) .get()
.or_else(|| Some(controller.selected_list.set(vec![value.clone()]))); .then(|| {
controller
.selected_list
.update(|list| list.push(value.clone()))
})
.or_else(|| Some(
controller.selected_list.set(vec![value.clone()]),
));
} }
controller.dirty.set(true); controller.dirty.set(true);
}; };
// Update the data list by checking if the value is present in it. If so,
// remove it. If not, add it.
view! { view! {
<Chip <Chip
checked=checked checked=checked
@@ -138,7 +152,7 @@ pub fn ChipsList(
} }
}) })
.collect_view() .collect_view()
} }}
</div> </div>
</div> </div>
<Show when=move || controller.show_errors.get()> <Show when=move || controller.show_errors.get()>
@@ -146,7 +160,7 @@ pub fn ChipsList(
{move || { {move || {
match controller.error.get() { match controller.error.get() {
ValidationState::Invalid(msg) => msg, ValidationState::Invalid(msg) => msg,
_ => "There is no error - should not see this message.".to_string() _ => "There is no error - should not see this message.".to_string(),
} }
}} }}
</div> </div>
+11 -6
View File
@@ -121,19 +121,24 @@ pub fn RadioList(
.into_iter() .into_iter()
.map(|item| { .map(|item| {
let item = RwSignal::new(item); let item = RwSignal::new(item);
let checked_signal = Signal::derive(move || { let checked_signal = Signal::derive(move || {
selected_value.get() == item.get() selected_value.get() == item.get()
}); });
let on_change = move || { let on_change = move || {
// on_change only runs when the radio button is checked, not when unchecked.
// Change the selected value to the new one.
selected_value.set(item.get()); selected_value.set(item.get());
error.set(validate(selected_value.get_untracked(), required.get_untracked())); error
.set(
validate(
selected_value.get_untracked(),
required.get_untracked(),
),
);
dirty.set(true); dirty.set(true);
}; };
// on_change only runs when the radio button is checked, not when unchecked.
// Change the selected value to the new one.
view! { view! {
<Radio <Radio
checked=checked_signal checked=checked_signal
@@ -152,7 +157,7 @@ pub fn RadioList(
{move || { {move || {
match error.get() { match error.get() {
ValidationState::Invalid(msg) => msg, ValidationState::Invalid(msg) => msg,
_ => "There is no error - should not see this message.".to_string() _ => "There is no error - should not see this message.".to_string(),
} }
}} }}
</div> </div>
+11 -8
View File
@@ -104,15 +104,18 @@ pub fn Select(
value="" value=""
disabled disabled
hidden hidden
selected={move || raw_value.get().is_empty()} selected=move || raw_value.get().is_empty()
>"Select one..."</option> >
"Select one..."
</option>
{move || { {move || {
value_list.iter().map( value_list
move |value| { .iter()
.map(move |value| {
let display = value.to_owned(); let display = value.to_owned();
view! { <option value={display}>{display.clone()}</option> } view! { <option value=display>{display.clone()}</option> }
} })
).collect::<Vec<_>>() .collect::<Vec<_>>()
}} }}
</select> </select>
</label> </label>
@@ -122,7 +125,7 @@ pub fn Select(
{move || { {move || {
match error.get() { match error.get() {
ValidationState::Invalid(msg) => msg, ValidationState::Invalid(msg) => msg,
_ => "There is no error - should not see this message.".to_string() _ => "There is no error - should not see this message.".to_string(),
} }
}} }}
</div> </div>
+4 -4
View File
@@ -147,9 +147,9 @@ pub fn OutlinedTextField(
transition-all duration-150 transition-all duration-150
border-red-700 bg-transparent border-red-700 bg-transparent
disabled:border-gray-600 disabled:pointer-events-none disabled:bg-gray-600/33" disabled:border-gray-600 disabled:pointer-events-none disabled:bg-gray-600/33"
r#type={str_type} r#type=str_type
disabled={disabled} disabled=disabled
placeholder={placeholder} placeholder=placeholder
prop:name=name prop:name=name
prop:value=raw_value prop:value=raw_value
on:input=on_input on:input=on_input
@@ -160,7 +160,7 @@ pub fn OutlinedTextField(
{move || { {move || {
match error.get() { match error.get() {
ValidationState::Invalid(msg) => msg, ValidationState::Invalid(msg) => msg,
_ => "There is no error - should not see this message.".to_string() _ => "There is no error - should not see this message.".to_string(),
} }
}} }}
</div> </div>
+29 -38
View File
@@ -57,51 +57,42 @@ pub fn ComparisonTestPage() -> impl IntoView {
let student_info = student_resource.get(); let student_info = student_resource.get();
let comparison_info = comparison_resource.get(); let comparison_info = comparison_resource.get();
let scholarship_info = scholarship_resource.get(); let scholarship_info = scholarship_resource.get();
match (student_info, comparison_info, scholarship_info) { match (student_info, comparison_info, scholarship_info) {
(Some(student), Some(comparisons), Some(scholarships)) => Either::Right(view! { (Some(student), Some(comparisons), Some(scholarships)) => {
Either::Right(
view! {
<Panel> <Panel>
<Row> <Row>
<p>{result_msg}</p> <p>{result_msg}</p>
</Row> </Row>
<Row> <Row>
<ActionButton on:click=move |_| { <ActionButton on:click=move |_| {
// Iterate over all scholarships, get the comparison IDs,
// get ComparisonData from the IDs, then perform the
// comparisons and return a boolean. Alternatively, return
// a list of comparisons that complete and a list that don't.
let comp_member = "requirements".to_string(); let comp_member = "requirements".to_string();
let comparison_results = scholarships.iter().map(|scholarship| { let comparison_results = scholarships
.iter()
.map(|scholarship| {
let list = match scholarship.data.get(&comp_member) { let list = match scholarship.data.get(&comp_member) {
Some(ValueType::List(Some(list))) => list, Some(ValueType::List(Some(list))) => list,
_ => { _ => {
log!("Cannot find requirements, assuming none."); log!("Cannot find requirements, assuming none.");
return Ok(Some(scholarship)) // students will always qualify when there are no requirements return Ok(Some(scholarship));
} }
}; };
let mut final_result = Ok(true); let mut final_result = Ok(true);
// The list should exist, and it should contain a series of strings.
for val in list { for val in list {
let comp_opt = match val { let comp_opt = match val {
ValueType::String(Some(comp_id)) => { ValueType::String(Some(comp_id)) => {
// Find the comparison
comparisons.iter().find(|comp| comp.id == *comp_id) comparisons.iter().find(|comp| comp.id == *comp_id)
} }
_ => None _ => None,
}; };
let comparison_outcome = match comp_opt { let comparison_outcome = match comp_opt {
Some(comp) => { Some(comp) => comp.compare(&student),
// Perform the comparison _ => Err("".to_string()),
comp.compare(&student)
}
_ => Err("".to_string())
}; };
match comparison_outcome { match comparison_outcome {
Ok(true) => {}, Ok(true) => {}
Ok(false) => final_result = Ok(false), Ok(false) => final_result = Ok(false),
Err(e) => { Err(e) => {
final_result = Err(e); final_result = Err(e);
@@ -109,41 +100,41 @@ pub fn ComparisonTestPage() -> impl IntoView {
} }
} }
} }
match final_result { match final_result {
Ok(true) => Ok(Some(scholarship)), Ok(true) => Ok(Some(scholarship)),
Ok(false) => Ok(None), Ok(false) => Ok(None),
Err(e) => Err(e) Err(e) => Err(e),
} }
}).collect::<Vec<Result<Option<&ExpandableInfo>, String>>>(); })
.collect::<Vec<Result<Option<&ExpandableInfo>, String>>>();
// Build a display string
let mut strings = Vec::new(); let mut strings = Vec::new();
strings.push("Scholarship results: \n".to_string()); strings.push("Scholarship results: \n".to_string());
for result in comparison_results { for result in comparison_results {
match result { match result {
Ok(Some(scholarship_info)) => { Ok(Some(scholarship_info)) => {
// Get the scholarship name.
let name_member = "name".to_string(); let name_member = "name".to_string();
let scl_name = scholarship_info.data.get(&name_member).unwrap() let scl_name = scholarship_info
.as_string().unwrap().unwrap(); .data
.get(&name_member)
.unwrap()
.as_string()
.unwrap()
.unwrap();
strings.push(scl_name); strings.push(scl_name);
}, }
Ok(None) => {}, Ok(None) => {}
Err(msg) => strings.push(msg) Err(msg) => strings.push(msg),
} }
} }
let display_text = strings.join("\n").to_string(); let display_text = strings.join("\n").to_string();
result_msg.set(display_text); result_msg.set(display_text);
}>"Test Comparison"</ActionButton> }>"Test Comparison"</ActionButton>
</Row> </Row>
</Panel> </Panel>
}), },
_ => Either::Left(view! { )
<p>"Failed API requests."</p> }
}) _ => Either::Left(view! { <p>"Failed API requests."</p> }),
} }
}} }}
</Suspense> </Suspense>
+8 -5
View File
@@ -289,7 +289,7 @@ pub fn HomePage() -> impl IntoView {
data_member="contact_email" data_member="contact_email"
data_map=form_data data_map=form_data
input_type=TextFieldType::Email( input_type=TextFieldType::Email(
vec!["fakeemail.org".to_string(), "gmail.com".to_string()] vec!["fakeemail.org".to_string(), "gmail.com".to_string()],
) )
required=true required=true
/> />
@@ -369,8 +369,12 @@ pub fn HomePage() -> impl IntoView {
data_map=form_data data_map=form_data
data_member="community_involvement" data_member="community_involvement"
schema=vec![ schema=vec![
input!(Text, "service_name", "Activity Name:", true, "Some service activity..."), input!(
input!(Number, "service_hours", "Total Service Hours", true, "20") Text, "service_name", "Activity Name:", true, "Some service activity..."
),
input!(
Number, "service_hours", "Total Service Hours", true, "20"
),
] ]
/> />
</Row> </Row>
@@ -380,8 +384,7 @@ pub fn HomePage() -> impl IntoView {
</Row> </Row>
} }
}) })
}} }} <Row>
<Row>
<ActionButton on:click=pdf_button_click>"Get PDF"</ActionButton> <ActionButton on:click=pdf_button_click>"Get PDF"</ActionButton>
</Row> </Row>
</Suspense> </Suspense>
+44 -39
View File
@@ -213,11 +213,7 @@ pub fn LoanerShell() -> impl IntoView {
// We'll create the page here - the sidebar contains all the buttons, while the form // We'll create the page here - the sidebar contains all the buttons, while the form
// container either shows forms or shows placeholder text. // container either shows forms or shows placeholder text.
view! { view! {
<Banner <Banner title="Chromebook Loaners" logo="/PHS_Stacked_Acronym.png" path="/loaners" />
title="Chromebook Loaners"
logo="/PHS_Stacked_Acronym.png"
path="/loaners"
/>
<div class="flex m-5"> <div class="flex m-5">
<div class="flex flex-1 flex-row gap-3"> <div class="flex flex-1 flex-row gap-3">
<div id="sidebar" class="flex flex-1 flex-col gap-2"> <div id="sidebar" class="flex flex-1 flex-col gap-2">
@@ -247,16 +243,9 @@ pub fn LoanerShell() -> impl IntoView {
#[component] #[component]
pub fn LoanerFallback() -> impl IntoView { pub fn LoanerFallback() -> impl IntoView {
view! { view! {
<div <div class="flex flex-col items-center justify-center" use:animate=pop_in_out()>
class="flex flex-col items-center justify-center" <div class="text-3xl font-bold mb-2">"Chromebook Loaner Form"</div>
use:animate=pop_in_out() <div class="text-lg">"Select an option from the left to begin."</div>
>
<div class="text-3xl font-bold mb-2">
"Chromebook Loaner Form"
</div>
<div class="text-lg">
"Select an option from the left to begin."
</div>
</div> </div>
} }
} }
@@ -431,34 +420,47 @@ pub fn LoanerReturnForm() -> impl IntoView {
<dialog <dialog
use:animate=pop_in_out() use:animate=pop_in_out()
class="p-3 m-auto rounded-md shadow-lg/33 backdrop:backdrop-blur-xs backdrop:transition-backdrop-filter" class="p-3 m-auto rounded-md shadow-lg/33 backdrop:backdrop-blur-xs backdrop:transition-backdrop-filter"
node_ref=dialog_ref> node_ref=dialog_ref
>
<h2 class="text-2xl font-bold">"Confirmation"</h2> <h2 class="text-2xl font-bold">"Confirmation"</h2>
<h4 class="text-xl mb-3"> <h4 class="text-xl mb-3">
{move || chosen_student.with(|opt_student| { {move || {
chosen_student
.with(|opt_student| {
if let Some(student) = opt_student.as_ref() { if let Some(student) = opt_student.as_ref() {
format!("Are you sure want to check in {} {}?", student.first_name, student.last_name) format!(
"Are you sure want to check in {} {}?",
student.first_name,
student.last_name,
)
} else { } else {
"There is no student selected.".to_string() "There is no student selected.".to_string()
} }
})} })
}}
</h4> </h4>
<ActionButton on:click=close_dialog disabled=dialog_disabled>"Close"</ActionButton> <ActionButton on:click=close_dialog disabled=dialog_disabled>
<ActionButton on:click=dialog_check_in disabled=dialog_disabled>"Check In"</ActionButton> "Close"
</ActionButton>
<ActionButton on:click=dialog_check_in disabled=dialog_disabled>
"Check In"
</ActionButton>
</dialog> </dialog>
<div <div class="flex flex-col gap-2 m-2" use:animate=pop_in_out()>
class="flex flex-col gap-2 m-2"
use:animate=pop_in_out()
>
<div class="flex flex-col justify-center gap-2 mb-3 py-3 px-2"> <div class="flex flex-col justify-center gap-2 mb-3 py-3 px-2">
<h2 class="text-2xl font-bold">"Student List"</h2> <h2 class="text-2xl font-bold">"Student List"</h2>
<p class="text-lg">"Please select your name from the list."</p> <p class="text-lg">"Please select your name from the list."</p>
</div> </div>
<Suspense fallback=move || "Loading...".into_view()> <Suspense fallback=move || {
"Loading...".into_view()
}>
{move || { {move || {
match return_list_resource.get() { match return_list_resource.get() {
Some(loaner_list) => { Some(loaner_list) => {
let list_view = loaner_list.iter().map(|student| { let list_view = loaner_list
.iter()
.map(|student| {
let on_click = { let on_click = {
let student_click = student.clone(); let student_click = student.clone();
move |_| { move |_| {
@@ -469,31 +471,34 @@ pub fn LoanerReturnForm() -> impl IntoView {
} }
} }
}; };
let naive_time = chrono::NaiveDateTime::parse_from_str(
let naive_time = chrono::NaiveDateTime::parse_from_str(&student.date, "%H:%M, %m/%d/%Y") &student.date,
"%H:%M, %m/%d/%Y",
)
.unwrap(); .unwrap();
let time_zone = FixedOffset::west_opt(5 * 3600).unwrap(); let time_zone = FixedOffset::west_opt(5 * 3600).unwrap();
let student_date = time_zone.from_utc_datetime(&naive_time) let student_date = time_zone
.from_utc_datetime(&naive_time)
.format("%l:%M %p, %m/%d/%Y") .format("%l:%M %p, %m/%d/%Y")
.to_string(); .to_string();
log!("Found current date {:?}", student_date); log!("Found current date {:?}", student_date);
view! { view! {
<div class="flex flex-row p-3 rounded-md cursor-pointer transition-shadow shadow-sm hover:shadow-lg/33" on:click=on_click> <div
class="flex flex-row p-3 rounded-md cursor-pointer transition-shadow shadow-sm hover:shadow-lg/33"
on:click=on_click
>
<div class="flex-1"> <div class="flex-1">
{student.first_name.clone()}" "{student.last_name.clone()} {student.first_name.clone()}" "{student.last_name.clone()}
</div> </div>
<div class="flex-none"> <div class="flex-none">{student_date.clone()}</div>
{student_date.clone()}
</div>
</div> </div>
} }
}).collect_view(); })
.collect_view();
Either::Left(list_view) Either::Left(list_view)
}, }
None => Either::Right("No loaners found.".into_view()) None => Either::Right("No loaners found.".into_view()),
} }
}} }}
</Suspense> </Suspense>
+11 -10
View File
@@ -35,34 +35,35 @@ pub fn TestPage() -> impl IntoView {
</div> </div>
<div class="p-2"> <div class="p-2">
<div class="flex flex-col p-3 gap-3"> <div class="flex flex-col p-3 gap-3">
<DateList <DateList dates=vec![
dates=vec![
DateInfo { DateInfo {
title: "Title".to_string(), title: "Title".to_string(),
date: DateRange::Range("February 2nd, 2026".to_string(), "February 10th, 2026".to_string()), date: DateRange::Range(
"February 2nd, 2026".to_string(),
"February 10th, 2026".to_string(),
),
description: "This is a test".to_string(), description: "This is a test".to_string(),
status: DateStatus::Upcoming status: DateStatus::Upcoming,
}, },
DateInfo { DateInfo {
title: "Scholarships Due".to_string(), title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()), date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(), description: "This is a test".to_string(),
status: DateStatus::Open status: DateStatus::Open,
}, },
DateInfo { DateInfo {
title: "Scholarships Due".to_string(), title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()), date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(), description: "This is a test".to_string(),
status: DateStatus::Deadline status: DateStatus::Deadline,
}, },
DateInfo { DateInfo {
title: "Scholarships Due".to_string(), title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()), date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(), description: "This is a test".to_string(),
status: DateStatus::Closed status: DateStatus::Closed,
} },
] ] />
/>
</div> </div>
</div> </div>
</div> </div>