mirror of
https://github.com/sissbruecker/linkding.git
synced 2025-08-14 14:09:26 +02:00
Add bookmark details view (#665)
* 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
This commit is contained in:
38
bookmarks/frontend/behaviors/bookmark-details.js
Normal file
38
bookmarks/frontend/behaviors/bookmark-details.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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);
|
Reference in New Issue
Block a user