- fix progressbar
- {slug} {chapterNumber} in Url
- activity toolbar
This commit is contained in:
Jérémy Guillot
2024-07-07 15:25:12 +02:00
parent 54c581b229
commit 4672886a67
15 changed files with 183 additions and 59 deletions

View File

@@ -1,20 +1,24 @@
// assets/controllers/toolbar_controller.js
import { Controller } from "@hotwired/stimulus"
import { visit } from "@hotwired/turbo"
export default class extends Controller {
static targets = ["dropdown", "icon"]
static values = {
currentSort: String,
currentOrder: String,
currentStatus: String
currentStatus: String,
mangaId: Number
}
connect() {
window.addEventListener('alert:show', this.stopLoading.bind(this));
}
stopLoading() {
this.iconTarget.classList.remove('fa-spin');
stopLoading(event) {
if(event.currentTarget.dataset !== undefined){
this.iconTarget.classList.remove('fa-spin');
}
}
refreshMetadata(event) {
@@ -65,6 +69,36 @@ export default class extends Controller {
document.dispatchEvent(event);
}
confirmDelete(event) {
event.preventDefault();
const url = `/manga/delete/${this.mangaIdValue}`;
fetch(url, {
method: 'DELETE',
headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json',
}
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.success) {
visit('/', {});
} else {
throw new Error(data.error);
}
})
.catch(error => {
console.error('Error:', error);
// Show error message to user
});
}
showOptions() {
console.log("Showing options...");
}