merge #2720 from ng-ui-tags-fixes

Sort tags when displaying ; use AND for search results
This commit is contained in:
Jannis Redmann 2016-10-19 13:21:54 +02:00 committed by GitHub
commit cf170418d5
2 changed files with 22 additions and 21 deletions

View File

@ -38,19 +38,21 @@ export default class Tags extends Component {
? [ styles.tag, styles.tagClickable ]
: [ styles.tag ];
return tags.map((tag, idx) => {
const onClick = handleAddSearchToken
? () => handleAddSearchToken(tag)
: null;
return tags
.sort()
.map((tag, idx) => {
const onClick = handleAddSearchToken
? () => handleAddSearchToken(tag)
: null;
return (
<div
key={ idx }
className={ tagClasses.join(' ') }
onClick={ onClick }>
{ tag }
</div>
);
});
return (
<div
key={ idx }
className={ tagClasses.join(' ') }
onClick={ onClick }>
{ tag }
</div>
);
});
}
}

View File

@ -130,15 +130,14 @@ export default class List extends Component {
.concat(tags, name)
.map(v => v.toLowerCase());
return values
.filter((value) => {
return searchValues
.map(searchValue => value.indexOf(searchValue) >= 0)
// `current && truth, true` => use tokens as AND
// `current || truth, false` => use tokens as OR
.reduce((current, truth) => current || truth, false);
return searchValues
.map(searchValue => {
return values
.some(value => value.indexOf(searchValue) >= 0);
})
.length > 0;
// `current && truth, true` => use tokens as AND
// `current || truth, false` => use tokens as OR
.reduce((current, truth) => current && truth, true);
});
}
}