|
|
@ -28,19 +28,6 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[RuleAction( |
|
|
|
|
|
Title = "Invalid", |
|
|
|
|
|
IconImage = "<svg></svg>", |
|
|
|
|
|
IconColor = "#1e5470", |
|
|
|
|
|
Display = "Action display", |
|
|
|
|
|
Description = "Action description.", |
|
|
|
|
|
ReadMore = "https://www.readmore.com/")] |
|
|
|
|
|
public sealed record MyInvalidRuleAction : RuleAction |
|
|
|
|
|
{ |
|
|
|
|
|
[DataType(DataType.Custom)] |
|
|
|
|
|
public string Custom { get; set; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public enum ActionEnum |
|
|
public enum ActionEnum |
|
|
{ |
|
|
{ |
|
|
Yes, |
|
|
Yes, |
|
|
@ -58,38 +45,38 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
{ |
|
|
{ |
|
|
[LocalizedRequired] |
|
|
[LocalizedRequired] |
|
|
[Display(Name = "Url Name", Description = "Url Description")] |
|
|
[Display(Name = "Url Name", Description = "Url Description")] |
|
|
[DataType(DataType.Url)] |
|
|
[Editor(RuleFieldEditor.Url)] |
|
|
[Formattable] |
|
|
[Formattable] |
|
|
public Uri Url { get; set; } |
|
|
public Uri Url { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.EmailAddress)] |
|
|
[Editor(RuleFieldEditor.Javascript)] |
|
|
public string Email { get; set; } |
|
|
public string Script { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public string Text { get; set; } |
|
|
public string Text { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.MultilineText)] |
|
|
[Editor(RuleFieldEditor.TextArea)] |
|
|
public string TextMultiline { get; set; } |
|
|
public string TextMultiline { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Password)] |
|
|
[Editor(RuleFieldEditor.Password)] |
|
|
public string Password { get; set; } |
|
|
public string Password { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public ActionEnum Enum { get; set; } |
|
|
public ActionEnum Enum { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public ActionEnum? EnumOptional { get; set; } |
|
|
public ActionEnum? EnumOptional { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public bool Boolean { get; set; } |
|
|
public bool Boolean { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public bool? BooleanOptional { get; set; } |
|
|
public bool? BooleanOptional { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public int Number { get; set; } |
|
|
public int Number { get; set; } |
|
|
|
|
|
|
|
|
[DataType(DataType.Text)] |
|
|
[Editor(RuleFieldEditor.Text)] |
|
|
public int? NumberOptional { get; set; } |
|
|
public int? NumberOptional { get; set; } |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -112,17 +99,17 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "url", |
|
|
Name = "url", |
|
|
Display = "Url Name", |
|
|
Display = "Url Name", |
|
|
Description = "Url Description", |
|
|
Description = "Url Description", |
|
|
Editor = RuleActionPropertyEditor.Url, |
|
|
Editor = RuleFieldEditor.Url, |
|
|
IsFormattable = true, |
|
|
IsFormattable = true, |
|
|
IsRequired = true |
|
|
IsRequired = true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expected.Properties.Add(new RuleActionProperty |
|
|
expected.Properties.Add(new RuleActionProperty |
|
|
{ |
|
|
{ |
|
|
Name = "email", |
|
|
Name = "script", |
|
|
Display = "Email", |
|
|
Display = "Script", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Email, |
|
|
Editor = RuleFieldEditor.Javascript, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -131,7 +118,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "text", |
|
|
Name = "text", |
|
|
Display = "Text", |
|
|
Display = "Text", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Text, |
|
|
Editor = RuleFieldEditor.Text, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -140,7 +127,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "textMultiline", |
|
|
Name = "textMultiline", |
|
|
Display = "TextMultiline", |
|
|
Display = "TextMultiline", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.TextArea, |
|
|
Editor = RuleFieldEditor.TextArea, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -149,7 +136,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "password", |
|
|
Name = "password", |
|
|
Display = "Password", |
|
|
Display = "Password", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Password, |
|
|
Editor = RuleFieldEditor.Password, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -158,7 +145,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "enum", |
|
|
Name = "enum", |
|
|
Display = "Enum", |
|
|
Display = "Enum", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Dropdown, |
|
|
Editor = RuleFieldEditor.Dropdown, |
|
|
IsRequired = false, |
|
|
IsRequired = false, |
|
|
Options = new[] { "Yes", "No" } |
|
|
Options = new[] { "Yes", "No" } |
|
|
}); |
|
|
}); |
|
|
@ -168,7 +155,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "enumOptional", |
|
|
Name = "enumOptional", |
|
|
Display = "EnumOptional", |
|
|
Display = "EnumOptional", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Dropdown, |
|
|
Editor = RuleFieldEditor.Dropdown, |
|
|
IsRequired = false, |
|
|
IsRequired = false, |
|
|
Options = new[] { "Yes", "No" } |
|
|
Options = new[] { "Yes", "No" } |
|
|
}); |
|
|
}); |
|
|
@ -178,7 +165,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "boolean", |
|
|
Name = "boolean", |
|
|
Display = "Boolean", |
|
|
Display = "Boolean", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Checkbox, |
|
|
Editor = RuleFieldEditor.Checkbox, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -187,7 +174,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "booleanOptional", |
|
|
Name = "booleanOptional", |
|
|
Display = "BooleanOptional", |
|
|
Display = "BooleanOptional", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Checkbox, |
|
|
Editor = RuleFieldEditor.Checkbox, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -196,7 +183,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "number", |
|
|
Name = "number", |
|
|
Display = "Number", |
|
|
Display = "Number", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Number, |
|
|
Editor = RuleFieldEditor.Number, |
|
|
IsRequired = true |
|
|
IsRequired = true |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -205,7 +192,7 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
Name = "numberOptional", |
|
|
Name = "numberOptional", |
|
|
Display = "NumberOptional", |
|
|
Display = "NumberOptional", |
|
|
Description = null, |
|
|
Description = null, |
|
|
Editor = RuleActionPropertyEditor.Number, |
|
|
Editor = RuleFieldEditor.Number, |
|
|
IsRequired = false |
|
|
IsRequired = false |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -215,11 +202,5 @@ namespace Squidex.Domain.Apps.Core.Operations.HandleRules |
|
|
|
|
|
|
|
|
currentDefinition.Should().BeEquivalentTo(expected); |
|
|
currentDefinition.Should().BeEquivalentTo(expected); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public void Should_throw_exception_if_validation_attribute_used_incorrectly() |
|
|
|
|
|
{ |
|
|
|
|
|
Assert.Throws<InvalidOperationException>(() => sut.Add<MyInvalidRuleAction>()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|