Fixed dropdown in project. PERFECT

This commit is contained in:
Franklin 2023-04-25 14:00:38 -04:00
parent 5240ec953b
commit c174123dc2

View File

@ -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 {
<TextField label={"Distrito"} value={location_district} required={true} onchange={ontype_cb.clone()} />
<MediaPicker value={media} onchange={ontype_cb.clone()} item={jl_types::dto::item::Item::Project}/>
{if (*agent).clone().is_none() {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Agente asignado"}</div>
<DropDown<Agent> options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} />
</div>
match props.edittype.clone() {
EditType::New => html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Agente asignado"}</div>
<DropDown<Agent> options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} />
</div>
},
EditType::Existing(_) => if *user_typed {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Agente asignado"}</div>
<DropDown<Agent> options={(*all_agents).clone()} selected={agent} onchange={onselect_cb.clone()} />
</div>
}
} else {
html! {}
}
}
} else {
html! {
@ -331,11 +332,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
}
}
{if (*project_state).clone().is_none() {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Estado del Proyecto"}</div>
<DropDown<ProjectState> options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} />
</div>
match props.edittype.clone() {
EditType::New => html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Estado del Proyecto"}</div>
<DropDown<ProjectState> options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} />
</div>
},
EditType::Existing(_) => if *user_typed {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Estado del Proyecto"}</div>
<DropDown<ProjectState> options={vec![ProjectState::Finished, ProjectState::InConstruction]} selected={project_state} onchange={onselect_cb2} />
</div>
}
} else {
html! {}
}
}
} else {
html! {
@ -348,11 +361,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
}
{if (*project_condition).clone().is_none() {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Condición del Proyecto"}</div>
<DropDown<ProjectCondition> options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} />
</div>
match props.edittype.clone() {
EditType::New => html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Condición del Proyecto"}</div>
<DropDown<ProjectCondition> options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} />
</div>
},
EditType::Existing(_) => if *user_typed {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Condición del Proyecto"}</div>
<DropDown<ProjectCondition> options={vec![ProjectCondition::Resale, ProjectCondition::New]} selected={project_condition} onchange={onselect_cb3} />
</div>
}
} else {
html! {}
}
}
} else {
html! {
@ -364,11 +389,23 @@ pub fn generate_fields_for_project(props: &ProjectFieldsProps) -> Html {
}
}
{if (*project_type).clone().is_none() {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Tipo de Proyecto"}</div>
<DropDown<ProjectType> options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} />
</div>
match props.edittype.clone() {
EditType::New => html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Tipo de Proyecto"}</div>
<DropDown<ProjectType> options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} />
</div>
},
EditType::Existing(_) => if *user_typed {
html! {
<div class={"textfield-container"}>
<div class={"textfield-label-required"}>{"Tipo de Proyecto"}</div>
<DropDown<ProjectType> options={vec![ProjectType::Apartamento, ProjectType::Casa, ProjectType::Oficina, ProjectType::Local, ProjectType::Solar]} selected={project_type} onchange={onselect_cb4} />
</div>
}
} else {
html! {}
}
}
} else {
html! {