Skip to content
Open
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
13 changes: 2 additions & 11 deletions src/components/GrampsjsEditGender.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {

import './GrampsjsIcon.js'
import {sharedStyles} from '../SharedStyles.js'
import {fireEvent, apiVersionAtLeast} from '../util.js'
import {fireEvent} from '../util.js'

const icons = {
0: mdiGenderFemale,
Expand All @@ -19,9 +19,6 @@ const icons = {
3: mdiGenderNonBinary,
}

const newGenderBasic = {0: 1, 1: 2, 2: 0}
const newGenderFull = {0: 1, 1: 2, 2: 3, 3: 0}

export class GrampsjsEditGender extends LitElement {
static get styles() {
return [sharedStyles]
Expand All @@ -31,19 +28,13 @@ export class GrampsjsEditGender extends LitElement {
return {
gender: {type: Number},
edit: {type: Boolean},
appState: {type: Object},
}
}

constructor() {
super()
this.gender = 2 // unknown
this.edit = false
this.appState = {}
}

_supportsOther() {
return apiVersionAtLeast(this.appState?.dbInfo, 3, 10)
}

render() {
Expand All @@ -58,7 +49,7 @@ export class GrampsjsEditGender extends LitElement {
}

_handleClick() {
const cycle = this._supportsOther() ? newGenderFull : newGenderBasic
const cycle = {0: 1, 1: 2, 2: 3, 3: 0}
fireEvent(this, 'edit:action', {
Comment thread
DavidMStraub marked this conversation as resolved.
action: 'updateProp',
data: {gender: cycle[this.gender] ?? 0},
Expand Down
1 change: 0 additions & 1 deletion src/components/GrampsjsPerson.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export class GrampsjsPerson extends GrampsjsObject {
<grampsjs-edit-gender
?edit="${this.edit}"
gender="${this.data.gender}"
.appState="${this.appState}"
></grampsjs-edit-gender>
${this._displayName()}
</h2>
Expand Down
7 changes: 2 additions & 5 deletions src/mixins/GrampsjsNewPersonMixin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {html} from 'lit'

import {makeHandle, dateIsEmpty, emptyDate, apiVersionAtLeast} from '../util.js'
import {makeHandle, dateIsEmpty, emptyDate} from '../util.js'

import '../components/GrampsjsFormSelectObjectList.js'
import '../components/GrampsjsFormSelectDate.js'
Expand All @@ -17,10 +17,7 @@ export const GrampsjsNewPersonMixin = superClass =>
}

get gender() {
const options = {2: 'Unknown', 1: 'Male', 0: 'Female'}
if (apiVersionAtLeast(this.appState?.dbInfo, 3, 10)) {
options[3] = 'Other'
}
const options = {2: 'Unknown', 1: 'Male', 0: 'Female', 3: 'Other'}
return options
Comment thread
DavidMStraub marked this conversation as resolved.
}

Expand Down
6 changes: 1 addition & 5 deletions src/views/GrampsjsViewFamily.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {html} from 'lit'

import {GrampsjsViewObject} from './GrampsjsViewObject.js'
import {apiVersionAtLeast} from '../util.js'
import '../components/GrampsjsFamily.js'

export class GrampsjsViewFamily extends GrampsjsViewObject {
Expand All @@ -11,12 +10,9 @@ export class GrampsjsViewFamily extends GrampsjsViewObject {
}

getUrl() {
const precision = apiVersionAtLeast(this.appState.dbInfo, 3, 10)
? '&precision=1'
: ''
return `/api/families/?gramps_id=${this.grampsId}&locale=${
this.appState.i18n.lang || 'en'
}&profile=all&backlinks=true&extend=all${precision}`
}&profile=all&backlinks=true&extend=all&precision=1`
}
Comment thread
DavidMStraub marked this conversation as resolved.

renderElement() {
Expand Down
8 changes: 2 additions & 6 deletions src/views/GrampsjsViewPerson.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {html} from 'lit'

import {GrampsjsViewObject} from './GrampsjsViewObject.js'
import {apiVersionAtLeast, fireEvent} from '../util.js'
import {fireEvent} from '../util.js'
import '../components/GrampsjsPerson.js'

export class GrampsjsViewPerson extends GrampsjsViewObject {
Expand Down Expand Up @@ -68,13 +68,9 @@ export class GrampsjsViewPerson extends GrampsjsViewObject {
}

getUrl() {
// the precision key for displaying age is only supported since Gramps Web API v3.10
const precision = apiVersionAtLeast(this.appState.dbInfo, 3, 10)
? '&precision=1'
: ''
return `/api/people/?gramps_id=${this.grampsId}&locale=${
this.appState.i18n.lang || 'en'
}&profile=all&backlinks=true&extend=all${precision}`
}&profile=all&backlinks=true&extend=all&precision=1`
}
Comment thread
DavidMStraub marked this conversation as resolved.

renderElement() {
Expand Down
Loading