Skip to content

Commit

Permalink
add checkbox component
Browse files Browse the repository at this point in the history
  • Loading branch information
kentico-ericd committed Nov 27, 2023
1 parent d2ee300 commit 365076b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ The project currently contains the following input types with depending field fu

- Text
- Number
- Radio group
- Checkbox
- Dropdown
- Radio group

## Configuring depending fields in the administration

Expand Down
3 changes: 3 additions & 0 deletions src/DependingFieldComponentsConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ public static class DependingFieldComponentsConstants
public const string DROPDOWNINPUT_IDENTIFIER = "Xperience.DependingFieldComponents.DropdownInput";
public const string DROPDOWNINPUT_FIELDDESCRIPTION = "Dropdown selector with field dependency";

public const string CHECKBOXINPUT_IDENTIFIER = "Xperience.DependingFieldComponents.CheckboxInput";
public const string CHECKBOXINPUT_FIELDDESCRIPTION = "Checkbox with field dependency";

public const string PROPERTY_DEPENDSON_LABEL = "Depends on";
public const string PROPERTY_DEPENDSON_TOOLTIP = "The name of the field that determines this field's visibility";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Kentico.Xperience.Admin.Base.FormAnnotations;

namespace Xperience.DependingFieldComponents.FormComponents.CheckboxInputDependsOnFieldComponent
{
public class CheckboxInputDependsOnFieldAttribute : FormComponentAttribute, IDependsOnPropertyProperties
{
public string? DependsOn { get; set; }


public string? ExpectedValue { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Kentico.Xperience.Admin.Base.Forms;

using Xperience.DependingFieldComponents;
using Xperience.DependingFieldComponents.FormComponents.CheckboxInputDependsOnFieldComponent;
using Xperience.DependingFieldComponents.VisibilityConditions;

[assembly: RegisterFormComponent(DependingFieldComponentsConstants.CHECKBOXINPUT_IDENTIFIER, typeof(CheckboxInputDependsOnFieldComponent), DependingFieldComponentsConstants.CHECKBOXINPUT_FIELDDESCRIPTION)]
namespace Xperience.DependingFieldComponents.FormComponents.CheckboxInputDependsOnFieldComponent
{
/// <summary>
/// A form component which can be configured to appear based on the value of another field.
/// </summary>
[ComponentAttribute(typeof(CheckboxInputDependsOnFieldAttribute))]
public class CheckboxInputDependsOnFieldComponent : FormComponent<CheckboxInputDependsOnFieldProperties, CheckBoxClientProperties, bool>
{
public override string ClientComponentName => "@kentico/xperience-admin-base/Checkbox";


/// <summary>
/// Initializes a new instance of <see cref="CheckboxInputDependsOnFieldComponent"/>
/// </summary>
public CheckboxInputDependsOnFieldComponent()
{
}


protected override void ConfigureComponent()
{
DependingFieldVisibilityCondition.Configure(this);

base.ConfigureComponent();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Kentico.Xperience.Admin.Base.FormAnnotations;
using Kentico.Xperience.Admin.Base.Forms;

namespace Xperience.DependingFieldComponents.FormComponents.CheckboxInputDependsOnFieldComponent
{
/// <summary>
/// Properties for the <see cref="CheckboxInputDependsOnFieldComponent"/> component.
/// </summary>
public class CheckboxInputDependsOnFieldProperties : FormComponentProperties, IDependsOnPropertyProperties
{
[TextInputComponent(Label = DependingFieldComponentsConstants.PROPERTY_DEPENDSON_LABEL, Tooltip = DependingFieldComponentsConstants.PROPERTY_DEPENDSON_TOOLTIP, Order = 1)]
public string? DependsOn { get; set; }


[TextInputComponent(Label = DependingFieldComponentsConstants.PROPERTY_EXPECTEDVALUE_LABEL, Tooltip = DependingFieldComponentsConstants.PROPERTY_EXPECTEDVALUE_TOOLTIP, Order = 2)]
public string? ExpectedValue { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
namespace Xperience.DependingFieldComponents.FormComponents.DropdownInputDependsOnFieldComponent
{
/// <summary>
/// Properties for the <see cref="DropdownInputDependsOnFieldComponent"/> component.
/// Properties for the <see cref="DropdownInputDependsOnFieldComponent"/> component which inherits the default
/// Xperience by Kentico dropdown input properties.
/// </summary>
public class DropdownInputDependsOnFieldProperties : DropDownProperties, IDependsOnPropertyProperties
{
Expand Down

0 comments on commit 365076b

Please sign in to comment.