mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-13 21:49:26 +02:00

* Experiment with bookmark details * Add basic tests * Refactor details into modal * Implement edit and delete button * Remove slide down animation * Add fallback details view * Add status actions * Improve dark theme * Improve return URLs * Make bookmark details sharable * Fix E2E tests
39 lines
958 B
JavaScript
39 lines
958 B
JavaScript
import { registerBehavior } from "./index";
|
|
|
|
class BookmarkDetails {
|
|
constructor(element) {
|
|
this.form = element.querySelector(".status form");
|
|
if (!this.form) {
|
|
// Form may not exist if user does not own the bookmark
|
|
return;
|
|
}
|
|
this.form.addEventListener("submit", (event) => {
|
|
event.preventDefault();
|
|
this.submitForm();
|
|
});
|
|
|
|
const inputs = this.form.querySelectorAll("input");
|
|
inputs.forEach((input) => {
|
|
input.addEventListener("change", () => {
|
|
this.submitForm();
|
|
});
|
|
});
|
|
}
|
|
|
|
async submitForm() {
|
|
const url = this.form.action;
|
|
const formData = new FormData(this.form);
|
|
|
|
await fetch(url, {
|
|
method: "POST",
|
|
body: formData,
|
|
redirect: "manual", // ignore redirect
|
|
});
|
|
|
|
// Refresh bookmark page if it exists
|
|
document.dispatchEvent(new CustomEvent("bookmark-page-refresh"));
|
|
}
|
|
}
|
|
|
|
registerBehavior("ld-bookmark-details", BookmarkDetails);
|