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

Filtering #59

Merged
merged 23 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
17 changes: 4 additions & 13 deletions actionlist/app/components/SideMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import {
} from 'react-native';

import Button from 'react-native-button';
import { Actions } from 'react-native-router-flux';
import Actions from 'react-native-router-flux';
import { connect } from 'react-redux';
import { sortActionList, resetFilters } from '../actions/action_items';
import { Colors, sortTypes, filterTypes } from '../lib/commons';
import FilterPicker from './filterPicker';
import ContentHeader from './contentHeader';

const style = StyleSheet.create({
view: {
Expand Down Expand Up @@ -49,12 +50,6 @@ const style = StyleSheet.create({
color: Colors.IUGray,
fontFamily: 'BentonSansBold, Arial, sans-serif',
},
headerText: {
fontSize: 10,
color: '#7B1500',
fontFamily: 'BentonSansBold, Arial, sans-serif',
margin: 10,
},
container: {
backgroundColor: '#f4f7f9',
paddingTop: 0,
Expand Down Expand Up @@ -132,12 +127,8 @@ const SideMenu = ({ optionSelected,
value={filters.actionRequested}
filterKey={'actionRequested'}
/>
<View style={style.header}>
<Text style={style.headerText}>{filterTypes.DocumentCreatedDate.title}</Text>
</View>
<View style={style.header}>
<Text style={style.headerText}>{filterTypes.DocumentAssignedDate.title}</Text>
</View>
<ContentHeader title={filterTypes.DocumentCreatedDate.title} />
<ContentHeader title={filterTypes.DocumentAssignedDate.title} />
</View>
<Button
containerStyle={style.resetContainer}
Expand Down
1 change: 0 additions & 1 deletion actionlist/app/components/action_item_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,3 @@ ActionItemHeader.propTypes = {
};

export default ActionItemHeader;

28 changes: 28 additions & 0 deletions actionlist/app/components/contentHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';
import {
StyleSheet,
View,
Text,
} from 'react-native';
import { Colors } from '../lib/commons';

const style = StyleSheet.create({
headerText: {
fontSize: 10,
color: Colors.IUCrimson,
fontFamily: 'BentonSansBold, Arial, sans-serif',
margin: 10,
},
});

const ContentHeader = ({ title }) => (
<View>
<Text style={style.headerText}>{title}</Text>
Copy link
Contributor

@burnumd burnumd Apr 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend not using a title prop and just use the children prop. It looks like it's allowed for Text components to have node children, so if you just use children you can pass off prop validation to the react-native component and allow yourself more flexibility.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to use children and lint threw an error saying I need to have a prop validation for it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the type of children should be documented as React.PropTypes.node: jsx-eslint/eslint-plugin-react#7

</View>
);

ContentHeader.propTypes = {
title: React.PropTypes.string.isRequired,
};

export default ContentHeader;
17 changes: 2 additions & 15 deletions actionlist/app/components/filterPicker.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import React from 'react';
import {
StyleSheet,
View,
Text,
Picker,
} from 'react-native';

/* eslint-disable no-unused-vars */
import { connect } from 'react-redux';
import { filterActionList } from '../actions/action_items';
import { Colors } from '../lib/commons';

const style = StyleSheet.create({
headerText: {
fontSize: 10,
color: Colors.IUCrimson,
fontFamily: 'BentonSansBold, Arial, sans-serif',
margin: 10,
},
});
import ContentHeader from './contentHeader';

const FilterPicker = ({ filter, value, filterKey, onActionListFiltering }) => (
<View>
<View>
<Text style={style.headerText}>{filter.title}</Text>
</View>
<ContentHeader title={filter.title} />
<Picker
selectedValue={value}
onValueChange={selectedOption => onActionListFiltering(filterKey, selectedOption)}
Expand Down