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

feat(editor): add field option when to be able to show fields conditionally #1894

Closed

Conversation

LoicMahieu
Copy link
Contributor

Summary

Add field option when to be able to show fields conditionally.

It could be useful to conditionally show/hide some fields depending on the data. This PR allows to specify a new option when which could be:

  • string: use of conscript.js for simple language for writing potentially-complex sets of conditions.
  • function: write own condition directly in javascript.

Test plan

WIP...

@verythorough
Copy link
Contributor

verythorough commented Nov 21, 2018

Deploy preview for netlify-cms-www ready!

Built with commit f140feb

https://deploy-preview-1894--netlify-cms-www.netlify.com

@erquhart
Copy link
Contributor

erquhart commented Nov 22, 2018

I'm definitely in favor of the goal here, but we need to think through how to go about it a bit more. We don't support functions in the config, and I'm not sure we want to bake conscript into our API.

There's some discussion of this feature in #1267, and I believe a PR was started but didn't get to completion.

@LoicMahieu LoicMahieu force-pushed the feature/fields-conditional branch from 56a1058 to 3b182b1 Compare December 5, 2018 16:49
@verythorough
Copy link
Contributor

verythorough commented Dec 5, 2018

Deploy preview for cms-demo ready!

Built with commit f140feb

https://deploy-preview-1894--cms-demo.netlify.com

@LoicMahieu
Copy link
Contributor Author

I found conscript by change. It seems pretty new and so not battle tested. I think it is promising.

Anyway, in my use-case, I don't use this syntax but only the function style. In fact, I configure only by JS, see #1866

@erquhart
Copy link
Contributor

Yeah - I'm not saying it isn't functional, but I'd like to avoid bringing outside specs into our API. For example, Immutable.js is a part of our API right now, meaning folks need to understand how that library works to do any customization in the CMS, and that's a decision I regret (planning to remove it in an upcoming major release).

Totally agree on the goal of this PR, we just need to find a different approach.

@erquhart
Copy link
Contributor

erquhart commented Feb 2, 2019

@LoicMahieu any thoughts on my last comment?

@erquhart
Copy link
Contributor

Closing as stale due to lack of activity and/or interest. Please comment if you feel this should be reopened.

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

Successfully merging this pull request may close these issues.

3 participants