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

Add Checkbox (boolean) field type #147

Merged
merged 10 commits into from
Jul 17, 2018
Merged

Add Checkbox (boolean) field type #147

merged 10 commits into from
Jul 17, 2018

Conversation

mikehazell
Copy link
Contributor

@mikehazell mikehazell commented Jul 4, 2018

resolves #146
Adds the Checkbox core field type

@mikehazell
Copy link
Contributor Author

Note, this is related to issue #19

@mikehazell mikehazell requested a review from jesstelford July 4, 2018 00:50
Copy link
Member

@JedWatson JedWatson left a comment

Choose a reason for hiding this comment

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

Looks good! A couple of questions noted.

Big change request: please rename this field type to Checkbox because Boolean is already a literal in JavaScript.

}
}

module.exports = {
Copy link
Member

Choose a reason for hiding this comment

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

Why not just export class ... above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just following the convention defined in the other field types. I'm guessing this is because the file is used in a node context as well as a webpack-ified context.

} from '@keystonejs/ui/src/primitives/fields';

// TODO: use pretty checkboxes - these only work in a CheckGroup situation.
// import { Checkbox } from '@keystonejs/ui/src/primitives/forms';
Copy link
Member

Choose a reason for hiding this comment

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

@jossmac this looks like a job for you

return (
<select onChange={this.handleChange} innerRef={innerRef} value={value}>
<option value="true">true</option>
<option value="false">false</option>
Copy link
Member

Choose a reason for hiding this comment

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

is it worth adding support for null (label "not set") here?

@@ -72,6 +73,7 @@ keystone.createList('User', {
// TODO: Create a Twitter field type to encapsulate these
twitterId: { type: Text },
twitterUsername: { type: Text },
isAdmin: { type: Boolean, defaultValue: true },
Copy link
Member

Choose a reason for hiding this comment

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

We don't support defaultValue yet - please don't include it in the test project until we do. Only stuff that's actually working belongs in here, otherwise it's not clear what's implemented and what's not.

There may be other exceptions to this rule already in place... if they are, we need to clean it up.

@mikehazell mikehazell changed the title Add boolean field type Add Checkbox (boolean) field type Jul 4, 2018
@mikehazell
Copy link
Contributor Author

👍 Checkbox - I was wondering what we should be call this.

@timleslie
Copy link
Contributor

This branch will conflict with #134, as the changes made in test-project will need to be moved to the new folder structure. I would suggest holding off merging this task until #134 has made its way into master.

Other than that this LGTM.

@mikehazell mikehazell force-pushed the add-boolean-field-type branch 2 times, most recently from d0df40d to 15ebaae Compare July 10, 2018 00:31
@mikehazell mikehazell removed the request for review from jesstelford July 10, 2018 00:43
@mikehazell mikehazell force-pushed the add-boolean-field-type branch from 15ebaae to ba1e25a Compare July 16, 2018 23:48
@timleslie
Copy link
Contributor

LGTM

@mikehazell mikehazell force-pushed the add-boolean-field-type branch from ba1e25a to e85cbc8 Compare July 17, 2018 01:39
@mikehazell mikehazell merged commit 61219c0 into master Jul 17, 2018
@mikehazell mikehazell deleted the add-boolean-field-type branch July 17, 2018 02:31
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.

Add Boolean field type
3 participants