feat(orm): add overridable NameSearch#188
Conversation
- Add BaseModel.NameSearch that defaults to DisplayName like via Search. - Wire M2O, M2O-Ref, and M2M Tags typeahead remotes to NameSearch. - Expose NameSearch on WebModelStore and webapistore base services. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds reusable ChangesNameSearch typeahead integration
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant RelationField
participant RelationStore
participant BaseModel
participant Search
RelationField->>RelationStore: NameSearch(keyword, effectiveConditions)
RelationStore->>BaseModel: invoke NameSearch
BaseModel->>Search: build condition and call Search
Search-->>RelationField: return matching rows
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Exercise name ?? '' when buildNameSearchCondition receives nullish name. - Call NameSearch with only the name argument to hit condition = []. Co-authored-by: Cursor <cursoragent@cursor.com>
- Mount M2O/M2O-Ref and M2M Tags fields with stubbed el-select-v2. - Assert remote-method calls NameSearch with trimmed keyword and options. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/web/web/components/field/relationTypeahead.NameSearch.test.ts`:
- Around line 171-197: Update the OManyToManyRefTagsField remote-search test to
assert that the mocked Search service is never called, while preserving the
existing NameSearch call and hydration-field assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 525d0911-c746-438b-a0d9-2db54e655647
📒 Files selected for processing (1)
modules/web/web/components/field/relationTypeahead.NameSearch.test.ts
- Align OManyToManyRefTagsField NameSearch coverage with the Tags case. Co-authored-by: Cursor <cursoragent@cursor.com>
- Exercise query ?? '' / keyword || '' via null and empty remote queries. - Hit relationStore?. short-circuit when the relation store is unresolved. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/improve |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@modules/web/web/components/field/relationTypeahead.NameSearch.test.ts`:
- Around line 295-313: Add an equivalent Search not-called assertion after the
.trigger-remote-null click in the OManyToManyRefTagsField test, alongside the
existing NameSearch expectation, so both falsy-query branches verify the legacy
Search service is not invoked.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8d264218-0672-48ec-8b4a-8cf5fb67e8ff
📒 Files selected for processing (1)
modules/web/web/components/field/relationTypeahead.NameSearch.test.ts
PR Code Suggestions ✨No code suggestions found for the PR. |
- Mirror the empty-keyword case after trigger-remote-null. Co-authored-by: Cursor <cursoragent@cursor.com>
Summary
BaseModel.NameSearch(name, condition?, options?) → T[]with a default DisplayNamelikekeyword path that reusesSearch(record rules / soft-delete unchanged).NameSearch:OManyToOneField,OManyToOneRefField,OManyToManyTagsField,OManyToManyRefTagsField(M2M tags align to DisplayNamelike; multi-field matching viastatic override).NameSearchonWebModelStoreand webapistore base services so conventional RPC/store binding stays consistent.Implements PR-P0-M3 from the module platform gap assessment (NameSearch hook; NameCreate still P2).
Test plan
./choysum test unit core --be --pattern 'NameSearch|buildNameSearch|mergeNameSearch'npx vitest run modules/web/web/components/field/OManyToOneField.mapping.test.ts modules/web/web/components/field/OManyToOneRefField.mapping.test.ts modules/web/web/components/field/OManyToManyTagsField.mapping.test.ts modules/web/web/components/field/OManyToManyRefTagsField.mapping.test.ts./choysum test typecheck coreand./choysum test typecheck webstatic override NameSearchon a demo model changes typeahead matchingBy submitting this pull request, you agree to the Contributor License Agreement (CLA) of this project. If you have not yet signed it, please follow the instructions provided by @cla-bot below.
Summary by CodeRabbit
NameSearchfor typeahead-style lookups (defaults toIdandDisplayName).NameSearchandCopyon the model store for use by the UI.NameSearchfor remote typeahead.NameSearchwiring, default options/limits, and that the legacySearchpath is not used.