import { BaseComponent } from '@uifabric/utilities/lib'; import { DetailsList, IDetailsListProps } from 'office-ui-fabric-react/lib-commonjs/DetailsList'; import * as React from 'react'; import { asyncState } from '../decorators/asyncState'; import { AsyncComponentState, AsyncState, IAsyncComponent } from '../models'; import { WithRouter } from '../withRouter'; export interface ListAttributes { items: T[]; selectedItem: T; rollbackItem: T; } export interface ListActions { list(asyncKey: Symbol); beginInsert(asyncKey: Symbol); commit(asyncKey: Symbol, item: T); delete(asyncKey: Symbol, item: T); discardEdit(asyncKey: Symbol, item: T); filterBy(asyncKey: Symbol, key: keyof T, val: any); } export type ListBaseProps = ListAttributes & ListActions; export type ListProps = ListBaseProps & WithRouter> & //tslint:disable-next-line ({ componentRef?: (x: IAsyncComponent) => void } | IDetailsListProps); /** * generic list view */ @asyncState export class GenericList extends BaseComponent, AsyncComponentState> { constructor(props: ListProps) { super(props); this.state = { ...this.state, asyncState: AsyncState.loading }; } public render(): JSX.Element { const { componentRef, ...listProps } = this.props; return (
{this.renderLoading()}
); } private renderLoading(): JSX.Element { if (this.state.asyncState === AsyncState.loading) { return

Loading...

; } return null; } }