-
Notifications
You must be signed in to change notification settings - Fork 80
/
TextFieldController.cs
123 lines (116 loc) · 5.15 KB
/
TextFieldController.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Telerik.Sitefinity.Data.Metadata;
using Telerik.Sitefinity.Forms.Model;
using Telerik.Sitefinity.Frontend.Forms.Mvc.Controllers.Base;
using Telerik.Sitefinity.Frontend.Forms.Mvc.Models.Fields.TextField;
using Telerik.Sitefinity.Frontend.Forms.Mvc.StringResources;
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers;
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes;
using Telerik.Sitefinity.Localization;
using Telerik.Sitefinity.Model;
using Telerik.Sitefinity.Modules.Forms.Web.UI.Fields;
using Telerik.Sitefinity.Modules.Pages.Web.Services;
using Telerik.Sitefinity.Mvc;
using Telerik.Sitefinity.Web.UI.Fields.Enums;
namespace Telerik.Sitefinity.Frontend.Forms.Mvc.Controllers
{
/// <summary>
/// This class represents the controller of the MVC forms text field.
/// </summary>
[DatabaseMapping(UserFriendlyDataType.ShortText)]
[Localization(typeof(FieldResources))]
[ControllerToolboxItem(
Name = "MvcTextField",
Toolbox = FormsConstants.FormControlsToolboxName,
SectionName = FormsConstants.CommonSectionName,
Title = "Textbox",
CssClass = "sfTextboxIcn sfMvcIcn",
Ordinal = 0.1f)]
public class TextFieldController : FormFieldControllerBase<ITextFieldModel>, ISupportRules, ITextField
{
public TextFieldController()
{
this.DisplayMode = FieldDisplayMode.Write;
}
/// <inheritDocs />
[TypeConverter(typeof(ExpandableObjectConverter))]
[ReflectInheritedProperties]
public override ITextFieldModel Model
{
get
{
if (this.model == null)
this.model = ControllerModelFactory.GetModel<ITextFieldModel>(this.GetType());
return this.model;
}
}
IDictionary<ConditionOperator, string> ISupportRules.Operators
{
get
{
switch (this.Model.InputType)
{
case TextType.Color:
return new Dictionary<ConditionOperator, string>()
{
[ConditionOperator.Equal] = Res.Get<Labels>().IsOperator,
[ConditionOperator.NotEqual] = Res.Get<Labels>().IsNotOperator
};
case TextType.Number:
case TextType.Range:
return new Dictionary<ConditionOperator, string>()
{
[ConditionOperator.Equal] = Res.Get<Labels>().IsEqualOperator,
[ConditionOperator.NotEqual] = Res.Get<Labels>().IsNotEqualOperator,
[ConditionOperator.IsGreaterThan] = Res.Get<Labels>().IsGreaterOperator,
[ConditionOperator.IsLessThan] = Res.Get<Labels>().IsLessOperator,
[ConditionOperator.IsFilled] = Res.Get<Labels>().IsFilledOperator,
[ConditionOperator.IsNotFilled] = Res.Get<Labels>().IsNotFilledOperator
};
case TextType.Date:
case TextType.Time:
case TextType.Month:
case TextType.Week:
case TextType.DateTimeLocal:
return new Dictionary<ConditionOperator, string>()
{
[ConditionOperator.Equal] = Res.Get<Labels>().IsOperator,
[ConditionOperator.IsLessThan] = Res.Get<Labels>().IsBeforeOperator,
[ConditionOperator.IsGreaterThan] = Res.Get<Labels>().IsAfterOperator,
[ConditionOperator.IsFilled] = Res.Get<Labels>().IsFilledOperator,
[ConditionOperator.IsNotFilled] = Res.Get<Labels>().IsNotFilledOperator
};
case TextType.Hidden:
return new Dictionary<ConditionOperator, string>();
default:
return new Dictionary<ConditionOperator, string>()
{
[ConditionOperator.Equal] = Res.Get<Labels>().IsOperator,
[ConditionOperator.NotEqual] = Res.Get<Labels>().IsNotOperator,
[ConditionOperator.Contains] = Res.Get<Labels>().ContainsOperator,
[ConditionOperator.NotContains] = Res.Get<Labels>().NotContainsOperator,
[ConditionOperator.IsFilled] = Res.Get<Labels>().IsFilledOperator,
[ConditionOperator.IsNotFilled] = Res.Get<Labels>().IsNotFilledOperator
};
}
}
}
TextType ITextField.InputType
{
get
{
return this.Model.InputType;
}
}
string ISupportRules.Title
{
get
{
return this.MetaField.Title;
}
}
private ITextFieldModel model;
}
}