Skip to content

Commit

Permalink
RelationshipChart: make maxImages configurable (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
geostag authored Nov 10, 2024
1 parent a218443 commit 56a60e5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/components/GrampsjsRelationshipChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class GrampsjsRelationshipChart extends GrampsjsChartBase {
return {
grampsId: {type: String},
nAnc: {type: Number},
nMaxImages: {type: Number},
gapX: {type: Number},
}
}
Expand All @@ -56,6 +57,7 @@ class GrampsjsRelationshipChart extends GrampsjsChartBase {
return html`
${RelationshipChart(this.data, {
nAnc: this.nAnc,
maxImages: this.nMaxImages,
grampsId: this.grampsId,
getImageUrl: d => getImageUrl(d?.data || {}, 200),
gapX: this.gapX,
Expand Down
2 changes: 2 additions & 0 deletions src/views/GrampsjsViewRelationshipChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class GrampsjsViewRelationshipChart extends GrampsjsViewTreeChartBase {
super()
this.nAnc = 2
this._setSep = true
this._setMaxImages = true
this.color = ''
}

Expand All @@ -43,6 +44,7 @@ export class GrampsjsViewRelationshipChart extends GrampsjsViewTreeChartBase {
<grampsjs-relationship-chart
grampsId=${this.grampsId}
nAnc=${this.nAnc + 1}
nMaxImages=${this.nMaxImages}
.data=${this._data}
>
</grampsjs-relationship-chart>
Expand Down
30 changes: 28 additions & 2 deletions src/views/GrampsjsViewTreeChartBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
}
#menu-controls mwc-textfield {
width: 4em;
width: 6em;
}
`,
]
Expand All @@ -55,9 +55,11 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
disableHome: {type: Boolean},
nAnc: {type: Number},
nDesc: {type: Number},
nMaxImages: {type: Number},
_data: {type: Array},
_setAnc: {type: Boolean},
_setDesc: {type: Boolean},
_setMaxImages: {type: Boolean},
}
}

Expand All @@ -66,12 +68,14 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
this.grampsId = ''
this.nAnc = 3
this.nDesc = 1
this.nMaxImages = 50
this.disableBack = false
this.disableHome = false
this._data = []
this._setAnc = false
this._setDesc = false
this._setSep = false
this._setMaxImages = false
}

renderContent() {
Expand Down Expand Up @@ -176,6 +180,23 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
</tr>
`
: ''
}${
this._setMaxImages
? html`
<tr>
<td>${this._('Max Number of Images displayed')}</td>
<td>
<mwc-textfield
value=${this.nMaxImages}
type="number"
min="0"
size="5"
@change=${this._handleChangeMaxImages}
></mwc-textfield>
</td>
</tr>
`
: ''
}
</table>
<mwc-button slot="primaryAction" dialogAction="close"
Expand Down Expand Up @@ -208,7 +229,8 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
if (
changed.has('grampsId') ||
changed.has('nAnc') ||
changed.has('nDesc')
changed.has('nDesc') ||
changed.has('nMaxImages')
) {
this._fetchData(this.grampsId)
}
Expand Down Expand Up @@ -267,6 +289,10 @@ export class GrampsjsViewTreeChartBase extends GrampsjsView {
this.nDesc = parseInt(e.target.value, 10)
}

_handleChangeMaxImages(e) {
this.nMaxImages = parseInt(e.target.value, 10)
}

_openMenuControls() {
const menu = this.shadowRoot.getElementById('menu-controls')
menu.open = true
Expand Down

0 comments on commit 56a60e5

Please sign in to comment.