Skip to content

[Feature]: Add deletion confirmation when deleting whole collection. #326

@Gamingappleh

Description

@Gamingappleh

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:

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

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions