From ef1e0eaff3be7863dd7ab1eb06689281d45eff55 Mon Sep 17 00:00:00 2001 From: David Straub Date: Thu, 19 Oct 2023 20:49:48 +0200 Subject: [PATCH] Allow editing place type (#146) --- ...ditNoteType.js => GrampsjsFormEditType.js} | 24 +++++--- src/components/GrampsjsNote.js | 8 ++- src/components/GrampsjsObjectForm.js | 6 ++ src/components/GrampsjsPlace.js | 57 ++++++++++++++++++- 4 files changed, 83 insertions(+), 12 deletions(-) rename src/components/{GrampsjsFormEditNoteType.js => GrampsjsFormEditType.js} (57%) diff --git a/src/components/GrampsjsFormEditNoteType.js b/src/components/GrampsjsFormEditType.js similarity index 57% rename from src/components/GrampsjsFormEditNoteType.js rename to src/components/GrampsjsFormEditType.js index 823db830..87868118 100644 --- a/src/components/GrampsjsFormEditNoteType.js +++ b/src/components/GrampsjsFormEditType.js @@ -8,14 +8,27 @@ import './GrampsjsFormSelectType.js' import {GrampsjsObjectForm} from './GrampsjsObjectForm.js' -class GrampsjsFormEditNoteType extends GrampsjsObjectForm { +class GrampsjsFormEditType extends GrampsjsObjectForm { + static get properties() { + return { + formId: {type: String}, + typeName: {type: String}, + } + } + + constructor() { + super() + this.formId = '' + this.typeName = '' + } + renderForm() { return html` - + ` } diff --git a/src/components/GrampsjsObjectForm.js b/src/components/GrampsjsObjectForm.js index f16720aa..52fd85f8 100644 --- a/src/components/GrampsjsObjectForm.js +++ b/src/components/GrampsjsObjectForm.js @@ -289,6 +289,12 @@ export class GrampsjsObjectForm extends GrampsjsTranslateMixin(LitElement) { type: {_class: 'NoteType', string: e.detail.data}, } } + if (originalTarget.id === 'place-type') { + this.data = { + ...this.data, + place_type: {_class: 'PlaceType', string: e.detail.data}, + } + } if (originalTarget.id === 'event-type') { this.data = { ...this.data, diff --git a/src/components/GrampsjsPlace.js b/src/components/GrampsjsPlace.js index 615e36b0..10bb4001 100644 --- a/src/components/GrampsjsPlace.js +++ b/src/components/GrampsjsPlace.js @@ -1,4 +1,4 @@ -import {html} from 'lit' +import {css, html} from 'lit' import '@material/mwc-icon' @@ -10,6 +10,20 @@ import {fireEvent} from '../util.js' const BASE_DIR = '' export class GrampsjsPlace extends GrampsjsObject { + static get styles() { + return [ + super.styles, + css` + :host { + } + + #btn-edit-type { + vertical-align: middle; + } + `, + ] + } + constructor() { super() this._showReferences = false @@ -33,7 +47,19 @@ export class GrampsjsPlace extends GrampsjsObject { ${this.data?.profile?.type - ? html`

${this.data?.profile?.type}

` + ? html`

+ ${this.data?.profile?.type} + ${this.edit + ? html` + + ` + : ''} +

` : ''} ${this.data?.profile?.parent_places.length > 0 ? html` @@ -84,6 +110,33 @@ export class GrampsjsPlace extends GrampsjsObject { ` } + _handleEditType() { + this.dialogContent = html` + + + ` + } + + _handleSaveType(e) { + fireEvent(this, 'edit:action', { + action: 'updateProp', + data: e.detail.data, + }) + e.preventDefault() + e.stopPropagation() + this.dialogContent = '' + } + _handleSaveName(e) { fireEvent(this, 'edit:action', { action: 'updateProp',