Changeset 7042 for SRUAggregator
- Timestamp:
- 07/27/16 12:43:50 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
SRUAggregator/trunk/src/main/resources/assets/js/search.jsx
r7041 r7042 21 21 var multipleLanguageCode = "mul"; // see ISO-693-3 22 22 23 //var queryTypes = [ 24 var layers = [ 23 var queryTypes = [ 25 24 { 26 25 id: "cql", … … 41 40 ]; 42 41 43 var layerMap = {44 cql: layers[0],45 fcs: layers[1],42 var queryTypeMap = { 43 cql: queryTypes[0], 44 fcs: queryTypes[1], 46 45 }; 46 47 47 // var layers = [ 48 48 // { 49 49 // id: "text", 50 // name: "Text Resources",50 // name: "Text", 51 51 // searchPlaceholder: "Elephant", 52 52 // searchLabel: "Search text", … … 177 177 }; 178 178 179 Corpora.prototype.isCorpusVisible = function(corpus, layerId, languageCode) {180 //if ( layerId !== "text") {179 Corpora.prototype.isCorpusVisible = function(corpus, queryTypeId, languageCode) { 180 //if (queryTypeId !== "text") { 181 181 // return false; 182 182 //} … … 202 202 }; 203 203 204 Corpora.prototype.setVisibility = function( layerId, languageCode) {204 Corpora.prototype.setVisibility = function(queryTypeId, languageCode) { 205 205 // top level 206 206 this.corpora.forEach(function(corpus) { 207 corpus.visible = this.isCorpusVisible(corpus, layerId, languageCode);207 corpus.visible = this.isCorpusVisible(corpus, queryTypeId, languageCode); 208 208 this.recurseCorpora(corpus.subCorpora, function(c) { c.visible = corpus.visible; }); 209 209 }.bind(this)); … … 285 285 languageMap: {}, 286 286 weblichtLanguages: [], 287 queryType: getQueryVariable('queryType') || 'cql',287 queryTypeId: getQueryVariable('queryType') || 'cql', 288 288 query: getQueryVariable('query') || '', 289 289 language: this.anyLanguage, 290 290 languageFilter: 'byMeta', 291 //fixme!292 searchLayerId: getQueryVariable('queryType') || 'cql',293 291 numberOfResults: 10, 294 292 … … 346 344 search: function() { 347 345 var query = this.state.query; 348 var queryType = this.state. searchLayerId;346 var queryType = this.state.queryTypeId; 349 347 if (!query || this.props.embedded) { 350 348 this.setState({ hits: this.nohits, searchId: null }); … … 363 361 type: "POST", 364 362 data: { 365 layer: this.state.searchLayerId, 363 query: query, 364 queryType: queryType, 366 365 language: this.state.language[0], 367 queryType: queryType,368 query: query,369 366 numberOfResults: this.state.numberOfResults, 370 367 corporaIds: selectedIds, … … 452 449 453 450 setLanguageAndFilter: function(languageObj, languageFilter) { 454 this.state.corpora.setVisibility(this.state. searchLayerId,451 this.state.corpora.setVisibility(this.state.queryTypeId, 455 452 languageFilter === 'byGuess' ? multipleLanguageCode : languageObj[0]); 456 453 this.setState({ … … 461 458 }, 462 459 463 set Layer: function(layerId) {464 this.state.corpora.setVisibility( layerId, this.state.language[0]);460 setQueryType: function(queryTypeId) { 461 this.state.corpora.setVisibility(queryTypeId, this.state.language[0]); 465 462 this.setState({ 466 searchLayerId: layerId, 467 queryType: layerId, 463 queryTypeId: queryTypeId, 468 464 hits: this.nohits, 469 465 searchId: null, 470 displayADV: layerId == "fcs" ? true : false,466 displayADV: queryTypeId == "fcs" ? true : false, 471 467 corpora: this.state.corpora, // === this.state.corpora.update(); 472 468 }); … … 573 569 if (this.props.embedded) { 574 570 var query = this.state.query; 575 var queryType = this.state.queryType ;571 var queryType = this.state.queryTypeId; 576 572 var newurl = !query ? "#" : 577 573 (window.MyAggregator.URLROOT + "?" + encodeQueryData({queryType:queryType, query:query, mode:'search'})); … … 591 587 592 588 render: function() { 593 var layer = layerMap[this.state.searchLayerId];589 var queryType = queryTypeMap[this.state.queryTypeId]; 594 590 return ( 595 591 <div className="top-gap"> … … 597 593 <div className="aligncenter" style={{marginLeft:16, marginRight:16}}> 598 594 <div className="input-group"> 599 <span className="input-group-addon" style={{backgroundColor: layer.searchLabelBkColor}}>600 { layer.searchLabel}595 <span className="input-group-addon" style={{backgroundColor:queryType.searchLabelBkColor}}> 596 {queryType.searchLabel} 601 597 </span> 602 598 … … 627 623 </div> 628 624 <div className="input-group-btn hidden-xxs"> 629 <ul ref=" layerDropdownMenu" className="dropdown-menu">630 { layers.map(function(l) {625 <ul ref="queryTypeDropdownMenu" className="dropdown-menu"> 626 { queryTypes.map(function(l) { 631 627 var cls = l.disabled ? 'disabled':''; 632 var handler = function() { if (!l.disabled) this.set Layer(l.id); }.bind(this);628 var handler = function() { if (!l.disabled) this.setQueryType(l.id); }.bind(this); 633 629 return <li key={l.id} className={cls}> <a tabIndex="-1" href="#" 634 630 onClick={handler}> {l.name} </a></li>; … … 638 634 <button className="form-control btn btn-default" 639 635 aria-expanded="false" data-toggle="dropdown" > 640 { layer.name} <span className="caret"/>636 {queryType.name} <span className="caret"/> 641 637 </button> 642 638 </div> … … 686 682 weblichtLanguages={this.state.weblichtLanguages} 687 683 languageMap={this.state.languageMap} 688 queryType ={this.state.queryType} />684 queryTypeId={this.state.queryTypeId} /> 689 685 </Modal> 690 686 … … 695 691 getToWeblichtLink={this.getToWeblichtLink} 696 692 searchedLanguage={this.state.language} 697 queryType ={this.state.queryType}/>693 queryTypeId={this.state.queryTypeId}/> 698 694 </div> 699 695 </div> … … 994 990 getDownloadLink: PT.func.isRequired, 995 991 getToWeblichtLink: PT.func.isRequired, 996 queryType : PT.string.isRequired,992 queryTypeId: PT.string.isRequired, 997 993 }, 998 994 mixins: [ResultMixin], … … 1073 1069 <div> 1074 1070 {this.renderDisplayKWIC()} 1075 {this.props.queryType !== "fcs" ? "" : this.renderDisplayADV()}1071 {this.props.queryTypeId !== "fcs" ? "" : this.renderDisplayADV()} 1076 1072 <div className="inline"> {this.renderDownloadLinks(corpusHit.corpus.id)} </div> 1077 1073 <div className="inline"> {this.renderToWeblichtLinks(corpus.id, forceLanguage, wlerror)} </div> … … 1100 1096 getDownloadLink: PT.func.isRequired, 1101 1097 getToWeblichtLink: PT.func.isRequired, 1102 queryType : PT.string.isRequired,1098 queryTypeId: PT.string.isRequired, 1103 1099 }, 1104 1100 mixins: [ResultMixin], … … 1170 1166 <div> 1171 1167 {this.renderDisplayKWIC()} 1172 {this.props.queryType !== "fcs" ? "" : this.renderDisplayADV()}1168 {this.props.queryTypeId !== "fcs" ? "" : this.renderDisplayADV()} 1173 1169 { collhits.inProgress === 0 ? 1174 1170 <div className="inline"> {this.renderDownloadLinks()} </div>
Note: See TracChangeset
for help on using the changeset viewer.