Better feedback for editors using property lists

Vote:
 

I'm using a PropertyList to let editors add a list of documents they wish to attach to the current article, but the editor experience in the 'all properties' screen leaves much to be desired and I was wondering if there is anything I can do to fix that?

As you can see from the above, "Attachment" just shows the Content Reference ID, which isn't very descriptive, combined with the fact that at the moment the 'adding items dialog' is letting editors add items not supported by the field :

        [UIHint(UIHint.MediaFile)]
        [AllowedTypes(typeof(DocumentFile))]        
        public virtual ContentReference Attachment { get; set; }

but after the editor adds the item, a vague and general validation message:

So, all in all, it would be really good if when they add the document, instead of display "56" it displayed "your_file-name~inHere.docx"

Is this possible?

#197675
Edited, Oct 10, 2018 10:33
Vote:
 

Hi Noel,

Your best bet would be to modify the way those lists render (though I tend to run screaming from anything that involves touching Dojo). Grzegorz Wiecheć put together an example of how you can modify that view here:

https://gregwiechec.com/2015/12/propertylist-with-images/

As a simple but not so good alternative option you might want to consider something like the following:

    public class ArticleAttachment
    {
        private Injected<IContentLoader> _contentLoader;

        public ContentReference Attachment { get; set; }

        [ScaffoldColumn(false)]
        public string AttachmentName {
            get {
                return ContentReference.IsNullOrEmpty(Attachment) ? "" : _contentLoader.Service.Get<IContent>(Attachment).Name;
            }
        }

        public string LinkText { get; set; }
    }

However, this will only run when you open the page in the editor so will help people coming back to the page in the editor but won't update as items are added.

As a final option, do you need add additional data to go with your attachment per usage of that attachment? If not, you could add the properties (e.g. LinkText) to your DocumentFile model and just use a ContentReferenceList instead of your PropertyList. When rendering the list you could then pull out the relevant properties from the DocumentFile rather than the list item.

#197680
Oct 10, 2018 13:28
Vote:
 

In this case I would use a regular link list. You can select a file and specify a link text.

public virtual LinkItemCollection ArticleAttachments { get; set; }

Not sure if it supports AllowedTypes though, but might be worth a try.

#197684
Edited, Oct 10, 2018 15:37
Vote:
 

I'd certainly be tempted to use a LinkItemCollection and I was tempted to mention it in my reply but, according to the docs, it doesn't support the AllowedTypes attribute so, if the list has to be limited to items of type DocumentFile, you'd need a custom validator or similar to enforce that.

#197687
Oct 10, 2018 16:00
Vote:
 

I would use it anyway, that editor has a better user experience. And as you mentioned - you can always have custom validation or just filter the items before displaying them.

#197689
Oct 10, 2018 16:05
Vote:
 

Also would like to add that PropertyList<T> with complex types is still in beta.

#197690
Oct 10, 2018 16:23
Vote:
 
#197704
Oct 10, 2018 19:35
Vote:
 

Just for value types, complex types is still in beta.

#197714
Oct 11, 2018 7:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.