PavelAndreyev1337_itransition-course-project/CollectionApp/CollectionApp.WEB/Views/Collection/_GetExtraField.cshtml
@using Microsoft.AspNetCore.Mvc.Localization
@using CollectionApp.DAL.Enums
@model CollectionApp.WEB.ViewModels.ExtraFieldViewModel

@inject IViewLocalizer Localizer

@functions{
    public int ConvertFieldType(FieldType fieldType)
    {
        return (int)fieldType;
    }
    public bool CheckOption(FieldType choice, FieldType option)
    {
        return choice == option;
    }
}

<div class="row align-baseline">
    <div class="d-inline-block mb-3 mt-1 col-6">
        <label class="form-label">@Localizer["FieldName"]</label>
        <input type="text" class="form-control" name="@Model.Prefix.ToLower()FieldName" value="@Model.Name" required />
        <div class="valid-feedback">
            @Localizer["LooksGood"]
        </div>
        <div class="invalid-feedback">
            @Localizer["FieldIsRequired"]
        </div>
    </div>
    <div class="d-inline-block mb-3 mt-1 col-6">
        <label class="form-label">@Localizer["FieldType"]</label>
        <select class="form-control" name="@Model.Prefix.ToLower()FieldType" required>
            <option value="@ConvertFieldType(FieldType.Integer)"
                    selected="@CheckOption(Model.FieldType, FieldType.Integer)">
                @Localizer["Integer"]
            </option>
            <option value="@ConvertFieldType(FieldType.String)"
                    selected="@CheckOption(Model.FieldType, FieldType.String)">
                @Localizer["String"]
            </option>
            <option value="@ConvertFieldType(FieldType.Markdown)"
                    selected="@CheckOption(Model.FieldType, FieldType.Markdown)">
                @Localizer["Markdown"]
            </option>
            <option value="@ConvertFieldType(FieldType.Date)"
                    selected="@CheckOption(Model.FieldType, FieldType.Date)">
                @Localizer["Date"]
            </option>
            <option value="@ConvertFieldType(FieldType.Boolean)"
                    selected="@CheckOption(Model.FieldType, FieldType.Boolean)">
                @Localizer["Boolean"]
            </option>
        </select>
    </div>
</div>
