PlotDirector/PlotLine/Views/Locations/_LocationSpatialPreview.cshtml

54 lines
2.8 KiB
Plaintext

@model LocationDetailViewModel
@{
var map = Model.Spatial?.Map;
var floor = Model.Spatial?.Floor;
var plan = Model.Spatial?.FloorPlan;
string Caption(int id) => id == Model.Location.LocationID
? Model.Location.LocationName
: $"Containing location: {Model.Locations.FirstOrDefault(item => item.LocationID == id)?.LocationName}";
}
<section class="edit-panel">
<h2>Spatial awareness</h2>
@if (map is not null)
{
<h3>@map.Name</h3>
<p>@Caption(map.LocationID)</p>
<div class="button-row mb-2">
<button type="button" class="btn btn-outline-secondary btn-sm" data-map-centre>Centre on mapped location</button>
<a asp-controller="Maps" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID"
asp-route-id="@map.MapID" asp-route-featureId="@map.FeatureID">Open map in Maps</a>
</div>
<iframe class="location-map-frame" title="Map of @Caption(map.LocationID)" data-location-map="@map.FeatureID"
data-map-label="@Caption(map.LocationID)"
data-src="@Url.Action("SpatialMap", new { id = Model.Location.LocationID, mapId = map.MapID, featureId = map.FeatureID })"></iframe>
}
@if (floor is not null && plan is not null)
{
<h3>@floor.Name</h3>
<p>@Caption(floor.LocationID)@(floor.FloorPlanBlockID.HasValue ? "" : " · No room is linked to this location.")</p>
<p><a asp-controller="FloorPlans" asp-action="Edit" asp-route-id="@floor.FloorPlanID"
asp-route-selectedBlockId="@floor.FloorPlanBlockID">Open plan in Floor Plans</a></p>
<div class="location-floor-preview" data-location-floor="@floor.FloorPlanFloorID" data-location-block="@floor.FloorPlanBlockID">
<label>Floor
<select class="form-select form-select-sm" data-floor-level>
@foreach (var level in plan.Floors.OrderBy(level => level.SortOrder).ThenBy(level => level.Name))
{
<option value="@level.FloorPlanFloorID" selected="@(level.FloorPlanFloorID == floor.FloorPlanFloorID)">@level.Name</option>
}
</select>
</label>
<div class="location-floor-scroll mt-2" tabindex="0" aria-label="Floor plan preview">
<partial name="~/Views/FloorPlans/_FloorPlanStage.cshtml" model="plan" />
</div>
</div>
}
@if (map is null && floor is null)
{
<p>No placed map feature or floor plan is linked to this location or its containing locations.</p>
}
<div class="button-row">
<a asp-controller="Maps" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">Browse Maps</a>
<a asp-controller="FloorPlans" asp-action="Index" asp-route-projectId="@Model.Project.ProjectID">Browse Floor Plans</a>
</div>
</section>