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

@@ -11,7 +11,7 @@
var roles = ViewData["roles"] as RoleDto[];
var users = ViewData["users"] as UserDto[];
var permissions = ViewData["permissions"] as PermissionDto[];
// 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();
}
@@ -24,7 +24,7 @@
<div id="authorization-permissions-container">
<input type="hidden" name="authorization-users-selected-id" id="authorization-users-selected-id" value="" />
<input type="hidden" name="authorization-roles-selected-id" id="authorization-roles-selected-id" value="" />
<!-- Users dropdown row -->
<!-- Users dropdown row. -->
<div class="h-30px w-100 text-end mb-5">
<label for="authorization-users-combobox" class="text-light-one">@_localizer["Users"]</label>
@@ -48,7 +48,7 @@
</div>
</div>
<!-- Roles dropdown row -->
<!-- Roles dropdown row. -->
<div class="h-30px w-100 text-end mb-5">
<label for="authorization-roles-combobox" class="text-light-one">@_localizer["Roles"]</label>
@@ -72,7 +72,7 @@
</div>
</div>
<!-- Permissions row -->
<!-- Permissions row. -->
<div id="authorization-permissions-permissions-container" class="">
<div id="authorization-permissions-permissions">
<div id="authorization-permissions-permissions-scroll" class="scroll-horizontal">
@@ -95,7 +95,7 @@
</div>
</div>
<!-- Submit Button Row -->
<!-- Submit Button Row. -->
<div class="w-100 h-25px mt-5 text-end">
<button id="btn-update-user" type="submit" class="confirm-button f-14 h-24px v-align-t" disabled>@_localizer["Update"]</button>
</div>
@@ -105,9 +105,10 @@
@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 = [];
// 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 btnUpdateUser = document.getElementById('btn-update-user');
const form = document.getElementById('authorization-permissions-form');
const rolesDropdown = document.getElementById('authorization-roles-combobox-dropdown');
@@ -115,7 +116,7 @@
const roleIdInput = document.getElementById('authorization-roles-selected-id');
const userIdInput = document.getElementById('authorization-users-selected-id');
// update user permissions and role
// Update user permissions and role.
async function handleUserAuthorizationSubmitAsync() {
const formData = {
userId: userIdInput.value,
@@ -131,7 +132,7 @@
async function fetchUserRoleAsync(userId) {
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.Admin.GET_ROLE_BY_USER_ID, new { userId = default(Guid) })';
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${userId}`)); // userId needs to be replaced here, because GetAbsoluteUrl is server side, userId is client side
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${userId}`)); // userId needs to be replaced here, because GetAbsoluteUrl is server side, userId is client side.
if (data) {
var roleElement = document.querySelector('#authorization-roles-combobox .enlightenment-option[data-value="' + data.id + '"]');
var roleName = roleElement.textContent;
@@ -143,13 +144,13 @@
async function fetchUserPermissionsAsync(userId) {
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.Admin.GET_PERMISSIONS_BY_USER_ID, new { userId = default(Guid) })';
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${userId}`)); // userId needs to be replaced here, because GetAbsoluteUrl is server side, userId is client side
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${userId}`)); // userId needs to be replaced here, because GetAbsoluteUrl is server side, userId is client side.
if (data) {
// clear all checkboxes
// Clear all checkboxes.
document.querySelectorAll("input[name='authorization-permissions-permissions']")
.forEach(input => input.checked = false);
// check the checkboxes for which permissions are assigned
// Check the checkboxes for which permissions are assigned.
data.forEach(p => {
const checkbox = document.querySelector(`input[name='authorization-permissions-permissions'][value='${p.id}']`);
if (checkbox)
@@ -158,7 +159,7 @@
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -166,15 +167,15 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleUserAuthorizationSubmitAsync();
};
// on document click
// On document click.
const handleDocumentClick = async function(e) {
// users dropdown change
// Users dropdown change.
if (e.target.closest('#authorization-users-combobox .enlightenment-option')) {
var selectedUserId = e.target.dataset.value;
document.querySelector('#authorization-roles-combobox .enlightenment-selected-text').textContent = '@_localizer["SelectARole"]';
@@ -190,26 +191,26 @@
else
btnUpdateUser.disabled = true;
}
// roles dropdown change
// Roles dropdown change.
else if (e.target.closest('#authorization-roles-combobox .enlightenment-option')) {
const roleId = e.target.dataset.value;
roleIdInput.value = roleId || '';
}
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
document.addEventListener('click', handleDocumentClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
document.removeEventListener('click', handleDocumentClick);
});
// when form's height changes, adjust the roles combobox dropdown maximum height accordingly, so it doesn't cause an <article> section overflow
// When form's height changes, adjust the roles combobox dropdown maximum height accordingly, so it doesn't cause an <article> section overflow.
const resizeObserver = new ResizeObserver(entries => {
const formHeight = form.getBoundingClientRect().height;
usersDropdown.style.maxHeight = `calc(${formHeight}px - 50px)`;
@@ -219,12 +220,12 @@
});
resizeObserver.observe(form);
// register cleanup for observer
// Register cleanup for observer.
cleanupFunctions.push(() => {
resizeObserver.disconnect();
});
// 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());
@@ -9,7 +9,7 @@
@{
var roles = ViewData["roles"] as RoleDto[];
var permissions = ViewData["permissions"] as PermissionDto[];
// 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();
}
@@ -21,7 +21,7 @@
<form id="authorization-roles-form" method="post" class="w-100 h-100 mx-auto pl-10 pr-10 pt-10 pb-10">
<div id="authorization-roles-container">
<input type="hidden" name="authorization-roles-selected-id" id="authorization-roles-selected-id" value="" />
<!-- Roles dropdown row -->
<!-- Roles dropdown row. -->
<div class="h-30px w-100 text-end mb-5">
<label for="authorization-roles-combobox" class="text-light-one">@_localizer["Roles"]</label>
@@ -45,13 +45,13 @@
</div>
</div>
<!-- Role name input row -->
<!-- Role name input row. -->
<div class="h-30px w-100 text-end mb-5">
<label for="txt-role-name" class="text-light-one">@_localizer["RoleName"]</label>
<input type="text" id="txt-role-name" name="authorization-role-name" class="enlightenment-input w-250px" />
</div>
<!-- Permissions row -->
<!-- Permissions row. -->
<div id="authorization-roles-permissions-container" class="">
<div id="authorization-roles-permissions">
<div id="authorization-roles-permissions-scroll" class="scroll-horizontal">
@@ -74,7 +74,7 @@
</div>
</div>
<!-- Submit Button Row -->
<!-- Submit Button Row. -->
<div class="w-100 h-25px mt-5 text-end">
<button id="btn-delete-role" type="button" class="abort-button f-14 h-24px v-align-t hidden">@_localizer["DeleteRole"]</button>
<button id="btn-confirm-role" type="submit" class="confirm-button f-14 h-24px v-align-t">@_localizer["CreateRole"]</button>
@@ -85,9 +85,10 @@
@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 = [];
// 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 btnDeleteRole = document.getElementById('btn-delete-role');
const btnConfirmRole = document.getElementById('btn-confirm-role');
const txtRoleName = document.getElementById('txt-role-name');
@@ -95,7 +96,7 @@
const dropdown = document.getElementById('authorization-roles-combobox-dropdown');
const roleIdInput = document.getElementById('authorization-roles-selected-id');
// create new or update existing role
// Create new or update existing role.
async function handleRoleSubmitAsync() {
const formData = {
roleId: roleIdInput.value,
@@ -118,14 +119,14 @@
async function fetchRolesAsync() {
const data = await callApiGetAsync('@_urlService.GetAbsoluteUrl(WebRoutes.Admin.GET_ROLES)');
if (data) {
// clear the roles drop down list
// Clear the roles drop down list.
const rolesDropdown = document.querySelector("#authorization-roles-combobox .enlightenment-dropdown");
rolesDropdown.innerHTML = `
<div class="shine-effect" style="top: -4px;"></div>
<div class="enlightenment-option first-option disabled">'@_localizer["SelectARole"]'</div>
`;
// populate the roles drop down
// Populate the roles drop down.
data.forEach((role, index) => {
const option = document.createElement('div');
option.className = `enlightenment-option ${index === data.length - 1 ? 'last-option' : ''}`;
@@ -134,21 +135,21 @@
rolesDropdown.appendChild(option);
});
// update the text of the toggle button of the combobox
// Update the text of the toggle button of the combobox.
document.querySelector('.enlightenment-selected-text').textContent = '@_localizer["SelectARole"]';
// all permissions should be "unchecked"
// All permissions should be "unchecked".
document.querySelectorAll("input[name='authorization-role-permissions']")
.forEach(input => input.checked = false);
// the delete button should be hidden
// The delete button should be hidden.
btnDeleteRole.classList.remove('inline');
btnDeleteRole.classList.add('hidden');
// the "update" button should be "create"
// The "update" button should be "create".
btnConfirmRole.textContent = '@_localizer["CreateRole"]';
// the input for the role name should also have its text emptied
// The input for the role name should also have its text emptied.
txtRoleName.value = '';
}
}
@@ -156,13 +157,13 @@
async function fetchRolePermissionsAsync(roleId) {
if (roleId) {
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.Admin.GET_PERMISSIONS_BY_ROLE_ID, new { roleId = default(Guid) })';
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${roleId}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side
const data = await callApiGetAsync(url.replace('/@(default(Guid))', `/${roleId}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side.
if (data) {
// clear all checkboxes
// Clear all checkboxes.
document.querySelectorAll("input[name='authorization-role-permissions']")
.forEach(input => input.checked = false);
// check the checkboxes for which permissions are assigned
// Check the checkboxes for which permissions are assigned.
data.permissions.forEach(p => {
const checkbox = document.querySelector(
`input[name='authorization-role-permissions'][value='${p.id}']`
@@ -171,13 +172,13 @@
});
}
} else {
// if no role is selected, clear checkboxes
// If no role is selected, clear checkboxes.
document.querySelectorAll("input[name='authorization-role-permissions']")
.forEach(input => input.checked = false);
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -185,18 +186,18 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleRoleSubmitAsync();
};
// on delete role button click
// On delete role button click.
const handleBtnDeleteRoleClick = async function(e) {
// ask the user for confirmation before deleting the role
// Ask the user for confirmation before deleting the role.
if (await dialogService.show('@_localizer["DeleteRoleConfirm"]', jsLocalizedDialogs.confirmation, DialogButtons.YES_NO, DialogIcon.QUESTION) === DialogButton.YES) {
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.Admin.DELETE_ROLE, new { roleId = default(Guid) })';
const success = await callApiDeleteAsync(url.replace('/@(default(Guid))', `/${roleIdInput.value}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side
const success = await callApiDeleteAsync(url.replace('/@(default(Guid))', `/${roleIdInput.value}`)); // roleId needs to be replaced here, because GetAbsoluteUrl is server side, roleId is client side.
if (success) {
await fetchRolesAsync();
notificationService.show('@_localizer["RoleDeleted"]', NotificationType.SUCCESS);
@@ -204,9 +205,9 @@
}
};
// on document click
// On document click.
const handleDocumentClick = async function(e) {
// roles dropdown change
// Roles dropdown change.
if (e.target.closest('#authorization-roles-combobox .enlightenment-option')) {
const roleId = e.target.dataset.value;
const selectedText = e.target.textContent;
@@ -228,13 +229,13 @@
}
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
btnDeleteRole.addEventListener('click', handleBtnDeleteRoleClick);
document.addEventListener('click', handleDocumentClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
@@ -242,7 +243,7 @@
document.removeEventListener('click', handleDocumentClick);
});
// when form's height changes, adjust the roles combobox dropdown maximum height accordingly, so it doesn't cause an <article> section overflow
// When form's height changes, adjust the roles combobox dropdown maximum height accordingly, so it doesn't cause an <article> section overflow.
const resizeObserver = new ResizeObserver(entries => {
const formHeight = form.getBoundingClientRect().height;
dropdown.style.maxHeight = `calc(${formHeight}px - 50px)`;
@@ -250,12 +251,12 @@
});
resizeObserver.observe(form);
// register cleanup for observer
// Register cleanup for observer.
cleanupFunctions.push(() => {
resizeObserver.disconnect();
});
// 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());
@@ -11,7 +11,7 @@
@{
var settingsByPluginId = ViewData["pluginSettings"] as Dictionary<Guid, PluginSettingsDto> ?? new Dictionary<Guid, PluginSettingsDto>();
// 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();
}
@@ -20,8 +20,8 @@
@Html.AntiForgeryToken()
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect mx-auto panel w-75 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<div class="form-row">
@@ -150,10 +150,10 @@
@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 = [];
// on settings toggle button click, show/hide the settings row of the plugin
// On settings toggle button click, show/hide the settings row of the plugin.
const handleSettingsToggleClick = function(e) {
if (e.target.matches('.btn-plugin-settings-toggle')) {
const row = e.target.closest('tr');
@@ -164,7 +164,7 @@
}
};
// on save plugin settings button click, collect the settings of the panel and send them to the API
// On save plugin settings button click, collect the settings of the panel and send them to the API.
const handleSavePluginSettingsClick = async function(e) {
if (e.target.matches('.btn-save-plugin-settings')) {
const panel = e.target.closest('.plugin-settings-panel');
@@ -186,11 +186,12 @@
}
};
// 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 uploadButton = document.getElementById('btn-upload-plugin');
const uploadInput = document.getElementById('plugin-upload-input');
const installUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Plugins.INSTALL_PLUGIN)';
// uploads the selected plugin archive as a multipart request, keeping the antiforgery token
// Uploads the selected plugin archive as a multipart request, keeping the antiforgery token.
async function handleUploadInputChange() {
const file = uploadInput.files[0];
if (!file)
@@ -211,18 +212,18 @@
}
}
// opens the file picker when the upload button is clicked
// Opens the file picker when the upload button is clicked.
function handleUploadButtonClick() {
uploadInput.click();
}
// add listeners
// Add listeners.
document.addEventListener('click', handleSettingsToggleClick);
document.addEventListener('click', handleSavePluginSettingsClick);
uploadButton.addEventListener('click', handleUploadButtonClick);
uploadInput.addEventListener('change', handleUploadInputChange);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
document.removeEventListener('click', handleSettingsToggleClick);
document.removeEventListener('click', handleSavePluginSettingsClick);
@@ -230,7 +231,7 @@
uploadInput.removeEventListener('change', handleUploadInputChange);
});
// 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());
@@ -198,6 +198,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
CleanScheduledJobExecutionHistory: '#ba68c8'
};
// 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 jobsTable = document.getElementById('scheduler-jobs-table');
const jobsTableBody = jobsTable.querySelector('tbody');
const legend = document.getElementById('scheduler-legend');
@@ -236,8 +237,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
return selected ? (selected.getAttribute('data-value') || '') : '';
}
// Binds the change of a themed combobox to a callback, so the page reacts to a selection the same way it did to
// the change event of a native select.
// Binds the change of a themed combobox to a callback, so the page reacts to a selection the same way it did to the change event of a native select.
function bindComboboxChange(combobox, onChange) {
const handler = event => {
const option = event.target.closest('.enlightenment-option');
@@ -313,7 +313,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
let isInitialized = false;
//+----------------------------------------------------------------------------------------+
// | Rendering |.
//| Rendering |
//+----------------------------------------------------------------------------------------+
// The API stores the execution and job timestamps in UTC, but the persistence medium (SQLite) stores them as
@@ -434,13 +434,12 @@ It keeps the DOM contract the client script binds to, without any images or colo
}
//+----------------------------------------------------------------------------------------+
// | Graph |.
//| Graph |
//+----------------------------------------------------------------------------------------+
function resizeGraph() {
// The graph fills the width of its container next to the legend, and its height follows the legend,
// with a sensible floor; the height must not be derived from the canvas element box, because the flex
// layout stretches the canvas and its replaced-element aspect ratio would blow the box up.
// The graph fills the width of its container next to the legend, and its height follows the legend, with a sensible floor; the height must not be derived
from the canvas element box, because the flex layout stretches the canvas and its replaced-element aspect ratio would blow the box up.
const container = graphCanvas.parentElement;
if (!container || container.clientWidth <= 0)
return;
@@ -613,7 +612,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
}
//+----------------------------------------------------------------------------------------+
// | Data loading |.
//| Data loading |
//+----------------------------------------------------------------------------------------+
async function loadJobsAsync() {
@@ -649,7 +648,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
}
//+----------------------------------------------------------------------------------------+
// | Job actions |.
//| Job actions |
//+----------------------------------------------------------------------------------------+
async function executeJobActionAsync(url, successMessage) {
@@ -707,7 +706,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
}
//+----------------------------------------------------------------------------------------+
// | SignalR |.
//| SignalR |
//+----------------------------------------------------------------------------------------+
async function getAccessTokenAsync() {
@@ -744,7 +743,7 @@ It keeps the DOM contract the client script binds to, without any images or colo
}
//+----------------------------------------------------------------------------------------+
// | Initialization |.
//| Initialization |
//+----------------------------------------------------------------------------------------+
async function initialize() {
@@ -10,7 +10,7 @@
@{
var themes = ViewData["themes"] as IReadOnlyList<ThemeInfoDto>;
var currentThemeId = ViewData["currentThemeId"] as string;
// 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();
int bundledThemeCount = 0;
if (themes is not null)
@@ -147,25 +147,26 @@
@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 uploadButton = document.getElementById('btn-upload-theme');
const uploadInput = document.getElementById('theme-upload-input');
const installUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Themes.INSTALL_THEME)';
// reloads the page after a theme mutation, so the new theme state and the themed shell are re-rendered
// Reloads the page after a theme mutation, so the new theme state and the themed shell are re-rendered.
function reloadPage() {
window.location.reload();
}
// refreshes the current page content without reloading the page, so the media player keeps playing
// Refreshes the current page content without reloading the page, so the media player keeps playing.
function refreshPageContent() {
updateContentAsync(window.location.href, false);
}
// activates the theme of the clicked row
// Activates the theme of the clicked row.
async function handleActivateClick(event) {
const button = event.target.closest('.activate-theme-button');
if (!button)
@@ -174,7 +175,7 @@
reloadPage();
}
// deletes the theme of the clicked row after confirmation
// Deletes the theme of the clicked row after confirmation.
async function handleDeleteClick(event) {
const button = event.target.closest('.delete-theme-button');
if (!button)
@@ -185,31 +186,31 @@
}
}
// restores the soft deleted bundled theme of the clicked row
// Restores the soft deleted bundled theme of the clicked row.
async function handleRestoreClick(event) {
const button = event.target.closest('.restore-theme-button');
if (!button)
return;
// an empty JSON body is sent so the antiforgery-protected POST request binds the route theme id without a JsonException
// An empty JSON body is sent so the antiforgery-protected POST request binds the route theme id without a JsonException.
await callApiPostAsync(button.dataset.url, {});
refreshPageContent();
}
// downloads the archive of the theme of the clicked row
// Downloads the archive of the theme of the clicked row.
function handleDownloadClick(event) {
const button = event.target.closest('.download-theme-button');
if (button)
window.location.href = button.dataset.url;
}
// opens the image viewer with the preview of the clicked theme
// Opens the image viewer with the preview of the clicked theme.
function handlePreviewClick(event) {
const button = event.target.closest('.theme-preview-button');
if (button)
imageViewer.open([{ src: button.dataset.previewUrl, title: button.dataset.previewTitle }]);
}
// falls back to the placeholder image when the preview of a theme is missing or fails to load
// Falls back to the placeholder image when the preview of a theme is missing or fails to load.
function attachPreviewErrorFallbacks() {
const placeholderUrl = '@Url.Content("~/admin/theme-placeholder.svg")';
document.querySelectorAll('.theme-preview-thumb').forEach(img => {
@@ -221,7 +222,7 @@
}
attachPreviewErrorFallbacks();
// uploads the selected theme archive as a multipart request, keeping the antiforgery token
// Uploads the selected theme archive as a multipart request, keeping the antiforgery token.
async function handleUploadInputChange() {
const file = uploadInput.files[0];
if (!file)
@@ -240,12 +241,12 @@
notificationService.show('@_localizer["UploadFailed"]', NotificationType.ERROR);
}
// opens the file picker when the upload button is clicked
// Opens the file picker when the upload button is clicked.
function handleUploadButtonClick() {
uploadInput.click();
}
// add listeners
// Add listeners.
uploadButton.addEventListener('click', handleUploadButtonClick);
uploadInput.addEventListener('change', handleUploadInputChange);
document.addEventListener('click', handleActivateClick);
@@ -254,7 +255,7 @@
document.addEventListener('click', handleRestoreClick);
document.addEventListener('click', handlePreviewClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
uploadButton.removeEventListener('click', handleUploadButtonClick);
uploadInput.removeEventListener('change', handleUploadInputChange);
@@ -265,7 +266,7 @@
document.removeEventListener('click', handlePreviewClick);
});
// 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());
@@ -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,15 +16,15 @@
@model ChangePasswordRequest
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-55 mb-10" style="min-width: 320px; margin-top: 1rem;">
<div class="shine-effect"></div>
<form method="post" id="change-password-form" class="inline">
@Html.AntiForgeryToken()
<input type="text" name="username" autocomplete="username" value="@User.Identity!.Name" hidden />
<div class="form-container">
<!-- Current Password -->
<!-- Current Password. -->
<div class="form-row" id="div-current-password">
<div class="form-label">
<label asp-for="CurrentPassword">@_localizer["CurrentPassword"]</label>
@@ -35,7 +35,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionCurrentPassword"]</small>
</div>
<!-- New Password -->
<!-- New Password. -->
<div class="form-row" id="div-new-password">
<div class="form-label">
<label asp-for="NewPassword">@_localizer["NewPassword"]</label>
@@ -46,7 +46,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionNewPassword"]</small>
</div>
<!-- New Password Confirm-->
<!-- New Password Confirm. -->
<div class="form-row" id="div-new-password-confirm">
<div class="form-label">
<label asp-for="NewPasswordConfirm">@_localizer["NewPasswordConfirm"]</label>
@@ -62,7 +62,7 @@
</div>
</div>
</form>
<!-- section registration success -->
<!-- Section registration success. -->
<div class="text-center w-100">
<p id="change-password-success" class="text-light-one w-100 hidden">@_localizer["PasswordChanged"]</p>
</div>
@@ -71,9 +71,10 @@
@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 = [];
// 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 form = document.getElementById('change-password-form');
const txtCurrentPassword = form.querySelector('[name="CurrentPassword"]');
const txtNewPassword = form.querySelector('[name="NewPassword"]');
@@ -85,7 +86,7 @@
const divNewPasswordConfirm = document.getElementById('div-new-password-confirm');
const divChangePasswordSubmit = document.getElementById('div-change-password-submit');
// perform the password change
// Perform the password change.
async function handleChangePasswordAsync() {
const formData = {
CurrentPassword: txtCurrentPassword.value,
@@ -102,7 +103,7 @@
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -110,23 +111,23 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleChangePasswordAsync();
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
});
// 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());
@@ -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,15 +16,15 @@
@model LoginRequest
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-50 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<form method="post" id="login-form" class="inline">
@Html.AntiForgeryToken()
<input type="hidden" name="ReturnUrl" value="@ViewData["ReturnUrl"]" />
<div class="form-container">
<!-- Username -->
<!-- Username. -->
<div class="form-row">
<div class="form-label">
<label asp-for="Username">@_localizer["Username"]</label>:
@@ -33,7 +33,7 @@
<input asp-for="Username" autocomplete="username" class="enlightenment-input" />
</div>
</div>
<!-- Password -->
<!-- Password. -->
<div class="form-row">
<div class="form-label">
<label asp-for="Password">@_localizer["Password"]</label>:
@@ -46,7 +46,7 @@
<button id="btn-recover-password" type="button" class="abort-button h-22px">@_localizer["RecoverPassword"]</button>
<button id="btn-login" type="submit" class="confirm-button h-22px">@_localizer["LoginKey"]</button>
</div>
<!-- 2FA -->
<!-- 2FA. -->
<div class="form-row mt-10 hidden" id="div-totp-code">
<div class="form-label">
<label asp-for="TotpCode">@_localizer["TotpCode"]</label>
@@ -65,9 +65,10 @@
@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 = [];
// 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 form = document.getElementById('login-form');
const returnUrlInput = form.querySelector('[name="ReturnUrl"]');
const txtUsername = form.querySelector('[name="Username"]');
@@ -78,7 +79,7 @@
const btnRecoverPassword = document.getElementById('btn-recover-password');
const btnValidateTotp = document.getElementById('btn-validate-totp');
// perform the authentication
// Perform the authentication.
async function handleLoginAsync() {
const formData = {
Username: txtUsername.value,
@@ -100,7 +101,7 @@
window.location.href = data;
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -108,30 +109,30 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleLoginAsync();
};
// on recover password button click
// On recover password button click.
const handleBtnRecoverPasswordClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.Authentication.RECOVER_PASSWORD_VIEW)';
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
btnRecoverPassword.addEventListener('click', handleBtnRecoverPasswordClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
btnRecoverPassword.removeEventListener('click', handleBtnRecoverPasswordClick);
});
// 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());
@@ -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,14 +16,14 @@
@model RecoverPasswordRequest
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-50 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<form method="post" id="recover-password-form" class="inline">
@Html.AntiForgeryToken()
<div class="form-container">
<!-- Username -->
<!-- Username. -->
<div class="form-row" id="div-username">
<div class="form-label">
<label asp-for="Username">@_localizer["Username"]</label>
@@ -33,7 +33,7 @@
<input asp-for="Username" autocomplete="username" class="enlightenment-input" />
</div>
</div>
<!-- 2FA -->
<!-- 2FA. -->
<div class="form-row" id="div-totp-code">
<div class="form-label">
<label asp-for="TotpCode">@_localizer["TotpCode"]</label>
@@ -49,7 +49,7 @@
</div>
</div>
</form>
<!-- section registration success -->
<!-- Section registration success. -->
<div class="text-center w-100">
<p id="recover-password-success" class="text-light-one w-100 hidden">@_localizer["PasswordTemporarilyReset"]</p>
<button id="btn-redirect-login" type="submit" class="confirm-button h-22px hidden">@_localizer["Login"]</button>
@@ -59,9 +59,10 @@
@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 = [];
// 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 form = document.getElementById('recover-password-form');
const txtUsername = form.querySelector('[name="Username"]');
const txtTotpCode = form.querySelector('[name="TotpCode"]');
@@ -72,7 +73,7 @@
const divUsername = document.getElementById('div-username');
const divTotpCode = document.getElementById('div-totp-code');
// perform the password recovery
// Perform the password recovery.
async function handleRecoverPasswordAsync() {
const formData = {
Username: txtUsername.value,
@@ -89,7 +90,7 @@
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -97,29 +98,29 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleRecoverPasswordAsync();
};
// on login button click
// On login button click.
const handleBtnLoginClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.Authentication.LOGIN_VIEW)';
};
// on login redirect button click
// On login redirect button click.
const handleBtnRedirectLoginClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.Authentication.LOGIN_VIEW)';
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
btnLogin.addEventListener('click', handleBtnLoginClick);
btnRedirectLogin.addEventListener('click', handleBtnRedirectLoginClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
@@ -127,7 +128,7 @@
btnRedirectLogin.removeEventListener('click', handleBtnRedirectLoginClick);
});
// 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());
@@ -8,7 +8,7 @@
@{
string? registrationType = ViewData["RegistrationType"] as string;
// 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();
}
@@ -17,13 +17,13 @@
@model RegisterRequest
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect p-2 mx-auto panel w-50 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<form method="post" id="register-account-form" class="inline">
@Html.AntiForgeryToken()
<!-- section for determining registration type (regular user/admin) -->
<!-- Section for determining registration type (regular user/admin). -->
<input type="hidden" name="RegistrationType" value="@registrationType" />
<div class="form-container">
@if (registrationType == "Admin")
@@ -32,7 +32,7 @@
<p class="invalid-feedback w-95 text-center f-18">@_localizer["AdminAccountRegistration"]</p>
</div>
}
<!-- Username -->
<!-- Username. -->
<div class="form-row">
<div class="form-label">
<label asp-for="Username">@_localizer["Username"]</label>
@@ -43,7 +43,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionUsername"]</small>
</div>
<!-- Password -->
<!-- Password. -->
<div class="form-row">
<div class="form-label">
<label asp-for="Password">@_localizer["Password"]</label>
@@ -54,7 +54,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionPassword"]</small>
</div>
<!-- Password Confirm-->
<!-- Password Confirm. -->
<div class="form-row">
<div class="form-label">
<label asp-for="PasswordConfirm">@_localizer["PasswordConfirm"]</label>
@@ -65,7 +65,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionPasswordConfirm"]</small>
</div>
<!-- 2FA -->
<!-- 2FA. -->
<input type="hidden" id="hidden-use-two-fa" name="use2fa" value="true">
<div class="form-row">
<div class="form-field">
@@ -85,7 +85,7 @@
</div>
</div>
</form>
<!-- section registration success -->
<!-- Section registration success. -->
<div class="text-center w-100">
<p id="register-success" class="text-light-one w-100 hidden">@_localizer["AccountCreated"]</p>
<img id="totp-image" class="w-200px h-200px h-align-m mx-auto mt-10 hidden" />
@@ -100,9 +100,10 @@
@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 = [];
// 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 form = document.getElementById('register-account-form');
const txtUsername = form.querySelector('[name="Username"]');
const txtPassword = form.querySelector('[name="Password"]');
@@ -115,7 +116,7 @@
const spnTwoFaAttention = document.getElementById('register-two-fa-attention');
const useTwoFaInput = document.getElementById('hidden-use-two-fa');
// perform the account registration
// Perform the account registration.
async function handleRegisterAccountAsync() {
const formData = {
Username: txtUsername.value,
@@ -144,7 +145,7 @@
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -152,13 +153,13 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleRegisterAccountAsync();
};
// on use 2FA change event
// On use 2FA change event.
const handleChkUse2FAChange = function() {
const isChecked = this.checked;
spnTwoFaAttention.classList.replace(
@@ -168,18 +169,18 @@
useTwoFaInput.value = isChecked.toString();
};
// on login button click
// On login button click.
const handleBtnLoginClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.Authentication.LOGIN_VIEW)';
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
chkUse2FA.addEventListener('click', handleChkUse2FAChange);
btnLogin.addEventListener('click', handleBtnLoginClick);
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
@@ -187,7 +188,7 @@
btnLogin.removeEventListener('click', handleBtnLoginClick);
});
// 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());
@@ -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());
@@ -18,7 +18,7 @@
@Html.AntiForgeryToken()
<style>
/* main container */
/* Main container. */
.td-scan {
display: flex;
align-items: center;
@@ -27,14 +27,14 @@
min-height: 50px;
}
/* text label */
/* Text label. */
.scan-job-status {
flex: 1;
padding: 0 10px;
min-width: 0;
}
/* progress bar container */
/* Progress bar container. */
.scan-progress {
flex: 0 0 80px;
height: 20px;
@@ -44,7 +44,7 @@
gap: 2px;
}
/* progress bars */
/* Progress bars. */
.scan-progress-total,
.scan-progress-job {
height: 50%;
@@ -75,28 +75,28 @@
}
.icon-groups {
flex: 0 0 auto; /* prevent shrinking */
flex: 0 0 auto; /* Prevent shrinking. */
display: flex;
gap: 10px;
margin-left: auto; /* push to right */
margin-left: auto; /* Push to right. */
}
/* status icons subgroup */
/* Status icons subgroup. */
.status-icons {
display: flex;
gap: 5px;
flex-shrink: 0;
}
/* action icons subgroup */
/* Action icons subgroup. */
.action-icons {
display: flex;
gap: 5px;
flex-shrink: 0;
}
/* icon groups */
/* status icons (right margin group) */
/* Icon groups. */
/* Status icons (right margin group). */
img[src*="green.png"],
img[src*="red.png"],
img[src*="yellow.png"] {
@@ -104,7 +104,7 @@
height: 20px;
}
/* action icons (fixed size group) */
/* Action icons (fixed size group). */
img[src*="stop.svg"],
img[src*="trigger.svg"],
img[src*="delete.svg"],
@@ -129,8 +129,8 @@
}
</style>
<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-->
<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. -->
<div class="enlightenment-panel shadow-effect mx-auto panel w-75 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<div class="form-row">
@@ -149,7 +149,7 @@
</tr>
</thead>
<tbody>
<!-- libraries will be populated here -->
<!-- Libraries will be populated here. -->
</tbody>
</table>
<div class="form-row pt-10">
@@ -214,6 +214,7 @@
PhotoAlbum: '@_localizer["PhotoAlbum"]',
Other: '@_localizer["Other"]'
};
// 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 btnScanAllLibraries = document.getElementById('btn-scan-all-libraries');
const btnCancelLibrariesScan = document.getElementById('btn-cancel-libraries-scan');
@@ -280,7 +281,7 @@
</tr>
`;
}).join('');
bindNavigationLinks(); // bind the dynamically created edit links, so that editing keeps the persistent chrome running
bindNavigationLinks(); // Bind the dynamically created edit links, so that editing keeps the persistent chrome running.
} else {
btnScanAllLibraries.style.display = 'none';
table.style.display = 'none';
@@ -333,7 +334,7 @@
const success = await callApiDeleteAsync(url.replace('/@(default(Guid))', `/${libraryId}`));
if (success) {
await loadLibrariesAsync(); // reload the entire library list
await loadLibrariesAsync(); // Reload the entire library list.
notificationService.show('@_localizer["LibraryDeleted"]', NotificationType.SUCCESS);
}
}
@@ -271,9 +271,10 @@
@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 = [];
// 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 saveSuccess = document.getElementById('save-success');
const btnBackToLibraries = document.getElementById('btn-back-to-libraries');
const btnAddNewLibrary = document.getElementById('btn-add-new-library');
@@ -288,7 +289,7 @@
const chkShouldSaveMetadataInMediaDirectories = form.querySelector('[name="ShouldSaveMetadataInMediaDirectories"]');
const chkShouldSkipUnchangedDirectoriesDuringScan = form.querySelector('[name="ShouldSkipUnchangedDirectoriesDuringScan"]');
// create new or update existing media library
// Create new or update existing media library.
async function handleAddMediaLibraryAsync() {
const formData = {
Id: form.querySelector('[name="Id"]').value || null,
@@ -298,9 +299,9 @@
ContentLocations: Array.from(mediaDirectoriesFormTable.querySelectorAll('.form-table-row span'))
.map(span => span.textContent),
CoverImage: (() => {
// get the first (and only) span in the mediaCoverFormTable, if it exists
// Get the first (and only) span in the mediaCoverFormTable, if it exists.
const coverSpan = mediaCoverFormTable.querySelector('.form-table-row span');
return coverSpan ? coverSpan.textContent : null; // return null if no cover image is selected
return coverSpan ? coverSpan.textContent : null; // Return null if no cover image is selected.
})(),
IsEnabled: chkIsEnabled.checked,
IsLocked: chkIsLocked.checked,
@@ -318,13 +319,13 @@
}
function addMediaLibraryDirectories(selectedPaths) {
// process the selected paths (remove quotes and split by comma)
// Process the selected paths (remove quotes and split by comma).
const paths = selectedPaths.slice(1, -1).split('","');
// add each path as a new row
// Add each path as a new row.
paths.forEach(path => {
// normalize the path for comparison
// Normalize the path for comparison.
const normalizedPath = path.replace(/\\\\/g, '\\');
// use querySelectorAll and compare explicitly, so that duplicates are not permitted
// Use querySelectorAll and compare explicitly, so that duplicates are not permitted.
const existingPaths = Array.from(mediaDirectoriesFormTable.querySelectorAll('span[title]'));
const isDuplicate = existingPaths.some(span => span.getAttribute('title') === normalizedPath);
if (!isDuplicate) {
@@ -339,13 +340,13 @@
}
function addMediaLibraryCoverImage(selectedPaths) {
// process the selected paths
// Process the selected paths.
const paths = selectedPaths.slice(1, -1).split('","');
// ensure only one row is allowed by first clearing all previous rows
// Ensure only one row is allowed by first clearing all previous rows.
mediaCoverFormTable.innerHTML = '';
// add the first valid path (if any) as a new row
// Add the first valid path (if any) as a new row.
if (paths.length > 0) {
const path = paths[0]; // only use the first path
const path = paths[0]; // Only use the first path.
mediaCoverFormTable.insertAdjacentHTML('beforeend', `
<div class="form-table-row">
<span title="${path}">${path}</span>
@@ -355,7 +356,7 @@
}
}
// on Enter key pressed
// On Enter key pressed.
const handleEnterKey = async function(e) {
if (e.key === 'Enter') {
e.preventDefault();
@@ -363,33 +364,33 @@
}
};
// on form submit event
// On form submit event.
const handleSubmit = async function(e) {
e.preventDefault();
await handleAddMediaLibraryAsync();
};
// on back to libraries button click
// On back to libraries button click.
const handleBtnBackToLibrariesClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.INDEX)';
};
// on add new library button click
// On add new library button click.
const handleBtnAddNewLibraryClick = function() {
window.location.href = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.EDIT_LIBRARY)';
};
// on add media directory image click
// On add media directory image click.
const handleImgAddMediaDirectoryClick = async function() {
await showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addMediaLibraryDirectories); // TODO: take path and include hidden elements from settings
await showFileSystemBrowserDialogAsync('C:\\Users\\', true, false, addMediaLibraryDirectories); // TODO: take path and include hidden elements from settings.
};
// on add cover image click
// On add cover image click.
const handleImgAddCoverClick = async function() {
await showFileSystemBrowserDialogAsync('C:\\Users\\', true, true, addMediaLibraryCoverImage); // TODO: take path and include hidden elements from settings
await showFileSystemBrowserDialogAsync('C:\\Users\\', true, true, addMediaLibraryCoverImage); // TODO: take path and include hidden elements from settings.
};
// on remove row icon click
// On remove row icon click.
const handleRowRemoval = (e) => {
if (e.target.matches('.remove-form-table-row-icon'))
e.target.parentElement.remove();
@@ -399,18 +400,18 @@
const metadataProvidersTable = document.getElementById('metadata-providers-table');
const metadataProvidersTbody = metadataProvidersTable ? metadataProvidersTable.querySelector('tbody') : null;
// loads the metadata providers configured for the library, when editing an existing library
// Loads the metadata providers configured for the library, when editing an existing library.
async function loadMetadataProvidersAsync() {
if (!id || !metadataProvidersTbody) return;
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_METADATA_PROVIDERS, new { libraryId = default(Guid) })'
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
const response = await callApiGetAsync(url);
if (response && response.length > 0) {
metadataProvidersTbody.innerHTML = response.map((provider, index) => renderMetadataProviderRow(provider, index, response.length)).join('');
}
}
// renders a metadata provider row of the library
// Renders a metadata provider row of the library.
function renderMetadataProviderRow(provider, index, count) {
return `
<tr data-provider-plugin-id="${provider.pluginId}">
@@ -428,7 +429,7 @@
</tr>`;
}
// on metadata provider move button click, reorders the providers and persists the new order
// On metadata provider move button click, reorders the providers and persists the new order.
async function handleMetadataProviderReorderAsync(e) {
const button = e.target.closest('.metadata-provider-move-up, .metadata-provider-move-down');
if (!button || !metadataProvidersTbody) return;
@@ -443,7 +444,7 @@
await saveMetadataProviderOrderAsync();
}
// persists the current order of the metadata providers of the library
// Persists the current order of the metadata providers of the library.
async function saveMetadataProviderOrderAsync() {
if (!id || !metadataProvidersTbody) return;
const pluginIds = Array.from(metadataProvidersTbody.querySelectorAll('tr[data-provider-plugin-id]'))
@@ -454,7 +455,7 @@
}
}
// on metadata provider enabled checkbox change, persists the new state
// On metadata provider enabled checkbox change, persists the new state.
async function handleMetadataProviderEnabledChangeAsync(e) {
if (e.target.matches('.metadata-provider-enabled')) {
const row = e.target.closest('tr');
@@ -470,18 +471,18 @@
const artworkProvidersTable = document.getElementById('artwork-providers-table');
const artworkProvidersTbody = artworkProvidersTable ? artworkProvidersTable.querySelector('tbody') : null;
// loads the artwork providers configured for the library, when editing an existing library
// Loads the artwork providers configured for the library, when editing an existing library.
async function loadArtworkProvidersAsync() {
if (!id || !artworkProvidersTbody) return;
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_ARTWORK_PROVIDERS, new { libraryId = default(Guid) })'
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
const response = await callApiGetAsync(url);
if (response && response.length > 0) {
artworkProvidersTbody.innerHTML = response.map((provider, index) => renderArtworkProviderRow(provider, index, response.length)).join('');
}
}
// renders an artwork provider row of the library
// Renders an artwork provider row of the library.
function renderArtworkProviderRow(provider, index, count) {
return `
<tr data-provider-plugin-id="${provider.pluginId}">
@@ -499,7 +500,7 @@
</tr>`;
}
// on artwork provider move button click, reorders the providers and persists the new order
// On artwork provider move button click, reorders the providers and persists the new order.
async function handleArtworkProviderReorderAsync(e) {
const button = e.target.closest('.artwork-provider-move-up, .artwork-provider-move-down');
if (!button || !artworkProvidersTbody) return;
@@ -514,7 +515,7 @@
await saveArtworkProviderOrderAsync();
}
// persists the current order of the artwork providers of the library
// Persists the current order of the artwork providers of the library.
async function saveArtworkProviderOrderAsync() {
if (!id || !artworkProvidersTbody) return;
const pluginIds = Array.from(artworkProvidersTbody.querySelectorAll('tr[data-provider-plugin-id]'))
@@ -525,7 +526,7 @@
}
}
// on artwork provider enabled checkbox change, persists the new state
// On artwork provider enabled checkbox change, persists the new state.
async function handleArtworkProviderEnabledChangeAsync(e) {
if (e.target.matches('.artwork-provider-enabled')) {
const row = e.target.closest('tr');
@@ -541,18 +542,18 @@
const bookReadersTable = document.getElementById('book-readers-table');
const bookReadersTbody = bookReadersTable ? bookReadersTable.querySelector('tbody') : null;
// loads the book readers configured for the library, when editing an existing library
// Loads the book readers configured for the library, when editing an existing library.
async function loadBookReadersAsync() {
if (!id || !bookReadersTbody) return;
const url = '@_urlService.GetAbsoluteUrl(WebRoutes.LibraryManagement.GET_BOOK_READERS, new { libraryId = default(Guid) })'
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side
.replace('/@(default(Guid))', `/${id}`); // libraryId needs to be replaced here, because GetAbsoluteUrl is server side, libraryId is client side.
const response = await callApiGetAsync(url);
if (response && response.length > 0) {
bookReadersTbody.innerHTML = response.map(reader => renderBookReaderRow(reader)).join('');
}
}
// renders a book reader row of the library
// Renders a book reader row of the library.
function renderBookReaderRow(reader) {
const extensions = (reader.supportedExtensions || []).join(', ');
return `
@@ -568,7 +569,7 @@
</tr>`;
}
// on book reader enabled checkbox change, persists the new state
// On book reader enabled checkbox change, persists the new state.
async function handleBookReaderEnabledChangeAsync(e) {
if (e.target.matches('.book-reader-enabled')) {
const row = e.target.closest('tr');
@@ -581,7 +582,7 @@
}
};
// add listeners
// Add listeners.
form.addEventListener('keypress', handleEnterKey);
form.addEventListener('submit', handleSubmit);
btnBackToLibraries.addEventListener('click', handleBtnBackToLibrariesClick);
@@ -602,7 +603,7 @@
bookReadersTbody.addEventListener('change', handleBookReaderEnabledChangeAsync);
}
// register cleanup for these listeners
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
form.removeEventListener('keypress', handleEnterKey);
form.removeEventListener('submit', handleSubmit);
@@ -625,14 +626,14 @@
}
});
// load the metadata and artwork providers and book readers when editing an existing library
// Load the metadata and artwork providers and book readers when editing an existing library.
if (id) {
loadMetadataProvidersAsync();
loadArtworkProvidersAsync();
loadBookReadersAsync();
}
// 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());
@@ -1,4 +1,15 @@
@*
FALLBACK BOOKS BROWSING VIEW - READ BEFORE EDITING
This view is the application fallback of the books browsing page, rendered only when the theme template
of the page cannot be loaded. On a healthy site the page comes from the theme's
library/written-content-library/book-library/books/index template. It keeps the DOM contract and the
client script the theme template mirrors, so that navigation, searching and the card actions menu keep
working even without the theme.
To restyle the page, edit the theme files. This fallback is intentionally plain, so that a broken theme
is obvious to the user while the page still functions.
/library/written-content-library/books-library/books?libraryId=...
*@
@@ -55,7 +66,9 @@
const libraryId = '@(Model.Id ?? Guid.Empty)';
const readUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.READ, new { bookId = default(Guid) })';
const detailsUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.EDIT_BOOK, new { id = default(Guid) })';
const availabilityUrlTemplate = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.GET_READING_AVAILABILITY, new { bookId = default(Guid) })';
// 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 booksContainer = document.getElementById('books-container');
const noItemsMessage = document.getElementById('no-items');
const noItemsMatchingMessage = document.getElementById('no-items-matching');
@@ -89,7 +102,9 @@
sortAscending: '@_localizer["SortAscending"]',
sortDescending: '@_localizer["SortDescending"]',
readerUnavailable: '@_localizer["ReaderUnavailable"]',
readerDisabled: '@_localizer["ReaderDisabled"]'
readerDisabled: '@_localizer["ReaderDisabled"]',
read: '@_localizer["Read"]',
viewDetails: '@_localizer["ViewDetails"]'
};
// Builds the URL of the retrieval endpoint, from the current state.
@@ -122,7 +137,7 @@
// Renders the retrieved books, the count label and the pagination controls.
function renderItems(response) {
booksContainer.querySelectorAll('.media-panel').forEach(card => card.remove());
booksContainer.querySelectorAll('.media-card').forEach(card => card.remove());
const hasActiveFilters = state.searchTerm !== '' || state.alphaKey !== null;
if (response.count === 0) {
@@ -144,20 +159,25 @@
}
// Creates a portrait card for a book, with its cover image (or a placeholder) and its title, that opens the reader when clicked.
// The card carries a actions trigger that opens a menu with the actions available for the book, like viewing its details.
function createBookCard(book) {
const card = document.createElement('a');
card.className = 'media-panel nav-link no-underline';
card.style.width = '160px';
card.style.height = '240px';
card.href = readUrlTemplate.replace('/@(default(Guid))', `/${book.id}`);
const card = document.createElement('div');
card.className = 'media-card';
card.dataset.bookId = book.id;
const cardLink = document.createElement('a');
cardLink.className = 'media-panel nav-link no-underline';
cardLink.style.width = '160px';
cardLink.style.height = '240px';
cardLink.dataset.bookId = book.id;
cardLink.href = readUrlTemplate.replace('/@(default(Guid))', `/${book.id}`);
// Opening the reader is conditional on the reader being available and enabled for the library, so the generic nav-link
// navigation is intercepted and replaced by one that first checks the reading availability, warning instead of navigating
// when the book cannot be read.
card.addEventListener('click', async event => {
cardLink.addEventListener('click', async event => {
event.preventDefault();
event.stopImmediatePropagation();
await handleBookCardClickAsync(card);
await handleBookCardClickAsync(cardLink);
});
const image = document.createElement('img');
@@ -172,11 +192,113 @@
title.textContent = book.title;
titleSpan.appendChild(title);
card.appendChild(image);
card.appendChild(titleSpan);
cardLink.appendChild(image);
cardLink.appendChild(titleSpan);
const detailsUrl = detailsUrlTemplate.replace('/@(default(Guid))', `/${book.id}`);
const trigger = document.createElement('button');
trigger.type = 'button';
trigger.className = 'card-actions-trigger';
trigger.setAttribute('aria-haspopup', 'menu');
trigger.setAttribute('aria-label', jsLocalizedStrings.viewDetails);
trigger.addEventListener('click', event => {
event.preventDefault();
event.stopImmediatePropagation();
toggleCardMenu(card, resolveMenuAnchor(event));
});
const menu = document.createElement('nav');
menu.className = 'card-actions-menu';
menu.setAttribute('role', 'menu');
menu.innerHTML = `
<a role="menuitem" href="${readUrlTemplate.replace('/@(default(Guid))', `/${book.id}`)}">${jsLocalizedStrings.read}</a>
<a role="menuitem" href="${detailsUrl}">${jsLocalizedStrings.viewDetails}</a>`;
// Menu entries navigate through the same AJAX navigation used by the nav-links, so that the persistent chrome keeps running.
menu.addEventListener('click', async event => {
const menuItem = event.target.closest('a[role="menuitem"]');
if (!menuItem)
return;
event.preventDefault();
event.stopImmediatePropagation();
closeCardMenus();
await updateContentAsync(menuItem.href, true);
});
card.appendChild(cardLink);
card.appendChild(trigger);
card.appendChild(menu);
// A right click on the card opens the same actions menu.
card.addEventListener('contextmenu', event => {
event.preventDefault();
event.stopImmediatePropagation();
toggleCardMenu(card, resolveMenuAnchor(event));
});
card.addEventListener('click', event => {
// Clicking anywhere on the card outside the trigger and the menu closes the menu, when it is open.
if (card.classList.contains('open') && !event.target.closest('.card-actions-menu'))
closeCardMenus();
});
return card;
}
// Toggles the actions menu of the book card, opening it with its top left corner at the given viewport position.
function toggleCardMenu(card, anchor) {
const wasOpen = card.classList.contains('open');
closeCardMenus();
if (wasOpen)
return;
card.classList.add('open');
const menu = card.querySelector('.card-actions-menu');
if (menu) {
menu.classList.add('open');
positionActionsMenu(menu, anchor);
}
}
// Resolves the viewport point where the card actions menu opens: the pointer tip for mouse gestures, and the lower
// left corner of the actions trigger for keyboard activation, whose synthetic click carries no pointer position.
function resolveMenuAnchor(event) {
if (event.clientX !== 0 || event.clientY !== 0)
return { x: event.clientX, y: event.clientY };
const triggerRect = event.currentTarget.getBoundingClientRect();
return { x: triggerRect.left, y: triggerRect.bottom };
}
// Places the card actions menu with its top left corner at the requested viewport point, moving it left or up only
// when it would otherwise run past the viewport edges, like a desktop context menu does.
function positionActionsMenu(menu, anchor) {
const margin = 4;
const maxLeft = Math.max(margin, window.innerWidth - menu.offsetWidth - margin);
const maxTop = Math.max(margin, window.innerHeight - menu.offsetHeight - margin);
menu.style.position = 'fixed';
menu.style.left = `${Math.min(Math.max(margin, anchor.x), maxLeft)}px`;
menu.style.top = `${Math.min(Math.max(margin, anchor.y), maxTop)}px`;
}
// Closes the actions menus of all the book cards.
function closeCardMenus() {
booksContainer.querySelectorAll('.media-card.open').forEach(card => {
card.classList.remove('open');
const menu = card.querySelector('.card-actions-menu');
if (menu)
menu.classList.remove('open');
});
}
// Closes the actions menus when clicking or pressing a key outside them.
function handleCardMenuDismiss(event) {
if (event.type === 'keydown' && event.key !== 'Escape')
return;
if (event.type === 'click' && event.target.closest('.card-actions-menu, .card-actions-trigger'))
return;
closeCardMenus();
}
// Opens the reader of the book when it can be read, and warns the user otherwise; the navigation is done through the same
// AJAX navigation used by the nav-links, so that the page is not reloaded (and the audio player is not interrupted).
async function handleBookCardClickAsync(card) {
@@ -198,6 +320,8 @@
// Updates the count label: total items when pagination is off, displayed range out of total when it is on.
function updateCountLabel(response) {
if (!countLabel)
return;
if (state.perPage === null)
countLabel.textContent = `${response.count} ${jsLocalizedStrings.items}`;
else if (response.count === 0)
@@ -211,6 +335,8 @@
// Updates the pagination controls, which are only visible when pagination is enabled.
function updatePagination(response) {
if (!pagination)
return;
if (state.perPage === null) {
pagination.classList.add('hidden');
return;
@@ -224,6 +350,8 @@
// Builds the alpha picker column, with the "All" key followed by the numbers, symbols and letters keys.
function buildAlphaPicker() {
if (!alphaPicker)
return;
const allKey = document.createElement('span');
allKey.className = 'alpha-key';
allKey.dataset.alphaKey = '';
@@ -245,6 +373,8 @@
// Highlights the currently active key of the alpha picker.
function updateAlphaPickerActiveState() {
if (!alphaPicker)
return;
alphaPicker.querySelectorAll('.alpha-key').forEach(key => {
const keyValue = key.dataset.alphaKey === '' ? null : key.dataset.alphaKey;
key.classList.toggle('alpha-key-active', keyValue === state.alphaKey);
@@ -313,29 +443,51 @@
loadItemsAsync();
}
// Binds an event handler to an element, when the element is present.
function bindEventHandler(element, type, handler) {
if (element)
element.addEventListener(type, handler);
}
// Unbinds an event handler from an element, when the element is present.
function unbindEventHandler(element, type, handler) {
if (element)
element.removeEventListener(type, handler);
}
// Add listeners.
searchButton.addEventListener('click', handleSearch);
searchInput.addEventListener('keydown', handleSearchKeydown);
sortToggle.addEventListener('click', handleSortToggle);
prevPageButton.addEventListener('click', handlePrevPageClick);
nextPageButton.addEventListener('click', handleNextPageClick);
bindEventHandler(searchButton, 'click', handleSearch);
bindEventHandler(searchInput, 'keydown', handleSearchKeydown);
bindEventHandler(sortToggle, 'click', handleSortToggle);
bindEventHandler(prevPageButton, 'click', handlePrevPageClick);
bindEventHandler(nextPageButton, 'click', handleNextPageClick);
document.addEventListener('keydown', handleAlphaKeydown);
document.addEventListener('click', handleCardMenuDismiss);
document.addEventListener('keydown', handleCardMenuDismiss);
document.addEventListener('DOMContentLoaded', InitializeAsync);
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
searchButton.removeEventListener('click', handleSearch);
searchInput.removeEventListener('keydown', handleSearchKeydown);
sortToggle.removeEventListener('click', handleSortToggle);
prevPageButton.removeEventListener('click', handlePrevPageClick);
nextPageButton.removeEventListener('click', handleNextPageClick);
unbindEventHandler(searchButton, 'click', handleSearch);
unbindEventHandler(searchInput, 'keydown', handleSearchKeydown);
unbindEventHandler(sortToggle, 'click', handleSortToggle);
unbindEventHandler(prevPageButton, 'click', handlePrevPageClick);
unbindEventHandler(nextPageButton, 'click', handleNextPageClick);
document.removeEventListener('keydown', handleAlphaKeydown);
document.removeEventListener('click', handleCardMenuDismiss);
document.removeEventListener('keydown', handleCardMenuDismiss);
document.removeEventListener('DOMContentLoaded', InitializeAsync);
});
async function InitializeAsync() {
if (isInitialized)
return;
// When the page is restored from the history cache before its fresh content arrives, its container may be missing;
// a fresh copy of this script initializes the page once the fresh content is in place, so this instance gives up.
if (!booksContainer || !sortToggle || !countLabel) {
isInitialized = true;
return;
}
isInitialized = true;
sortToggle.textContent = jsLocalizedStrings.sortAscending;
buildAlphaPicker();
@@ -1 +1,853 @@
<p>A book</p>
@*
FALLBACK BOOK DETAILS / EDITING VIEW - READ BEFORE EDITING
This view is the application fallback of the book details and editing page, rendered only when the
active theme does not provide its own template for the page. On a healthy site the page is presented
by the theme files, which hook into the class names and element ids that this view uses as a contract,
exactly like the media library editing page.
To change the behavior of the page, edit this script (and the theme template, when present). To restyle
the page, edit the theme files. This fallback keeps every feature working without styling, so that a
broken theme is obvious to the user while the page still functions.
/library/written-content-library/books-library/books/{id}
*@
@using Lumina.Presentation.Web.Common.DTO.WrittenContentLibrary.BookLibrary
@using Lumina.Presentation.Web.Common.DTO.MediaContributors
@using Lumina.Presentation.Web.Common.Enums.BookLibrary
@using Lumina.Presentation.Web.Common.Services
@using Microsoft.AspNetCore.Mvc.Localization
@using System.Globalization
@{
// 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();
var bookId = Model.Id.ToString();
var libraryId = Model.LibraryId.ToString();
var metadata = Model.Metadata;
var releaseInfo = metadata?.ReleaseInfo;
var language = metadata?.Language;
var originalLanguage = metadata?.OriginalLanguage;
var genres = metadata?.Genres ?? [];
var tags = metadata?.Tags ?? [];
var isbns = Model.ISBNs ?? [];
var contributors = Model.Contributors ?? [];
var ratings = Model.Ratings ?? [];
// Resolves the localized label of a contributor role category, keyed by its domain value.
Func<string?, string> categoryLabel = category => category switch
{
"Publisher" => _localizer["PublisherRole"].Value,
"Other" => _localizer["OtherRole"].Value,
"Author" => _localizer["Author"].Value,
"Translator" => _localizer["Translator"].Value,
"Illustrator" => _localizer["Illustrator"].Value,
"Narrator" => _localizer["Narrator"].Value,
_ => category ?? string.Empty
};
}
@inject IViewLocalizer _localizer
@inject IUrlService _urlService
@model BookDetailsDto
@Html.AntiForgeryToken()
<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. -->
<div class="enlightenment-panel shadow-effect mx-auto panel w-60 mb-10 book-details-panel" style="min-width: 320px;">
<div class="shine-effect"></div>
<div class="form-row book-details-top-bar">
<button id="btn-back-to-library" type="button" class="abort-button">@_localizer["BackToLibrary"]</button>
</div>
<div class="form-row book-details-title-row">
<h1 class="text-light-two w-100 text-center pt-0 pb-0 engraved-title">@_localizer["BookDetails"]</h1>
</div>
<div class="book-details-body">
<!-- Cover, on the left. -->
<div class="book-details-cover">
<div class="book-cover-frame">
<img id="book-cover-image" class="book-cover-image" data-cover-path="@(Model.CoverPath ?? string.Empty)" alt="@_localizer["CoverImage"]" />
</div>
<div class="form-row">
<button id="btn-change-cover" type="button" class="confirm-button">@_localizer["ChangeCover"]</button>
<input id="book-cover-input" type="file" accept="image/*" class="hidden" />
</div>
<div class="form-row">
<small id="book-cover-path" class="book-cover-path text-disabled" title="@(Model.CoverPath ?? string.Empty)">@(Model.CoverPath ?? _localizer["NoCover"].Value)</small>
</div>
</div>
<!-- Editable fields, on the right. -->
<div class="book-details-form">
<h3 class="text-light-two">@_localizer["GeneralInformation"]</h3>
<!-- Title. -->
<div class="form-row">
<div class="form-label">
<label for="title-input">@_localizer["Title"]</label>
<span class="mandatory-field">*</span>:
</div>
<div class="form-field">
<input id="title-input" type="text" class="enlightenment-input" value="@(metadata?.Title ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["TitleDescription"]</small>
</div>
<!-- Original title. -->
<div class="form-row">
<div class="form-label">
<label for="original-title-input">@_localizer["OriginalTitle"]</label>:
</div>
<div class="form-field">
<input id="original-title-input" type="text" class="enlightenment-input" value="@(metadata?.OriginalTitle ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["OriginalTitleDescription"]</small>
</div>
<!-- Description. -->
<div class="form-row">
<div class="form-label">
<label for="description-input">@_localizer["Description"]</label>:
</div>
<div class="form-field">
<textarea id="description-input" class="enlightenment-input">@(metadata?.Description ?? string.Empty)</textarea>
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionDescription"]</small>
</div>
<!-- Publisher. -->
<div class="form-row">
<div class="form-label">
<label for="publisher-input">@_localizer["Publisher"]</label>:
</div>
<div class="form-field">
<input id="publisher-input" type="text" class="enlightenment-input" value="@(metadata?.Publisher ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["PublisherDescription"]</small>
</div>
<!-- Page count. -->
<div class="form-row">
<div class="form-label">
<label for="page-count-input">@_localizer["PageCount"]</label>:
</div>
<div class="form-field">
<input id="page-count-input" type="number" min="1" class="enlightenment-input" value="@(metadata?.PageCount?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["PageCountDescription"]</small>
</div>
<!-- Format. -->
<div class="form-row">
<div class="form-label">
<label for="format-combobox-toggle">@_localizer["Format"]</label>:
</div>
<div class="form-field">
<div class="enlightenment-combobox inline-block w-100" id="format-combobox">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="format-combobox-toggle" />
<label class="enlightenment-toggle" for="format-combobox-toggle">
<span class="enlightenment-selected-text" data-value="@(Model.Format?.ToString() ?? string.Empty)">@(Model.Format.HasValue ? _localizer[Model.Format.Value.ToString()].Value : "-")</span>
</label>
<div class="enlightenment-dropdown">
<div class="enlightenment-option" data-value="">-</div>
@foreach (string format in Enum.GetNames<BookFormat>())
{
<div class="enlightenment-option" data-value="@format">@_localizer[format].Value</div>
}
</div>
</div>
</div>
<small class="form-label text-disabled form-description">@_localizer["FormatDescription"]</small>
</div>
<!-- Edition. -->
<div class="form-row">
<div class="form-label">
<label for="edition-input">@_localizer["Edition"]</label>:
</div>
<div class="form-field">
<input id="edition-input" type="text" class="enlightenment-input" value="@(Model.Edition ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["EditionDescription"]</small>
</div>
<!-- Volume number. -->
<div class="form-row">
<div class="form-label">
<label for="volume-number-input">@_localizer["VolumeNumber"]</label>:
</div>
<div class="form-field">
<input id="volume-number-input" type="number" step="any" min="0" class="enlightenment-input" value="@(Model.VolumeNumber?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["VolumeNumberDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["ReleaseInformation"]</h3>
<!-- Original release. -->
<div class="form-row">
<div class="form-label">
<label for="original-release-date-input">@_localizer["OriginalReleaseDate"]</label>:
</div>
<div class="form-field">
<input id="original-release-date-input" type="date" class="enlightenment-input" value="@(releaseInfo?.OriginalReleaseDate?.ToString("yyyy-MM-dd") ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["OriginalReleaseDateDescription"]</small>
</div>
<div class="form-row">
<div class="form-label">
<label for="original-release-year-input">@_localizer["OriginalReleaseYear"]</label>:
</div>
<div class="form-field">
<input id="original-release-year-input" type="number" min="1" max="9999" class="enlightenment-input" value="@(releaseInfo?.OriginalReleaseYear?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["OriginalReleaseYearDescription"]</small>
</div>
<!-- Re-release. -->
<div class="form-row">
<div class="form-label">
<label for="re-release-date-input">@_localizer["ReReleaseDate"]</label>:
</div>
<div class="form-field">
<input id="re-release-date-input" type="date" class="enlightenment-input" value="@(releaseInfo?.ReReleaseDate?.ToString("yyyy-MM-dd") ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["ReReleaseDateDescription"]</small>
</div>
<div class="form-row">
<div class="form-label">
<label for="re-release-year-input">@_localizer["ReReleaseYear"]</label>:
</div>
<div class="form-field">
<input id="re-release-year-input" type="number" min="1" max="9999" class="enlightenment-input" value="@(releaseInfo?.ReReleaseYear?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["ReReleaseYearDescription"]</small>
</div>
<!-- Country and version. -->
<div class="form-row">
<div class="form-label">
<label for="release-country-input">@_localizer["ReleaseCountry"]</label>:
</div>
<div class="form-field">
<input id="release-country-input" type="text" maxlength="2" class="enlightenment-input" value="@(releaseInfo?.ReleaseCountry ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["ReleaseCountryDescription"]</small>
</div>
<div class="form-row">
<div class="form-label">
<label for="release-version-input">@_localizer["ReleaseVersion"]</label>:
</div>
<div class="form-field">
<input id="release-version-input" type="text" class="enlightenment-input" value="@(releaseInfo?.ReleaseVersion ?? string.Empty)" />
</div>
<small class="form-label text-disabled form-description">@_localizer["ReleaseVersionDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Language"]</h3>
<div class="form-row">
<div class="form-label"><label for="language-code-input">@_localizer["LanguageCode"]</label>:</div>
<div class="form-field"><input id="language-code-input" type="text" maxlength="2" class="enlightenment-input" value="@(language?.LanguageCode ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["LanguageCodeDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="language-name-input">@_localizer["LanguageName"]</label>:</div>
<div class="form-field"><input id="language-name-input" type="text" class="enlightenment-input" value="@(language?.LanguageName ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["LanguageNameDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="language-native-name-input">@_localizer["NativeName"]</label>:</div>
<div class="form-field"><input id="language-native-name-input" type="text" class="enlightenment-input" value="@(language?.NativeName ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["NativeNameDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["OriginalLanguage"]</h3>
<div class="form-row">
<div class="form-label"><label for="original-language-code-input">@_localizer["OriginalLanguageCode"]</label>:</div>
<div class="form-field"><input id="original-language-code-input" type="text" maxlength="2" class="enlightenment-input" value="@(originalLanguage?.LanguageCode ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["OriginalLanguageCodeDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="original-language-name-input">@_localizer["OriginalLanguageName"]</label>:</div>
<div class="form-field"><input id="original-language-name-input" type="text" class="enlightenment-input" value="@(originalLanguage?.LanguageName ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["OriginalLanguageNameDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="original-language-native-name-input">@_localizer["OriginalLanguageNativeName"]</label>:</div>
<div class="form-field"><input id="original-language-native-name-input" type="text" class="enlightenment-input" value="@(originalLanguage?.NativeName ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["OriginalLanguageNativeNameDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Genres"]</h3>
<div class="form-row">
<div class="form-label"><label for="genres-input">@_localizer["Genres"]</label>:</div>
<div class="form-field">
<input id="genres-input" type="text" class="enlightenment-input" value="@(string.Join(", ", genres.Select(genre => genre.Name)))" />
</div>
<small class="form-label text-disabled form-description">@_localizer["GenresDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Tags"]</h3>
<div class="form-row">
<div class="form-label"><label for="tags-input">@_localizer["Tags"]</label>:</div>
<div class="form-field">
<input id="tags-input" type="text" class="enlightenment-input" value="@(string.Join(", ", tags.Select(tag => tag.Name)))" />
</div>
<small class="form-label text-disabled form-description">@_localizer["TagsDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Identifiers"]</h3>
<div class="form-row">
<div class="form-label"><label for="asin-input">@_localizer["ASIN"]</label>:</div>
<div class="form-field"><input id="asin-input" type="text" class="enlightenment-input" value="@(Model.ASIN ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["ASINDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="goodreads-id-input">@_localizer["GoodreadsId"]</label>:</div>
<div class="form-field"><input id="goodreads-id-input" type="text" class="enlightenment-input" value="@(Model.GoodreadsId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["GoodreadsIdDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="lccn-input">@_localizer["LCCN"]</label>:</div>
<div class="form-field"><input id="lccn-input" type="text" class="enlightenment-input" value="@(Model.LCCN ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["LCCNDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="oclc-number-input">@_localizer["OCLCNumber"]</label>:</div>
<div class="form-field"><input id="oclc-number-input" type="text" class="enlightenment-input" value="@(Model.OCLCNumber ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["OCLCNumberDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="open-library-id-input">@_localizer["OpenLibraryId"]</label>:</div>
<div class="form-field"><input id="open-library-id-input" type="text" class="enlightenment-input" value="@(Model.OpenLibraryId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["OpenLibraryIdDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="library-thing-id-input">@_localizer["LibraryThingId"]</label>:</div>
<div class="form-field"><input id="library-thing-id-input" type="text" class="enlightenment-input" value="@(Model.LibraryThingId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["LibraryThingIdDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="google-books-id-input">@_localizer["GoogleBooksId"]</label>:</div>
<div class="form-field"><input id="google-books-id-input" type="text" class="enlightenment-input" value="@(Model.GoogleBooksId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["GoogleBooksIdDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="barnes-noble-id-input">@_localizer["BarnesAndNobleId"]</label>:</div>
<div class="form-field"><input id="barnes-noble-id-input" type="text" class="enlightenment-input" value="@(Model.BarnesAndNobleId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["BarnesAndNobleIdDescription"]</small>
</div>
<div class="form-row">
<div class="form-label"><label for="apple-books-id-input">@_localizer["AppleBooksId"]</label>:</div>
<div class="form-field"><input id="apple-books-id-input" type="text" class="enlightenment-input" value="@(Model.AppleBooksId ?? string.Empty)" /></div>
<small class="form-label text-disabled form-description">@_localizer["AppleBooksIdDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["ISBNs"]</h3>
<div class="form-row">
<table class="w-100 form-table book-list-table">
<thead>
<tr>
<th class="w-50">@_localizer["IsbnValue"]</th>
<th class="w-40">@_localizer["IsbnFormat"]</th>
<th class="w-10"></th>
</tr>
</thead>
<tbody id="isbns-body">
@{ int isbnIndex = 0; }
@foreach (var isbn in isbns)
{
<tr class="isbn-row">
<td><input type="text" class="enlightenment-input isbn-value" value="@(isbn.Value ?? string.Empty)" /></td>
<td>
<div class="enlightenment-combobox inline-block w-100 isbn-format-combobox">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="isbn-format-toggle-@isbnIndex" />
<label class="enlightenment-toggle" for="isbn-format-toggle-@isbnIndex">
<span class="enlightenment-selected-text" data-value="@(isbn.Format?.ToString() ?? string.Empty)">@(isbn.Format.HasValue ? _localizer[isbn.Format.Value.ToString()].Value : "-")</span>
</label>
<div class="enlightenment-dropdown">
<div class="enlightenment-option" data-value="">-</div>
<div class="enlightenment-option" data-value="Isbn10">@_localizer["Isbn10"]</div>
<div class="enlightenment-option" data-value="Isbn13">@_localizer["Isbn13"]</div>
</div>
</div>
</td>
<td><img src="~/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" /></td>
</tr>
isbnIndex++;
}
</tbody>
</table>
<button id="btn-add-isbn" type="button" class="confirm-button">@_localizer["AddRow"]</button>
<small class="form-label text-disabled form-description">@_localizer["ISBNsDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Contributors"]</h3>
<div class="form-row">
<table class="w-100 form-table book-list-table">
<thead>
<tr>
<th class="w-35">@_localizer["ContributorName"]</th>
<th class="w-25">@_localizer["RoleName"]</th>
<th class="w-30">@_localizer["RoleCategory"]</th>
<th class="w-10"></th>
</tr>
</thead>
<tbody id="contributors-body">
@{ int contributorIndex = 0; }
@foreach (var contributor in contributors)
{
<tr class="contributor-row">
<td><input type="text" class="enlightenment-input contributor-name" value="@(contributor.Name?.DisplayName ?? string.Empty)" /></td>
<td><input type="text" class="enlightenment-input contributor-role" value="@(contributor.Role?.Name ?? string.Empty)" /></td>
<td>
<div class="enlightenment-combobox inline-block w-100 contributor-category-combobox">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="contributor-category-toggle-@contributorIndex" />
<label class="enlightenment-toggle" for="contributor-category-toggle-@contributorIndex">
<span class="enlightenment-selected-text" data-value="@(contributor.Role?.Category?.ToString() ?? "Other")">@categoryLabel(contributor.Role?.Category?.ToString())</span>
</label>
<div class="enlightenment-dropdown">
<div class="enlightenment-option" data-value="Other">@_localizer["OtherRole"]</div>
<div class="enlightenment-option" data-value="Author">@_localizer["Author"]</div>
<div class="enlightenment-option" data-value="Translator">@_localizer["Translator"]</div>
<div class="enlightenment-option" data-value="Illustrator">@_localizer["Illustrator"]</div>
<div class="enlightenment-option" data-value="Publisher">@_localizer["PublisherRole"]</div>
<div class="enlightenment-option" data-value="Narrator">@_localizer["Narrator"]</div>
</div>
</div>
</td>
<td><img src="~/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" /></td>
</tr>
contributorIndex++;
}
</tbody>
</table>
<button id="btn-add-contributor" type="button" class="confirm-button">@_localizer["AddContributor"]</button>
<small class="form-label text-disabled form-description">@_localizer["ContributorsDescription"]</small>
</div>
<h3 class="text-light-two">@_localizer["Ratings"]</h3>
<div class="form-row">
<table class="w-100 form-table book-list-table">
<thead>
<tr>
<th class="w-15">@_localizer["RatingValue"]</th>
<th class="w-15">@_localizer["RatingMaxValue"]</th>
<th class="w-25">@_localizer["RatingSource"]</th>
<th class="w-25">@_localizer["RatingVoteCount"]</th>
<th class="w-10"></th>
</tr>
</thead>
<tbody id="ratings-body">
@{ int ratingIndex = 0; }
@foreach (var rating in ratings)
{
<tr class="rating-row">
<td><input type="number" step="any" min="0" class="enlightenment-input rating-value" value="@(rating.Value?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" /></td>
<td><input type="number" step="any" min="0" class="enlightenment-input rating-max-value" value="@(rating.MaxValue?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" /></td>
<td>
<div class="enlightenment-combobox inline-block w-100 rating-source-combobox">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="rating-source-toggle-@ratingIndex" />
<label class="enlightenment-toggle" for="rating-source-toggle-@ratingIndex">
<span class="enlightenment-selected-text" data-value="@(rating.Source?.ToString() ?? string.Empty)">@(rating.Source.HasValue ? _localizer[rating.Source.Value.ToString()].Value : "-")</span>
</label>
<div class="enlightenment-dropdown">
<div class="enlightenment-option" data-value="">-</div>
<div class="enlightenment-option" data-value="User">@_localizer["User"]</div>
<div class="enlightenment-option" data-value="OpenLibrary">@_localizer["OpenLibrary"]</div>
<div class="enlightenment-option" data-value="Goodreads">@_localizer["Goodreads"]</div>
<div class="enlightenment-option" data-value="Amazon">@_localizer["Amazon"]</div>
<div class="enlightenment-option" data-value="GoogleBooks">@_localizer["GoogleBooks"]</div>
<div class="enlightenment-option" data-value="Calibre">@_localizer["Calibre"]</div>
</div>
</div>
</td>
<td><input type="number" min="0" class="enlightenment-input rating-vote-count" value="@(rating.VoteCount?.ToString(CultureInfo.InvariantCulture) ?? string.Empty)" /></td>
<td><img src="~/images/ui/delete.svg" alt="@_localizer["Remove"]" title="@_localizer["Remove"]" class="remove-form-table-row-icon" /></td>
</tr>
ratingIndex++;
}
</tbody>
</table>
<button id="btn-add-rating" type="button" class="confirm-button">@_localizer["AddRating"]</button>
<small class="form-label text-disabled form-description">@_localizer["RatingsDescription"]</small>
</div>
<div class="form-row mt-10">
<button id="btn-save-book" type="button" class="confirm-button w-100px">@_localizer["Save"]</button>
</div>
</div>
</div>
</div>
</div>
@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, callApiPutAsync, ...). 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.
const cleanupFunctions = [];
let isInitialized = false;
let generatedId = 1000;
const bookId = '@bookId';
const libraryId = '@libraryId';
const libraryIndexUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.INDEX)';
const saveUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.SAVE_BOOK, new { id = default(Guid) })'.replace('/@(default(Guid))', `/${bookId}`);
const coverUrl = '@_urlService.GetAbsoluteUrl(WebRoutes.Books.UPDATE_BOOK_COVER, new { id = default(Guid) })'.replace('/@(default(Guid))', `/${bookId}`);
// 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 coverImage = document.getElementById('book-cover-image');
const coverPathLabel = document.getElementById('book-cover-path');
const coverInput = document.getElementById('book-cover-input');
const btnChangeCover = document.getElementById('btn-change-cover');
const btnBackToLibrary = document.getElementById('btn-back-to-library');
const btnSaveBook = document.getElementById('btn-save-book');
const isbnsBody = document.getElementById('isbns-body');
const contributorsBody = document.getElementById('contributors-body');
const ratingsBody = document.getElementById('ratings-body');
const btnAddIsbn = document.getElementById('btn-add-isbn');
const btnAddContributor = document.getElementById('btn-add-contributor');
const btnAddRating = document.getElementById('btn-add-rating');
const jsLocalizedStrings = {
bookSaved: @Json.Serialize(_localizer["BookSaved"].Value),
coverSaved: @Json.Serialize(_localizer["CoverSaved"].Value),
saveFailed: @Json.Serialize(_localizer["SaveFailed"].Value),
coverUploadFailed: @Json.Serialize(_localizer["CoverUploadFailed"].Value),
noCover: @Json.Serialize(_localizer["NoCover"].Value),
remove: @Json.Serialize(_localizer["Remove"].Value)
};
// Reads the trimmed value of the element with the provided id.
function readValue(id) {
const element = document.getElementById(id);
return element ? element.value.trim() : '';
}
// Reads the value of the enlightenment combobox with the provided id.
function readComboboxValue(id) {
const element = document.querySelector(`#${id} .enlightenment-selected-text`);
return element ? (element.getAttribute('data-value') || '') : '';
}
// Reads the value of the enlightenment combobox inside the provided row, selected by its class.
function readRowComboboxValue(row, className) {
const element = row.querySelector(className + ' .enlightenment-selected-text');
return element ? (element.getAttribute('data-value') || '') : '';
}
// Reads an optional number from a field, returning null when the field is empty or not a number.
function readNumber(id) {
const value = readValue(id);
if (value === '')
return null;
const parsed = Number(value);
return Number.isNaN(parsed) ? null : parsed;
}
// Splits a comma separated list into trimmed values.
function splitList(value) {
return value.split(',').map(item => item.trim()).filter(item => item !== '');
}
// Builds the payload of the edited book, matching the update request of the API.
function buildPayload() {
return {
Id: bookId,
Format: readComboboxValue('format-combobox') || null,
Edition: readValue('edition-input') || null,
VolumeNumber: readNumber('volume-number-input'),
ASIN: readValue('asin-input') || null,
GoodreadsId: readValue('goodreads-id-input') || null,
LCCN: readValue('lccn-input') || null,
OCLCNumber: readValue('oclc-number-input') || null,
OpenLibraryId: readValue('open-library-id-input') || null,
LibraryThingId: readValue('library-thing-id-input') || null,
GoogleBooksId: readValue('google-books-id-input') || null,
BarnesAndNobleId: readValue('barnes-noble-id-input') || null,
AppleBooksId: readValue('apple-books-id-input') || null,
ISBNs: Array.from(isbnsBody.querySelectorAll('.isbn-row')).map(row => ({
Value: row.querySelector('.isbn-value').value.trim() || null,
Format: readRowComboboxValue(row, '.isbn-format-combobox') || null
})),
Contributors: Array.from(contributorsBody.querySelectorAll('.contributor-row')).map(row => ({
Name: { DisplayName: row.querySelector('.contributor-name').value.trim() || null },
Role: {
Name: row.querySelector('.contributor-role').value.trim() || null,
Category: readRowComboboxValue(row, '.contributor-category-combobox') || null
}
})),
Ratings: Array.from(ratingsBody.querySelectorAll('.rating-row')).map(row => ({
Value: parseOptionalDecimal(row.querySelector('.rating-value').value),
MaxValue: parseOptionalDecimal(row.querySelector('.rating-max-value').value),
Source: readRowComboboxValue(row, '.rating-source-combobox') || null,
VoteCount: parseIntOrNull(row.querySelector('.rating-vote-count').value)
})),
Metadata: {
Title: readValue('title-input'),
OriginalTitle: readValue('original-title-input') || null,
Description: readValue('description-input') || null,
Publisher: readValue('publisher-input') || null,
PageCount: readNumber('page-count-input'),
ReleaseInfo: {
OriginalReleaseDate: readValue('original-release-date-input') || null,
OriginalReleaseYear: readNumber('original-release-year-input'),
ReReleaseDate: readValue('re-release-date-input') || null,
ReReleaseYear: readNumber('re-release-year-input'),
ReleaseCountry: readValue('release-country-input') || null,
ReleaseVersion: readValue('release-version-input') || null
},
Genres: splitList(readValue('genres-input')).map(name => ({ Name: name })),
Tags: splitList(readValue('tags-input')).map(name => ({ Name: name })),
Language: buildLanguage('language-code-input', 'language-name-input', 'language-native-name-input'),
OriginalLanguage: buildLanguage('original-language-code-input', 'original-language-name-input', 'original-language-native-name-input')
}
};
}
// Builds the language object of a language group, or null when no field of the group carries a value.
function buildLanguage(codeId, nameId, nativeNameId) {
const code = readValue(codeId);
const name = readValue(nameId);
const nativeName = readValue(nativeNameId);
if (code === '' && name === '' && nativeName === '')
return null;
return { LanguageCode: code || null, LanguageName: name || null, NativeName: nativeName || null };
}
// Parses a decimal value, returning null when the value is empty or not a number.
function parseOptionalDecimal(value) {
if (value.trim() === '')
return null;
const parsed = Number(value);
return Number.isNaN(parsed) ? null : parsed;
}
// Parses an integer value, returning null when the value is empty or not a number.
function parseIntOrNull(value) {
if (value.trim() === '')
return null;
const parsed = parseInt(value, 10);
return Number.isNaN(parsed) ? null : parsed;
}
// Sends the edited book data to the server.
async function handleSaveAsync() {
const result = await callApiPutAsync(saveUrl, buildPayload());
if (result && result.success === true) {
notificationService.show(jsLocalizedStrings.bookSaved, NotificationType.SUCCESS);
} else {
notificationService.show(jsLocalizedStrings.saveFailed, NotificationType.ERROR);
}
}
// Opens the file picker that chooses the new cover image.
function handleChangeCoverClick() {
coverInput.click();
}
// Uploads the selected cover image to the server.
async function handleCoverChangeAsync() {
const file = coverInput.files && coverInput.files[0];
if (!file)
return;
const formData = new FormData();
formData.append('cover', file);
const token = document.querySelector('input[name="__RequestVerificationToken"]')?.value;
const headers = { 'X-Requested-With': 'XMLHttpRequest' };
if (token)
headers['RequestVerificationToken'] = token;
let response;
try {
response = await fetch(coverUrl, {
method: 'PUT',
headers: headers,
body: formData
});
} catch (error) {
console.error('Error:', error);
notificationService.show(jsLocalizedStrings.coverUploadFailed, NotificationType.ERROR);
return;
}
if (response.redirected) {
window.location.href = response.url;
return;
}
if (!response.ok) {
notificationService.show(jsLocalizedStrings.coverUploadFailed, NotificationType.ERROR);
return;
}
const jsonResponse = await response.json();
if (jsonResponse.success === true) {
// Show the uploaded cover immediately, so that the user sees the change without reloading.
const reader = new FileReader();
reader.onload = function(event) {
coverImage.src = event.target.result;
const storedPath = jsonResponse.data || '';
coverImage.dataset.coverPath = storedPath;
coverPathLabel.textContent = storedPath ? storedPath : jsLocalizedStrings.noCover;
coverPathLabel.title = storedPath;
};
reader.readAsDataURL(file);
notificationService.show(jsLocalizedStrings.coverSaved, NotificationType.SUCCESS);
} else {
notificationService.show(jsLocalizedStrings.coverUploadFailed, NotificationType.ERROR);
}
}
// Shows the cover image of the book, or a placeholder when the book has no cover.
function showCover() {
const coverPath = coverImage.dataset.coverPath || '';
coverImage.src = coverPath
? `${globalConfiguration.serverBasePath}${coverPath}`
: `/images/ui/book-placeholder.svg`;
coverPathLabel.textContent = coverPath ? coverPath : jsLocalizedStrings.noCover;
coverPathLabel.title = coverPath || '';
}
// Navigates back to the library page of the book.
async function handleBackToLibraryAsync() {
await updateContentAsync(`${libraryIndexUrl}?libraryId=${encodeURIComponent(libraryId)}`, true);
}
// Builds the HTML of an enlightenment combobox of a row, with the provided option values.
function buildRowCombobox(optionValues, selectedValue) {
const id = `row-combobox-${generatedId++}`;
const options = optionValues.map(option => {
const selected = option.value === selectedValue ? ' selected' : '';
return `<div class="enlightenment-option" data-value="${option.value}">${option.label}</div>`;
}).join('');
return `
<div class="enlightenment-combobox inline-block w-100">
<div class="shine-effect" style="top: 1px;"></div>
<input type="checkbox" class="enlightenment-toggle-checkbox" id="${id}" />
<label class="enlightenment-toggle" for="${id}">
<span class="enlightenment-selected-text" data-value="${selectedValue || ''}">${selectedLabel(selectedValue)}</span>
</label>
<div class="enlightenment-dropdown">
<div class="enlightenment-option" data-value="">-</div>
${options}
</div>
</div>`;
}
// Returns the display text of a selected combobox value, using the default dash when nothing is selected.
function selectedLabel(value) {
if (!value)
return '-';
const isbn = isbnOptions.find(option => option.value === value);
if (isbn)
return isbn.label;
const category = contributorCategoryOptions.find(option => option.value === value);
if (category)
return category.label;
const source = ratingSourceOptions.find(option => option.value === value);
if (source)
return source.label;
return value;
}
const isbnOptions = [
{ value: 'Isbn10', label: @Json.Serialize(_localizer["Isbn10"].Value) },
{ value: 'Isbn13', label: @Json.Serialize(_localizer["Isbn13"].Value) }
];
const contributorCategoryOptions = [
{ value: 'Other', label: @Json.Serialize(_localizer["OtherRole"].Value) },
{ value: 'Author', label: @Json.Serialize(_localizer["Author"].Value) },
{ value: 'Translator', label: @Json.Serialize(_localizer["Translator"].Value) },
{ value: 'Illustrator', label: @Json.Serialize(_localizer["Illustrator"].Value) },
{ value: 'Publisher', label: @Json.Serialize(_localizer["PublisherRole"].Value) },
{ value: 'Narrator', label: @Json.Serialize(_localizer["Narrator"].Value) }
];
const ratingSourceOptions = [
{ value: 'User', label: @Json.Serialize(_localizer["User"].Value) },
{ value: 'OpenLibrary', label: @Json.Serialize(_localizer["OpenLibrary"].Value) },
{ value: 'Goodreads', label: @Json.Serialize(_localizer["Goodreads"].Value) },
{ value: 'Amazon', label: @Json.Serialize(_localizer["Amazon"].Value) },
{ value: 'GoogleBooks', label: @Json.Serialize(_localizer["GoogleBooks"].Value) },
{ value: 'Calibre', label: @Json.Serialize(_localizer["Calibre"].Value) }
];
// Adds a blank ISBN row.
function addIsbnRow() {
isbnsBody.insertAdjacentHTML('beforeend', `
<tr class="isbn-row">
<td><input type="text" class="enlightenment-input isbn-value" /></td>
<td>${buildRowCombobox(isbnOptions, '')}</td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);
}
// Adds a blank contributor row.
function addContributorRow() {
contributorsBody.insertAdjacentHTML('beforeend', `
<tr class="contributor-row">
<td><input type="text" class="enlightenment-input contributor-name" /></td>
<td><input type="text" class="enlightenment-input contributor-role" value="Author" /></td>
<td>${buildRowCombobox(contributorCategoryOptions, 'Author')}</td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);
}
// Adds a blank rating row.
function addRatingRow() {
ratingsBody.insertAdjacentHTML('beforeend', `
<tr class="rating-row">
<td><input type="number" step="any" min="0" class="enlightenment-input rating-value" /></td>
<td><input type="number" step="any" min="0" class="enlightenment-input rating-max-value" /></td>
<td>${buildRowCombobox(ratingSourceOptions, '')}</td>
<td><input type="number" min="0" class="enlightenment-input rating-vote-count" /></td>
<td><img src="/images/ui/delete.svg" alt="${jsLocalizedStrings.remove}" title="${jsLocalizedStrings.remove}" class="remove-form-table-row-icon" /></td>
</tr>`);
}
// Removes the row of the clicked remove icon.
function handleRowRemoval(event) {
if (event.target.matches('.remove-form-table-row-icon'))
event.target.closest('tr').remove();
}
// Add listeners.
btnSaveBook.addEventListener('click', handleSaveAsync);
btnBackToLibrary.addEventListener('click', handleBackToLibraryAsync);
btnChangeCover.addEventListener('click', handleChangeCoverClick);
coverInput.addEventListener('change', handleCoverChangeAsync);
btnAddIsbn.addEventListener('click', addIsbnRow);
btnAddContributor.addEventListener('click', addContributorRow);
btnAddRating.addEventListener('click', addRatingRow);
isbnsBody.addEventListener('click', handleRowRemoval);
contributorsBody.addEventListener('click', handleRowRemoval);
ratingsBody.addEventListener('click', handleRowRemoval);
document.addEventListener('DOMContentLoaded', InitializeAsync);
// Register cleanup for these listeners.
cleanupFunctions.push(() => {
btnSaveBook.removeEventListener('click', handleSaveAsync);
btnBackToLibrary.removeEventListener('click', handleBackToLibraryAsync);
btnChangeCover.removeEventListener('click', handleChangeCoverClick);
coverInput.removeEventListener('change', handleCoverChangeAsync);
btnAddIsbn.removeEventListener('click', addIsbnRow);
btnAddContributor.removeEventListener('click', addContributorRow);
btnAddRating.removeEventListener('click', addRatingRow);
isbnsBody.removeEventListener('click', handleRowRemoval);
contributorsBody.removeEventListener('click', handleRowRemoval);
ratingsBody.removeEventListener('click', handleRowRemoval);
document.removeEventListener('DOMContentLoaded', InitializeAsync);
});
// Initializes the page, showing the cover image of the book.
function InitializeAsync() {
if (isInitialized)
return;
isInitialized = true;
showCover();
}
// Store all cleanups for this view on window object using the scriptId.
window.viewCleanups = window.viewCleanups || {};
window.viewCleanups['@scriptId'] = () => {
cleanupFunctions.forEach(cleanup => cleanup());
console.log(`Unloaded @scriptId`);
};
console.log(`Loaded @scriptId`);
</script>
}
@@ -18,7 +18,7 @@
<div class="cotton-candy reader-root">
<div class="reader-toolbar form-row">
<button id="btn-back" type="button" class="abort-button">@_localizer["Back"]</button>
<button id="btn-back" type="button" class="abort-button">@_localizer["BackToLibrary"]</button>
<button id="btn-toc-toggle" type="button" class="confirm-button">@_localizer["TableOfContents"]</button>
<button id="btn-prev" type="button" class="abort-button">@_localizer["Previous"]</button>
<button id="btn-next" type="button" class="confirm-button">@_localizer["Next"]</button>
@@ -54,6 +54,7 @@
return String(value).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#39;');
}
// 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 readerTitle = document.getElementById('reader-title');
const readerContent = document.getElementById('reader-content');
const readerStatus = document.getElementById('reader-status');
@@ -16,8 +16,8 @@
@model UserSettingsDto
<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.-->
<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. -->
<div class="enlightenment-panel shadow-effect mx-auto panel w-50 mb-10" style="min-width: 320px;">
<div class="shine-effect"></div>
<form method="post" id="user-settings-form" class="inline">
@@ -52,7 +52,7 @@
</div>
<small class="form-label text-disabled form-description">@_localizer["DescriptionItemsPerPage"]</small>
</div>
<!-- Alpha picker -->
<!-- Alpha picker. -->
<div class="form-row">
<div class="form-label">
<label asp-for="ShouldIgnoreThePrefixForAlphaPicker">@_localizer["ShouldIgnoreThePrefixForAlphaPicker"]</label>:
@@ -118,6 +118,7 @@
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 form = document.getElementById('user-settings-form');
const checkboxIsPaginationEnabled = document.getElementById('IsPaginationEnabled');
const inputItemsPerPage = document.getElementById('ItemsPerPage');