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

Add a flag so custom classes and custom enums are only usable as class members #4118

Open
adrien-bon opened this issue Dec 6, 2024 · 3 comments
Labels
feature It's a feature, not a bug.

Comments

@adrien-bon
Copy link

Feature request description
As far as I know, it is currently not possible to select which custom enums we see when adding a new property.
We always see all available enums, while some of them could only be used through custom classes (and not directly added as properties).
It would be nice to be able to select which enum to show or to hide.

Describe the solution you'd like
When creating a new custom enum, add the possibility to hide it when adding new properties, ie. to not use it as a property value.

It could be done the same as for custom classes, by adding a Property value tickbox:
image

For JSON export, we could use the same useAs array but only take into account the property value.

@adrien-bon adrien-bon added the feature It's a feature, not a bug. label Dec 6, 2024
@eishiya
Copy link
Contributor

eishiya commented Dec 6, 2024

Class members and properties directly on objects are all "properties". The reason Classes have a checkbox for use as property values is that they can also be Classes set on objects (causing those objects to inherit the class members as top-level properties), which isn't something that makes sense for Enums. Since Enums can only be property values, they don't have the checkbox.

That said, I do think it would be nice to have an additional checkbox or something to distinguish enums and classes that are intended for use only as class members from those intended to (also) be top-level properties. This should be available for both classes and enums, not just enums.

For now, a common workaround seems to be to use prefixes to make the property list easier to navigate, but it would be nice if these weren't necessary.
A different possible solution to this problem (and organisational problems due to having many classes more generally) is to allow a custom sort order on custom property types instead of listing them alphabetically, so that "unwanted" types can be put at the end, and so related types can be together.

@bjorn
Copy link
Member

bjorn commented Dec 6, 2024

I've noticed the same issue, not just for enums but also for classes. I guess it's quite a common need that some of your types are simply never relevant on their own but only as class members (or also, that some properties are only used as property values and never as class members?).

I guess we can indeed just have another usage flag for "class member" separately from "property value" and to also add these usage flags for enums. Just a little tricky to add this in a backwards-compatible way.

@adrien-bon
Copy link
Author

Class members and properties directly on objects are all "properties". The reason Classes have a checkbox for use as property values is that they can also be Classes set on objects (causing those objects to inherit the class members as top-level properties), which isn't something that makes sense for Enums. Since Enums can only be property values, they don't have the checkbox.

Oh! I did not see that!
Yeah, you are right. I though that by un-ticking the Property Value tickbox I was only preventing to add this class as a custom property, but actually it also prevents me from using it as a member in another class.

That said, I do think it would be nice to have an additional checkbox or something to distinguish enums and classes that are intended for use only as class members from those intended to (also) be top-level properties. This should be available for both classes and enums, not just enums.

That would be my actual feature request :)
I'll rename the issue accordingly.

For now, a common workaround seems to be to use prefixes to make the property list easier to navigate, but it would be nice if these weren't necessary.

I'm actually importing several hundreds of pre-existing types so not a practical solution for me.

A different possible solution to this problem (and organisational problems due to having many classes more generally) is to allow a custom sort order on custom property types instead of listing them alphabetically, so that "unwanted" types can be put at the end, and so related types can be together.

A custom sort order would be very nice to have, or some way to filter out some types dynamically ?
But probably more complicated to implement.

@adrien-bon adrien-bon changed the title Hide some custom enums when adding a new property Add a flag so custom classes and custom enums are only usable as class members Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature It's a feature, not a bug.
Projects
None yet
Development

No branches or pull requests

3 participants