-
-
Notifications
You must be signed in to change notification settings - Fork 81
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Context
Currently when deleting a whole collection no confirmation is given, so user can accidentally delete whole archive (yup I've done this now multiple times). This is not the case for pages within the collection.
What change would you like to see?
The funciton "onDeleteItem" in UI.js Seems to link to:
archiveweb.page/src/ui/coll-index.ts
Lines 107 to 118 in 26fdca5
| onDeleteColl(event) { | |
| event.preventDefault(); | |
| event.stopPropagation(); | |
| if (!this.sortedItems) { | |
| return; | |
| } | |
| const index = Number(event.currentTarget.getAttribute("data-coll-index")); | |
| this.deleteConfirm = this.sortedItems[index]; | |
| } |
so changing
onDeleteItem(e) {
return i(this, void 0, void 0, (function*() {
if (e.preventDefault(),
e.stopPropagation(),
!this.sortedItems)
return;
const t = Number(e.currentTarget.getAttribute("data-coll-index"))
, i = this.sortedItems[t];
if (!i || this._deleting[i.sourceUrl])
return;
this._deleting[i.sourceUrl] = !0,
this.requestUpdate();
const o = yield fetch(`${De}/c/${i.id}`, {
method: "DELETE"
});
if (200 === o.status) {
const e = yield o.json();
this.items = e.colls
}
return !1
}
))
}
to:
onDeleteItem(e) {
return i(this, void 0, void 0, (function*() {
e.preventDefault();
e.stopPropagation();
// Confirmation dialog added here
if (!window.confirm("Are you sure you want to delete this item?")) {
return !1;
// User cancelled deletion, keep original return style
}
if (!this.sortedItems)
return;
const t = Number(e.currentTarget.getAttribute("data-coll-index"))
, i = this.sortedItems[t];
if (!i || this._deleting[i.sourceUrl])
return;
this._deleting[i.sourceUrl] = !0;
this.requestUpdate();
const o = yield fetch(`${De}/c/${i.id}`, {
method: "DELETE"
});
if (200 === o.status) {
const e = yield o.json();
this.items = e.colls;
}
return !1;
}
));
}
Requirements
No response
Todo
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request