- toogle chapter visibility
- delete chapter cbz
- preferred ContentSource.php and modal
- minor fixes
This commit is contained in:
Jérémy Guillot
2024-07-21 22:21:04 +02:00
parent fafff5014c
commit c56f72b813
17 changed files with 474 additions and 82 deletions

View File

@@ -5,7 +5,7 @@
{% set volume_cbz_path = chapters|first.cbzPath %}
{% set all_chapters_same_cbz = chapters|reduce((carry, chapter) => carry and chapter.cbzPath == volume_cbz_path, true) %}
{% set available_chapters = chapters|filter(chapter => chapter.cbzPath is not null) %}
{% set total_chapters = chapters|length %}
{% set total_chapters = chapters|filter(chapter => chapter.visible)|length %}
<div data-controller="table" data-table-open-value="{{ is_first ? 'true' : 'false' }}">
<div class="bg-white rounded-sm shadow mb-4">

View File

@@ -1,48 +1,65 @@
<tr id="chapter-{{ chapter.id }}" class="border-t hover:bg-green-100">
{% if chapter.cbzPath is not null %}
<td class="px-4 py-2 text-green-500">
<a data-turbo-frame="_top" href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ '%02d'|format(chapter.number) }}
</a>
</td>
{% else %}
<td class="px-4 py-2">{{ '%02d'|format(chapter.number) }}</td>
{% endif %}
<td class="px-4 py-2 w-full text-left">
{% if chapter.visible %}
<tr id="chapter-{{ chapter.id }}" class="border-t hover:bg-green-100">
{% if chapter.cbzPath is not null %}
<a data-turbo-frame="_top" href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ chapter.title ?? 'No title' }}
</a>
<td class="px-4 py-2 text-green-500">
<a data-turbo-frame="_top"
href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ chapter.number < 10 ? '0' ~ chapter.number : chapter.number }}
</a>
</td>
{% else %}
{{ chapter.title ?? 'No title' }}
<td class="px-4 py-2">{{ chapter.number < 10 ? '0' ~ chapter.number : chapter.number }}</td>
{% endif %}
</td>
<td class="px-4 py-2 flex justify-end gap-2">
{% if chapter.cbzPath is null %}
<button
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('search_chapter', {id: chapter.id}) }}"
>
<td class="px-4 py-2 w-full text-left">
{% if chapter.cbzPath is not null %}
<a data-turbo-frame="_top"
href="{{ path('app_manga_read', { mangaSlug: manga.slug, chapterNumber: chapter.number, pageNumber: 1 }) }}">
{{ chapter.title ?? 'No title' }}
</a>
{% else %}
{{ chapter.title ?? 'No title' }}
{% endif %}
</td>
<td class="px-4 py-2 flex justify-end gap-2">
{% if chapter.cbzPath is null %}
<button
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('search_chapter', {id: chapter.id}) }}"
>
<span class="text-gray-500 hover:text-green-500">
<i data-download-target="icon" class="fas fa-search"></i>
</span>
</button>
{% else %}
<button disabled>
<span class="text-gray-500">
<i class="fas fa-search"></i>
</button>
{% else %}
<button
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('app_delete_cbz', {id: chapter.id}) }}"
>
<span class="text-gray-500 hover:text-green-500">
<i data-download-target="icon" class="fas fa-times"></i>
</span>
</button>
{% endif %}
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('download_cbz', {chapterId: chapter.id}) }}"
class="w-8 text-center">
<i data-download-target="icon"
class="fas fa-download text-gray-500 hover:text-green-500"></i>
</a>
<button
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('app_hide_chapter', {id: chapter.id}) }}"
>
<span class="text-gray-500 hover:text-green-500">
<i data-download-target="icon" class="fas fa-trash-can"></i>
</span>
</button>
{% endif %}
<a href="#"
data-controller="download"
data-action="download#download"
data-download-url-value="{{ path('download_cbz', {chapterId: chapter.id}) }}"
class="w-8 text-center">
<i data-download-target="icon"
class="fas fa-download text-gray-500 hover:text-green-500"></i>
</a>
</td>
</tr>
</td>
</tr>
{% endif %}

View File

@@ -49,7 +49,9 @@
</div>
<turbo-frame id="chapter_list"
src="{{ fragment_uri(controller('App\\Controller\\MangaController::_chaptersByManga', {'id': manga.id})) }}"></turbo-frame>
src="{{ fragment_uri(controller('App\\Controller\\MangaController::_chaptersByManga', {'id': manga.id})) }}"
>
</turbo-frame>
{# Modal d'édition #}
<twig:Modal
openTrigger="openEditModal"
@@ -81,21 +83,26 @@
<label class="block text-sm font-medium text-gray-700">Slugs alternatifs</label>
<div data-collection-target="container" class="grid grid-cols-4 gap-2 mt-1">
{% for slug in form.alternativeSlugs %}
<div class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
<div
class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
{{ form_widget(slug, {'attr': {'class': 'bg-transparent border-none focus:outline-none focus:border-b focus:border-green-500 p-0 w-full'}}) }}
<button type="button" data-action="collection#remove" class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<button type="button" data-action="collection#remove"
class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<i class="fas fa-times"></i>
</button>
</div>
{% endfor %}
</div>
<button type="button" data-action="collection#add" class="mt-2 text-sm text-green-500 hover:text-green-700">
<button type="button" data-action="collection#add"
class="mt-2 text-sm text-green-500 hover:text-green-700">
+ Ajouter un slug alternatif
</button>
<template data-collection-target="template">
<div class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
<div
class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
{{ form_widget(form.alternativeSlugs.vars.prototype, {'attr': {'class': 'bg-transparent border-none focus:outline-none focus:border-b focus:border-green-500 p-0 w-full'}}) }}
<button type="button" data-action="collection#remove" class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<button type="button" data-action="collection#remove"
class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<i class="fas fa-times"></i>
</button>
</div>
@@ -106,21 +113,26 @@
<label class="block text-sm font-medium text-gray-700">{{ form_label(form.genres) }}</label>
<div data-collection-target="container" class="grid grid-cols-4 gap-2 mt-1">
{% for genre in form.genres %}
<div class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
<div
class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
{{ form_widget(genre, {'attr': {'class': 'bg-transparent border-none focus:outline-none focus:border-b focus:border-green-500 p-0 w-full'}}) }}
<button type="button" data-action="collection#remove" class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<button type="button" data-action="collection#remove"
class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<i class="fas fa-times"></i>
</button>
</div>
{% endfor %}
</div>
<button type="button" data-action="collection#add" class="mt-2 text-sm text-green-500 hover:text-green-700">
<button type="button" data-action="collection#add"
class="mt-2 text-sm text-green-500 hover:text-green-700">
+ Ajouter un genre
</button>
<template data-collection-target="template">
<div class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
<div
class="inline-flex items-center bg-gray-100 rounded-full px-3 py-1 text-sm collection-item">
{{ form_widget(form.genres.vars.prototype, {'attr': {'class': 'bg-transparent border-none focus:outline-none focus:border-b focus:border-green-500 p-0 w-full'}}) }}
<button type="button" data-action="collection#remove" class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<button type="button" data-action="collection#remove"
class="ml-2 text-gray-500 hover:text-green-500 flex-shrink-0">
<i class="fas fa-times"></i>
</button>
</div>
@@ -166,5 +178,63 @@
</button>
</twig:block>
</twig:Modal>
<twig:Modal
openTrigger="openPreferredSourcesModal"
closeTrigger="closePreferredSourcesModal"
title="Manage Preferred Sources"
modalClass="w-full max-w-4xl"
>
{% block content %}
<div {{ stimulus_controller('preferred-sources', {
mangaId: manga.id,
preferredSources: manga.preferredSources|map(s => s.id)|json_encode,
allSources: contentSources|map(s => {
id: s.id,
name: s.cleanBaseUrl
})|json_encode
}) }}>
<div>
<h3 class="text-lg font-medium text-gray-900">Preferred Sources</h3>
<ul data-preferred-sources-target="preferredList" class="mt-2 space-y-2">
{% for source in manga.preferredSources %}
<li data-id="{{ source.id }}" draggable="true"
class="flex items-center justify-between p-2 bg-gray-100 rounded cursor-move">
<span>{{ source.cleanBaseUrl }}</span>
<button type="button" data-action="preferred-sources#removeSource"
data-source-id="{{ source.id }}" class="text-red-500 hover:text-red-700">
<i class="fas fa-times"></i>
</button>
</li>
{% endfor %}
</ul>
</div>
<div>
<h3 class="text-lg font-medium text-gray-900">Available Sources</h3>
<ul data-preferred-sources-target="availableList" class="mt-2 space-y-2">
{% for source in contentSources %}
{% if source not in manga.preferredSources %}
<li class="flex items-center justify-between p-2 bg-gray-100 rounded">
<span>{{ source.cleanBaseUrl }}</span>
<button type="button" data-action="preferred-sources#addSource"
data-source-id="{{ source.id }}"
class="text-green-500 hover:text-green-700">
<i class="fas fa-plus"></i>
</button>
</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
{% endblock %}
{% block footer %}
<button type="button" data-action="modal#close"
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm">
Close
</button>
{% endblock %}
</twig:Modal>
{% endblock %}