forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInputParserUtils.cs
More file actions
116 lines (107 loc) · 5.26 KB
/
Copy pathInputParserUtils.cs
File metadata and controls
116 lines (107 loc) · 5.26 KB
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
namespace SiteServer.Utils
{
public class InputParserUtils
{
private InputParserUtils()
{
}
//private static string GetValidateCheckMethod(string attributeName, string displayName, InputValidateInfo validateInfo)
//{
// if (validateInfo != null)
// {
// return
// $"checkAttributeValue('{attributeName}', '{displayName}', {validateInfo.IsRequire.ToString().ToLower()}, {validateInfo.MinNum}, {validateInfo.MaxNum}, '{validateInfo.RegExp}', '{validateInfo.ErrorMessage}');";
// }
// return string.Empty;
//}
public static string GetValidateAttributes(bool isValidate, string displayName, bool isRequire, int minNum, int maxNum, string validateType, string regExp, string errorMessage)
{
if (isValidate)
{
return
$@"isValidate=""{true.ToString().ToLower()}"" displayName=""{displayName}"" isRequire=""{isRequire
.ToString().ToLower()}"" minNum=""{minNum}"" maxNum=""{maxNum}"" validateType=""{validateType}"" regExp=""{regExp}"" errorMessage=""{errorMessage}""";
}
return string.Empty;
}
public static string GetValidateSubmitOnClickScript(string formId)
{
return $"return checkFormValueById('{formId}');";
}
/// <summary>
/// 带有提示的确认操作
/// </summary>
/// <param name="formId"></param>
/// <param name="isConfirm"></param>
/// <param name="confirmFunction"></param>
/// <returns></returns>
public static string GetValidateSubmitOnClickScript(string formId, bool isConfirm, string confirmFunction)
{
if (!string.IsNullOrWhiteSpace(confirmFunction))
{
return !isConfirm ? GetValidateSubmitOnClickScript(formId) : $"return checkFormValueById('{formId}') && {confirmFunction};";
}
return !isConfirm ? GetValidateSubmitOnClickScript(formId) : $"return checkFormValueById('{formId}');";
}
//public static string GetAdditionalAttributes(string whereUsed, InputType inputType)
//{
// var additionalAttributes = string.Empty;
// if (string.IsNullOrEmpty(whereUsed))
// {
// //if (inputType == InputType.Text || inputType == InputType.Image || inputType == InputType.File)
// //{
// // additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" size=""60""";
// //}
// //else if (inputType == InputType.TextArea)
// //{
// // additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" cols=""60"" rows=""5""";
// //}
// //else if (inputType == InputType.Date || inputType == InputType.DateTime)
// //{
// // additionalAttributes = @"class=""colorblur Wdate"" size=""25""";
// //}
// }
// else if (whereUsed == "usercenter")
// {
// if (inputType == InputType.Text || inputType == InputType.Image || inputType == InputType.Video || inputType == InputType.File)
// {
// additionalAttributes = @"class=""input-txt"" style=""width:320px""";
// }
// else if (inputType == InputType.TextArea)
// {
// additionalAttributes = @"class=""input-area area-s5"" cols=""60"" rows=""5""";
// }
// else if (inputType == InputType.Date || inputType == InputType.DateTime)
// {
// additionalAttributes = @"class=""input-txt Wdate"" style=""width:120px""";
// }
// }
// return additionalAttributes;
//}
//public static string GetInnerAdditionalAttributes(InputType inputType, EAuxiliaryTableType tableType, string attributeName)
//{
// string additionalAttributes = string.Empty;
// if (inputType == InputType.Default)
// {
// inputType = InputTypeUtils.GetDefaultInputType(tableType, attributeName);
// }
// if (inputType == InputType.Text)
// {
// additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" size=""60""";
// }
// else if (inputType == InputType.TextArea)
// {
// additionalAttributes = @"class=""colorblur"" onfocus=""this.className='colorfocus';"" onblur=""this.className='colorblur';"" cols=""60"" rows=""5""";
// }
// else if (inputType == InputType.Date || inputType == InputType.DateTime)
// {
// additionalAttributes = @"class=""colorblur"" size=""30""";
// }
// else if (inputType == InputType.Image || inputType == InputType.File)
// {
// additionalAttributes = @"size=""50""";
// }
// return additionalAttributes;
//}
}
}