Skip to content

Add ha-form context#12062

Merged
balloob merged 1 commit intodevfrom
ha-form-context
Mar 16, 2022
Merged

Add ha-form context#12062
balloob merged 1 commit intodevfrom
ha-form-context

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Mar 16, 2022

Breaking change

Proposed change

Add a new feature to selectors to allow specifying a context.

Each selector can define their own supported context keys. The values of context in a configuration are set to field names. <ha-form> will process context and substitute field names with the value of the field.

Currently only implemented in the attribute picker.

Important requirement: if context is used, the selector is responsible to adjust the value if a new context value is passed in. So in the case of attribute picker, if a new entity is passed in, set value to undefined if the new entity does not support the picked attribute.

const schema = [
      { name: "entity", selector: { entity: {} } },
      {
        name: "Attribute",
        selector: { attribute: { entity_id: "" } },
        context: { filter_entity: "entity" },
      },
]

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

@balloob balloob added the needs design preview PRs with this label will trigger a GitHub action to generate a gallery preview label Mar 16, 2022
@balloob balloob merged commit d5010dd into dev Mar 16, 2022
@balloob balloob deleted the ha-form-context branch March 16, 2022 21:12
@github-actions github-actions bot locked and limited conversation to collaborators Mar 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla-signed needs design preview PRs with this label will trigger a GitHub action to generate a gallery preview

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants