A massive, unorganized PR. #44
@@ -40,20 +40,13 @@ pub fn ScholarshipInfoPage() -> impl IntoView {
|
|||||||
// Remember that we only want to show the page after we've got authentication information
|
// Remember that we only want to show the page after we've got authentication information
|
||||||
// and if there's data for us to use.
|
// and if there's data for us to use.
|
||||||
view! {
|
view! {
|
||||||
<Banner
|
<Banner title="R15 Scholarships" logo="/PHS_Stacked_Acronym.png" path="/" />
|
||||||
title="R15 Scholarships"
|
|
||||||
logo="/PHS_Stacked_Acronym.png"
|
|
||||||
path="/"
|
|
||||||
/>
|
|
||||||
<ToastList>
|
<ToastList>
|
||||||
<AuthLoaded fallback=Loading>
|
<AuthLoaded fallback=Loading>
|
||||||
<Authenticated unauthenticated=UnauthenticatedPage>
|
<Authenticated unauthenticated=UnauthenticatedPage>
|
||||||
<div class="flex flex-row align-top items-start">
|
<div class="flex flex-row align-top items-start">
|
||||||
<div class="flex flex-col flex-1" />
|
<div class="flex flex-col flex-1" />
|
||||||
<ScholarshipList
|
<ScholarshipList refresh_token=list_refresh on_delete=on_delete />
|
||||||
refresh_token=list_refresh
|
|
||||||
on_delete=on_delete
|
|
||||||
/>
|
|
||||||
<Transition fallback=Loading>
|
<Transition fallback=Loading>
|
||||||
<ScholarshipForm
|
<ScholarshipForm
|
||||||
scholarship_id=scholarship_id
|
scholarship_id=scholarship_id
|
||||||
@@ -183,37 +176,41 @@ fn ScholarshipList(
|
|||||||
});
|
});
|
||||||
|
|
||||||
view! {
|
view! {
|
||||||
<dialog
|
<dialog node_ref=delete_dialog_ref class="m-auto p-2">
|
||||||
node_ref=delete_dialog_ref
|
|
||||||
class="m-auto p-2"
|
|
||||||
>
|
|
||||||
<h2 class="text-2xl font-bold">"Confirm Deletion"</h2>
|
<h2 class="text-2xl font-bold">"Confirm Deletion"</h2>
|
||||||
<p>
|
<p>
|
||||||
"Are you sure you want to delete "
|
"Are you sure you want to delete "
|
||||||
{move || {
|
{move || {
|
||||||
pending_delete.get().map(|s| {
|
pending_delete
|
||||||
s.data.get("name").unwrap_or(&ValueType::String(None))
|
.get()
|
||||||
|
.map(|s| {
|
||||||
|
s.data
|
||||||
|
.get("name")
|
||||||
|
.unwrap_or(&ValueType::String(None))
|
||||||
.as_string()
|
.as_string()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.unwrap_or("<no name found>".to_string())
|
.unwrap_or("<no name found>".to_string())
|
||||||
})
|
})
|
||||||
}}
|
}} "?"
|
||||||
"?"
|
|
||||||
</p>
|
</p>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
on:click=move |_| {
|
on:click=move |_| {
|
||||||
let subject = pending_delete.get().map(|s| s.subject.clone()).unwrap_or_default();
|
let subject = pending_delete
|
||||||
|
.get()
|
||||||
|
.map(|s| s.subject.clone())
|
||||||
|
.unwrap_or_default();
|
||||||
log!("Deleting scholarship with subject {}", subject);
|
log!("Deleting scholarship with subject {}", subject);
|
||||||
delete_action.dispatch(DeleteProviderScholarship {
|
delete_action
|
||||||
|
.dispatch(DeleteProviderScholarship {
|
||||||
scholarship_id: subject,
|
scholarship_id: subject,
|
||||||
provider_id: provider_id.get().unwrap_or_default()
|
provider_id: provider_id.get().unwrap_or_default(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
disabled=modal_disabled
|
disabled=modal_disabled
|
||||||
>"Confirm"</ActionButton>
|
>
|
||||||
<ActionButton
|
"Confirm"
|
||||||
on:click=move |_| pending_delete.set(None)
|
</ActionButton>
|
||||||
>"Cancel"</ActionButton>
|
<ActionButton on:click=move |_| pending_delete.set(None)>"Cancel"</ActionButton>
|
||||||
</dialog>
|
</dialog>
|
||||||
<div class="w-75">
|
<div class="w-75">
|
||||||
<Panel>
|
<Panel>
|
||||||
@@ -223,31 +220,42 @@ fn ScholarshipList(
|
|||||||
<Transition fallback=Loading>
|
<Transition fallback=Loading>
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
{move || {
|
{move || {
|
||||||
scholarships.get().map(|result| {
|
scholarships
|
||||||
|
.get()
|
||||||
|
.map(|result| {
|
||||||
match result {
|
match result {
|
||||||
Ok(list) => {
|
Ok(list) => {
|
||||||
let views = list.iter().map(|entry| {
|
let views = list
|
||||||
|
.iter()
|
||||||
|
.map(|entry| {
|
||||||
view! {
|
view! {
|
||||||
<ScholarshipListEntry scholarship=entry.clone()
|
<ScholarshipListEntry
|
||||||
on_delete=Callback::new(on_item_delete)/>
|
scholarship=entry.clone()
|
||||||
|
on_delete=Callback::new(on_item_delete)
|
||||||
|
/>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Either::Left(views.collect_view())
|
Either::Left(views.collect_view())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
Either::Right(view! {
|
Either::Right(
|
||||||
|
view! {
|
||||||
<div>
|
<div>
|
||||||
<p>"Failed to load scholarship list: "{err.to_string()}</p>
|
<p>"Failed to load scholarship list: "{err.to_string()}</p>
|
||||||
</div>
|
</div>
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
.collect_view()
|
||||||
}
|
|
||||||
}).collect_view()
|
|
||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="p-2 bg-red-800 rounded-md text-center text-white hover:bg-red-900 transition-all cursor-pointer"
|
<div
|
||||||
on:click=create_on_click>
|
class="p-2 bg-red-800 rounded-md text-center text-white hover:bg-red-900 transition-all cursor-pointer"
|
||||||
|
on:click=create_on_click
|
||||||
|
>
|
||||||
"Create New"
|
"Create New"
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -307,13 +315,15 @@ fn ScholarshipListEntry(
|
|||||||
<span>{name}</span>
|
<span>{name}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<div class="p-2 flex-1 bg-red-800 border-r border-white rounded-bl-md text-white text-center
|
<div
|
||||||
|
class="p-2 flex-1 bg-red-800 border-r border-white rounded-bl-md text-white text-center
|
||||||
hover:bg-red-900 cursor-pointer transition-all"
|
hover:bg-red-900 cursor-pointer transition-all"
|
||||||
on:click=edit_click
|
on:click=edit_click
|
||||||
>
|
>
|
||||||
"Edit"
|
"Edit"
|
||||||
</div>
|
</div>
|
||||||
<div class="p-2 flex-1 bg-red-800 border-l border-white rounded-br-md text-white text-center
|
<div
|
||||||
|
class="p-2 flex-1 bg-red-800 border-l border-white rounded-br-md text-white text-center
|
||||||
hover:bg-red-900 cursor-pointer transition-all"
|
hover:bg-red-900 cursor-pointer transition-all"
|
||||||
on:click=move |_| on_delete.run(scholarship.clone())
|
on:click=move |_| on_delete.run(scholarship.clone())
|
||||||
>
|
>
|
||||||
@@ -490,16 +500,22 @@ fn ScholarshipForm(
|
|||||||
<Panel>
|
<Panel>
|
||||||
<Show
|
<Show
|
||||||
when=move || scholarship_id.get().is_some()
|
when=move || scholarship_id.get().is_some()
|
||||||
fallback=|| view! { <p>"Choose a scholarship from the right, or create a new one."</p> }
|
fallback=|| {
|
||||||
|
view! { <p>"Choose a scholarship from the right, or create a new one."</p> }
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Suspense fallback=Loading>
|
<Suspense fallback=Loading>
|
||||||
<ValidatedForm on_submit=Callback::new(on_submit)>
|
<ValidatedForm on_submit=Callback::new(
|
||||||
|
on_submit,
|
||||||
|
)>
|
||||||
{move || {
|
{move || {
|
||||||
scholarship_info.get()
|
scholarship_info
|
||||||
|
.get()
|
||||||
.map(|res_scholarship| {
|
.map(|res_scholarship| {
|
||||||
match res_scholarship {
|
match res_scholarship {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
Either::Left(view! {
|
Either::Left(
|
||||||
|
view! {
|
||||||
<Row>
|
<Row>
|
||||||
<h1 class="text-3xl font-bold">
|
<h1 class="text-3xl font-bold">
|
||||||
"Scholarship Info Form (test)"
|
"Scholarship Info Form (test)"
|
||||||
@@ -584,7 +600,10 @@ fn ScholarshipForm(
|
|||||||
<RadioList
|
<RadioList
|
||||||
data_member="essay_prompt"
|
data_member="essay_prompt"
|
||||||
data_map=form_data
|
data_map=form_data
|
||||||
items=vec!["Test 1", "Test 2", "Test 3"].iter().map(|s| s.to_string()).collect()
|
items=vec!["Test 1", "Test 2", "Test 3"]
|
||||||
|
.iter()
|
||||||
|
.map(|s| s.to_string())
|
||||||
|
.collect()
|
||||||
disabled=elements_disabled
|
disabled=elements_disabled
|
||||||
label="If so, select a prompt from the list below."
|
label="If so, select a prompt from the list below."
|
||||||
/>
|
/>
|
||||||
@@ -634,22 +653,24 @@ fn ScholarshipForm(
|
|||||||
displayed_text=misc_text
|
displayed_text=misc_text
|
||||||
/>
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
})
|
},
|
||||||
|
)
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
Either::Right(view! {
|
Either::Right(
|
||||||
|
view! {
|
||||||
<p>"Error while getting scholarship: "{err.to_string()}</p>
|
<p>"Error while getting scholarship: "{err.to_string()}</p>
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
.collect_view()
|
||||||
}
|
|
||||||
}).collect_view()
|
|
||||||
}}
|
}}
|
||||||
</ValidatedForm>
|
</ValidatedForm>
|
||||||
<ActionButton
|
<ActionButton on:click=move |_| {
|
||||||
on:click=move |_| {
|
|
||||||
create_comps.dispatch(CreateTestComparisons {});
|
create_comps.dispatch(CreateTestComparisons {});
|
||||||
}
|
}>"Create Comparisons"</ActionButton>
|
||||||
>"Create Comparisons"</ActionButton>
|
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</Show>
|
</Show>
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
Reference in new issue
Block a user