Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[search] Add message if no result #101

Merged
merged 1 commit into from
Jun 12, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions page/search/common/group-by-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@ let ArgumentNullException = require('focus').exception.ArgumentNullException;
let SingleGroupComponent = require('./single-group-component').component;
let ListSelection = require('../../../list/selection').list.component;

// Mixins

let i18nMixin = require('../../../common/i18n/mixin');

/**
* Mixin used in order to create a block.
* @type {Object}
*/
let GroupByMixin = {
mixins: [i18nMixin],
/**
* Init default props.
* @returns {object} Default props.
Expand All @@ -40,11 +45,15 @@ let GroupByMixin = {
};
},
getResultListComponent(advancedSearch) {
// First check if there is any result
if (this.state.totalRecords === 0) {
return this._getEmptyResultList();
}
let isBounded = keys(this.state.map).length > 1;
let noDecoration = keys(this.state.map).length === 1;
if (noDecoration && advancedSearch) {
let groupKey = keys(this.state.map)[0];
return this.getSingleTypeResultList(groupKey, this.state.map[groupKey], isBounded && this.props.groupMaxRows);
return this._getSingleTypeResultList(groupKey, this.state.map[groupKey], isBounded && this.props.groupMaxRows);
} else {
let groupList = keys(this.state.map).map((groupKey) => {
return (
Expand All @@ -62,7 +71,10 @@ let GroupByMixin = {
return groupList;
}
},
getSingleTypeResultList(groupKey, list, maxRows) {
_getSingleTypeResultList(groupKey, list, maxRows) {
if (list.length === 0) {
return this._getEmptyResultList();
}
if (maxRows) {
list = list.slice(0, maxRows);
}
Expand All @@ -85,11 +97,18 @@ let GroupByMixin = {
/>
);
},
_getEmptyResultList() {
return (
<div data-focus='empty-result'>
{this.i18n('search.empty')}
</div>
);
},
renderGroupByBlock(groupKey, list, maxRows) {
let GroupWrapper = this.props.groupComponent;
return (
<GroupWrapper data-focus="group-result-container" groupKey={groupKey} query={this.state.query} showAll={this.changeGroupByMaxRows}>
{this.getSingleTypeResultList(groupKey, list, maxRows)}
{this._getSingleTypeResultList(groupKey, list, maxRows)}
</GroupWrapper>
);
}
Expand Down