Merge pull request #1193 from rschamp/bugfix/1189

Search view fixes
This commit is contained in:
Ray Schamp 2017-02-21 19:01:58 -05:00 committed by GitHub
commit 201b2ad152
3 changed files with 14 additions and 10 deletions

View file

@ -27,12 +27,12 @@ var Grid = React.createClass({
return ( return (
<div className={classes}> <div className={classes}>
<FlexRow> <FlexRow>
{this.props.items.map(function (item) { {this.props.items.map(function (item, key) {
var href = '/' + this.props.itemType + '/' + item.id + '/'; var href = '/' + this.props.itemType + '/' + item.id + '/';
if (this.props.itemType == 'projects') { if (this.props.itemType == 'projects') {
return ( return (
<Thumbnail key={item.id} <Thumbnail key={key}
showLoves={this.props.showLoves} showLoves={this.props.showLoves}
showFavorites={this.props.showFavorites} showFavorites={this.props.showFavorites}
showRemixes={this.props.showRemixes} showRemixes={this.props.showRemixes}
@ -53,7 +53,7 @@ var Grid = React.createClass({
} }
else { else {
return ( return (
<Thumbnail key={item.id} <Thumbnail key={key}
type={'gallery'} type={'gallery'}
href={href} href={href}
title={item.title} title={item.title}

View file

@ -75,10 +75,12 @@ var Thumbnail = React.createClass({
} }
var imgElement,titleElement,avatarElement; var imgElement,titleElement,avatarElement;
if (this.props.linkTitle) { if (this.props.linkTitle) {
imgElement = <a className="thumbnail-image" href={this.props.href}> imgElement = <a className="thumbnail-image" href={this.props.href} key="imgElement">
<img src={this.props.src} alt={this.props.alt} /> <img src={this.props.src} alt={this.props.alt} />
</a>; </a>;
titleElement = <a href={this.props.href}>{this.props.title}</a>; titleElement = <a href={this.props.href} key="titleElement">
{this.props.title}
</a>;
} else { } else {
imgElement = <img src={this.props.src} />; imgElement = <img src={this.props.src} />;
titleElement = this.props.title; titleElement = this.props.title;

View file

@ -51,14 +51,16 @@ var Search = injectIntl(React.createClass({
while (term.indexOf('&') > -1) { while (term.indexOf('&') > -1) {
term = term.substring(0, term.indexOf('&')); term = term.substring(0, term.indexOf('&'));
} }
term = term.split('+').join(' '); term = decodeURI(term.split('+').join(' '));
this.getSearchMore(); this.props.dispatch(navigationActions.setSearchTerm(term));
this.props.dispatch(navigationActions.setSearchTerm(decodeURI(term))); },
componentDidUpdate: function (prevProps) {
if (this.props.searchTerm !== prevProps.searchTerm) this.getSearchMore();
}, },
getSearchMore: function () { getSearchMore: function () {
var termText = ''; var termText = '';
if (this.props.searchTerm !== '') { if (this.props.searchTerm !== '') {
termText = '&q=' + this.props.searchTerm; termText = '&q=' + encodeURIComponent(this.props.searchTerm.split(' ').join('+'));
} }
api({ api({
uri: '/search/' + this.props.tab + uri: '/search/' + this.props.tab +
@ -76,7 +78,7 @@ var Search = injectIntl(React.createClass({
}.bind(this)); }.bind(this));
}, },
onSearchSubmit: function (formData) { onSearchSubmit: function (formData) {
window.location.href = '/search/projects?q=' + formData.q; window.location.href = '/search/projects?q=' + encodeURIComponent(formData.q);
}, },
getTab: function (type) { getTab: function (type) {
var term = this.props.searchTerm.split(' ').join('+'); var term = this.props.searchTerm.split(' ').join('+');