fix: use signals for select dropdown data
This commit is contained in:
1 parent
bb5dfa2563
commit
f0f22bb68b
6 files changed
+17
-16
No files matched your search
@@ -20,7 +20,7 @@ fn validate(required: bool, value: String) -> ValidationState {
|
|||||||
/// by the `value` prop of the component.
|
/// by the `value` prop of the component.
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Select(
|
pub fn Select(
|
||||||
#[prop()] value_list: Vec<String>,
|
#[prop(into)] value_list: Signal<Vec<String>>,
|
||||||
#[prop(into)] data_member: Signal<String>,
|
#[prop(into)] data_member: Signal<String>,
|
||||||
#[prop()] data_map: RwSignal<HashMap<String, ValueType>>,
|
#[prop()] data_map: RwSignal<HashMap<String, ValueType>>,
|
||||||
#[prop(optional, into)] label: String,
|
#[prop(optional, into)] label: String,
|
||||||
@@ -110,6 +110,7 @@ pub fn Select(
|
|||||||
</option>
|
</option>
|
||||||
{move || {
|
{move || {
|
||||||
value_list
|
value_list
|
||||||
|
.get()
|
||||||
.iter()
|
.iter()
|
||||||
.map(move |value| {
|
.map(move |value| {
|
||||||
let display = value.to_owned();
|
let display = value.to_owned();
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ fn new_entry() -> ValueType {
|
|||||||
/// `first_name` and `last_name` keys within that `Entry`.
|
/// `first_name` and `last_name` keys within that `Entry`.
|
||||||
#[component]
|
#[component]
|
||||||
pub fn MultiEntry(
|
pub fn MultiEntry(
|
||||||
|
#[prop(into)] label: Signal<String>,
|
||||||
|
#[prop(optional, into)] description: Signal<String>,
|
||||||
/// The data member that contains the list of entries within the `data_map`.
|
/// The data member that contains the list of entries within the `data_map`.
|
||||||
#[prop(into)]
|
#[prop(into)]
|
||||||
data_member: String,
|
data_member: String,
|
||||||
@@ -101,7 +103,11 @@ pub fn MultiEntry(
|
|||||||
let add_entry = move |_| data_reactive.update(|list| list.push(new_entry()));
|
let add_entry = move |_| data_reactive.update(|list| list.push(new_entry()));
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<div class="flex flex-col flex-1">
|
<div class="flex flex-col flex-1 gap-2">
|
||||||
|
<span class="font-bold">{label}</span>
|
||||||
|
<Show when=move || !description.get().is_empty()>
|
||||||
|
<span>{description}</span>
|
||||||
|
</Show>
|
||||||
<div class="flex flex-col gap-2 p-2">
|
<div class="flex flex-col gap-2 p-2">
|
||||||
// Render the entries
|
// Render the entries
|
||||||
<For
|
<For
|
||||||
|
|||||||
+2
-14
@@ -12,7 +12,7 @@ use crate::common::ExpandableInfo;
|
|||||||
use crate::pages::UnauthenticatedPage;
|
use crate::pages::UnauthenticatedPage;
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
ActionButton, CheckboxList, Loading, MultiEntry, OutlinedTextField, Panel, RadioList, Row,
|
ActionButton, CheckboxList, Loading, MultiEntry, OutlinedTextField, Panel, RadioList, Row,
|
||||||
Select, TextFieldType, ValidatedForm
|
TextFieldType, ValidatedForm
|
||||||
};
|
};
|
||||||
use crate::input;
|
use crate::input;
|
||||||
use leptos::leptos_dom::logging::console_log;
|
use leptos::leptos_dom::logging::console_log;
|
||||||
@@ -329,21 +329,9 @@ pub fn HomePage() -> impl IntoView {
|
|||||||
required=true
|
required=true
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
<Row>
|
|
||||||
<Select
|
|
||||||
label="Gender:"
|
|
||||||
value_list=vec!["Male", "Female", "Prefer not to answer"]
|
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.to_owned())
|
|
||||||
.collect()
|
|
||||||
disabled=elements_disabled
|
|
||||||
data_member="gender"
|
|
||||||
data_map=form_data
|
|
||||||
required=true
|
|
||||||
/>
|
|
||||||
</Row>
|
|
||||||
<Row>
|
<Row>
|
||||||
<MultiEntry
|
<MultiEntry
|
||||||
|
label="Testing community involvement:"
|
||||||
data_map=form_data
|
data_map=form_data
|
||||||
data_member="community_involvement"
|
data_member="community_involvement"
|
||||||
schema=vec![
|
schema=vec![
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ pub fn StudentAthleticsPage() -> impl IntoView {
|
|||||||
<div class="flex flex-col flex-2 mt-6">
|
<div class="flex flex-col flex-2 mt-6">
|
||||||
<ValidatedForm title="Athletics Information" on_submit=move || {}>
|
<ValidatedForm title="Athletics Information" on_submit=move || {}>
|
||||||
<MultiEntry
|
<MultiEntry
|
||||||
|
label="Athletics Activities:"
|
||||||
|
description="Leave blank if not applicable."
|
||||||
data_map=data_map
|
data_map=data_map
|
||||||
data_member="athletic_participation"
|
data_member="athletic_participation"
|
||||||
schema=vec![
|
schema=vec![
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ pub fn StudentExtracurricularsPage() -> impl IntoView {
|
|||||||
required=true
|
required=true
|
||||||
/>
|
/>
|
||||||
<MultiEntry
|
<MultiEntry
|
||||||
|
label="Extracurricular Activities:"
|
||||||
|
description="Leave blank if not applicable."
|
||||||
data_map=data_map
|
data_map=data_map
|
||||||
data_member="extracurricular"
|
data_member="extracurricular"
|
||||||
schema=vec![
|
schema=vec![
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ pub fn StudentWorkExperiencePage() -> impl IntoView {
|
|||||||
<div class="flex flex-col flex-2 mt-6">
|
<div class="flex flex-col flex-2 mt-6">
|
||||||
<ValidatedForm title="Student Work Experience" on_submit=move || {}>
|
<ValidatedForm title="Student Work Experience" on_submit=move || {}>
|
||||||
<MultiEntry
|
<MultiEntry
|
||||||
|
label="Work Experience:"
|
||||||
|
description="Leave blank if not applicable."
|
||||||
data_map=data_map
|
data_map=data_map
|
||||||
data_member="extracurricular"
|
data_member="extracurricular"
|
||||||
schema=vec![
|
schema=vec![
|
||||||
|
|||||||
Reference in new issue
Block a user