feat: cross-record (relation-path) visibility conditions [3.x]#161
Open
ManukMinasyan wants to merge 13 commits into
Open
feat: cross-record (relation-path) visibility conditions [3.x]#161ManukMinasyan wants to merge 13 commits into
ManukMinasyan wants to merge 13 commits into
Conversation
Wires RelationAttribute conditions into VisibilityData.evaluate(): relation branch resolves related keys via RelationConditionResolver before the model-attribute branch; null record fails open. Generalises the flag-skip guard to cover both relation and model-attribute sources. Adds hasRelationAttributeConditions() helper. Enables MODEL_ATTRIBUTE_CONDITIONS in the test environment so both new and existing condition tests run under the same flag gate.
…cord value picker in condition UI
Apply Rector RemoveNullArgOnNullDefaultParamRector and EncapsedStringsToSprintfRector to our changed files; fix Pint import ordering and spacing in RelationConditionResolver.
…s (relation is_in edit 500)
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.
Summary
Extends the package so a custom-field/section visibility condition can reference a related record via a one/two-hop relation path (e.g.
household.projects), not just a field on the same record.Driving use case (ClickUp 868jtwph3, customer: Los Angeles): show an external-ID Section on Household Member only when the member's Household is associated with specific Projects — i.e.
HouseholdMember → Household → Projects.What's new
ConditionSource::RelationAttribute— the dotted relation path is stored in the existingfield_code(no schema/migration change).IS_IN/IS_NOT_IN, set-intersection semantics (string-normalized), exposed only for the relation source.RelationConditionResolver— walks a ≤2-hop dotted path on a record to the set of terminal related keys; reflects the terminal related model (no DB query) for the value picker.VisibilityData::evaluateCondition) — relation conditions resolve against the record's relations and never emit client JS (FrontendVisibilityServicebails to null); form fields/sections fall back to a server-sidevisible()closure. Create form (no record) → fail-open.VisibilityComponent) — relation source option, path picker (from config allowlist),IS_IN/IS_NOT_INoperator menu, and a related-record multi-select value picker (with edit-time hydration).RelationConditionConfig,config('custom-fields.visibility')) — per-entity allowlist of relation paths;restrict_to_configured(defaultfalse) governs the own-column model-attribute source so existing flag behavior is unchanged.Backward compatibility
?Model $recordparam is on concrete classes only, optional).MODEL_ATTRIBUTE_CONDITIONS;restrict_to_configureddefaults to legacy behavior.v3.2.0).Test plan
vendor/bin/pest --parallel→ 685 passed, 0 failed (2633 assertions)vendor/bin/phpstan analyse→ no errors (254 files)vendor/bin/pest --type-coverage --min=100→ 100%vendor/bin/pint --test/vendor/bin/rector --dry-run→ cleanNew coverage: operator set-intersection; resolver (2-hop, null intermediate, empty terminal, invalid path); backend eval (matching / non-matching / no-relation / fail-open); section + field server-side wiring; JS exclusion; per-entity scoping + backward-compat defaults; and a consolidated field/section/backend/JS parity test. Adds a
Post belongsToMany Tagtest fixture (prior fixtures had onlyBelongsTo).Notes