84 lines
1.7 KiB
JavaScript
84 lines
1.7 KiB
JavaScript
// assets/controllers/toolbar_controller.js
|
|
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["dropdown"]
|
|
static values = {
|
|
currentSort: String,
|
|
currentOrder: String,
|
|
currentStatus: String
|
|
}
|
|
|
|
refreshMetadata() {
|
|
console.log("Refreshing...");
|
|
}
|
|
|
|
searchLastChapter() {
|
|
console.log("Searching last chapter...");
|
|
}
|
|
|
|
import() {
|
|
console.log("Importing...");
|
|
}
|
|
|
|
editMangas() {
|
|
console.log("Editing mangas...");
|
|
}
|
|
|
|
editManga() {
|
|
console.log("Editing manga...");
|
|
}
|
|
|
|
deleteMangas() {
|
|
console.log("Deleting mangas...");
|
|
}
|
|
|
|
deleteManga() {
|
|
console.log("Deleting manga...");
|
|
}
|
|
|
|
showOptions() {
|
|
console.log("Showing options...");
|
|
}
|
|
|
|
changeView(event) {
|
|
event.preventDefault();
|
|
const viewOption = event.currentTarget.dataset.view;
|
|
|
|
const url = new URL(window.location);
|
|
url.searchParams.set('view', viewOption);
|
|
|
|
window.location = url.toString();
|
|
}
|
|
|
|
sort(event) {
|
|
event.preventDefault()
|
|
const sortOption = event.currentTarget.dataset.sort;
|
|
let order = 'asc';
|
|
|
|
if (sortOption === this.currentSortValue && this.currentOrderValue === 'asc') {
|
|
order = 'desc';
|
|
}
|
|
|
|
const url = new URL(window.location);
|
|
url.searchParams.set('sort', sortOption);
|
|
url.searchParams.set('order', order);
|
|
|
|
window.location = url.toString();
|
|
}
|
|
|
|
filter(event) {
|
|
event.preventDefault();
|
|
const filterOption = event.currentTarget.dataset.filter;
|
|
|
|
const url = new URL(window.location);
|
|
url.searchParams.set('status', filterOption);
|
|
|
|
// Réinitialiser la page à 1 si on utilise la pagination
|
|
// url.searchParams.set('page', '1');
|
|
|
|
window.location = url.toString();
|
|
}
|
|
|
|
}
|