@model SceneEditViewModel
@{
    var primaryLocation = Model.LocationOptions.FirstOrDefault(x => x.Value == Model.PrimaryLocationID?.ToString())?.Text?.Trim();
}

<form asp-controller="Scenes" asp-action="SaveSceneLocations" method="post" class="scene-inspector-editor-form" data-scene-editor-form>
    @Html.AntiForgeryToken()
    <input type="hidden" asp-for="SceneID" />

    <div class="scene-inspector-editor-error" data-scene-editor-error hidden></div>

    <div class="scene-inspector-editor-fields">
        <section class="scene-world-editor-section">
            <div class="scene-world-editor-heading">
                <span>Scene location</span>
                <strong>@(Model.PrimaryLocationID.HasValue ? "1" : "0")</strong>
            </div>

            <article class="scene-world-editor-card">
                <div class="scene-world-editor-card-header">
                    <div>
                        <h4>@(primaryLocation ?? "No primary location")</h4>
                        <p>Primary location is the supported scene-level location for this scene.</p>
                    </div>
                </div>

                <div class="form-group">
                    <label for="PrimaryLocationID">Primary location</label>
                    <select class="form-control form-control-sm" id="PrimaryLocationID" name="PrimaryLocationID">
                        <option value="">No primary location</option>
                        @foreach (var option in Model.LocationOptions)
                        {
                            <option value="@option.Value" selected="@(option.Value == Model.PrimaryLocationID?.ToString())">@option.Text</option>
                        }
                    </select>
                </div>
            </article>
        </section>
    </div>

    <div class="scene-inspector-editor-footer">
        <button type="button" class="btn btn-sm btn-outline-secondary" data-scene-editor-close>Cancel</button>
        <button type="submit" class="btn btn-sm btn-primary" data-scene-editor-save>Save locations</button>
    </div>
</form>
