Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display alternative place names #566

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/GrampsjsObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import './GrampsjsEvents.js'
import './GrampsjsNames.js'
import './GrampsjsPlaceChildren.js'
import './GrampsjsPlaceRefs.js'
import './GrampsjsPlaceNames.js'
import './GrampsjsGallery.js'
import './GrampsjsMap.js'
import './GrampsjsMapMarker.js'
Expand Down Expand Up @@ -59,6 +60,11 @@ const _allTabs = {
('placeref_list' in data && data?.backlinks?.place?.length >= 0),
conditionEdit: data => 'placeref_list' in data,
},
placeNames: {
title: 'Alternate Names',
condition: data => data?.alt_names?.length > 0,
conditionEdit: data => data?.alt_names?.length > 0,
},
map: {
title: 'Map',
condition: data =>
Expand Down Expand Up @@ -369,6 +375,14 @@ export class GrampsjsObject extends GrampsjsTranslateMixin(LitElement) {
?edit=${this.edit}
></grampsjs-names>
`
case 'placeNames':
return html` ${this.data.alt_names?.length > 0
? html` <grampsjs-place-names
.strings="${this.strings}"
.data="${this.data.alt_names}"
?edit=${false}
></grampsjs-place-names>`
: ''}`
case 'enclosed':
return html` ${this.data.placeref_list?.length || this.edit
? html`
Expand Down
34 changes: 34 additions & 0 deletions src/components/GrampsjsPlaceNames.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {html} from 'lit'

import '@material/mwc-icon-button'
import '@material/mwc-dialog'
import '@material/mwc-button'
import {toDate} from '../date.js'
import {dateIsEmpty} from '../util.js'
import {GrampsjsEditableTable} from './GrampsjsEditableTable.js'

export class GrampsjsPlaceNames extends GrampsjsEditableTable {
constructor() {
super()
this.objType = 'PlaceName'
this._columns = ['Name', 'Date', '']
this.dialogContent = ''
this.edit = false
}

row(obj, i, arr) {
return html`
<tr>
<td>${obj.value}</td>
<td>${dateIsEmpty(obj.date) ? '' : toDate(obj.date?.dateval)}</td>
<td>
${false // ${this.edit TODO: implement place name edit

Check warning on line 25 in src/components/GrampsjsPlaceNames.js

View workflow job for this annotation

GitHub Actions / test

Unexpected constant condition
? this._renderActionBtns(obj.ref, i === 0, i === arr.length - 1)
: ''}
</td>
</tr>
`
}
}

window.customElements.define('grampsjs-place-names', GrampsjsPlaceNames)
1 change: 1 addition & 0 deletions src/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export const grampsStrings = [
'Aide',
'Album',
'Also Known As',
'Alternate Names',
'Alternate Marriage',
'Ancestor Tree',
'and',
Expand Down
Loading