Polite way of telling user via edit interface something went wrong with an item

Topics: Developer Forum
Oct 8, 2008 at 9:30 AM
I have a complex dependencies between items, which requires many conditions to be met by the user (editor) for the system to function properly.

Here's one scenario, for example:

Given a definition:
[Definition]
public MyPage: ContentItem {
    [EditableLink("Item store", 1, Required = true)]
    public StorageItem Storage { get { return this.GetDetail<StorageItem >("Storage", null); } set { this.SetItem<StorageItem >("Storage", value); } }
    ...
}

Our user is required to set Storage property and, thanks to N2, an extensive validation mechanism is in place to enforce this. However, there are times, when this property might loose it's value, say a linked StorageItem was moved to trash, ot just cleared by other means. We have no control of this situation, except writing custom plugin.

I think what would be helpful here is to signify user that the item is in an inconsistent state using some sort of graphical aids, without resorting to throwing exceptions. Here's how i'd accomplish this, using capabilities of N2 edit interface by setting item's icon and tool tip properties:

public MyPage: N2.ContentItem, N2.Web.ILink {
    ...
    public override string IconUrl { get { return null == this.Storage ? "~/error.png" : base.IconUrl; } }

    #region

 

ILink Members 
    string ILink.Contents { get { return this.Title; } } 
    string ILink.Target { get { return string.Empty; } } 
    string N2.Web.ILink.ToolTipget { return null == this.Storage ? "Storage is not set" : string.Empty; } }
    string ILink.Url { get { return this.Url; } }
   
#endregion
}

This looks just fine in edit UI, however i'm worried it's suboptimal to tailor this pattern by hand every time. I mean implementing ILink, overriding ToolTip, copy-pasting other ILink's stuff from ContentItem is tedious. The next logical step is to accumulate error messages somehow. What if such functionality already exists deep inside N2, i began to think ? 

If anyone ever tried to implement this sort of diagnostics for the user/editor, how did you do it ?

Thanks.

Coordinator
Oct 8, 2008 at 6:20 PM
It's an interesting idea. You're far ahead of anything in N2. Maybe an abstraction between the content item and the code that renderes the icon? Or an event. Why don't you send a patch?