- {move || displayed_text.get().into_iter().zip(values.get())
- .into_iter()
- .map(|(text, value)| {
- let value = RwSignal::new(value);
+ {move || {
+ displayed_text
+ .get()
+ .into_iter()
+ .zip(values.get())
+ .into_iter()
+ .map(|(text, value)| {
+ let value = RwSignal::new(value);
+ let checked = Signal::derive(move || {
+ controller.selected_list.get().contains(&value.get())
+ });
+ let on_change = move || {
+ let value = value.get();
+ let list = controller.selected_list.get();
+ if list.contains(&value) {
+ allows_multiple
+ .get()
+ .then(|| {
+ controller
+ .selected_list
+ .update(|list| list.retain(|v| v != &value))
+ })
+ .or_else(|| Some(controller.selected_list.set(Vec::new())));
+ } else {
+ allows_multiple
+ .get()
+ .then(|| {
+ controller
+ .selected_list
+ .update(|list| list.push(value.clone()))
+ })
+ .or_else(|| Some(
+ controller.selected_list.set(vec![value.clone()]),
+ ));
+ }
+ controller.dirty.set(true);
+ };
- let checked = Signal::derive(move || {
- controller.selected_list.get().contains(&value.get())
- });
-
- 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 list = controller.selected_list.get();
- if list.contains(&value) {
- allows_multiple.get()
- .then(|| controller.selected_list.update(|list| list.retain(|v| v != &value)))
- .or_else(|| Some(controller.selected_list.set(Vec::new())));
- } else {
- allows_multiple.get()
- .then(|| controller.selected_list.update(|list| list.push(value.clone())))
- .or_else(|| Some(controller.selected_list.set(vec![value.clone()])));
+ view! {
+
}
-
- controller.dirty.set(true);
- };
-
- view! {
-
- }
- })
- .collect_view()
- }
+ })
+ .collect_view()
+ }}
@@ -146,7 +160,7 @@ pub fn ChipsList(
{move || {
match controller.error.get() {
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(),
}
}}
diff --git a/src/components/lists/single/radio.rs b/src/components/lists/single/radio.rs
index 86b4ddf..20619f9 100644
--- a/src/components/lists/single/radio.rs
+++ b/src/components/lists/single/radio.rs
@@ -121,19 +121,24 @@ pub fn RadioList(
.into_iter()
.map(|item| {
let item = RwSignal::new(item);
-
let checked_signal = Signal::derive(move || {
selected_value.get() == item.get()
});
-
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());
- error.set(validate(selected_value.get_untracked(), required.get_untracked()));
+ error
+ .set(
+ validate(
+ selected_value.get_untracked(),
+ required.get_untracked(),
+ ),
+ );
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! {
msg,
- _ => "There is no error - should not see this message.".to_string()
+ _ => "There is no error - should not see this message.".to_string(),
}
}}
diff --git a/src/components/lists/single/select.rs b/src/components/lists/single/select.rs
index 3fd6ab6..b20cddc 100644
--- a/src/components/lists/single/select.rs
+++ b/src/components/lists/single/select.rs
@@ -93,9 +93,9 @@ pub fn Select(
{label}
@@ -122,7 +125,7 @@ pub fn Select(
{move || {
match error.get() {
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(),
}
}}
diff --git a/src/components/text_field.rs b/src/components/text_field.rs
index dee1854..40e9052 100644
--- a/src/components/text_field.rs
+++ b/src/components/text_field.rs
@@ -144,12 +144,12 @@ pub fn OutlinedTextField(
msg,
- _ => "There is no error - should not see this message.".to_string()
+ _ => "There is no error - should not see this message.".to_string(),
}
}}
diff --git a/src/pages/comparison_test.rs b/src/pages/comparison_test.rs
index d01f03e..57afa5a 100644
--- a/src/pages/comparison_test.rs
+++ b/src/pages/comparison_test.rs
@@ -57,93 +57,84 @@ pub fn ComparisonTestPage() -> impl IntoView {
let student_info = student_resource.get();
let comparison_info = comparison_resource.get();
let scholarship_info = scholarship_resource.get();
-
match (student_info, comparison_info, scholarship_info) {
- (Some(student), Some(comparisons), Some(scholarships)) => Either::Right(view! {
-
-
-
{result_msg}
-
-
- list,
- _ => {
- log!("Cannot find requirements, assuming none.");
- return Ok(Some(scholarship)) // students will always qualify when there are no requirements
- }
- };
+ (Some(student), Some(comparisons), Some(scholarships)) => {
+ Either::Right(
- let mut final_result = Ok(true);
-
- // The list should exist, and it should contain a series of strings.
- for val in list {
- let comp_opt = match val {
- ValueType::String(Some(comp_id)) => {
- // Find the comparison
- comparisons.iter().find(|comp| comp.id == *comp_id)
- }
- _ => None
- };
-
- let comparison_outcome = match comp_opt {
- Some(comp) => {
- // Perform the comparison
- comp.compare(&student)
- }
- _ => Err("".to_string())
- };
-
- match comparison_outcome {
- Ok(true) => {},
- Ok(false) => final_result = Ok(false),
- Err(e) => {
- final_result = Err(e);
- break;
+ view! {
+
+
+
{result_msg}
+
+
+ list,
+ _ => {
+ log!("Cannot find requirements, assuming none.");
+ return Ok(Some(scholarship));
+ }
+ };
+ let mut final_result = Ok(true);
+ for val in list {
+ let comp_opt = match val {
+ ValueType::String(Some(comp_id)) => {
+ comparisons.iter().find(|comp| comp.id == *comp_id)
+ }
+ _ => None,
+ };
+ let comparison_outcome = match comp_opt {
+ Some(comp) => comp.compare(&student),
+ _ => Err("".to_string()),
+ };
+ match comparison_outcome {
+ Ok(true) => {}
+ Ok(false) => final_result = Ok(false),
+ Err(e) => {
+ final_result = Err(e);
+ break;
+ }
+ }
+ }
+ match final_result {
+ Ok(true) => Ok(Some(scholarship)),
+ Ok(false) => Ok(None),
+ Err(e) => Err(e),
+ }
+ })
+ .collect::, String>>>();
+ let mut strings = Vec::new();
+ strings.push("Scholarship results: \n".to_string());
+ for result in comparison_results {
+ match result {
+ Ok(Some(scholarship_info)) => {
+ let name_member = "name".to_string();
+ let scl_name = scholarship_info
+ .data
+ .get(&name_member)
+ .unwrap()
+ .as_string()
+ .unwrap()
+ .unwrap();
+ strings.push(scl_name);
+ }
+ Ok(None) => {}
+ Err(msg) => strings.push(msg),
}
}
- }
-
- match final_result {
- Ok(true) => Ok(Some(scholarship)),
- Ok(false) => Ok(None),
- Err(e) => Err(e)
- }
- }).collect::, String>>>();
-
- // Build a display string
- let mut strings = Vec::new();
- strings.push("Scholarship results: \n".to_string());
- for result in comparison_results {
- match result {
- Ok(Some(scholarship_info)) => {
- // Get the scholarship name.
- let name_member = "name".to_string();
- let scl_name = scholarship_info.data.get(&name_member).unwrap()
- .as_string().unwrap().unwrap();
- strings.push(scl_name);
- },
- Ok(None) => {},
- Err(msg) => strings.push(msg)
- }
- }
-
- let display_text = strings.join("\n").to_string();
-
- result_msg.set(display_text);
- }>"Test Comparison"
-
-
- }),
- _ => Either::Left(view! {
-