Remove unused movie sorting functionality
The movie sorting dropdown and its associated logic were removed as they are no longer needed. Co-authored-by: mathieumoran1 <[email protected]>
This commit is contained in:
co-authored by
mathieumoran1
parent
bacd25f1ac
commit
2968ca7c80
@@ -360,7 +360,6 @@ window.addEventListener('DOMContentLoaded', async function () {
|
|||||||
// Modal UI (Films regardés)
|
// Modal UI (Films regardés)
|
||||||
const moviesModalEl = document.getElementById('moviesModal');
|
const moviesModalEl = document.getElementById('moviesModal');
|
||||||
const movieGridEl = document.getElementById('movie-grid');
|
const movieGridEl = document.getElementById('movie-grid');
|
||||||
const movieSortEl = document.getElementById('movie-sort');
|
|
||||||
const moviesSummaryEl = document.getElementById('movies-summary');
|
const moviesSummaryEl = document.getElementById('movies-summary');
|
||||||
const moviesEmptyEl = document.getElementById('movies-empty');
|
const moviesEmptyEl = document.getElementById('movies-empty');
|
||||||
const moviesModalTitleEl = document.getElementById('moviesModalLabel');
|
const moviesModalTitleEl = document.getElementById('moviesModalLabel');
|
||||||
@@ -394,21 +393,9 @@ window.addEventListener('DOMContentLoaded', async function () {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sortMovies(list, mode) {
|
function sortMoviesRecent(list) {
|
||||||
const arr = Array.isArray(list) ? list.slice() : [];
|
const arr = Array.isArray(list) ? list.slice() : [];
|
||||||
if (mode === 'title') {
|
// watchedDate desc, fallback title
|
||||||
arr.sort((a, b) => safeStr(a?.title).localeCompare(safeStr(b?.title), 'fr', { sensitivity: 'base' }));
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
if (mode === 'category') {
|
|
||||||
arr.sort((a, b) => {
|
|
||||||
const c = safeStr(a?.category).localeCompare(safeStr(b?.category), 'fr', { sensitivity: 'base' });
|
|
||||||
if (c !== 0) return c;
|
|
||||||
return safeStr(a?.title).localeCompare(safeStr(b?.title), 'fr', { sensitivity: 'base' });
|
|
||||||
});
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
// recent (default): watchedDate desc, fallback title
|
|
||||||
arr.sort((a, b) => {
|
arr.sort((a, b) => {
|
||||||
const at = a?.watchedDate ? new Date(a.watchedDate).getTime() : 0;
|
const at = a?.watchedDate ? new Date(a.watchedDate).getTime() : 0;
|
||||||
const bt = b?.watchedDate ? new Date(b.watchedDate).getTime() : 0;
|
const bt = b?.watchedDate ? new Date(b.watchedDate).getTime() : 0;
|
||||||
@@ -419,11 +406,9 @@ window.addEventListener('DOMContentLoaded', async function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function renderMoviesModal() {
|
function renderMoviesModal() {
|
||||||
if (!movieGridEl || !movieSortEl || !moviesSummaryEl || !moviesEmptyEl) return;
|
if (!movieGridEl || !moviesSummaryEl || !moviesEmptyEl) return;
|
||||||
|
|
||||||
const sortMode = safeStr(movieSortEl.value).trim() || 'recent';
|
const sorted = sortMoviesRecent((Array.isArray(currentModalMovies) ? currentModalMovies : []));
|
||||||
|
|
||||||
const sorted = sortMovies((Array.isArray(currentModalMovies) ? currentModalMovies : []), sortMode);
|
|
||||||
|
|
||||||
const total = Array.isArray(currentModalMovies) ? currentModalMovies.length : 0;
|
const total = Array.isArray(currentModalMovies) ? currentModalMovies.length : 0;
|
||||||
moviesSummaryEl.textContent = total ? `${total} film${total > 1 ? 's' : ''}` : '0 film';
|
moviesSummaryEl.textContent = total ? `${total} film${total > 1 ? 's' : ''}` : '0 film';
|
||||||
@@ -614,7 +599,6 @@ window.addEventListener('DOMContentLoaded', async function () {
|
|||||||
: `Films regardés (${count})`;
|
: `Films regardés (${count})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movieSortEl) movieSortEl.value = 'recent';
|
|
||||||
renderMoviesModal();
|
renderMoviesModal();
|
||||||
|
|
||||||
if (moviesModalEl) {
|
if (moviesModalEl) {
|
||||||
@@ -623,12 +607,9 @@ window.addEventListener('DOMContentLoaded', async function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movieSortEl) {
|
|
||||||
movieSortEl.addEventListener('change', () => renderMoviesModal());
|
|
||||||
}
|
|
||||||
if (moviesModalEl) {
|
if (moviesModalEl) {
|
||||||
moviesModalEl.addEventListener('shown.bs.modal', () => {
|
moviesModalEl.addEventListener('shown.bs.modal', () => {
|
||||||
try { movieSortEl?.focus(); } catch (_) {}
|
// no controls to focus
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,14 +173,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="d-flex flex-column gap-3">
|
<div class="d-flex flex-column gap-3">
|
||||||
<div class="d-flex flex-wrap gap-2 align-items-center justify-content-end">
|
|
||||||
<select id="movie-sort" class="form-select form-select-sm" style="max-width: 240px;">
|
|
||||||
<option value="recent">Plus récents</option>
|
|
||||||
<option value="title">Titre (A → Z)</option>
|
|
||||||
<option value="category">Catégorie</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="movies-summary" class="text-muted small"></div>
|
<div id="movies-summary" class="text-muted small"></div>
|
||||||
|
|
||||||
<div id="movies-empty" class="text-muted d-none">Aucun film à afficher.</div>
|
<div id="movies-empty" class="text-muted d-none">Aucun film à afficher.</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user