Geta / geta-optimizely-genericlinks

An extensive alternative to LinkItemCollection in Optimizely.
Apache License 2.0
4 stars 0 forks source link

Content Creation Screen is blank when a custom link is present #11

Closed benmurphycb closed 2 years ago

benmurphycb commented 2 years ago

Hello,

I am running into an issue - I have created a custom LinkData property and I am using it on our models. There is an issue at the moment that if there is a custom LinkData present then no properties will show on the content creation screen in the CMS.

public class GeneralLinkData : LinkData
    {
        [ScaffoldColumn(false)]
        public override string? Target => OpenInNewTab ? "_blank" : "_self";

        [ScaffoldColumn(false)]
        public override string? Title => base.Text;

        [Ignore]
        public Url? Url => !string.IsNullOrWhiteSpace(base.Href) ? new Url(base.Href) : null;

        [Display(Name = "Open In New Tab")]
        public virtual bool OpenInNewTab 
        {
            get => GetAttribute((v) => bool.Parse(v));
            set => SetAttribute(value, (v) => v.ToString());
        }

        [Required]
        public override string? Href 
        { 
            get => base.Href; 
            set => base.Href = value; 
        }
    }
[PropertyDefinitionTypePlugIn(
        DisplayName = "General link", 
        GUID = "41589b68-f826-459e-bc11-e4db2c8f51cc")]
    public class PropertyGeneralLink : PropertyLinkData<GeneralLinkData>
    {
    }
[ContentType(
        DisplayName = "Static Three Up Item",
        Description = "An item to be used in a Static Three Up block.",
        GUID = "eec5gfea-f570-4384-8916-ec2279a0cc80")]
    [ImageUrl("~/assets/images/episerver/thumbnails/staticthreeupitemblock.png")]
    public class StaticThreeUpItemBlock : BlockData
    {
        [Required]
        public virtual string? Heading { get; set; }

        [Required]
        public virtual GeneralLinkData? Link { get; set; }

        [UIHint(UIHint.Image)]
        public virtual ContentReference? Image { get; set; }

        public virtual string? Text { get; set; }
    }

image

As you can see from the screenshot, when I have the custom LinkData property on the model, the creation screen is completely blank. If I set it to [ScaffoldColumn(false)] the properties will show again. This is a showstopper as when you create block directly from a ContentArea, it will not let you create it without required fields being populated, so the item cannot be added this way.

benmurphycb commented 2 years ago

@valdisiljuconoks @svenrog any info on this?

valdisiljuconoks commented 2 years ago

Hi,

We will look into this next week.

svenrog commented 2 years ago

@benmurphycb I think I've found the issue, _setValueAttr is called before the model is created inside GenericItemEditor. I've pushed a fix for it in version 1.4.3. You can either try the package available directly from this repo feed or wait for it to be approved on the Optimizely nuget feed. Please let us know if this fixes your issue. Sorry for the late reply.

benmurphycb commented 2 years ago

Awesome, thank you both. I will let you know once I get the package updated. Do you know roughly when Optimizely might approve the change? No worries if not

valdisiljuconoks commented 2 years ago

1.4.3 is out on feed.