namespace Server.Infrastructure.TagHelpers.Buttons;

[Microsoft.AspNetCore.Razor.TagHelpers.HtmlTargetElement
    (tag: "button-reset",
    ParentTag = "section-form-buttons",
    TagStructure = Microsoft.AspNetCore.Razor.TagHelpers.TagStructure.WithoutEndTag)]
public class ButtonResetTagHelper :
    Microsoft.AspNetCore.Razor.TagHelpers.TagHelper
{
    public ButtonResetTagHelper() : base()
    {
    }

    public override void Process
        (Microsoft.AspNetCore.Razor.TagHelpers.TagHelperContext context,
        Microsoft.AspNetCore.Razor.TagHelpers.TagHelperOutput output)
    {
        // **************************************************
        var icon =
            Utility.GetIconReset();
        // **************************************************

        // **************************************************
        var body =
            new Microsoft.AspNetCore.Mvc
            .Rendering.TagBuilder(tagName: "button");

        body.Attributes.Add
            (key: "type", value: "reset");

        body.AddCssClass(value: "btn");
        body.AddCssClass(value: "btn-secondary");

        body.InnerHtml.AppendHtml(content: icon);
        body.InnerHtml.Append(unencoded: Resources.ButtonCaptions.Reset);
        // **************************************************

        // **************************************************
        output.TagName = null;

        output.TagMode =
            Microsoft.AspNetCore.Razor
            .TagHelpers.TagMode.StartTagAndEndTag;

        output.Content.SetHtmlContent(htmlContent: body);
        // **************************************************
    }
}
