mirror of
https://github.com/PeWu/topola-viewer.git
synced 2026-05-26 15:16:14 +00:00
Fix lint warnings
This commit is contained in:
@@ -27,12 +27,13 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
'@typescript-eslint/no-unused-vars': [
|
'@typescript-eslint/no-unused-vars': [
|
||||||
'warn',
|
'error',
|
||||||
{
|
{
|
||||||
argsIgnorePattern: '^_',
|
argsIgnorePattern: '^_',
|
||||||
varsIgnorePattern: '^_',
|
varsIgnorePattern: '^_',
|
||||||
caughtErrorsIgnorePattern: '^_',
|
caughtErrorsIgnorePattern: '^_',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
'@typescript-eslint/no-explicit-any': 'error',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -437,6 +437,7 @@ export function App() {
|
|||||||
setSelection(newSelection);
|
setSelection(newSelection);
|
||||||
setDetailIndi(newSelection.id);
|
setDetailIndi(newSelection.id);
|
||||||
setState(AppState.SHOWING_CHART);
|
setState(AppState.SHOWING_CHART);
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
setState(AppState.SHOWING_CHART);
|
setState(AppState.SHOWING_CHART);
|
||||||
displayErrorPopup(
|
displayErrorPopup(
|
||||||
|
|||||||
@@ -119,9 +119,9 @@ export function convertFams(people: Person[]): JsonFam[] {
|
|||||||
if (husband) {
|
if (husband) {
|
||||||
fam.husb = husband;
|
fam.husb = husband;
|
||||||
}
|
}
|
||||||
fam.children = Array.from(getSet(children, key)).map(
|
fam.children = Array.from(getSet(children, key))
|
||||||
(child) => idToName.get(child)!,
|
.map((child) => idToName.get(child))
|
||||||
);
|
.filter((x) => !!x) as string[];
|
||||||
if (
|
if (
|
||||||
value.spouse &&
|
value.spouse &&
|
||||||
((value.spouse.marriage_date &&
|
((value.spouse.marriage_date &&
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import f3 from 'family-chart';
|
import {
|
||||||
|
Datum,
|
||||||
|
Store,
|
||||||
|
TreeDatum,
|
||||||
|
createStore,
|
||||||
|
createSvg,
|
||||||
|
elements,
|
||||||
|
view,
|
||||||
|
} from 'family-chart';
|
||||||
import {useEffect, useRef} from 'react';
|
import {useEffect, useRef} from 'react';
|
||||||
import {IntlShape, useIntl} from 'react-intl';
|
import {IntlShape, useIntl} from 'react-intl';
|
||||||
import {IndiInfo, JsonFam, JsonGedcomData} from 'topola';
|
import {IndiInfo, JsonFam, JsonGedcomData} from 'topola';
|
||||||
@@ -15,7 +23,7 @@ function getOtherSpouse(fam: JsonFam, indi: string) {
|
|||||||
return fam.husb === indi ? fam.wife : fam.husb;
|
return fam.husb === indi ? fam.wife : fam.husb;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertData(data: JsonGedcomData, intl: IntlShape) {
|
function convertData(data: JsonGedcomData, intl: IntlShape): Datum[] {
|
||||||
const famMap = new Map<string, JsonFam>();
|
const famMap = new Map<string, JsonFam>();
|
||||||
data.fams.forEach((fam) => famMap.set(fam.id, fam));
|
data.fams.forEach((fam) => famMap.set(fam.id, fam));
|
||||||
return data.indis.map((indi) => {
|
return data.indis.map((indi) => {
|
||||||
@@ -25,6 +33,7 @@ function convertData(data: JsonGedcomData, intl: IntlShape) {
|
|||||||
.filter((fam): fam is JsonFam => fam !== undefined);
|
.filter((fam): fam is JsonFam => fam !== undefined);
|
||||||
const father = famc?.husb;
|
const father = famc?.husb;
|
||||||
const mother = famc?.wife;
|
const mother = famc?.wife;
|
||||||
|
const parents = [father, mother].filter((x) => !!x);
|
||||||
const spouses = fams
|
const spouses = fams
|
||||||
.map((fam) => getOtherSpouse(fam, indi.id))
|
.map((fam) => getOtherSpouse(fam, indi.id))
|
||||||
.filter((indi): indi is string => indi !== undefined);
|
.filter((indi): indi is string => indi !== undefined);
|
||||||
@@ -40,40 +49,51 @@ function convertData(data: JsonGedcomData, intl: IntlShape) {
|
|||||||
gender: indi.sex,
|
gender: indi.sex,
|
||||||
},
|
},
|
||||||
rels: {
|
rels: {
|
||||||
father,
|
parents,
|
||||||
mother,
|
|
||||||
spouses,
|
spouses,
|
||||||
children,
|
children,
|
||||||
},
|
},
|
||||||
};
|
} as Datum;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ChartWrapper {
|
class ChartWrapper {
|
||||||
private store?: any;
|
private store!: Store;
|
||||||
|
|
||||||
initializeChart(props: DonatsoChartProps, intl: IntlShape) {
|
initializeChart(props: DonatsoChartProps, intl: IntlShape) {
|
||||||
const data = convertData(props.data, intl);
|
const data = convertData(props.data, intl);
|
||||||
this.store = f3.createStore({
|
this.store = createStore({
|
||||||
data,
|
data,
|
||||||
main_id: props.selection.id,
|
main_id: props.selection.id,
|
||||||
});
|
});
|
||||||
const svg = f3.createSvg(document.querySelector('#dotatsoSvgContainer'));
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const card = f3.elements.Card({
|
const svg = createSvg(document.querySelector('#dotatsoSvgContainer')!);
|
||||||
|
const card = elements.CardSvg({
|
||||||
store: this.store,
|
store: this.store,
|
||||||
svg,
|
svg,
|
||||||
card_display: [
|
card_display: [
|
||||||
(i: any) =>
|
(i: Datum) =>
|
||||||
`${i.data['first name'] || ''} ${i.data['last name'] || ''}`,
|
`${i.data['first name'] || ''} ${i.data['last name'] || ''}`,
|
||||||
(i: any) => `${i.data.birthday || ''}`,
|
(i: Datum) => `${i.data.birthday || ''}`,
|
||||||
],
|
] as any, // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||||
mini_tree: true,
|
mini_tree: true,
|
||||||
link_break: false,
|
link_break: false,
|
||||||
onCardClick: (e: any, d: any) =>
|
onCardClick: (e: MouseEvent, d: TreeDatum) =>
|
||||||
props.onSelection({id: d.data.id, generation: 0}),
|
props.onSelection({id: d.data.id, generation: 0}),
|
||||||
|
card_dim: {
|
||||||
|
w: 220,
|
||||||
|
h: 70,
|
||||||
|
text_x: 75,
|
||||||
|
text_y: 15,
|
||||||
|
img_w: 60,
|
||||||
|
img_h: 60,
|
||||||
|
img_x: 5,
|
||||||
|
img_y: 5,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
this.store.setOnUpdate((props: any) => {
|
this.store.setOnUpdate((props: unknown) => {
|
||||||
f3.view(this.store.getTree(), svg, card, props || {});
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
view(this.store.getTree()!, svg, card, props || {});
|
||||||
});
|
});
|
||||||
this.store.updateTree({initial: true});
|
this.store.updateTree({initial: true});
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/family-chart.d.ts
vendored
8
src/family-chart.d.ts
vendored
@@ -1,8 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
// Data type definitions for the family-chart library.
|
|
||||||
declare module 'family-chart' {
|
|
||||||
export function createStore(args: any): any;
|
|
||||||
export function createSvg(args: any): any;
|
|
||||||
export function view(arg1: any, arg2: any, arg3: any, arg4: any): any;
|
|
||||||
export const elements: any;
|
|
||||||
}
|
|
||||||
@@ -104,7 +104,7 @@ class LunrSearchIndex implements SearchIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private initMultiLingualLunrWithoutTrimmer(
|
private initMultiLingualLunrWithoutTrimmer(
|
||||||
lunrInstance: any,
|
lunrInstance: lunr.Builder,
|
||||||
languages: string[],
|
languages: string[],
|
||||||
): void {
|
): void {
|
||||||
const pipelineFunctions: PipelineFunction[] = [];
|
const pipelineFunctions: PipelineFunction[] = [];
|
||||||
@@ -142,13 +142,16 @@ class LunrSearchIndex implements SearchIndex {
|
|||||||
.filter((s) => !!s)
|
.filter((s) => !!s)
|
||||||
.map((s) => `${s} ${s}*`)
|
.map((s) => `${s} ${s}*`)
|
||||||
.join(' ');
|
.join(' ');
|
||||||
const results = this.index!.search(query);
|
const results = this.index.search(query);
|
||||||
return results
|
return results
|
||||||
.sort(compare)
|
.sort(compare)
|
||||||
.slice(0, MAX_RESULTS)
|
.slice(0, MAX_RESULTS)
|
||||||
.map((result) => ({
|
.map((result) => ({
|
||||||
id: result.ref,
|
id: result.ref,
|
||||||
indi: this.indiMap.get(result.ref)!,
|
indi: this.indiMap.get(result.ref) || {
|
||||||
|
id: result.ref,
|
||||||
|
firstName: 'INDI NOT FOUND',
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user