import {autobind} from "core-decorators"; import {observer} from "mobx-react"; import * as React from "react"; import Button from "focus-components/button"; import {TopicDisplayer} from "../../../list"; import {SearchStore} from "../../store"; import {injectStyle} from "../../../theming"; import * as styles from "./style/list-summary.css"; export type ListSummaryStyle = Partial; export interface ListSummaryProps { classNames?: ListSummaryStyle; exportAction?: () => void; scopes: {code: string, label: string}[]; scopeLock: boolean; store: SearchStore; } @injectStyle("listSummary") @autobind @observer export class ListSummary extends React.Component { private onScopeClick() { this.props.store.setProperties({ groupingKey: undefined, scope: "ALL", selectedFacets: {} }); } private get scopeLabel() { const {store, scopes} = this.props; const selectedScope = scopes.find(sc => sc.code === store.scope); return selectedScope && selectedScope.label || store.scope; } private get resultSentence() { const {totalCount, query} = this.props.store; const hasText = query && query.trim().length > 0; return ( {totalCount}  {`résultat${totalCount > 1 ? "s" : ""} ${hasText && `pour "${query}"`}`} ); } render() { const {store, exportAction, classNames} = this.props; const scope = store.scope && store.scope !== "ALL" ? {scope: { code: store.scope, label: "Scope", value: this.scopeLabel }} : undefined; return (
{exportAction ?
: null} {this.resultSentence}
); } }