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

Index and create for survey #1917

Merged
merged 7 commits into from
Jan 24, 2017

Conversation

kxmbrian
Copy link
Contributor

Set up the front end for surveys.

load_and_authorize_resource :survey, through: :course, class: Course::Survey.name
add_breadcrumb :index, :course_surveys_path

def index

Choose a reason for hiding this comment

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

Put empty method definitions on a single line.

}

// Default start date to start of next day in current Time Zone
const defaultStartAt = new Date();
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering, is it beneficial to move some of these default form values into a separate file/helper so we can set the defaults in just 1 file?

@kxmbrian
Copy link
Contributor Author

  • Used redux-form instead of formsy. So far, it has been easy to work with. I've adapted the wrapper macros from redux-form-material-ui. Not using the redux-form-material-ui directly since we want more control, e.g. can default all TextFields to have floatingLabelFixed. Quite a bit in this PR already - we can add wrappers for the other components in a next PR.
  • One issue with redux-form is that the intl object is not (easily) available in the validation function. Instead of setting error strings directly, set the translation object.
  • Spent some time to create a date-time input where dates can be copied in. It is slightly makeshift since I'm using only whatever Material-UI exposes, but good enough I think. Once merged, will use this for lesson plan edit as well.

floatingLabelText: PropTypes.string,
value: PropTypes.instanceOf(Date),
errorText: PropTypes.string,
onBlur: PropTypes.func.isRequired,
Copy link
Member

Choose a reason for hiding this comment

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

If this is required, means we cannot use it without redux-form ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Separated the wrapper and underlying component in the latest push

@allenwq
Copy link
Member

allenwq commented Jan 24, 2017

One issue with redux-form is that the intl object is not (easily) available in the validation function. Instead of setting error strings directly, set the translation object.

Maybe making intl a global key value store will help ? but we can use this way for now.

@allenwq
Copy link
Member

allenwq commented Jan 24, 2017

LGTM !

@kxmbrian
Copy link
Contributor Author

Maybe making intl a global key value store will help ? but we can use this way for now.

Yeah, it's starting to look like a good idea. Quite troublesome to keep doing injectIntl and the date/time formatting feature can be better done with moment.js. (Although I wonder if we should keep date/time unlocalised as 31-12-2017 and 23:59 for some places like in v1.)

@allenwq
Copy link
Member

allenwq commented Jan 24, 2017

@kxmbrian think this can be merged after the build error is fixed.

Thanks for the date time input, should be really useful !

@allenwq allenwq merged commit ab82e83 into Coursemology:master Jan 24, 2017
@kxmbrian kxmbrian mentioned this pull request Apr 24, 2017
22 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants