Skip to content

Instantly share code, notes, and snippets.

@callumflack
Created August 16, 2018 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save callumflack/4423d07fbabe9997524706bda57627c6 to your computer and use it in GitHub Desktop.
Save callumflack/4423d07fbabe9997524706bda57627c6 to your computer and use it in GitHub Desktop.
Keystone.js: toggle and display content elements in admin UI
const Post = new keystone.List('Post', { . . . });
Post.add({
category: {
type: Types.Select,
options: ['Post', 'Event', 'Newsletter', 'Resource', 'Job'],
default: 'Post',
emptyOption: true,
},
// if category is Job, show another CMS element (in this case, a dropdown)
jobCategory: {
dependsOn: {
category: 'Job',
},
type: Types.Select,
options: ['Vacancies', 'Professional development', 'Volunteers'],
},
// toggle for showing a CMS element
includeClosingImages: Boolean,
closingImages: {
type: Types.CloudinaryImages,
dependsOn: {
includeClosingImages: true,
},
note: 'Up to 3 images may be set',
},
// another toggle example
includeButton: Boolean,
fileLocation: {
type: String,
dependsOn: {
includeButton: true,
},
},
buttonLabel: {
type: String,
default: 'Download',
dependsOn: {
includeButton: true,
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment