Enrich invoice line items and previews, migrate several CRM surfaces to Ant, and wire shared money/picker helpers.
4.9 KiB
4.9 KiB
PersonPicker — Design Spec
Date: 2026-11-29
Status: Approved in conversation (layout A, scope 2, create-via-modal)
Problem
«افزودن شخص جدید» alongside person select is duplicated and visually awkward (link button under select). Activity and Deal copy the same search + modal logic; Invoice uses a different label and navigates away instead of creating inline.
Goals
- One Ant Design Vue component for person select + create.
- Cleaner UX: create action lives in the select dropdown footer.
- Create always opens embedded
PersonFormViewin a modal; after save, select that person without leaving the parent form. - Wire into Activity form, Deal form, and Invoice form. Treasury stays out of scope.
Non-goals
- Refactoring
TreasuryPartySelect(multi-kind party: person/company/user/other). - Migrating unrelated form chrome or legacy
Ui*kits beyond what this component needs for its own modal. - Shared company picker.
Approach
Full PersonPicker component that owns:
a-selectwith server search (GET /people?q=&limit=30, 300ms debounce)- Dropdown footer: divider + link button (
UserAddOutlined+ configurable label) - Modal with embedded
PersonFormView - Optional seed list so parents can keep already-loaded people visible
Parents keep only v-model (person id) and optional side effects on created / change.
API
File: apps/web/src/components/PersonPicker.vue
| Prop / model | Type | Default | Notes |
|---|---|---|---|
modelValue (v-model) |
string |
'' |
Selected person id |
placeholder |
string |
'جستجو و انتخاب شخص' |
|
allowClear |
boolean |
true |
|
disabled |
boolean |
false |
|
addLabel |
string |
'افزودن شخص جدید' |
Invoice may pass 'افزودن مشتری جدید' |
seedPeople |
PersonDto[] |
[] |
Initial / remembered options |
modalNest |
boolean |
false |
Forward nest to modal when parent is already nested |
| Emit | Payload | When |
|---|---|---|
update:modelValue |
string |
Selection cleared or changed |
change |
PersonDto | null |
Resolved person object when known; null on clear |
created |
PersonDto |
After successful create in modal (also selects that person) |
UI / design rules
- Ant-only controls; no raw HTML buttons/inputs; no new scoped look CSS.
- No manual
sizeon Ant controls (themecontrolHeight: 36). - Dropdown footer:
a-divider+a-button type="link"with icon; stop mousedown so select does not steal focus/close incorrectly (same pattern asTreasuryPartySelect). - Modal: prefer
a-modalif the surrounding page is Ant-migrated and does not already depend onUiModalfor this flow; if nesting/UiModalis required for Activity’s existing nest behavior, match current Activity/Deal nesting so z-index/stacking does not regress. - Pass
:initial-queryfrom the current search string intoPersonFormViewwhen opening create.
Parent integration
ActivityFormView
- Replace select + link + person-search watchers + create modal with
<PersonPicker v-model="personId" :seed-people="people" @change="…" @created="…" />. - On
change/created, call existingrememberPerson/ deal-link side effects as today. - Remove duplicated
personQuery/personResults/newPersonOpen/ modal block when fully owned by the picker (seed viapeopleref still updated fromchange).
DealFormView
- Same as Activity.
- On
created/ person pick: keepcontactKind = 'person'and company auto-fill fromperson.company(existingpickPersonbehavior).
InvoiceFormView
- Replace select +
RouterLink«افزودن مشتری جدید» withPersonPicker(add-labeloptional). - Switch from client-only filter over loaded
peopleto server search inside the picker; pass currentpeopleasseedPeople. - On create/select, ensure parent
peoplelist still has the chosen person for any labels/downstream logic.
Behavior details
- Empty query: show seed / remembered options (not a forced empty list).
- Clear: emit
''andchange(null). - Create cancel: close modal only.
- Create save: close modal, merge person into internal options, set
modelValue, emitcreatedthen selection updates. - Loading: select
loadingwhile search in flight. - Errors: failed search → empty options for that query (silent or message consistent with Activity today).
Governance
- Shared component under
apps/web/src/components/(notcomponents/ui). - Touch only the three views listed for replacement; no drive-by refactors.
- Ant strict rules: no new chrome CSS, no
sizeprops.
Success criteria
- One shared component used in Activity, Deal, Invoice.
- No standalone «افزودن شخص جدید» link under the select in those three views.
- Create stays in-modal; Invoice no longer navigates away to create.
npm run build -w @mento/webpasses.