Adds book details and editing with cover uploads across the stack

This commit is contained in:
BinaryAlley committed 2026-09-06 09:37:23 -07:00
1 parent c2715dea2e
commit 1bfa07ba5d
103 files changed
+8782 -387

No files matched your search

@@ -7,7 +7,7 @@
@using Microsoft.AspNetCore.Mvc.Localization
@{
// generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler
// Generate a unique id for the scripts section of this view, so it can be dynamically loaded/unloaded by the global AJAX navigator handler.
var scriptId = ScriptIdentifierHelper.GenerateScriptId();
}
@@ -16,8 +16,8 @@
<div class="cotton-candy">
<div style="display: grid; grid-template-rows: auto 1fr;">
<!--container with two rows, one fixed, one filling remaining space-->
<div style="min-height: 1rem;"></div><!--the first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position-->
<!-- Container with two rows, one fixed, one filling remaining space. -->
<div style="min-height: 1rem;"></div><!-- The first row is a dummy row for "margin", because setting a margin on the next row would offset the parent's position. -->
<div id="libraries-container" class="cards-container justify-start pl-10 pr-10 w-100 h-100">
<p id="no-libraries" class="hidden">@_localizer["NoLibraries"]</p>
</div>
@@ -26,10 +26,11 @@
@section Scripts {
<!-- The "text/plain" type is a design choice, not a mistake: it keeps the browser from executing this view script during HTML parsing, before site.js defines the API helpers it calls (callApiGetAsync, callApiPostAsync, ...). site.js (which loads deferred) executes these scripts once it is loaded, both on the initial page load and during AJAX navigation. -->
<script type="text/plain" data-form="@scriptId">
// create cleanup registry for this view
// Create cleanup registry for this view.
const cleanupFunctions = [];
let isInitialized = false;
// The element references are captured once, so that the cleanup can unbind their listeners even after the AJAX navigator has swapped the content out of the document.
const librariesContainer = document.getElementById('libraries-container');
const noLibrariesMessage = document.getElementById('no-libraries');
@@ -37,15 +38,15 @@
if (isInitialized)
return;
isInitialized = true;
// get the media libraries
// TODO: add setting check whether the user desires this feature or not
// Get the media libraries.
// TODO: add setting check whether the user desires this feature or not.
const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_ENABLED_LIBRARIES)');
if (data && data.length > 0) {
noLibrariesMessage.classList.replace('block', 'hidden');
librariesContainer.classList.replace('justify-center', 'justify-start');
// populate media library items
// Populate media library items.
data.forEach((library) => {
// book libraries are browsable, so their panel is rendered as a link to their browse page
// Book libraries are browsable, so their panel is rendered as a link to their browse page.
const isBrowsable = library.libraryType === 'Book';
const browseUrl = isBrowsable
? '@_urlService.GetAbsoluteUrl(WebRoutes.Books.INDEX)' + '?libraryId=' + library.id
@@ -56,7 +57,7 @@
if (browseUrl)
libraryElement.href = browseUrl;
// the cover image is optional, so it is only rendered when the library has one
// The cover image is optional, so it is only rendered when the library has one.
const coverImageHtml = library.coverImage
? `<img src="${globalConfiguration.serverBasePath}/media/libraries/${library.id}/${library.coverImage.substring(library.coverImage.lastIndexOf('cover.'))}" />`
: '';
@@ -68,7 +69,7 @@
librariesContainer.appendChild(libraryElement);
});
// bind the AJAX navigation behavior to the library links, which were created after the initial navigation binding
// Bind the AJAX navigation behavior to the library links, which were created after the initial navigation binding.
bindNavigationLinks();
} else {
noLibrariesMessage.classList.replace('hidden', 'block');
@@ -76,15 +77,15 @@
}
}
// add listeners
// Add listeners.
document.addEventListener('DOMContentLoaded', InitializeAsync);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
document.removeEventListener('DOMContentLoaded', InitializeAsync);
});
// store all cleanups for this view on window object using the scriptId
// Store all cleanups for this view on window object using the scriptId.
window.viewCleanups = window.viewCleanups || {};
window.viewCleanups['@scriptId'] = () => {
cleanupFunctions.forEach(cleanup => cleanup());