mirror of
https://github.com/lidarr/Lidarr
synced 2025-02-22 05:50:56 +00:00
Add HelpTextWarning support in FieldDefinition
(cherry picked from commit 0e07d54ee77d5f83716e17b6757e23f38ff73694) Closes #3793
This commit is contained in:
parent
2d320ebc8c
commit
e4341a1b60
5 changed files with 20 additions and 13 deletions
|
@ -64,6 +64,7 @@ function ProviderFieldFormGroup(props) {
|
||||||
name,
|
name,
|
||||||
label,
|
label,
|
||||||
helpText,
|
helpText,
|
||||||
|
helpTextWarning,
|
||||||
helpLink,
|
helpLink,
|
||||||
placeholder,
|
placeholder,
|
||||||
value,
|
value,
|
||||||
|
@ -97,6 +98,7 @@ function ProviderFieldFormGroup(props) {
|
||||||
name={name}
|
name={name}
|
||||||
label={label}
|
label={label}
|
||||||
helpText={helpText}
|
helpText={helpText}
|
||||||
|
helpTextWarning={helpTextWarning}
|
||||||
helpLink={helpLink}
|
helpLink={helpLink}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
value={value}
|
value={value}
|
||||||
|
@ -123,6 +125,7 @@ ProviderFieldFormGroup.propTypes = {
|
||||||
name: PropTypes.string.isRequired,
|
name: PropTypes.string.isRequired,
|
||||||
label: PropTypes.string.isRequired,
|
label: PropTypes.string.isRequired,
|
||||||
helpText: PropTypes.string,
|
helpText: PropTypes.string,
|
||||||
|
helpTextWarning: PropTypes.string,
|
||||||
helpLink: PropTypes.string,
|
helpLink: PropTypes.string,
|
||||||
placeholder: PropTypes.string,
|
placeholder: PropTypes.string,
|
||||||
value: PropTypes.any,
|
value: PropTypes.any,
|
||||||
|
|
|
@ -9,6 +9,7 @@ public class Field
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public string Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
public string HelpText { get; set; }
|
public string HelpText { get; set; }
|
||||||
|
public string HelpTextWarning { get; set; }
|
||||||
public string HelpLink { get; set; }
|
public string HelpLink { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
|
@ -98,6 +98,7 @@ private static FieldMapping[] GetFieldMapping(Type type, string prefix, Func<obj
|
||||||
Label = fieldAttribute.Label,
|
Label = fieldAttribute.Label,
|
||||||
Unit = fieldAttribute.Unit,
|
Unit = fieldAttribute.Unit,
|
||||||
HelpText = fieldAttribute.HelpText,
|
HelpText = fieldAttribute.HelpText,
|
||||||
|
HelpTextWarning = fieldAttribute.HelpTextWarning,
|
||||||
HelpLink = fieldAttribute.HelpLink,
|
HelpLink = fieldAttribute.HelpLink,
|
||||||
Order = fieldAttribute.Order,
|
Order = fieldAttribute.Order,
|
||||||
Advanced = fieldAttribute.Advanced,
|
Advanced = fieldAttribute.Advanced,
|
||||||
|
|
|
@ -27,35 +27,36 @@ public void schema_should_have_proper_fields()
|
||||||
|
|
||||||
var schema = SchemaBuilder.ToSchema(model);
|
var schema = SchemaBuilder.ToSchema(model);
|
||||||
|
|
||||||
schema.Should().Contain(c =>
|
schema.Should().Contain(c => c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && c.HelpTextWarning == "Mandatory Last Name" && (string)c.Value == "Poop");
|
||||||
c.Order == 1 && c.Name == "lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" &&
|
schema.Should().Contain(c => c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && c.HelpTextWarning == "Mandatory First Name" && (string)c.Value == "Bob");
|
||||||
(string)c.Value == "Poop");
|
|
||||||
schema.Should().Contain(c =>
|
|
||||||
c.Order == 0 && c.Name == "firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" &&
|
|
||||||
(string)c.Value == "Bob");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void schema_should_have_nested_fields()
|
public void schema_should_have_nested_fields()
|
||||||
{
|
{
|
||||||
var model = new NestedTestModel();
|
var model = new NestedTestModel
|
||||||
model.Name.FirstName = "Bob";
|
{
|
||||||
model.Name.LastName = "Poop";
|
Name =
|
||||||
|
{
|
||||||
|
FirstName = "Bob",
|
||||||
|
LastName = "Poop"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var schema = SchemaBuilder.ToSchema(model);
|
var schema = SchemaBuilder.ToSchema(model);
|
||||||
|
|
||||||
schema.Should().Contain(c => c.Order == 0 && c.Name == "name.firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && (string)c.Value == "Bob");
|
schema.Should().Contain(c => c.Order == 0 && c.Name == "name.firstName" && c.Label == "First Name" && c.HelpText == "Your First Name" && c.HelpTextWarning == "Mandatory First Name" && (string)c.Value == "Bob");
|
||||||
schema.Should().Contain(c => c.Order == 1 && c.Name == "name.lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && (string)c.Value == "Poop");
|
schema.Should().Contain(c => c.Order == 1 && c.Name == "name.lastName" && c.Label == "Last Name" && c.HelpText == "Your Last Name" && c.HelpTextWarning == "Mandatory Last Name" && (string)c.Value == "Poop");
|
||||||
schema.Should().Contain(c => c.Order == 2 && c.Name == "quote" && c.Label == "Quote" && c.HelpText == "Your Favorite Quote");
|
schema.Should().Contain(c => c.Order == 2 && c.Name == "quote" && c.Label == "Quote" && c.HelpText == "Your Favorite Quote");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TestModel
|
public class TestModel
|
||||||
{
|
{
|
||||||
[FieldDefinition(0, Label = "First Name", HelpText = "Your First Name")]
|
[FieldDefinition(0, Label = "First Name", HelpText = "Your First Name", HelpTextWarning = "Mandatory First Name")]
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
|
|
||||||
[FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name")]
|
[FieldDefinition(1, Label = "Last Name", HelpText = "Your Last Name", HelpTextWarning = "Mandatory Last Name")]
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
|
|
||||||
public string Other { get; set; }
|
public string Other { get; set; }
|
||||||
|
|
|
@ -15,6 +15,7 @@ public FieldDefinitionAttribute(int order)
|
||||||
public string Label { get; set; }
|
public string Label { get; set; }
|
||||||
public string Unit { get; set; }
|
public string Unit { get; set; }
|
||||||
public string HelpText { get; set; }
|
public string HelpText { get; set; }
|
||||||
|
public string HelpTextWarning { get; set; }
|
||||||
public string HelpLink { get; set; }
|
public string HelpLink { get; set; }
|
||||||
public FieldType Type { get; set; }
|
public FieldType Type { get; set; }
|
||||||
public bool Advanced { get; set; }
|
public bool Advanced { get; set; }
|
||||||
|
|
Loading…
Reference in a new issue