Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ChoiceVar Filter #6818

Open
3 of 12 tasks
kdakss opened this issue Jan 26, 2025 · 1 comment
Open
3 of 12 tasks

ChoiceVar Filter #6818

kdakss opened this issue Jan 26, 2025 · 1 comment
Labels
type: feature Introduction of substantial new functionality to the application

Comments

@kdakss
Copy link

kdakss commented Jan 26, 2025

As ...

Cora - Coder

I want ...

Company = ChoiceVar(

    label="Company",

    description="Target platform to be updated",

    choices=tuple(get_company_choices())

)


kit_type = ChoiceVar(

    label="Kit Type",

    description="New kit type for the target tenant",

    choices=tuple(get_kit_choices())

)

Scenario: Company D uses a different brand of kits than the rest of the organization. I have a tuple of different kits, which are also separated by brand. Say I want, if company D is selected, the choices for kit_type only show the brand that Company D uses, ensuring that throughout the organization, companies only see the brand of kits associated to them. So, it's a dynamic filter of the dropdown. I have been trying different if, else statements to no prevail. For security, I hope this makes sense and doesn't sound too vague. Any ideas of if this is possible?

I've tried separate functions like get_kit_choices and get_d_kit_choices where if company == "d" choices=tuple(get_d_kit_choices()) else choices=tuple(get_kit_choices()).

So that ...

Companies when they run the job and select their company, they go to select their kit and only see the brands that that company uses. I could end up having 30 different kits and the drop-down could get long and messy. I want to limit the view,

I know this is done when...

I select the company, then I don't see every kit in the organization, only the brand of kits associated to the company

Optional - Feature groups this request pertains to.

  • Automation
  • Circuits
  • DCIM
  • IPAM
  • Misc (including Data Sources)
  • Organization
  • Apps (and other Extensibility)
  • Security (Secrets, etc)
  • Image Management
  • UI/UX
  • Documentation
  • Other (not directly a platform feature)

Database Changes

No response

External Dependencies

No response

@kdakss kdakss added triage This issue is new and has not been reviewed. type: feature Introduction of substantial new functionality to the application labels Jan 26, 2025
@glennmatthews
Copy link
Contributor

The way I'd probably tackle this, without needing to wait for any enhancements to core, would be to have the ChoiceVar declaration accept all possible kit type choices, then use a custom HTML template + JS to have the browser filter the displayed choices when a company is selected, then have the Job run() double-check that the selected kit type is in fact valid for the selected company.

@glennmatthews glennmatthews removed the triage This issue is new and has not been reviewed. label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Introduction of substantial new functionality to the application
Projects
None yet
Development

No branches or pull requests

2 participants