Repository navigation
fix(plugin-detail): a related tab's 「+ 添加」 no longer reads a row's own party as its catalog (#36659) - #36704
Merged
Conversation
…ick makes a whole row A master_detail child's one other required lookup was taken as its source catalog even when it was a party of the row (a contract's primary contact, scoped by dependsOn to the account) and when the child still had required fields a pick leaves empty. The account's contracts tab then offered a picker of every account's contacts. The catalog now needs candidates that do not depend on the row and no other required field left for a person to write. Claude-Session: https://claude.ai/code/session_01JQwxbY1aynwSYJFZFRNKBL
Contributor
Author
|
repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj 维护者速读在客户的「合同」页签点「添加」,以前会弹出一个列着所有客户联系人的选择框(选了还会出错)。现在直接新建一份属于这个客户的合同,客户已经填好。报价、商机的产品明细页签仍然弹出产品选择框。浏览器里在 HotCRM 上验证过。 席位核对 — ACCEPT (L1) · repo:objectstack#1 · head
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Warren · project thread
Fixes #36659
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
The related tab's 「+ 添加」 (objectstack#35601) derives its picker from the relationship when the page authors no
add(derivedAddOf,ui/packages/plugin-detail/src/RelatedList.tsx). For amaster_detailchild it took the child's one other required single-valued lookup as the child's source catalog: the picker listed that lookup's object and a pick created a child row naming it. That is right for a line's product and wrong for a row's own party:crm_contractismaster_detailtocrm_accountand requirescrm_contact(its primary contact,dependsOn: ['crm_account']). So an account's 合同 tab opened a picker ofcrm_contactwith no filter (the reportedGET /api/v1/data/crm_contact?populate=crm_account&top=10&skip=0), listing other accounts' contacts, and a pick would have tried to create a contract from a contact.The function's own docblock already stated the condition for a catalog: "the field every row must name, so a pick is a whole row". This PR checks both halves of that sentence before returning a catalog picker:
dependsOnentry, or alookupFilterscomparand{ $record }, is scoped by the row; the picker lists the catalog for the whole list and cannot apply that scope. Such a lookup is a party of the row, not a catalog (scopedByRow).defaultValueor a select option markeddefault(the engine'sapplyFieldDefaults,packages/objectql/src/engine-select-option-default.test.ts),readonly, or a computed type (isComputedFieldType: formula, summary, rollup, autonumber).requiredis the writer's contract, so a contract that still needs its value and dates is filled in on its form, not completed by a pick (insertDefaults).When either fails,
derivedAddOfreturnsundefined, which is the existing "master_detail with no catalog" path: 「+ 添加」 opens New with the parent filled in. Thelookuppath (pick unlinked children of the list's own object) and an authoredaddare untouched.Measured against HotCRM 6.6.0 metadata (read, not run):
crm_contractloses the picker on both counts (contactdependsOnthe account;contract_term_months,start_date,end_date,contract_valuerequired with no default).crm_opportunity_line_item,crm_quote_line_itemkeep the product picker (product required, nodependsOn,quantityrequired withdefaultValue: 1,unit_pricedeliberately notrequired).Changeset:
@object-ui/plugin-detailpatch.Tests
ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx, in the existing describe "「+ 添加」 is decided by the relationship":dependsOnthe parent, required value and start date, autonumber number): 「+ 添加」 calls New, opens no picker, and no read ofcontactis made;derivedAddOfreturnsundefinedfor a required lookup scoped bydependsOn, and for one whoselookupFiltersreads$record;derivedAddOfreturnsundefinedwhen another required field has no default;defaultValue, select optiondefault), arereadonlyor computed, and whose product carries a staticlookupFilters, keeps{ picker: { object: 'product' }, linkField: 'product' }. The existing catalog test ("master_detail with a catalog: the picker lists the catalog…") passes unchanged.Reverse verification: with the fix committed,
RelatedList.tsxrestored fromorigin/mainand the file run, then restored fromHEAD(git diff HEADempty): the 4 new defect tests fail, the control and the 17 existing tests pass.Package run under the verify lock
The package run started before the select-option-default arm was added; the touched test file was re-run at
26c5daf1:Tests 21 passed (21).Acceptance notes
lookupFilters(for example HotCRM'scrm_productlookupis_active = trueon opportunity lines), so it can offer a retired product. Read from code, not reproduced in a browser.name); with the contract tab no longer opening a picker it does not appear there.lookuparm this PR does not touch): on an opportunity's 合同 tab, 「+ 添加」 lists unlinked contracts of every account (HotCRM 6.6.0, opportunity "Initech Cloud Migration": the picker offers CTR-0004 of Stark Medical next to CTR-0003 of Initech Solutions; requestGET /api/v1/data/crm_contract?populate=crm_account&top=10&skip=0&filter=[["crm_opportunity","is_empty"]]), althoughcrm_contract.crm_opportunitydeclaresdependsOn: ['crm_account']. The same picker's first column is headed 「NAME」 and is empty, because the derived picker's label field falls back tonameand a contract's name field iscontract_number. Reported to the seat for filing.Verification
Read first:
ui/packages/plugin-detail/src/RelatedList.tsx,derivedAddOf: the two new early returns (riskiest hunk:leftToWrite, which decides which existing line tabs keep their picker).scopedByRowandinsertDefaultsjust below it.Browser, HotCRM 6.6.0 (
d513851,objectstack dev --seed-admin --fresh) behind this branch's Console (Vite,DEV_PROXY_TARGET), zh-CN, at961e6e57:[data-testid="record-picker-dialog"]count 0); the requests after the click are the record page's own reads, noGET /api/v1/data/crm_contact.GET /api/v1/meta/objects/crm_contract→crm_contactrequired: true,dependsOn: ["crm_account"];contract_value,start_daterequired: truewith no default.origin/main, the card's own repro on 18.6.0): the same click opened 「添加」 listing contacts of two accounts.Screenshots are attached in the project thread (GitHub's image store takes browser uploads only): the account's 合同 tab; the New contract form after 「+ 添加」.
Two-minute check: on a HotCRM account, open the 合同 tab and click 「+ 添加」: the New contract form opens with the account filled in, no picker. On an opportunity's product lines tab, 「+ 添加」 still opens the product picker.
Generated by Claude Code