u_key fuer react key
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
/node_modules
|
/node_modules
|
||||||
|
**/node_modules
|
||||||
/.pnp
|
/.pnp
|
||||||
.pnp.js
|
.pnp.js
|
||||||
|
|
||||||
@ -17,6 +18,7 @@
|
|||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
.env.production.local
|
.env.production.local
|
||||||
|
/.metadata
|
||||||
|
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
yarn-debug.log*
|
yarn-debug.log*
|
||||||
|
|||||||
@ -117,7 +117,7 @@ export class CFlightsProxy {
|
|||||||
public readonly success: boolean;
|
public readonly success: boolean;
|
||||||
public readonly message: string;
|
public readonly message: string;
|
||||||
public readonly meta: MetaProxy;
|
public readonly meta: MetaProxy;
|
||||||
public readonly data: IFlightProxy[] | null;
|
public readonly data: CFlightProxy[] | null;
|
||||||
public static Parse(d: string): CFlightsProxy {
|
public static Parse(d: string): CFlightsProxy {
|
||||||
return CFlightsProxy.Create(JSON.parse(d));
|
return CFlightsProxy.Create(JSON.parse(d));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,6 @@ import {groupByMap} from './global/tools';
|
|||||||
import flights from './data/HoPe_all_flights.json';
|
import flights from './data/HoPe_all_flights.json';
|
||||||
import {CFlight} from './classes/CFlight';
|
import {CFlight} from './classes/CFlight';
|
||||||
import {CSeason} from './classes/CSeason';
|
import {CSeason} from './classes/CSeason';
|
||||||
import {CheckArray} from './tools/tools';
|
|
||||||
|
|
||||||
const data_raw = flights.data;
|
const data_raw = flights.data;
|
||||||
const data: CFlight[] = [];
|
const data: CFlight[] = [];
|
||||||
@ -16,7 +15,6 @@ for (let fl of data_raw)
|
|||||||
{
|
{
|
||||||
data.push(new CFlight(fl));
|
data.push(new CFlight(fl));
|
||||||
}
|
}
|
||||||
CheckArray(data);
|
|
||||||
|
|
||||||
const seasondata_raw = groupByMap(data, i => i.FKSeason);
|
const seasondata_raw = groupByMap(data, i => i.FKSeason);
|
||||||
|
|
||||||
|
|||||||
@ -3,20 +3,20 @@ import SortableTable from "./SortableTable";
|
|||||||
import {THeader} from "./SortableTable";
|
import {THeader} from "./SortableTable";
|
||||||
import {CFlight} from '../classes/CFlight';
|
import {CFlight} from '../classes/CFlight';
|
||||||
|
|
||||||
function Link2Flight(key: string, row: any, data: string | null)
|
function Link2Flight(u_key: string, key: string, row: any, data: string | null)
|
||||||
{
|
{
|
||||||
var val: JSX.Element = <></>;
|
var val: JSX.Element = <></>;
|
||||||
const link: string = 'https://de.dhv-xc.de/flight/' + row['IDFlight'];
|
const link: string = 'https://de.dhv-xc.de/flight/' + row['IDFlight'];
|
||||||
val = <td><a href={link} target="_blank" rel="noopener noreferrer" >{data}</a></td>;
|
val = <td key={u_key}><a href={link} target="_blank" rel="noopener noreferrer" >{data}</a></td>;
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Meter2Km(key: string, row: any, data: string | null)
|
function Meter2Km(u_key: string, key: string, row: any, data: string | null)
|
||||||
{
|
{
|
||||||
var val: JSX.Element = <></>;
|
var val: JSX.Element = <></>;
|
||||||
const numdata: number = +data! / 1000;
|
const numdata: number = +data! / 1000;
|
||||||
val = <td>{numdata}</td>;
|
val = <td key={u_key}>{numdata}</td>;
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { orderBy } from 'natural-orderby';
|
|||||||
import { MouseEventHandler, useState } from "react";
|
import { MouseEventHandler, useState } from "react";
|
||||||
import { IKey } from "../interfaces/IKey";
|
import { IKey } from "../interfaces/IKey";
|
||||||
|
|
||||||
export interface ITableTdCallback {(key: string, row: any, data: string | null): JSX.Element};
|
export interface ITableTdCallback {(u_key: string, key: string, row: any, data: string | null): JSX.Element};
|
||||||
export type THeader = { key: string; label: string; visible?: boolean; callback?: ITableTdCallback };
|
export type THeader = { key: string; label: string; visible?: boolean; callback?: ITableTdCallback };
|
||||||
|
|
||||||
type TSortOrder = "ascn" | "desc";
|
type TSortOrder = "ascn" | "desc";
|
||||||
@ -73,19 +73,19 @@ export default function SortableTable<T extends IKey>({ headers, dataTbl }:
|
|||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
function TableTd({ item, key, row_item, data }
|
function TableTd({ item, u_key, row_item, data }
|
||||||
: {item: THeader, key: number, row_item: T, data: string | null})
|
: {item: THeader, u_key: string, row_item: T, data: string | null})
|
||||||
{
|
{
|
||||||
var val_complete: JSX.Element = <></>;
|
var val_complete: JSX.Element = <></>;
|
||||||
if(item.visible === undefined || item.visible === true)
|
if(item.visible === undefined || item.visible === true)
|
||||||
{
|
{
|
||||||
if(item.callback)
|
if(item.callback)
|
||||||
{
|
{
|
||||||
val_complete = item.callback(item.key, row_item, data);
|
val_complete = item.callback(u_key, item.key, row_item, data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val_complete = (<td key={key}>{data}</td>);
|
val_complete = (<td key={u_key}>{data}</td>);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return val_complete;
|
return val_complete;
|
||||||
@ -95,7 +95,7 @@ export default function SortableTable<T extends IKey>({ headers, dataTbl }:
|
|||||||
{headers, row_item}:
|
{headers, row_item}:
|
||||||
{
|
{
|
||||||
headers: THeader[],
|
headers: THeader[],
|
||||||
row_item: any
|
row_item: T
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
return(
|
return(
|
||||||
@ -104,7 +104,8 @@ export default function SortableTable<T extends IKey>({ headers, dataTbl }:
|
|||||||
headers.map((h_item, key) =>
|
headers.map((h_item, key) =>
|
||||||
{
|
{
|
||||||
var c: any = row_item; // workaround TS2322 TS7053
|
var c: any = row_item; // workaround TS2322 TS7053
|
||||||
return ( <TableTd item={h_item} key={key} row_item={row_item} data={c[h_item.key]}></TableTd> );
|
var unique_key: string = row_item.key + "_" + key;
|
||||||
|
return ( <TableTd item={h_item} u_key={unique_key} row_item={row_item} data={c[h_item.key]}></TableTd> );
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
</tr>
|
</tr>
|
||||||
@ -117,9 +118,8 @@ export default function SortableTable<T extends IKey>({ headers, dataTbl }:
|
|||||||
|
|
||||||
for(var flight of tableDataSorted)
|
for(var flight of tableDataSorted)
|
||||||
{
|
{
|
||||||
var index: number = flight.key;
|
|
||||||
body.push(
|
body.push(
|
||||||
<TableTr headers={headers} key={index} row_item = {flight} />
|
<TableTr headers={headers} row_item = {flight} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user