Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    Jun 16, 2020 @ 16:22
    Ulrich Wagner Gade Ebsen
    0

    Custom list editor

    Hi Lee,

    This package is super nice.. :D .. I'm pretty sure that I will use this in every upcomming project.. ;)

    A really nice feature would be the posibility to add your own list editor..

    enter image description here

    So you could build something like this or other editors.. ;)

    enter image description here

    /ulrich

  • Lee Kelleher 4020 posts 15807 karma points MVP 13x admin c-trib
    Jun 16, 2020 @ 16:39
    Lee Kelleher
    101

    Hi Ulrich, thanks for the nice feedback!

    You can definitely create your own custom list editors, here's some initial documentation. (It probably needs to be expanded out to its own page).

    https://github.com/leekelleher/umbraco-contentment/blob/develop/docs/editors/data-list.md#extending-with-your-own-custom-list-editor

    Here's an example of how the CheckboxList one is built...

    During development, I did prototype with a Buttons editor (and a "Templated List" editor, where you could add custom HTML), but they were a little too experimental for the initial v1.0 release. I'm hoping to include them in a future release.

    Cheers,
    - Lee

  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    Jun 16, 2020 @ 17:04
    Ulrich Wagner Gade Ebsen
    1

    Oh.. very sweet... :D

    ..better tell my wife it is going to be late tonight.. ;)

    /ulrich

  • Lee Kelleher 4020 posts 15807 karma points MVP 13x admin c-trib
    Jun 17, 2020 @ 09:56
    Lee Kelleher
    0

    I hope your wife is forgiving. ;-)

  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    Jun 17, 2020 @ 10:23
    Ulrich Wagner Gade Ebsen
    0

    She is.. ;) .. and this is really, really cool... :D

    Great work.. ! :D

  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    Jun 17, 2020 @ 14:39
    Ulrich Wagner Gade Ebsen
    0

    Hi Lee,

    I'm a bit curious about this:

    public Dictionary<string, object> DefaultValues => default;
    

    Do you have any examples of how to set a default value?

    EDIT---

    Ahh.. that is for config default values.. ;) What I was looking for was a way to set a initial default value from the list... guess i can put in a textfield in the config and just type the value.. ;)

    /ulrich

  • Lee Kelleher 4020 posts 15807 karma points MVP 13x admin c-trib
    Jun 17, 2020 @ 14:54
    Lee Kelleher
    0

    Hi Ulrich, yeah you're correct, those are the default values for the config.

    Setting the default value for the property can be done as you said. 👍

  • Ulrich Wagner Gade Ebsen 127 posts 277 karma points
    Jun 18, 2020 @ 07:49
    Ulrich Wagner Gade Ebsen
    1

    Hi Lee,

    This is really cool.. ;) .. the sky is the limit.. :D

    enter image description here

    /ulrich

  • Sven 34 posts 138 karma points
    May 12, 2022 @ 10:44
    Sven
    0

    Hey Ulrich,

    Could you share how you managed to set the default value?

    I'm trying to set the default value using an enum, but it's not working. Any idea what I'm doing wrong?

    public class HeroBlockVariantsDataSource : IDataListSource
    {
        public Dictionary<string, object> DefaultValues => new Dictionary<string, object>() { { HeroBlockVariants.Large.ToString(), HeroBlockVariants.Large.ToString() } };
    
        public IEnumerable<ConfigurationField> Fields => Enumerable.Empty<ConfigurationField>();
    
        public string Group => string.Empty;
    
        public OverlaySize OverlaySize => OverlaySize.Medium;
    
        public string Name => "Hero Block Variants";
    
        public string Description => "Data source for all hero block variants.";
    
        public string Icon => "icon-tags";
    
        public IEnumerable<DataListItem> GetItems(Dictionary<string, object> config)
        {
            var blockVariants = Enum.GetValues(typeof(HeroBlockVariants)).Cast<HeroBlockVariants>();
    
            if (blockVariants?.Any() == true)
            {
                return blockVariants.Select(x => new DataListItem
                {
                    Name = x.ToString(),
                    Value = x.ToString()
                });
            }
    
            return Enumerable.Empty<DataListItem>();
        }
    }
    
  • Lee Kelleher 4020 posts 15807 karma points MVP 13x admin c-trib
    May 12, 2022 @ 15:56
    Lee Kelleher
    0

    Hi Sven,

    In the context of the IDataListSource class, the DefaultValues are for the configuration Fields of that data-source, not the value of the property (on a content node) itself.

    The need for a default value for the Data List itself has come up in discussion a few times. See the thread on package's GitHub repo:

    https://github.com/leekelleher/umbraco-contentment/discussions/91

    Ultimately it comes around to "how would you set a default value for any property-editor?" Which is either using Content Templates (blueprints) or custom C# code to hook into the Editor Model API, (either EditorModelEventManager.SendingContentModel for v8, or SendingContentNotification for v9).

    I hope this helps?

    Cheers,
    - Lee

  • Lee Kelleher 4020 posts 15807 karma points MVP 13x admin c-trib
    Jun 18, 2020 @ 08:03
    Lee Kelleher
    0

    Awesome! 🎉 #h5yr

Please Sign in or register to post replies

Write your reply to:

Draft