Bug: entities show raw SIDs instead of names in list and detail views; relationship fields wiped on edit #11
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_biz#11
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Two systemic bugs across many entity types:
Bug 1 — Raw SIDs shown instead of entity names
List views (all affected)
List handlers pass raw entity structs to templates without loading related entities. Templates then render the raw
*_sidstring.instruments_listcompany_sidcontracts_listperson_sid,company_sid,instrument_sid,fund_sidtransactions_listcontract_sidcontacts_listperson_sid,company_sid,user_sid,contract_sid,opportunity_sid,deal_sidopportunities_listcompany_sid,person_siddeals_listcompany_sid,person_sid,opportunity_sid,instrument_sid,contract_sidprojects_listcompany_sid,owner_sidtasks_listproject_sid,milestone_sid,assignee_sid,story_sidmilestones_listproject_sid,owner_sidDetail views (two affected)
Most detail handlers correctly load and resolve related entities. Two exceptions:
persons_detailcompany_sid— person has a company field but handler never loads itcomments_detailcompany_sid,person_sid,instrument_sid,contract_sid,opportunity_sid,deal_sid,project_sid,task_sid,milestone_sid,transaction_sid,contact_sid) — handler only loads the comment itselfAll in
crates/hero_biz_ui/src/web/handlers/mod.rs.Fix pattern: load related entities in each handler (the same lookups the working detail handlers already do), then pass them to the template for name resolution.
Bug 2 — Relationship fields silently wiped on create/update
When building the updated struct, several
*_sidand other fields are hardcoded toNone/Vec::new()instead of being read from the form or preserved from the existing record. Any value set via the Links button is lost the moment the edit form is saved.contact_create(~line 6373) andcontact_update(~line 6524)ContactForm(line 6280) has no fields for these three.deal_create(~line 2377) anddeal_update(~line 2562)deal_updatepreserveslinksfrom the existing record but still wipes these two.task_create(~line 7316) andtask_update(~line 7481)TaskFormhas nostory_sidfield.project_create(~line 6701) andproject_update(~line 6846)None preserved from existing record.
milestone_create(~line 7002) andmilestone_update(~line 7156)Fix pattern: in each
*_updatehandler, load the existing record first, then copy the hardcoded-None fields from it before saving — the same read-modify-write pattern already used byupdate_contact_links,update_deal_links, etc. For*_createhandlers, decide whether each field is intentionally absent from the creation form (acceptable) or should be settable.Bug: entities show ID instead of name in list views; contact links lost on editto Bug: entities show raw SIDs instead of names in list and detail views; relationship fields wiped on editImplementation Spec for Issue #11
Objective
Fix two systemic bugs in
crates/hero_biz_ui/src/web/handlers/mod.rsandcrates/hero_biz_ui/src/web/templates/mod.rs:*_updatehandlers hardcode relationship SID fields toNone/Vec::new(), silently wiping any links set via the Links button.Requirements
persons_detailmust load the linked Company and display it as a resolved link.comments_detailmust load all 11 possible related entities and display whichever are set as resolved links.*_updatehandler must perform a read-modify-write: load the existing record first, then apply form values on top, copying any fields not in the form from the existing record.Files to Modify
crates/hero_biz_ui/src/web/handlers/mod.rscrates/hero_biz_ui/src/web/templates/mod.rsImplementation Plan
Step 1 -- Fix
instruments_list: load companies, resolvecompany_sidFiles:
handlers/mod.rs(~line 483),templates/mod.rs(~line 953)instruments_list, load all companies for the space after loading instrumentscompanies: Vec<Company>field toInstrumentsListTemplatecompany_sidwith a lookup producing a resolved name/linkDependencies: none
Step 2 -- Fix
contracts_list: load persons/companies, resolve SIDsFiles:
handlers/mod.rs(~line 860),templates/mod.rs(~line 1587)personsandcompaniesfor the spaceContractsListTemplateDependencies: none
Step 3 -- Fix
transactions_list: load contracts, resolvecontract_sidFiles:
handlers/mod.rs(~line 1292),templates/mod.rs(~line 2186)contractsfor the spacecontracts: Vec<Contract>toTransactionsListTemplatecontract_siddisplay with resolved contract nameDependencies: none
Step 4 -- Fix
contacts_list: load persons/companies, add resolved columnsFiles:
handlers/mod.rs(~line 1690),templates/mod.rs(~line 2749)personsandcompaniesfor the spaceContactsListTemplateDependencies: none
Step 5 -- Fix
opportunities_list: load companies/persons, add resolved columnsFiles:
handlers/mod.rs(~line 1773),templates/mod.rs(~line 2984)companiesandpersonsfor the spaceOpportunitiesListTemplateDependencies: none
Step 6 -- Fix
deals_list: load companies/persons/opportunities, add resolved columnsFiles:
handlers/mod.rs(~line 1842),templates/mod.rs(~line 3184)companies,persons, andopportunitiesfor the spaceDealsListTemplateDependencies: none
Step 7 -- Fix
projects_list: load companies/persons, add resolved columnsFiles:
handlers/mod.rs(~line 4536),templates/mod.rs(~line 3726)companiesandpersonsfor the spaceProjectsListTemplateDependencies: none
Step 8 -- Fix
tasks_list: load milestones/persons, resolvemilestone_sidandassignee_sidFiles:
handlers/mod.rs(~line 4639),templates/mod.rs(~line 4021)milestonesandpersonsfor the space (projects already loaded)milestonesandpersonstoTasksListTemplateDependencies: none
Step 9 -- Fix
milestones_list: load projects/persons, add resolved columnsFiles:
handlers/mod.rs(~line 4725),templates/mod.rs(~line 4422)projectsandpersonsfor the spaceMilestonesListTemplateDependencies: none
Step 10 -- Fix
persons_detail: load company, display as resolved linkFiles:
handlers/mod.rs(~line 322),templates/mod.rs(~line 401)Companyfromperson.company_sid(if set)company: Option<Company>toPersonDetailTemplate<dl>in the rendered detail viewDependencies: none
Step 11 -- Fix
comments_detail: load all 11 related entities and display themFiles:
handlers/mod.rs(~line 1667),templates/mod.rs(~line 2692)Option<EntityType>fields onCommentDetailTemplate<dt>/<dd>rows to the rendered detail viewDependencies: none
Step 12 -- Fix
contact_update: preservecontract_sid,opportunity_sid,deal_sidFiles:
handlers/mod.rs(~line 6524)contract_sid: None,opportunity_sid: None,deal_sid: Nonewith values from existing recordDependencies: none
Step 13 -- Fix
deal_update: preserveinstrument_sidandcontract_sidFiles:
handlers/mod.rs(~line 2562)existingto preservelinksinstrument_sidandcontract_sidfrom the existing recordDependencies: none
Step 14 -- Fix
task_update: preservestory_sid,depends_on, andlinksFiles:
handlers/mod.rs(~line 7481)story_sid: None,depends_on: Vec::new(),links: Vec::new()with values from existing recordDependencies: none
Step 15 -- Fix
project_update: preserveend_date,links, andswimlanesFiles:
handlers/mod.rs(~line 6846)end_date: None,links: Vec::new(),swimlanes: Vec::new()with values from existing recordDependencies: none
Step 16 -- Fix
milestone_update: preservecompleted_date,completed_at, andlinksFiles:
handlers/mod.rs(~line 7156)completed_date: None,completed_at: None,links: Vec::new()with values from existing recordDependencies: none
Acceptance Criteria
instruments_listshows company name (linked) instead of raw SIDcontracts_listshows resolved person and company columnstransactions_listshows resolved contract name instead of raw SIDcontacts_listshows resolved person and company columnsopportunities_listshows resolved company and person columnsdeals_listshows resolved company and person columnsprojects_listshows resolved company and owner columnstasks_listshows resolved milestone and assignee columnsmilestones_listshows resolved project and owner columnspersons_detailshows a Company field with a resolved linkcomments_detailshows resolved links for all relationship fields that are setcontract_sid,opportunity_sid, ordeal_sidinstrument_sidorcontract_sidstory_sid,depends_on, orlinksend_date,links, orswimlanescompleted_date,completed_at, orlinkscargo buildcompletes with no errors and no new warningsNotes
t.x_sid.as_ref().and_then(|sid| self.xs.iter().find(|x| x.id() == sid.as_str())).map(|x| x.name.clone()).unwrap_or_else(|| "-".to_string())).if let Some(x) = &self.x { format link } else { raw_sid }.*_createhandlers for Contact, Deal, and Task are intentionally left withNonefor link SID fields not in their forms -- document each with a comment.Build & Test Results
Build
PASS
Build completed successfully (release profile, optimized). No errors or warnings.
Tests
1 passed; 0 failed; 0 ignored
All tests passed.
Implementation Complete
Bug 1 — Raw SIDs replaced with resolved names
List views (9 handlers fixed):
instruments_list: loads companies, resolvescompany_sidto name in the Company columncontracts_list: loads persons and companies, adds Person and Company columns with resolved namestransactions_list: loads contracts, resolvescontract_sidto contract namecontacts_list: loads persons and companies, adds Person and Company columnsopportunities_list: loads companies and persons, adds Company and Person columnsdeals_list: loads companies and persons, adds Company and Person columnsprojects_list: loads companies and persons, resolvescompany_sidandowner_sidtasks_list: loads milestones and persons, adds Milestone and Assignee columns (project column was already resolved)milestones_list: loads projects and persons, adds Project and Owner columnsDetail views (2 handlers fixed):
persons_detail: loads the linked Company (if set) and displays it as a resolved link in the detail<dl>comments_detail: loads all 11 possible related entities (company, person, instrument, contract, opportunity, deal, project, task, milestone, transaction, contact) and renders whichever are set as resolved links in the detail viewBug 2 — Relationship fields preserved on update
Five
*_updatehandlers now perform a read-modify-write: the existing record is loaded first and any fields not present in the edit form are copied from it rather than defaulted toNone/Vec::new().contact_update: preservescontract_sid,opportunity_sid,deal_siddeal_update: preservesinstrument_sid,contract_sid(handler already preservedlinks)task_update: preservesstory_sid,depends_on,linksproject_update: preservesend_date,links,swimlanesmilestone_update: preservescompleted_date,completed_at,linksFiles changed
crates/hero_biz_ui/src/web/handlers/mod.rscrates/hero_biz_ui/src/web/templates/mod.rsBuild & Tests
make buildpasses with no errors or warnings. All existing tests pass (1 test inhero_biz_ui).