Skip to content

Commit

Permalink
修改富文本必填验证的bug,更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuLiang authored and LiuLiang committed Jan 3, 2019
1 parent 55a9921 commit e9f2cd0
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
1 change: 1 addition & 0 deletions demo/WalkingTec.Mvvm.Demo/Models/School.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class School : BasePoco
public SchoolTypeEnum? SchoolType { get; set; }

[Display(Name = "备注")]
[Required]
public string Remark { get; set; }

[Display(Name = "专业")]
Expand Down
2 changes: 1 addition & 1 deletion demo/WalkingTec.Mvvm.Demo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"ConnectionStrings": [
{
"Key": "default",
"Value": "Server=(localdb)\\mssqllocaldb;Database=111222;Trusted_Connection=True;MultipleActiveResultSets=true"
"Value": "Server=(localdb)\\mssqllocaldb;Database=1112221;Trusted_Connection=True;MultipleActiveResultSets=true"
}
],
"DBType": "sqlserver", //使用的数据库,可选mysql,sqlserver
Expand Down
2 changes: 1 addition & 1 deletion doc/WalkingTec.Mvvm.Doc/Views/UI/Rich.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<wt:tabcontent>
<wt:code>
&ltwt:form vm="@@Model" width="600"&gt
&ltwt:textbox field="Entity.Remark" height="400" /&gt
&ltwt:richtextbox field="Entity.Remark" height="400" /&gt
&ltwt:row align="AlignEnum.Right"&gt
&ltwt:submitbutton disabled="true" /&gt
&ltwt:closebutton disabled="true" /&gt
Expand Down
15 changes: 15 additions & 0 deletions src/WalkingTec.Mvvm.Core/Attributes/MiddleTableAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace WalkingTec.Mvvm.Core.Attributes
{

/// <summary>
/// 标记某个Model是一个多对多的中间表
/// </summary>
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class MiddleTableAttribute : Attribute
{
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (!_excludeType.Contains(output.Attributes["type"]?.Value?.ToString()))
{
output.Attributes.Add("lay-verify", "required");
//richtextbox不需要进行必填验证
if (output.Attributes["isrich"] == null)
{
output.Attributes.Add("lay-verify", "required");
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
using Microsoft.AspNetCore.Razor.TagHelpers;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Attributes;
using WalkingTec.Mvvm.Core.Extensions;

namespace WalkingTec.Mvvm.TagHelpers.LayUI
Expand Down Expand Up @@ -41,6 +43,13 @@ public override void Process(TagHelperContext context, TagHelperOutput output)

var modelType = Field.Metadata.ModelType;
var listitems = new List<ComboSelectListItem>();

var middleTable = modelType.GetCustomAttributes(typeof(MiddleTableAttribute), false).FirstOrDefault();
//如果指向多对多中间表
if(middleTable != null)
{

}
if (Items?.Model == null)
{
if (modelType.IsList())
Expand Down
1 change: 1 addition & 0 deletions src/WalkingTec.Mvvm.TagHelpers.LayUI/Form/RichTextBox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
output.TagMode = TagMode.StartTagAndEndTag;
output.Attributes.Add("placeholder", placeHolder);
output.Attributes.Add("style", "display:none");
output.Attributes.Add("isrich", "1");
if (DefaultValue != null)
{
output.Content.SetContent(DefaultValue.ToString());
Expand Down

0 comments on commit e9f2cd0

Please sign in to comment.