LocalGovIMS_localgov-ims/src/Admin/Views/ImportProcessingRule/Edit.cshtml
@model Admin.Models.ImportProcessingRule.EditViewModel
@{
    ViewBag.Title = "Edit import processing rule";
}

@section Messages {
    @if (TempData.ContainsKey("Message") && TempData["Message"] != null) { Html.RenderPartial("_Message", TempData["Message"]); }
}

@section Header { @Model.Name }

@section Subheader { Import processing rule details }

@section Actions { @Html.ActionLink(Model.IsDisabled ? "Enable" : "Disable", "ChangeStatus", "ImportProcessingRule", new { id = Model.Id, isDisabled = !Model.IsDisabled }, new { @class = "btn " + (Model.IsDisabled ? "btn-success" : "btn-danger") }) }

@using (Html.BeginForm("Edit", "ImportProcessingRule", FormMethod.Post))
{

    @Html.HiddenFor(m => m.Id)
    @Html.HiddenFor(m => m.IsDisabled)

    <div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Name, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Name, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Name)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.Description, new { @class = "form-label" })
                @Html.TextBoxFor(m => m.Description, new { @class = "form-control" })
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.Description)
                </div>
            </div>
        </div>

        <div class="row mb-3">
            <div class="col col-sm-6 col-md-5 col-lg-4">
                @Html.LabelFor(m => m.IsGlobal, new { @class = "form-label" })
                <div class="form-check form-switch">
                    @Html.CheckBoxFor(m => m.IsGlobal, new { @class = "form-check-input", role = "switch" })
                </div>
                <div class="form__element--error">
                    @Html.ValidationMessageFor(m => m.IsGlobal)
                </div>
            </div>
        </div>

        <div class="d-flex flex-wrap mb-3">
            <div class="me-auto p-0">
                <h3>
                    Rules
                </h3>
            </div>
            <div class="order-lg-2 p-0">
                @Html.ActionLink("Add a rule", "Create", "ImportProcessingRuleCondition", new { importProcessingRuleId = Model.Id }, new { @class = "btn btn-primary" })
            </div>
        </div>

        <div class="mb-3">
            @Html.Action("_EditListForImportProcessingRule", "ImportProcessingRuleCondition", new { id = Model.Id })
        </div>

        <div class="d-flex flex-wrap mb-3">
            <div class="me-auto p-0">
                <h3>
                    Actions
                </h3>
            </div>
            <div class="order-lg-2 p-0">
                @Html.ActionLink("Add an action", "Create", "ImportProcessingRuleAction", new { importProcessingRuleId = Model.Id }, new { @class = "btn btn-primary" })
            </div>
        </div>

        <div class="mb-3">
            @Html.Action("_EditListForImportProcessingRule", "ImportProcessingRuleAction", new { id = Model.Id })
        </div>

        <div class="d-flex flex-wrap mb-3">
            <div class="me-auto p-0">
                <h3>
                    Transaction import types
                </h3>
            </div>
            <div class="order-lg-2 p-0">
                @if (Model.ImportTypesAreAvailableToAdd)
                {
                    @Html.ActionLink("Add an import type", "Create", "ImportProcessingRuleImportType", new { id = Model.Id }, new { @class = "btn btn-primary" })
                }
            </div>
        </div>

        <div class="mb-3">
            @Html.Action("_EditList", "ImportProcessingRuleImportType", new { id = Model.Id })
        </div>

        <div>
            <input type="submit" value="Save" class="btn btn-primary" />
            @Html.ActionLink("Back", "Back", "ImportProcessingRule", null, new { @class = "btn btn-secondary" })
        </div>

    </div>
}