OnTopicCMS / OnTopic-Editor-AspNetCore

ASP.NET Core version of an editor for Ignia's OnTopic CMS.
4 stars 0 forks source link

`EnumListAttribute`? #28

Open JeremyCaney opened 3 years ago

JeremyCaney commented 3 years ago

Establish a new attribute type which can be associated with a given enum, and will display the options of the enum as a list. This is similar to TopicListAttribute, but the data source would be an enum, not e.g. Topic.Children.

TypeListAttribute

To support this, ideally the EnumListAttribute would dynamically identify all enums in scope, and allow the definition to select an enum, thus ensuring that the fully qualified name can be easily verified. This could be a challenge in that there may be a lot of enums in scope, thus necessitating e.g. a combo box. To support this, we'd likely need an e.g. TypeListAttribute which could be filtered by type (e.g., record, class, enum), extension (e.g., ViewModel, Collection), as well as e.g. a backend TypeQueryService.

Note: A quick and easy compromise here would be to require the editor to type in the fully-qualified enum without any validation. This would dramatically simplify this component, and may be a better option for the first version. This could lead to errors in rendering the attribute type if the enum name was not correctly entered or could not be resolved in scope.

View Component

On the view component itself, we'd need to be able to lookup that type, evaluate its values, and return them as a collection to be bound to the dropdown box source.