angular-schema-form icon indicating copy to clipboard operation
angular-schema-form copied to clipboard

Support for conditional expression on individual types

Open rhelgeby opened this issue 11 years ago • 8 comments

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 avatar Jan 28 '15 14:01 rhelgeby

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

Anthropic avatar Jan 30 '15 05:01 Anthropic

+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?

nmorse avatar Feb 19 '15 19:02 nmorse

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!

davidlgj avatar Feb 19 '15 22:02 davidlgj

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).

rhelgeby avatar Feb 19 '15 22:02 rhelgeby

@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 :-)

davidlgj avatar Feb 20 '15 07:02 davidlgj

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.

rhelgeby avatar Feb 20 '15 09:02 rhelgeby

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

davidlgj avatar Feb 20 '15 14:02 davidlgj

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

rhelgeby avatar Feb 20 '15 22:02 rhelgeby