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

Custom goal dates #117

Open
doub1ejack opened this issue Sep 10, 2019 · 2 comments
Open

Custom goal dates #117

doub1ejack opened this issue Sep 10, 2019 · 2 comments
Assignees
Labels
UI User Interface
Projects

Comments

@doub1ejack
Copy link
Member

Add some UI (probably a date picker) that allows users to specify a specific date on goal detail modal.

@doub1ejack doub1ejack added this to To do in CVOEO via automation Sep 10, 2019
@doub1ejack doub1ejack added the UI User Interface label Sep 10, 2019
@mpettit mpettit self-assigned this Sep 10, 2019
@mpettit mpettit moved this from To do to In progress in CVOEO Sep 10, 2019
@kmeyersvt
Copy link
Collaborator

@johnneed's suggestion of date picker code he's used.

// @flow
import React from 'react';
import {StyleSheet, View, Text, TouchableHighlight} from 'react-native';
import DateTimePicker from 'react-native-modal-datetime-picker';
import moment from 'moment';
import * as R from 'ramda';
import commonStyles from '../../styles/common-styles';

const styles = StyleSheet.create(commonStyles);

type Props = { report: Object, config: { key: string }, text: string, update: string => void, valueKey: string };

export default class DateTimeControl extends React.Component {

constructor(props) {
    super(props);
    this.state = {
        isDatePickerVisible: false,
        isTimePickerVisible: false
    };
}

showDatePicker = () => {
    this.setState({isDatePickerVisible: true});
};
showTimePicker = () => {
    this.setState({isTimePickerVisible: true});
};

hideDateTimePicker = () => {
    this.setState({isDatePickerVisible: false, isTimePickerVisible: false});
};

handleDateTimePicked = R.curry((update, key, report, date) => {
    const newDateTime = date;
    update(key, newDateTime);
    this.hideDateTimePicker();
});


render() {
    const {config, report, update} = this.props;
    return (
        <View style={styles.controlView}>
            <Text style={styles.controlLabel}>{config.dateText}</Text>
            <TouchableHighlight onPress={this.showDatePicker}>
                <Text style={{...styles.textInput, fontSize: 20, paddingTop: 7, paddingLeft: 10, color: '#888'}}>
                    {moment(report.data[config.key]).format('MMMM DD YYYY')}
                </Text>
            </TouchableHighlight>
            <DateTimePicker
                date={moment(report.data[config.key]).toDate()}
                isVisible={this.state.isDatePickerVisible}
                maximumDate={(new Date())}
                mode={'date'}
                onCancel={this.hideDateTimePicker}
                onConfirm={this.handleDateTimePicked(update, config.key, report)}
            />
            <Text style={styles.controlLabel}>{config.timeText}</Text>
            <TouchableHighlight onPress={this.showTimePicker}>
                <Text style={{...styles.textInput, fontSize: 20, paddingTop: 7, paddingLeft: 10, color: '#888'}}>
                    {moment(report.data[config.key]).format('hh:mm A')}
                </Text>
            </TouchableHighlight>
            <DateTimePicker
                date={moment(report.data[config.key]).toDate()}
                isVisible={this.state.isTimePickerVisible}
                mode={'time'}
                onCancel={this.hideDateTimePicker}
                onConfirm={this.handleDateTimePicked(update, config.key, report)}
            />
        </View>
    );

}

}

@kmeyersvt
Copy link
Collaborator

@mpettit mpettit moved this from In progress to Needs review in CVOEO Sep 15, 2019
@mpettit mpettit moved this from Needs review to Done in CVOEO Sep 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI User Interface
Projects
CVOEO
  
Done
Development

No branches or pull requests

3 participants