Remove confirmation dialog when deleting place bookmarks

This commit is contained in:
2026-03-13 13:27:01 +04:00
parent bcb9b20e85
commit a8613ab81a
3 changed files with 33 additions and 48 deletions

View File

@@ -25,10 +25,8 @@ export default class PlaceListsManager extends Component {
@action
async toggleSaved() {
if (this.isSaved) {
if (confirm(`Remove "${this.args.place.title}" from saved places?`)) {
await this.storage.removePlace(this.args.place);
if (this.args.onClose) this.args.onClose();
}
await this.storage.removePlace(this.args.place);
if (this.args.onClose) this.args.onClose();
} else {
await this.storage.storePlace(this.args.place);
}

View File

@@ -51,40 +51,39 @@ export default class PlacesSidebar extends Component {
if (!place) return;
if (place.createdAt) {
if (confirm(`Delete "${place.title}"?`)) {
try {
await this.storage.removePlace(place);
console.debug('Place deleted:', place.title);
// Direct delete without confirmation
try {
await this.storage.removePlace(place);
console.debug('Place deleted:', place.title);
// Notify parent to refresh map bookmarks
if (this.args.onBookmarkChange) {
this.args.onBookmarkChange();
}
if (this.args.onUpdate) {
// Reconstruct the "original" place without ID/Geohash/CreatedAt
const freshPlace = {
...place,
id: undefined,
geohash: undefined,
createdAt: undefined,
};
this.args.onUpdate(freshPlace);
}
// Also fire onSelect if it exists (for list view)
if (this.args.onSelect) {
this.args.onSelect(null);
}
// Close sidebar after delete
if (this.args.onClose) {
this.args.onClose();
}
} catch (e) {
console.error('Failed to delete:', e);
alert('Failed to delete: ' + e.message);
// Notify parent to refresh map bookmarks
if (this.args.onBookmarkChange) {
this.args.onBookmarkChange();
}
if (this.args.onUpdate) {
// Reconstruct the "original" place without ID/Geohash/CreatedAt
const freshPlace = {
...place,
id: undefined,
geohash: undefined,
createdAt: undefined,
};
this.args.onUpdate(freshPlace);
}
// Also fire onSelect if it exists (for list view)
if (this.args.onSelect) {
this.args.onSelect(null);
}
// Close sidebar after delete
if (this.args.onClose) {
this.args.onClose();
}
} catch (e) {
console.error('Failed to delete:', e);
alert('Failed to delete: ' + e.message);
}
} else {
// It's a fresh POI -> Save it

View File

@@ -127,14 +127,6 @@ module('Integration | Component | place-details', function (hooks) {
test('it handles removing a saved place via master toggle', async function (assert) {
let removedPlace = null;
let confirmCalled = false;
// Mock confirm
const originalConfirm = window.confirm;
window.confirm = () => {
confirmCalled = true;
return true;
};
class MockStorage extends Service {
lists = [];
@@ -168,11 +160,7 @@ module('Integration | Component | place-details', function (hooks) {
// Click it to remove
await click(masterToggle);
assert.ok(confirmCalled, 'confirm dialog was shown');
assert.strictEqual(removedPlace.id, 'saved-id', 'removePlace was called');
// Restore confirm
window.confirm = originalConfirm;
});
test('it adds place to a list', async function (assert) {