Data List: Custom Value Converters #89
Replies: 8 comments
-
This is a step up from what I suggested, but I like it. This should developers the most amount of flexibility 😎 I'd imagine it could work much like the And the It could possibly also make sense to pass the |
Beta Was this translation helpful? Give feedback.
-
For those following along at home, I've done a proof of concept. See commit 6eb9653 for initial So far I've prototyped 3 value converters, one for the Enum, another for Ambitiously called "Universal Type Converter"... 😆 The idea is that the output value type can be configured in the backoffice without getting into C# code. Notes (for self), this would be a breaking change, as it removes the |
Beta Was this translation helpful? Give feedback.
-
@leekelleher Just want to say that this looks utterly awesome Lee! I'd have thunk this was a giant can of worms, to be honest :D - I was really just thinking of how the Color Picker can be configured to either just return the hexcolor, or to return an object (tuple?) with This would be all sorts of cool! /Chriztian |
Beta Was this translation helpful? Give feedback.
-
@leekelleher I haven't tried this package yet, but I wonder if it only makes sense to convert to |
Beta Was this translation helpful? Give feedback.
-
Thanks @bjarnef. This is purely a prototype at the moment - nothing set in stone. 😃 |
Beta Was this translation helpful? Give feedback.
-
Wouldn't it be possible to make a data list of elements from a block list / nested content, and then need a conversion to IPublishedElements? |
Beta Was this translation helpful? Give feedback.
-
@skttl Yeah, that'd be totally possible. I was only meaning that the "Umbraco Content" data source (which I'm developing for v1.1) would only return It's all still in the prototyping phase, so anything is possible! 😃 |
Beta Was this translation helpful? Give feedback.
-
Moved this topic to a discussion, as I'm not convinced if it's a good feature for Data List or not. I'm still having niggles about users needing to manually configure value converters for certain data sources. Totally open for discussion though. 👍 |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
@greystate asked on the forum if it was possible for the built-in XML data source could return additional meta-data from the selected value? e.g. the
Name
,Icon
, etc.https://our.umbraco.com/packages/backoffice-extensions/contentment/contentment-feedback/102742-how-can-i-output-the-label-of-a-datalist-item
Currently only the
Value
is stored against the property, and that's the value returned on the front-end. However we do have an interfaceIDataListSourceValueConverter
for enabling custom object-types and values, e.g. for Enums (and in upcoming v1.1 anIPublishedContent
for an Umbraco content data source).I wonder if there is a better way to configure the type of value you would to be returned from a Data List?
Describe the solution you'd like
Currently the
IDataListSourceValueConverter
interface can be used on a data source to convert the value to a specific type. However this ties the data source and output object-type close together, which irks me a little. I'm wondering about the scenario where users could specify a different value type, e.g. for the Umbraco content data source, whether they would prefer to have theIPublishedContent
, or theUdi
, or the raw string of the UDI, or even theint
?On the data type configuration, we could have a 3rd field for "Value converter", with options on how to configure the desired output. The default option would still be a
string
(and whether that'd be single or enumerable, depending on the list editor used).I haven't considered much on the technical implementation of this yet, I envisage an interface (much like the data source and list editor interfaces), e.g.
IDataListValueConverter
, which would open it up to user customisation too.Beta Was this translation helpful? Give feedback.
All reactions