U4-2692 - Add attribute access to property editor prevalues

Created by Per Ploug 22 Aug 2013, 09:57:22 Updated by Shannon Deminick 02 Oct 2013, 09:19:16

Subtask of: U4-2887

The current c# syntax is super flexible, but too complex, lets complement it with some simpler to use attributes like so:

[PrevalueField("Connection string")] public string ConnectionString { get; set; }

[PrevalueField("ConnectionTime", view: 'datetime')] public datetime ConnectionTime { get; set; }

Which just gets appended to the field collection


Shannon Deminick 23 Aug 2013, 04:27:16

Its a good idea, will implement (will just piggy back on what is there). In some cases internally we won't be able to use attributes like for the drop down list pre-value we use localization to create our Name value and you can put that on an attribute... unless we create a metadata provider, etc... but that is too much work for something like that.

Shannon Deminick 23 Aug 2013, 04:40:57

The other downfall with this approach is you cannot assign custom validators but we'll just have to make people aware of that.

Shannon Deminick 23 Aug 2013, 05:02:42

But, we'll be able to use this same attribute if people want to create their own instance of PreValueField, they can attribute the class as well, and then just create their own validators in there.... anyways, can show you this all once it's done.

Shannon Deminick 23 Aug 2013, 05:25:15

Ok, this is all implemented, here's what you can do:

  1. You can define your fields inside of the overridden CreatePreValueEditor like I had before with the DropDownPropertyEditor.

  2. You can create a derived PreValueEditor class and create properties with the [PreValueField(...)] assigned and then return an instance of this class in your CreatePreValueEditor method.

[PreValueField("temp", "Add pre value", "Views/PropertyEditors/dropdown/dropdown.prevalue.html", Description = "Add and remove values for the drop down list")] public string TempPreValueField { get; set; }

  1. You can create a derived PreValueField class which you can also attribute with [PreValueField(...)] and then you can create properties with [PreValueField(typeof(YourPreValueFieldClass)] which will instantiate your custom class in case it needs to localize properties or return custom validators.

So lots of options now.

Shannon Deminick 23 Aug 2013, 05:35:40

FYI I've left my DropDownPropertyEditor as it was since I think it's actually less code to create the fields collection than using the attribute way because I'd have to create a custom implementation of the PreValueField class to have the Name localized.

Shannon Deminick 23 Aug 2013, 05:49:22

I've realized we can probably do more with this attribute and strongly typed properties to possibly have auto-strongly typed pre-values... stay tuned.

Per Ploug 30 Sep 2013, 21:18:32

is this still work in progress?

Shannon Deminick 02 Oct 2013, 09:19:08

Going to leave this as-is, i honestly don't think many people will be doing this, plus if they can just save json directly now that's all that people will really use. Just need to get this done U4-2829

Priority: Normal

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions: 7.0.0

Due in version: 7.0.0


Story Points: