mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-10 07:02:39 +00:00
Add title filtering to User Page.
This commit is contained in:
@@ -31,8 +31,9 @@ const UserPage = createClass({
|
|||||||
},
|
},
|
||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
return {
|
return {
|
||||||
sortType : 'alpha',
|
sortType : 'alpha',
|
||||||
sortDir : 'asc'
|
sortDir : 'asc',
|
||||||
|
filterString : ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
getUsernameWithS : function() {
|
getUsernameWithS : function() {
|
||||||
@@ -52,6 +53,7 @@ const UserPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
sortBrewOrder : function(brew){
|
sortBrewOrder : function(brew){
|
||||||
|
if(!brew.title){brew.title='No Title';};
|
||||||
const mapping = {
|
const mapping = {
|
||||||
'alpha' : _.deburr(brew.title.toLowerCase()),
|
'alpha' : _.deburr(brew.title.toLowerCase()),
|
||||||
'created' : moment(brew.createdAt).format(),
|
'created' : moment(brew.createdAt).format(),
|
||||||
@@ -90,6 +92,25 @@ const UserPage = createClass({
|
|||||||
</td>;
|
</td>;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleFilterTextChange : function(e){
|
||||||
|
this.setState({
|
||||||
|
filterString : e.target.value
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
|
||||||
|
renderFilterOption : function(){
|
||||||
|
return <td>
|
||||||
|
<label>
|
||||||
|
Filter Title:
|
||||||
|
<input
|
||||||
|
type='text'
|
||||||
|
onChange={this.handleFilterTextChange}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
</td>;
|
||||||
|
},
|
||||||
|
|
||||||
renderSortOptions : function(){
|
renderSortOptions : function(){
|
||||||
return <div className='sort-container'>
|
return <div className='sort-container'>
|
||||||
<table>
|
<table>
|
||||||
@@ -114,6 +135,7 @@ const UserPage = createClass({
|
|||||||
{`${(this.state.sortDir == 'asc' ? '\u25B2 ASC' : '\u25BC DESC')}`}
|
{`${(this.state.sortDir == 'asc' ? '\u25B2 ASC' : '\u25BC DESC')}`}
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
{this.renderFilterOption()}
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
@@ -121,7 +143,11 @@ const UserPage = createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getSortedBrews : function(){
|
getSortedBrews : function(){
|
||||||
return _.groupBy(this.props.brews, (brew)=>{
|
const testString = _.deburr(this.state.filterString).toLowerCase();
|
||||||
|
const brewCollection = this.state.filterString ? _.filter(this.props.brews, (brew)=>{
|
||||||
|
return (_.deburr(brew?.title).toLowerCase().includes(testString));
|
||||||
|
}) : this.props.brews;
|
||||||
|
return _.groupBy(brewCollection, (brew)=>{
|
||||||
return (brew.published ? 'published' : 'private');
|
return (brew.published ? 'published' : 'private');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -34,8 +34,9 @@
|
|||||||
font-family : 'Open Sans', sans-serif;
|
font-family : 'Open Sans', sans-serif;
|
||||||
position : fixed;
|
position : fixed;
|
||||||
top : 35px;
|
top : 35px;
|
||||||
|
left : calc(50vw - 408px);
|
||||||
border : 2px solid #58180D;
|
border : 2px solid #58180D;
|
||||||
width : 675px;
|
width : 800px;
|
||||||
background-color : #EEE5CE;
|
background-color : #EEE5CE;
|
||||||
padding : 2px;
|
padding : 2px;
|
||||||
text-align : center;
|
text-align : center;
|
||||||
|
|||||||
Reference in New Issue
Block a user