Skip to content
This repository has been archived by the owner on Aug 27, 2018. It is now read-only.

Commit

Permalink
[Pagination] add pagination and ungroup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephrame committed Dec 30, 2016
1 parent f7cf7c3 commit da3ed54
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "focus-search",
"version": "3.0.1-beta1",
"version": "3.0.1-beta5",
"description": "Serach FOCUS",
"main": "src/index.js",
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/behaviours/paginate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {PropTypes, PureComponent} from 'react';
import {slice, set} from 'lodash';
import Button from 'focus-components/button';
import i18next from 'i18next';

export default () => {
return (ComponentToConnect) => {
Expand Down Expand Up @@ -28,18 +29,17 @@ export default () => {
}
render() {
const {top} = this.state;
const {totalCount, isOtherAction} = this.props;
const {totalCount, isOtherAction, data} = this.props;
return (
<div data-focus='list-with-pagination'>
<ComponentToConnect {...this.props} />
<div data-focus='pagination'>
<div data-focus='pagination-indicators'>{top} / {totalCount}</div>
<div data-focus='pagination-indicators'>{data.length < top ? data.length : top} {i18next.t(`search.paginate.totalCount`)}</div>
<div data-focus='pagination__actions'>
{!isOtherAction && <Button data-focus='paginate.show.next' label='focus.application.paginate.show.next' onClick={this._onClickNext} />}
{isOtherAction && <Button data-focus='paginate.other.action' label='focus.application.paginate.other.action' onClick={this._otherAction} />}
{!isOtherAction && <Button data-focus='paginate.show.next' label='search.paginate.show.next' onClick={this._onClickNext} />}
{isOtherAction && <Button data-focus='paginate.other.action' label='search.paginate.other.action' onClick={this._otherAction} />}
</div>
</div>
<Button className='tsonga' label='bonjour' />
</div>
);
}
Expand Down
11 changes: 7 additions & 4 deletions src/behaviours/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {map} from 'lodash/map';
import isArray from 'lodash/isArray';
import isUndefined from 'lodash/isUndefined';
import {loadLine} from '../actions/single-action-creator';
import {get, set} from 'lodash';
import {get, set, omit, keys} from 'lodash';


const SEARCH_CONTEXT_TYPE = {
Expand Down Expand Up @@ -48,10 +48,11 @@ export function getResultsForGroup(groups, searchMetadata){
});
};

export function getResultsForList(list = [], searchMetadata, listType) {
export function getResultsForList(list = [], searchMetadata, listType, selectedFacet) {
const metadatas = extractMedatadas(searchMetadata.getListMetadata(listType, list));
return {
...metadatas,
groupList: metadatas.groupList && metadatas.groupList.reduce((acc, element) => { if(keys(selectedFacet).indexOf(element) === -1) {acc.push(element); } return acc }, [] ),
data: list,
listType
};
Expand Down Expand Up @@ -116,10 +117,12 @@ export function connect(searchOptions) {
const scope = hasDefinedScopes ? criteriaScope || 'all' : undefined;
const hasScope = hasDefinedScopes ? !isUndefined(get(criteria, 'query.scope')) : false;
const groupSelect = get(criteria, 'group');
const selectedFacet = get(criteria, 'selectedFacets')
const term = get(criteria, 'query.term');
const results = hasGroups ? getResultsForGroup(data, searchMetadata) : getResultsForList(data, searchMetadata, listType);
const results = hasGroups ? getResultsForGroup(data, searchMetadata) : getResultsForList(data, searchMetadata, listType, selectedFacet);
const facetInformations = facetListWithselectedInformation(this.props);

console.log(facetInformations)
console.log(selectedFacet)
set(results, 'totalCount', totalCount);
set(results, 'groupSelect', groupSelect);

Expand Down
6 changes: 4 additions & 2 deletions src/components/searchbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ export class SearchBarInput extends PureComponent {
if(onChange) onChange({term: value});
}
render() {
console.log(this.props.placeholder)
return (
<InputText
data-focus='search-bar-input'
placeholder={this.props.placeholder}
name='search-bar-input'
onChange={this._debouncedOnSearchBarInputChange}
ref='searchBarInputText' />
Expand Down Expand Up @@ -92,7 +94,7 @@ SearchBarScopeSelection.defaultProps = {

export default class SearchBar extends PureComponent {
render() {
const {hasFocus, onChange, queryAction, queryActionWait, scope, scopeAction, scopes, term} = this.props;
const {hasFocus, onChange, queryAction, queryActionWait, scope, scopeAction, scopes, term, placeholder} = this.props;
const hasScopes = scopes && scopes.length > 0;
return (
<div data-focus='search-bar'>
Expand All @@ -103,7 +105,7 @@ export default class SearchBar extends PureComponent {
scopes={scopes}
scope={scope} />
}
<SearchBarInput hasFocus={hasFocus} onChange={onChange} queryAction={queryAction} queryActionWait={queryActionWait} term={term} />
<SearchBarInput hasFocus={hasFocus} placeholder={placeholder} onChange={onChange} queryAction={queryAction} queryActionWait={queryActionWait} term={term} />
</div>
);
}
Expand Down

0 comments on commit da3ed54

Please sign in to comment.