From 0d5a0325f44b652faf52f3864fd5dbf8ec33bad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A2u=20Cao?= Date: Sat, 24 Jan 2026 16:15:33 +0700 Subject: [PATCH] Allow editing of bookmarks/places --- app/components/icon.gjs | 2 + app/components/place-details.gjs | 106 ++++++++++++++++++++++++++++-- app/components/places-sidebar.gjs | 22 +++++++ app/services/storage.js | 24 +++++-- app/styles/app.css | 70 +++++++++++++++++++- 5 files changed, 207 insertions(+), 17 deletions(-) diff --git a/app/components/icon.gjs b/app/components/icon.gjs index e65be9f..9a70663 100644 --- a/app/components/icon.gjs +++ b/app/components/icon.gjs @@ -5,6 +5,7 @@ import arrowLeft from 'feather-icons/dist/icons/arrow-left.svg?raw'; import activity from 'feather-icons/dist/icons/activity.svg?raw'; import bookmark from 'feather-icons/dist/icons/bookmark.svg?raw'; import clock from 'feather-icons/dist/icons/clock.svg?raw'; +import edit from 'feather-icons/dist/icons/edit.svg?raw'; import globe from 'feather-icons/dist/icons/globe.svg?raw'; import home from 'feather-icons/dist/icons/home.svg?raw'; import logIn from 'feather-icons/dist/icons/log-in.svg?raw'; @@ -25,6 +26,7 @@ const ICONS = { activity, bookmark, clock, + edit, globe, home, 'log-in': logIn, diff --git a/app/components/place-details.gjs b/app/components/place-details.gjs index ff11418..cd722d1 100644 --- a/app/components/place-details.gjs +++ b/app/components/place-details.gjs @@ -4,7 +4,19 @@ import { on } from '@ember/modifier'; import capitalize from '../helpers/capitalize'; import Icon from '../components/icon'; +import { tracked } from '@glimmer/tracking'; +import { action } from '@ember/object'; + export default class PlaceDetails extends Component { + @tracked isEditing = false; + @tracked editTitle = ''; + @tracked editDescription = ''; + + constructor() { + super(...arguments); + this.resetEditFields(); + } + get place() { return this.args.place || {}; } @@ -22,6 +34,47 @@ export default class PlaceDetails extends Component { ); } + @action + resetEditFields() { + this.editTitle = this.name; + this.editDescription = this.place.description || ''; + } + + @action + startEditing() { + if (!this.place.createdAt) return; // Only allow editing saved places + this.resetEditFields(); + this.isEditing = true; + } + + @action + cancelEditing() { + this.isEditing = false; + } + + @action + async saveChanges(event) { + event.preventDefault(); + if (this.args.onSave) { + await this.args.onSave({ + ...this.place, + title: this.editTitle, + description: this.editDescription, + }); + } + this.isEditing = false; + } + + @action + updateTitle(e) { + this.editTitle = e.target.value; + } + + @action + updateDescription(e) { + this.editDescription = e.target.value; + } + get type() { return ( this.tags.amenity || @@ -117,14 +170,41 @@ export default class PlaceDetails extends Component {