"use strict"; import classNames from "classnames"; import ResultMixin from "./resultmixin.jsx"; import PropTypes from "prop-types"; import createReactClass from "create-react-class"; import {CSSTransition, TransitionGroup} from "react-transition-group"; var PT = PropTypes; var ZoomedResult = createReactClass({ propTypes: { corpusHit: PT.object, nextResults: PT.func.isRequired, languageMap: PT.object.isRequired, weblichtLanguages: PT.array.isRequired, searchedLanguage: PT.array.isRequired, getDownloadLink: PT.func.isRequired, getToWeblichtLink: PT.func.isRequired, queryTypeId: PT.string.isRequired, }, mixins: [ResultMixin], getInitialState: function() { return { forceUpdate: 1, // hack to force an update, used when searching for next results }; }, nextResults: function(e) { this.props.corpusHit.inProgress = true; this.setState({forceUpdate: this.state.forceUpdate+1}); this.props.nextResults(this.props.corpusHit.corpus.id); }, renderLanguages: function(languages) { return languages .map(function(l) { return this.props.languageMap[l]; }.bind(this)) .sort() .join(", "); }, renderMoreResults:function(){ if (this.props.corpusHit.inProgress) return (Retrieving results, please wait...); var moreResults = true; for (var i = 0; i < this.props.corpusHit.diagnostics.length; i++) { var d = this.props.corpusHit.diagnostics[i]; if (d.uri === window.MyAggregator.NO_MORE_RECORDS_DIAGNOSTIC_URI) { moreResults = false; break; } } if (!moreResults) return (No other results available for this query); return (); }, render: function() { var corpusHit = this.props.corpusHit; if (!corpusHit) { return false; } var forceLanguage = null, wlerror = null; if (this.props.weblichtLanguages.indexOf(this.props.searchedLanguage[0]) < 0) { // the search language is either AnyLanguage or unsupported if (this.props.searchedLanguage[0] === window.MyAggregator.multipleLanguageCode) { if (corpusHit.corpus.languages && corpusHit.corpus.languages.length === 1) { forceLanguage = corpusHit.corpus.languages[0]; } else { var langs = corpusHit.kwics.map(function(kwic) {return kwic.language;}); langs = _.uniq(langs.filter(function(l){ return l !== null; })); if (langs.length === 1) { forceLanguage = langs[0]; } } } if (!forceLanguage) { wlerror = "Cannot use WebLicht: unsupported language ("+this.props.searchedLanguage[1]+")"; } } var corpus = corpusHit.corpus; return (

{corpus.institution.name}

{corpus.description ?

{corpus.description}

: false}

{this.renderLanguages(corpus.languages)}

{this.renderDisplayKWIC()} {this.props.queryTypeId !== "fcs" ? "" : this.renderDisplayADV()}
{this.renderDownloadLinks(corpusHit.corpus.id)}
{this.renderToWeblichtLinks(corpus.id, forceLanguage, wlerror)}
{this.renderPanelBody(corpusHit)}
{ this.renderMoreResults() }
); }, }); module.exports = ZoomedResult;