Skip to content

Support for conditional expression on individual types #234

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

Closed
rhelgeby opened this issue Jan 28, 2015 · 8 comments
Closed

Support for conditional expression on individual types #234

rhelgeby opened this issue Jan 28, 2015 · 8 comments

Comments

@rhelgeby
Copy link

Since the only special thing about the conditional type is an ng-if directive in the template, it may be useful to support conditional in other types too.

Not very important, though it would simplify some form definitions. The workaround is just to wrap it in a conditional type.

@rhelgeby rhelgeby changed the title Support for conditional expression individual types Support for conditional expression on individual types Jan 28, 2015
@Anthropic
Copy link
Member

I was thinking about this myself, it would reduce form definition bloat, I have so many similar conditions the definition is now quite massive.

@nmorse
Copy link

nmorse commented Feb 19, 2015

+1 for options that could reduce form complexity.
I often put a single field in a type:conditional... making an items list of one.
in #180, I agree w @davidlgj:

I think a "condition" on every field could be a solution that would ease up the typing.

Is this something that might be added to sf? Or are there any workarounds that could insert an ng-hide?

@davidlgj
Copy link
Contributor

I just pushed form option condition onto every field, it's in the development branch. See the docs there for usage but it exactly is the same as the conditional form type (which now is an alias for section).

Love to hear your feedback on it!

@rhelgeby
Copy link
Author

Nice. Your solution is better than mine.

I've just duplicated the ng-if directive in custom templates, because I also needed access to custom variables in the evaluation scope (a part of my dynamic form definition builder).

@davidlgj
Copy link
Contributor

@rhelgeby I' don't know if you've gleaned at the code, but it basically slaps on an ng-if on the decorator directives children, i.e. on the top level of the template. I tried to be smart about it though so of there already is an ng-if it adds it as an || statement.

If it fits your needs just close the issue :-)

@rhelgeby
Copy link
Author

Yes, I've studied that code. When this gets into master I can simplify my custom ng-if directives and avoid duplication so it will combine the built-in expression with my custom expression like you mentioned.

Thank you.

@davidlgj
Copy link
Contributor

@rhelgeby no promises, but we're aiming at monday morning for a release.

@rhelgeby
Copy link
Author

That's ok, no rush. I have already made a workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants