/
DecimalPropertyEditor.cs
57 lines (54 loc) · 2.03 KB
/
DecimalPropertyEditor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Umbraco.Core;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Web.PropertyEditors
{
[PropertyEditor(Constants.PropertyEditors.DecimalAlias, "Decimal", PropertyEditorValueTypes.Decimal, "decimal", IsParameterEditor = true)]
public class DecimalPropertyEditor : PropertyEditor
{
/// <summary>
/// Overridden to ensure that the value is validated
/// </summary>
/// <returns></returns>
protected override PropertyValueEditor CreateValueEditor()
{
var editor = base.CreateValueEditor();
editor.Validators.Add(new DecimalValidator());
return editor;
}
protected override PreValueEditor CreatePreValueEditor()
{
return new DecimalPreValueEditor();
}
/// <summary>
/// A custom pre-value editor class to deal with the legacy way that the pre-value data is stored.
/// </summary>
internal class DecimalPreValueEditor : PreValueEditor
{
public DecimalPreValueEditor()
{
//create the fields
Fields.Add(new PreValueField(new DecimalValidator())
{
Description = "Enter the minimum amount of number to be entered",
Key = "min",
View = "decimal",
Name = "Minimum"
});
Fields.Add(new PreValueField(new DecimalValidator())
{
Description = "Enter the intervals amount between each step of number to be entered",
Key = "step",
View = "decimal",
Name = "Step Size"
});
Fields.Add(new PreValueField(new DecimalValidator())
{
Description = "Enter the maximum amount of number to be entered",
Key = "max",
View = "decimal",
Name = "Maximum"
});
}
}
}
}