Skip to content

Commit

Permalink
[search] Make empty component a prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Bernardstanislas committed Jun 13, 2015
1 parent 7330021 commit 71e1557
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
18 changes: 8 additions & 10 deletions page/search/common/group-by-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ let GroupByMixin = {
orderableColumnList: {},
lineComponentMapper() {
throw new ArgumentNullException('Please provide a inferLineComponentFromList(list) function.');
}
},
emptyComponent: (

This comment has been minimized.

Copy link
@pierr

pierr Jun 13, 2015

Contributor

I would have done

let NoRsultComponent = React.createClass({render(){
  return <div data-focus='empty-result'>
{this.i18n('search.empty')}
            </div>
})
yourmixin= {
  emptyComponent: NoRsultComponent
//Later
renderResult(){
if (this.state.totalRecords === 0) {
             return <this.props.emptyComponent />;
}
}
}

This comment has been minimized.

Copy link
@pierr

pierr Jun 13, 2015

Contributor

This way the can specify an other Component

This comment has been minimized.

Copy link
@Bernardstanislas

Bernardstanislas Jun 13, 2015

Author Contributor

Yes you're right

<div data-focus='empty-result'>
{this.i18n('search.empty')}
</div>
)
});
},
/**
Expand All @@ -47,7 +52,7 @@ let GroupByMixin = {
getResultListComponent(advancedSearch) {
// First check if there is any result
if (this.state.totalRecords === 0) {
return this._getEmptyResultList();
return this.props.emptyComponent;
}
let isBounded = keys(this.state.map).length > 1;
let noDecoration = keys(this.state.map).length === 1;
Expand All @@ -73,7 +78,7 @@ let GroupByMixin = {
},
_getSingleTypeResultList(groupKey, list, maxRows) {
if (list.length === 0) {
return this._getEmptyResultList();
return this.emptyComponent;
}
if (maxRows) {
list = list.slice(0, maxRows);
Expand All @@ -97,13 +102,6 @@ let GroupByMixin = {
/>
);
},
_getEmptyResultList() {
return (
<div data-focus='empty-result'>
{this.i18n('search.empty')}
</div>
);
},
renderGroupByBlock(groupKey, list, maxRows) {
let GroupWrapper = this.props.groupComponent;
return (
Expand Down
6 changes: 6 additions & 0 deletions page/search/common/search-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ let SearchMixin = {
if(!isFunction(this.props.searchAction)){
console.warn(`Your page seems to miss a search action, add in your props a {searchAction: function(scope, query, facets){}}`, this.props.searchAction);
}
<<<<<<< Updated upstream
=======
return this._buildSearchCriteria(this.state.scope, this.state.query, facets);
},

This comment has been minimized.

Copy link
@pierr

pierr Jun 13, 2015

Contributor

strange...

This comment has been minimized.

Copy link
@Bernardstanislas

Bernardstanislas Jun 13, 2015

Author Contributor

oups sorry, there were some conflicts

search() {
>>>>>>> Stashed changes
this.props.searchAction(
this.getSearchCriteria(this.state.scope, this.state.query, facets)
);
Expand Down

0 comments on commit 71e1557

Please sign in to comment.