77 lines
6.1 KiB
Plaintext
77 lines
6.1 KiB
Plaintext
@model ApplicationNavigationViewModel
|
|
@inject PlotLine.Data.IToolbarPreferenceRepository ToolbarPreferences
|
|
@inject ICurrentUserService CurrentToolbarUser
|
|
@using System.Text.Json
|
|
@{
|
|
var keys = ToolbarCommands.Resolve(CurrentToolbarUser.UserId is int toolbarUserId ? await ToolbarPreferences.GetAsync(toolbarUserId) : null);
|
|
var ordered = keys.Select(key => ToolbarCommands.All.Single(x => x.Key == key))
|
|
.Concat(ToolbarCommands.All.Where(x => !keys.Contains(x.Key))).ToList();
|
|
var controller = ViewContext.RouteData.Values["controller"]?.ToString() ?? "";
|
|
var action = ViewContext.RouteData.Values["action"]?.ToString() ?? "";
|
|
var appearance = ViewData["ApplicationAppearance"] as ApplicationAppearance ?? new();
|
|
}
|
|
<nav class="app-toolbar" aria-label="Quick Access Toolbar" data-app-toolbar>
|
|
<div class="app-toolbar-commands" data-toolbar-commands>
|
|
@foreach (var command in ordered)
|
|
{
|
|
var available = command.IsAvailable(Model);
|
|
var active = available && command.IsActive(controller, action, Model.ActiveSection);
|
|
<a aria-label="@command.Label" class="app-toolbar-command @(active ? "active" : null)" data-toolbar-key="@command.Key"
|
|
data-review-url="@(command.RequiresBook ? Url.Action(command.Action, command.Controller, new { bookId = 0 }) : null)"
|
|
hidden="@(!keys.Contains(command.Key))" href="@(available ? Url.Action(command.Action, command.Controller, command.RouteValues(Model)) : null)"
|
|
aria-current="@(active ? "page" : null)" aria-disabled="@(!available ? "true" : null)"
|
|
title="@(available ? command.Label : command.RequiresBook && Model.Project is not null ? "Select a book to open Review Centre" : "Select a project to use this tool")">
|
|
<svg class="pd-icon" data-tone="@ApplicationRibbon.Tone(command.Key)" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="@command.IconPath" /></svg><span>@command.Label</span>
|
|
</a>
|
|
}
|
|
<span class="app-toolbar-empty" data-toolbar-empty hidden="@(keys.Length != 0)">Choose shortcuts from Customise PlotDirector…</span>
|
|
</div>
|
|
<button type="button" class="app-toolbar-customise" data-bs-toggle="modal" data-bs-target="#customiseToolbar" title="Customise PlotDirector" aria-label="Customise PlotDirector">⋯</button>
|
|
</nav>
|
|
<div class="modal fade" id="customiseToolbar" tabindex="-1" aria-labelledby="customiseToolbarTitle" aria-hidden="true" data-toolbar-dialog>
|
|
<div class="modal-dialog modal-dialog-scrollable">
|
|
<form class="modal-content" action="@Url.Action("Save", "Toolbar")" method="post" data-toolbar-form>
|
|
@Html.AntiForgeryToken()
|
|
<div class="modal-header">
|
|
<h2 class="modal-title fs-5" id="customiseToolbarTitle">Customise PlotDirector</h2>
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cancel"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<h3 class="fs-6">Quick Access Toolbar</h3>
|
|
<p class="small text-muted" id="toolbarInstructions">Select your shortcuts. Drag rows or use Move up and Move down to set their order. Changes apply when you save.</p>
|
|
<div data-toolbar-choices aria-describedby="toolbarInstructions">
|
|
@foreach (var command in ToolbarCommands.All)
|
|
{
|
|
<div class="toolbar-choice" data-command-key="@command.Key" draggable="true">
|
|
<span class="toolbar-drag-handle" aria-hidden="true">⠿</span>
|
|
<label><input type="checkbox" value="@command.Key" /> @command.Label</label>
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" data-move="-1" aria-label="Move @command.Label up">↑</button>
|
|
<button type="button" class="btn btn-sm btn-outline-secondary" data-move="1" aria-label="Move @command.Label down">↓</button>
|
|
</div>
|
|
}
|
|
</div>
|
|
<p class="small text-muted mt-2 mb-0">Project tools need an open project. Review Centre also needs a selected book.</p>
|
|
<section class="pd-customise-section" aria-labelledby="applicationBarPreferencesTitle">
|
|
<h3 class="fs-6" id="applicationBarPreferencesTitle">Application Bar</h3>
|
|
<div class="form-check mb-2">
|
|
<input class="form-check-input" type="checkbox" id="showProjectContextMenu" data-show-project-menu checked="@appearance.ShowProjectContextMenu" />
|
|
<label class="form-check-label" for="showProjectContextMenu"><strong>Show project menu</strong><span>Shows the current project dropdown in the application bar.</span></label>
|
|
</div>
|
|
<div class="form-check">
|
|
<input class="form-check-input" type="checkbox" id="showBookContextMenu" data-show-book-menu checked="@appearance.ShowBookContextMenu" />
|
|
<label class="form-check-label" for="showBookContextMenu"><strong>Show book menu</strong><span>Shows the current book dropdown in the application bar.</span></label>
|
|
</div>
|
|
</section>
|
|
<p class="text-danger mt-2 mb-0" role="alert" data-toolbar-error></p>
|
|
<span class="visually-hidden" role="status" data-toolbar-status></span>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-outline-secondary me-auto" data-toolbar-defaults>Restore defaults</button>
|
|
<button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<button type="submit" class="btn btn-primary">Save</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<script type="application/json" data-toolbar-config>@Html.Raw(JsonSerializer.Serialize(new { keys, defaults = ToolbarCommands.Defaults, showProjectContextMenu = appearance.ShowProjectContextMenu, showBookContextMenu = appearance.ShowBookContextMenu }))</script>
|