PlotDirector/PlotLine/Views/Shared/_ApplicationShell.cshtml

201 lines
18 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@model ApplicationNavigationViewModel
@{
var project = Model.Project;
var book = Model.Book;
var controller = ViewContext.RouteData.Values["controller"]?.ToString() ?? "";
var action = ViewContext.RouteData.Values["action"]?.ToString() ?? "";
var selectedCategory = ApplicationRibbon.ActiveCategory(controller, Model.ActiveSection);
var appearance = ViewData["ApplicationAppearance"] as ApplicationAppearance ?? new();
}
<section class="pd-shell" aria-label="Application commands" data-app-navigation data-ribbon-shell data-collapsed="@appearance.RibbonCollapsed.ToString().ToLowerInvariant()">
<div class="pd-titlebar">
<a class="pd-brand" asp-controller="Projects" asp-action="Index">PlotDirector<span class="pd-brand-mark" aria-hidden="true">.</span></a>
<partial name="_ApplicationToolbar" model="Model" />
@if (appearance.ShowProjectContextMenu || (appearance.ShowBookContextMenu && project is not null))
{
<ul class="pd-context-menus">
@if (appearance.ShowProjectContextMenu)
{
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle @(controller == "Projects" ? "active" : null)" type="button" id="appProjectMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(project?.ProjectName ?? "Project")">
<span class="app-context-label">@(project?.ProjectName ?? "Project")</span>
</button>
<ul class="dropdown-menu" aria-labelledby="appProjectMenu">
@if (project is not null)
{
<li><h2 class="dropdown-header">@project.ProjectName</h2></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">Project overview</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Edit" asp-route-id="@project.ProjectID">Edit project</a></li>
<li><a class="dropdown-item" asp-controller="Books" asp-action="Create" asp-route-projectId="@project.ProjectID">Add book</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Activity" asp-route-id="@project.ProjectID">Activity</a></li>
@if (project.IsOwner)
{
<li><a class="dropdown-item" asp-controller="ProjectCollaborators" asp-action="Index" asp-route-projectId="@project.ProjectID">Collaborators</a></li>
<li><a class="dropdown-item" asp-controller="BookRecovery" asp-action="Backup" asp-route-projectId="@project.ProjectID">Back up books</a></li>
}
@if(project.IsOwner){<li><a class="dropdown-item" asp-controller="ProjectRestorePoints" asp-action="Index" asp-route-projectId="@project.ProjectID">Rewind project · saved restore points</a></li>}
<li><hr class="dropdown-divider" /></li>
}
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Index">@(project is null ? "Projects" : "Switch project…")</a></li>
<li><form asp-controller="Onboarding" asp-action="StartImport" method="post"><button class="dropdown-item">Import a manuscript</button></form></li>
@if(project is null){<li><a class="dropdown-item" asp-controller="BookRecovery" asp-action="Backup">Back up books</a></li>}
<li><a class="dropdown-item" asp-controller="BookRecovery" asp-action="Restore">Restore books from backup</a></li>
</ul>
</li>
}
@if (appearance.ShowBookContextMenu && project is not null)
{
<li class="nav-item dropdown">
<button class="nav-link dropdown-toggle @(controller is "Books" or "Chapters" or "Scenes" ? "active" : null)" type="button" id="appBookMenu" data-bs-toggle="dropdown" aria-expanded="false" title="@(book?.BookDisplayTitle ?? "Book")">
<span class="app-context-label app-book-label" data-app-book-label>@(book?.BookDisplayTitle ?? "Book")</span>
</button>
<ul class="dropdown-menu app-book-menu" aria-labelledby="appBookMenu">
<li><h2 class="dropdown-header" data-app-book-heading>@(book?.BookDisplayTitle ?? "Books in this project")</h2></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Details", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Details" asp-route-id="@book?.BookID">Book overview</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Edit", "Books", new { id = (int?)null })" asp-controller="Books" asp-action="Edit" asp-route-id="@book?.BookID">Edit book</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-book-url="@Url.Action("Create", "Chapters", new { id = (int?)null })" data-app-book-param="bookId" asp-controller="Chapters" asp-action="Create" asp-route-bookId="@book?.BookID">Add chapter</a></li>
<li hidden="@(book is null)" data-app-book-action><a class="dropdown-item" data-app-review-link data-review-url="@Url.Action("StoryIntelligenceBookReviewCentre", "Onboarding", new { bookId = 0 })" asp-controller="Onboarding" asp-action="StoryIntelligenceBookReviewCentre" asp-route-bookId="@book?.BookID">Review Centre</a></li>
<li><a class="dropdown-item" asp-controller="Projects" asp-action="Details" asp-route-id="@project.ProjectID">All books / project overview</a></li>
<li><hr class="dropdown-divider" /></li>
@foreach (var choice in Model.Books)
{
<li><a class="dropdown-item @(choice.BookID == book?.BookID ? "active" : null)" aria-current="@(choice.BookID == book?.BookID ? "page" : null)" data-app-book-choice="@choice.BookID" data-app-book-title="@choice.BookDisplayTitle" href="@(Model.ActiveSection == "Writer" ? Url.Action("Index", "Writer", new { projectId = project.ProjectID, bookId = choice.BookID }) : Url.Action("Details", "Books", new { id = choice.BookID }))">Book @choice.BookNumber: @choice.BookDisplayTitle</a></li>
}
@if (Model.Books.Count == 0)
{
<li><span class="dropdown-item-text text-muted">No books yet</span></li>
}
</ul>
</li>
}
</ul>
}
<div class="pd-titlebar-end">
@if (Model.ShowCompanionPresence)
{
<button type="button" id="native-companion-status" class="pd-presence" data-word-companion-presence data-word-companion-status="Offline" title="Word connection details" aria-haspopup="dialog" aria-controls="writing-connection-details"><span class="word-companion-presence-dot" data-word-companion-status-dot></span><span id="native-companion-status-text" data-word-companion-status-label>Offline</span></button>
}
<div class="nav-item dropdown app-account-menu">
<button class="nav-link dropdown-toggle" type="button" id="accountMenuButton" data-bs-toggle="dropdown" aria-expanded="false" title="@User.Identity?.Name">
<span class="app-account-label">@User.Identity?.Name</span>
</button>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="accountMenuButton">
<li><h2 class="dropdown-header">@User.Identity?.Name</h2></li>
<li hidden data-pwa-install-item><button type="button" class="dropdown-item" data-pwa-install>PlotDirector Desktop</button></li>
<li><span class="visually-hidden" role="status" data-pwa-status></span></li>
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Index">Manage Account</a></li>
<li><a class="dropdown-item" asp-controller="Onboarding" asp-action="Index">Setup preferences</a></li>
@if (!(ViewData["ShellClass"] as string ?? "").Contains("marketing-shell", StringComparison.OrdinalIgnoreCase))
{
<li><button type="button" class="dropdown-item" data-bs-toggle="modal" data-bs-target="#customiseToolbar">Customise PlotDirector…</button></li>
}
<li><a class="dropdown-item" asp-controller="ManageAccount" asp-action="Subscription">Billing / Subscription</a></li>
@if (Model.IsAdmin)
{
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" asp-controller="Admin" asp-action="Index">Admin @if (Model.AdminFeatureRequestAttentionCount > 0) { <span class="badge text-bg-danger ms-1">@Model.AdminFeatureRequestAttentionCount</span> }</a></li>
}
<li><hr class="dropdown-divider" /></li>
<li><div class="px-3 py-2">
<div class="small text-muted mb-2">Theme</div>
<div class="pd-theme-picker" role="group" aria-label="Theme selection">
@foreach (var theme in ApplicationAppearance.Themes)
{
<button type="button" data-app-theme-choice="@theme.Key" aria-pressed="false"><span class="pd-theme-swatch" data-swatch="@theme.Key" aria-hidden="true"></span>@theme.Value</button>
}
</div>
<p class="small mb-0" role="status" data-appearance-status></p>
</div></li>
<li><hr class="dropdown-divider" /></li>
<li><form asp-controller="Account" asp-action="Logout" method="post" class="m-0"><button class="dropdown-item" type="submit">Logout</button></form></li>
</ul>
</div>
</div>
</div>
<div class="pd-ribbon-heading">
<div class="pd-ribbon-tabs" role="tablist" aria-label="Command categories">
@foreach (var category in ApplicationRibbon.Categories)
{
@if (category.Key == "writer")
{
<a class="pd-ribbon-navigation" aria-current="@(Model.ActiveSection == "Writer" ? "page" : null)" asp-controller="Writer" asp-action="Index" asp-route-projectId="@project?.ProjectID" asp-route-bookId="@book?.BookID" id="ribbon-tab-writer">Writer</a>
continue;
}
<button type="button" role="tab" id="ribbon-tab-@category.Key" aria-controls="ribbon-panel-@category.Key" aria-selected="@(category.Key == selectedCategory ? "true" : "false")" tabindex="@(category.Key == selectedCategory ? "0" : "-1")" data-ribbon-tab="@category.Key">@category.Label</button>
}
</div>
<button type="button" class="pd-ribbon-collapse" data-ribbon-collapse aria-expanded="@(!appearance.RibbonCollapsed ? "true" : "false")" aria-controls="ribbon-surface" title="Collapse or expand ribbon">@(appearance.RibbonCollapsed ? "Expand ribbon" : "Collapse ribbon") <span aria-hidden="true">⌃</span></button>
</div>
<div id="ribbon-surface" class="pd-ribbon-surface" hidden="@appearance.RibbonCollapsed">
@foreach (var category in ApplicationRibbon.Categories)
{
<div class="pd-ribbon-panel" id="ribbon-panel-@category.Key" role="tabpanel" aria-labelledby="ribbon-tab-@category.Key" hidden="@(category.Key != selectedCategory)">
@foreach (var group in category.Groups)
{
<div class="pd-ribbon-group" role="group" aria-label="@group.Label">
<div class="pd-ribbon-commands">
@foreach (var command in group.Commands.Where(x => !x.OwnerOnly || project?.IsOwner == true))
{
var shortcut = command.ToolbarKey is null ? null : ToolbarCommands.All.Single(x => x.Key == command.ToolbarKey);
var available = shortcut?.IsAvailable(Model) ?? command.Available(Model);
var url = available ? Url.Action(command.Action, command.Controller, shortcut?.RouteValues(Model) ?? command.Values(Model)) : null;
var active = available && (shortcut?.IsActive(controller, action, Model.ActiveSection) ?? (controller == command.Controller && action == command.Action));
var bookScoped = command.Scope is "book" or "chapter" or "writerBook";
var presentationIcon = RibbonPresentation.IconFor(RibbonPresentation.Operation(command.Controller, command.Action)) ?? command.IconKey;
var icon = ApplicationRibbon.Icon(presentationIcon);
@if(command.Post){
<form asp-controller="@command.Controller" asp-action="@command.Action" method="post">
<button class="pd-ribbon-command" disabled="@(!available)" data-command-operation="@RibbonPresentation.Operation(command.Controller,command.Action)" data-ribbon-icon="@presentationIcon" title="@command.Label">
<svg viewBox="0 0 24 24" class="pd-icon" data-tone="@icon.Tone" aria-hidden="true" focusable="false"><path d="@icon.IconPath" /></svg><span>@command.Label</span>
</button>
</form>
}else{
<a class="pd-ribbon-command" href="@url" aria-disabled="@(!available ? "true" : null)" aria-current="@(active ? "page" : null)"
data-review-url="@(command.ToolbarKey == "review" ? Url.Action(command.Action, command.Controller, new { bookId = 0 }) : null)"
data-ribbon-book-url="@(bookScoped ? Url.Action(command.Action, command.Controller, new { id = (int?)null, bookId = (int?)null }) : null)" data-book-param="@(command.Scope is "chapter" or "writerBook" ? "bookId" : "id")"
data-command-operation="@RibbonPresentation.Operation(command.Controller, command.Action)" data-ribbon-icon="@presentationIcon" title="@(available ? command.Label : bookScoped || shortcut?.RequiresBook == true ? "Select a book to use this command" : "Select a project to use this command")">
<svg viewBox="0 0 24 24" class="pd-icon" data-tone="@icon.Tone" aria-hidden="true" focusable="false"><path d="@icon.IconPath" /></svg><span>@command.Label @if (command.Controller == "FeatureRequests" && Model.FeatureRequestAttentionCount > 0) { <span class="badge text-bg-warning">@Model.FeatureRequestAttentionCount</span> }</span>
</a>
}
}
</div>
<span class="pd-ribbon-group-label">@group.Label</span>
</div>
}
@if (category.Key == selectedCategory)
{
<div class="pd-page-context" data-pwa-context-host hidden aria-label="Current page commands">
<div class="pd-page-context-controls" data-pwa-context-controls></div>
</div>
}
</div>
}
</div>
<template data-pwa-icon-catalog>
@foreach (var iconCommand in RibbonPresentation.Icons)
{
<svg viewBox="0 0 24 24" class="pd-icon" data-icon-key="@iconCommand.Key" data-tone="@iconCommand.Tone" aria-hidden="true" focusable="false"><path d="@iconCommand.IconPath" /></svg>
}
</template>
<form hidden data-appearance-form data-theme-url="@Url.Action("Theme", "Appearance")" data-ribbon-url="@Url.Action("Ribbon", "Appearance")">@Html.AntiForgeryToken()</form>
</section>
<div class="modal fade" id="pwaInstallationHelp" tabindex="-1" aria-labelledby="pwaInstallationTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title fs-5" id="pwaInstallationTitle">Install PlotDirector</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>Open PlotDirector in its own application window using your browser’s installation menu.</p>
<p><strong>Google Chrome:</strong> open the ⋮ menu, then <strong>Cast, save, and share → Install page as app…</strong></p>
<p><strong>Microsoft Edge:</strong> open the … menu, then <strong>More tools → Apps → Install this site as an app</strong>.</p>
<p>The address-bar install icon may also appear. When your browser offers installation directly, the account menu will show <strong>Install PlotDirector…</strong>.</p>
<p class="small text-muted mb-0">If installation is unavailable, check whether PlotDirector is already installed in this browser. Private browsing or your organisation’s browser settings may limit installation. PlotDirector requires an internet connection.</p>
</div>
<div class="modal-footer"><button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button></div>
</div>
</div>
</div>