diff --git a/src/pages/admin/fields/project.rs b/src/pages/admin/fields/project.rs index 34a733f..6efb140 100644 --- a/src/pages/admin/fields/project.rs +++ b/src/pages/admin/fields/project.rs @@ -89,14 +89,7 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { location_district.set(listing_opt.clone().unwrap_or_default().location.district); agent.set(match listing_opt.clone() { Some(listing) => Some(listing.agent), - None => { - let agents = (*all_agents).clone(); - if let Some(default_agent) = agents.last() { - Some(default_agent.clone()) - } else { - None - } - }, + None => None, }); project_state.set(match listing_opt.clone() { Some(listing) => Some(listing.project.project_state), @@ -106,15 +99,11 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { }); project_condition.set(match listing_opt.clone() { Some(listing) => Some(listing.project.project_condition), - None => { - Some(ProjectCondition::New) - }, + None => None, }); project_type.set(match listing_opt.clone() { Some(listing) => Some(listing.project.project_type), - None => { - Some(ProjectType::Solar) - }, + None => None, }); project_description.set(match listing_opt.clone() { Some(listing) => listing.project.description, @@ -315,11 +304,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { {if (*agent).clone().is_none() { - html! { -
-
{"Agente asignado"}
- options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} /> -
+ match props.edittype.clone() { + EditType::New => html! { +
+
{"Agente asignado"}
+ options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} /> +
+ }, + EditType::Existing(_) => if *user_typed { + html! { +
+
{"Agente asignado"}
+ options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} /> +
+ } + } else { + html! {} + } } } else { html! { @@ -331,11 +332,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { } } {if (*project_state).clone().is_none() { - html! { -
-
{"Estado del Proyecto"}
- options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} /> -
+ match props.edittype.clone() { + EditType::New => html! { +
+
{"Estado del Proyecto"}
+ options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} /> +
+ }, + EditType::Existing(_) => if *user_typed { + html! { +
+
{"Estado del Proyecto"}
+ options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} /> +
+ } + } else { + html! {} + } } } else { html! { @@ -348,11 +361,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { } {if (*project_condition).clone().is_none() { - html! { -
-
{"Condición del Proyecto"}
- options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} /> -
+ match props.edittype.clone() { + EditType::New => html! { +
+
{"Condición del Proyecto"}
+ options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} /> +
+ }, + EditType::Existing(_) => if *user_typed { + html! { +
+
{"Condición del Proyecto"}
+ options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} /> +
+ } + } else { + html! {} + } } } else { html! { @@ -364,11 +389,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html { } } {if (*project_type).clone().is_none() { - html! { -
-
{"Tipo de Proyecto"}
- options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} /> -
+ match props.edittype.clone() { + EditType::New => html! { +
+
{"Tipo de Proyecto"}
+ options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} /> +
+ }, + EditType::Existing(_) => if *user_typed { + html! { +
+
{"Tipo de Proyecto"}
+ options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} /> +
+ } + } else { + html! {} + } } } else { html! {