UNPKG

@websolutespa/payload-plugin-bowl

Version:

Bowl PayloadCms plugin of the BOM Repository

79 lines (78 loc) 2.46 kB
import { hasRole, isAdmin, isRole } from '../core'; import { roles } from '../types'; export const Template = (options)=>({ type: 'withCollection', slug: options.slug.template, admin: { group: options.group.config, useAsTitle: 'name', defaultColumns: [ 'name', 'id' ], hidden: (args)=>!hasRole(args.user, roles.Admin) }, access: { create: isAdmin, read: isRole(), update: isAdmin, delete: isAdmin }, fields: [ // inherited fields: id, createdAt, updatedAt { type: 'withId', required: true }, { type: 'withName', required: true }, // !!! todo withSelect ? { name: 'compatibleCollections', label: 'Compatible pages', type: 'select', hasMany: true, admin: { isClearable: true }, options: (()=>{ const selectOptions = options.pages.map((slug)=>({ value: slug, label: slug })); if (selectOptions.length > 0) { return selectOptions; } else { return [ { value: '', label: 'none' } ]; } })() }, // !!! todo withCheckbox ? { name: 'hasCompatibleCollections', type: 'checkbox', admin: { disabled: true }, hooks: { beforeChange: [ ({ data })=>{ if (data?.compatibleCollections && data.compatibleCollections.length > 0) { return true; } else { return false; } } ] } } ] }); //# sourceMappingURL=Template.js.map