Try our conversational search powered by Generative AI!

Is it possible to check if ClientEditingClass exists?

Vote:
 

Is it possible to check if the editor for "ClientEditingClass" actually exist?

If I add a UIHint to a property and create the EditorDescriptor that specifies a ClientEditingClass that does not exist as a Dojo editor the entire Forms editor stops responding.

Model:

	[ContentType()]
	public class MyBlock : BlockData
	{
		[UIHint("myhint")]
		public virtual string MyProperty{ get; set; }
	}

Descriptor:

	[EditorDescriptorRegistration(UIHint = "myhint", TargetType = typeof(string))]
	public class MyDescriptor : EditorDescriptor
	{
		public MyDescriptor()
		{
			ClientEditingClass = "module-that.does.not-exist";
		}
	}
#86529
May 23, 2014 8:49
Vote:
 

Hi Thomas!

This is not possible. Actually, the metadata handling is totally separated from the UI though it must be possible to load the script file defined. I tried this on a local installation and the error message that is showed in the console log seems clear enough to be able to fix the error if it occurs:

  • Error {src"dojoLoader"infoArray[2]stack(...)message"scriptError"}
    dojo.js:1834
src: dojoLoader dojo.js:1837
info:
["/ClientResources/Scripts/editors/StringList123.js"Event]
#86645
May 27, 2014 13:12
Vote:
 

Thanks for replying.

The reason for why I want this feature to be handled by the UI:

* Addon #1 includes a EditorDescriptor and the .js-files

* Addon #2, not actually dependent on #1, but if #1 exists it would like to use a Editor (with different metadata) from #1

In #2 I want to use the Editor from #1 but with other metadata. I therefore created a new EditorDescriptor (and UIHint) in #2 and pointing to the Editor with using the the ClientEditingClass as in #1.

This works fine as long as #1 is also installed in the application, but I want #2 to be independent of #1 and therefore I just want the UI to fallback to the default Editor when the ClientEditingClass does not exist.

If I could find a way to pass in metadata with just assigning a UIHint on the property the problem would be solved as UIHint will fallback if there are no EditorDescriptor and ClientEditingClass defined for it.

#86772
Edited, May 30, 2014 10:48
Vote:
 

Found a solution! :)

    [EditorDescriptorRegistration(UIHint = "myhint", TargetType = typeof(string))]
    public class TextDescriptor : EditorDescriptor
    {
        public TextDescriptor()
        {
            ClientEditingClass = "mymodule.myeditor.Editor";
        }


        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            var uiHintAttribute = metadata.Attributes.OfType<UIHintAttribute>().FirstOrDefault();
            object myValue;
            uiHintAttribute.ControlParameters.TryGetValue("myKey", out myValue);
            base.ModifyMetadata(metadata, attributes);
            metadata.EditorConfiguration.Add("myProperty", myValue ?? "defaultValue");
        }
    }

Then use this EditorDescriptor with UIHint and pass in a control parameter:

        [UIHint("myhint", null, "myKey", "myValue")]
        public virtual string MyString { get; set; }
#86782
May 30, 2014 15:19
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.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.