mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-05-27 07:36:18 +00:00
Don't display items in details panel with only a reference (#13)
This commit is contained in:
@@ -13,7 +13,7 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const EVENT_TAGS = ['BIRT', 'BAPM', 'CHR', 'DEAT', 'BURI'];
|
const EVENT_TAGS = ['BIRT', 'BAPM', 'CHR', 'DEAT', 'BURI'];
|
||||||
const EXCLUDED_TAGS = ['NAME', 'SEX', 'FAMC', 'FAMS', 'SOUR', 'NOTE'];
|
const EXCLUDED_TAGS = ['NAME', 'SEX', 'FAMC', 'FAMS', 'NOTE'];
|
||||||
const TAG_DESCRIPTIONS = new Map([
|
const TAG_DESCRIPTIONS = new Map([
|
||||||
['BAPM', 'Baptism'],
|
['BAPM', 'Baptism'],
|
||||||
['BIRT', 'Birth'],
|
['BIRT', 'Birth'],
|
||||||
@@ -152,12 +152,22 @@ function getDetails(
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if there is displayable information in this entry.
|
||||||
|
* Returns false if there is no data in this entry or this is only a reference
|
||||||
|
* to another entry.
|
||||||
|
*/
|
||||||
|
function hasData(entry: GedcomEntry) {
|
||||||
|
return entry.tree.length > 0 || (entry.data && !entry.data.startsWith('@'));
|
||||||
|
}
|
||||||
|
|
||||||
function getOtherDetails(entries: GedcomEntry[]) {
|
function getOtherDetails(entries: GedcomEntry[]) {
|
||||||
return entries
|
return entries
|
||||||
.filter(
|
.filter(
|
||||||
(entry) =>
|
(entry) =>
|
||||||
!EXCLUDED_TAGS.includes(entry.tag) && !EVENT_TAGS.includes(entry.tag),
|
!EXCLUDED_TAGS.includes(entry.tag) && !EVENT_TAGS.includes(entry.tag),
|
||||||
)
|
)
|
||||||
|
.filter(hasData)
|
||||||
.map((entry) => dataDetails(entry))
|
.map((entry) => dataDetails(entry))
|
||||||
.filter((element) => element !== null)
|
.filter((element) => element !== null)
|
||||||
.map((element, index) => (
|
.map((element, index) => (
|
||||||
@@ -175,6 +185,7 @@ export class Details extends React.Component<Props, {}> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const entries = this.props.gedcom.indis[this.props.indi].tree;
|
const entries = this.props.gedcom.indis[this.props.indi].tree;
|
||||||
|
const entriesWithData = entries.filter(hasData);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="ui segments" id="details">
|
<div className="ui segments" id="details">
|
||||||
@@ -182,8 +193,8 @@ export class Details extends React.Component<Props, {}> {
|
|||||||
{getDetails(entries, EVENT_TAGS, (entry) =>
|
{getDetails(entries, EVENT_TAGS, (entry) =>
|
||||||
eventDetails(entry, this.context.intl as InjectedIntl),
|
eventDetails(entry, this.context.intl as InjectedIntl),
|
||||||
)}
|
)}
|
||||||
{getOtherDetails(entries)}
|
{getOtherDetails(entriesWithData)}
|
||||||
{getDetails(entries, ['NOTE'], noteDetails)}
|
{getDetails(entriesWithData, ['NOTE'], noteDetails)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user