fix issue 19341
This commit is contained in:
committed by
Matthew-Wise
parent
135f0f63de
commit
f0e37e04fa
@@ -22,34 +22,29 @@ public class ColorPickerValueConverter : PropertyValueConverterBase
|
||||
=> propertyType.EditorAlias.InvariantEquals(Constants.PropertyEditors.Aliases.ColorPicker);
|
||||
|
||||
public override Type GetPropertyValueType(IPublishedPropertyType propertyType)
|
||||
=> UseLabel(propertyType) ? typeof(PickedColor) : typeof(string);
|
||||
=> typeof(PickedColor);
|
||||
|
||||
public override PropertyCacheLevel GetPropertyCacheLevel(IPublishedPropertyType propertyType)
|
||||
=> PropertyCacheLevel.Element;
|
||||
|
||||
public override object? ConvertSourceToIntermediate(IPublishedElement owner, IPublishedPropertyType propertyType, object? source, bool preview)
|
||||
{
|
||||
var useLabel = UseLabel(propertyType);
|
||||
|
||||
if (source is null)
|
||||
{
|
||||
return useLabel ? null : string.Empty;
|
||||
return null;
|
||||
}
|
||||
|
||||
var value = source.ToString()!;
|
||||
if (value.DetectIsJson())
|
||||
{
|
||||
PickedColor? convertedValue = _jsonSerializer.Deserialize<PickedColor>(value);
|
||||
return useLabel ? convertedValue : convertedValue?.Color;
|
||||
return convertedValue;
|
||||
}
|
||||
|
||||
// This seems to be something old old where it may not be json at all.
|
||||
if (useLabel)
|
||||
else
|
||||
{
|
||||
// This seems to be something old old where it may not be json at all.
|
||||
return new PickedColor(value, value);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private bool UseLabel(IPublishedPropertyType propertyType) => ConfigurationEditor
|
||||
|
||||
Reference in New Issue
Block a user