Hey @timgeyssens
! Thanks for trying out Contentment and writing up a how to guide on making a custom data source, very cool! 😎
The trouble I have with developing Contentment is knowing when to stop, I get carried away with refining the editor/developer experience. From reading this guide, I mind went "hmm, what if...?" 🤔
What if for the Property Alias field, we replaced it with a dropdown, so to prevent any typos? I recall seeing something on the Template editor to let you pick from an existing property... can we leverage that? Ah yes, it's a parameter editor called PropertyTypeParameterEditor.
OK, then we can try taking that config and add it in our custom data source...
newConfigurationField{Key="propAlias",Name="Property",Description="Select the property to populate the data source with.",View="~/umbraco/views/propertyeditors/entitypicker/entitypicker.html",Config=newDictionary<string,object>{{"multiple","0"},{"entityType","PropertyType"},{"publishBy","alias"},}}
Now that gives us...
A friendly incremental enhancement. 🤗
Next I saw the use of DependencyResolver.Current.GetService(), but this is Umbraco v8... DEPENDENCY INJECT ALL THE THINGS!!!1 💪
We could inject the IUmbracoContextAccessor? A-la...
I haven't gone to the full extend of writing unit-tests for every custom data source, but with using DI, it's a step towards that, (or so I'm told!)
I tinkered around with a couple of other bits, but mostly to satisfy my own opinionated coding style! 😆 Here's my latest gist: gist.github.com/leekelleher/d786f4...
I still don't fully understand how DI all works - feels like a lot of dark magic. The main thing to watch out for is circular dependencies, it's a headwrecker! 😆
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hey @timgeyssens ! Thanks for trying out Contentment and writing up a how to guide on making a custom data source, very cool! 😎
The trouble I have with developing Contentment is knowing when to stop, I get carried away with refining the editor/developer experience. From reading this guide, I mind went "hmm, what if...?" 🤔
What if for the Property Alias field, we replaced it with a dropdown, so to prevent any typos? I recall seeing something on the Template editor to let you pick from an existing property... can we leverage that? Ah yes, it's a parameter editor called PropertyTypeParameterEditor.
OK, then we can try taking that config and add it in our custom data source...
Now that gives us...
A friendly incremental enhancement. 🤗
Next I saw the use of
DependencyResolver.Current.GetService()
, but this is Umbraco v8... DEPENDENCY INJECT ALL THE THINGS!!!1 💪We could inject the
IUmbracoContextAccessor
? A-la...I haven't gone to the full extend of writing unit-tests for every custom data source, but with using DI, it's a step towards that, (or so I'm told!)
I tinkered around with a couple of other bits, but mostly to satisfy my own opinionated coding style! 😆 Here's my latest gist: gist.github.com/leekelleher/d786f4...
Thanks again! Happy coding! 🎉
Woot, wasn't sure if DI would work... Why did I doubt you! Lovely!
I still don't fully understand how DI all works - feels like a lot of dark magic. The main thing to watch out for is circular dependencies, it's a headwrecker! 😆