Skip to content

Commit

Permalink
Merge branch 'opencrud'
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/getting-started/lib/components/steps/Step10.jsx
  • Loading branch information
SachaG committed Aug 29, 2018
2 parents 0771e53 + 44d5db6 commit 0e88e2b
Show file tree
Hide file tree
Showing 40 changed files with 463 additions and 420 deletions.
8 changes: 4 additions & 4 deletions packages/example-customization/lib/custom_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Posts.addField(
fieldName: 'color',
fieldSchema: {
type: String,
control: "select", // use a select form control
input: "select", // use a select form control
optional: true, // this field is not required
insertableBy: ['members'],
editableBy: ['members'],
viewableBy: ['members'],
canCreate: ['members'],
canUpdate: ['members'],
canRead: ['members'],
options: function () { // options for the select form control
return [
{value: "white", label: "White"},
Expand Down
2 changes: 1 addition & 1 deletion packages/example-forms/lib/components/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Home = ({ flash }) => (

<Components.Datatable
collection={Customers}
columns={['name', 'meetingDate', 'stage', 'addresses', 'product']}
columns={['name', 'meetingDate', 'stage', 'addresses', 'product', 'categories', 'isVIP', 'notes']}
emptyState={<p className="datatable-empty">No customers to display</p>}
options={{ fragmentName: 'customerFragment' }}
/*
Expand Down
4 changes: 4 additions & 0 deletions packages/example-forms/lib/modules/customers/fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ registerFragment(`
_id
stage
name
notes
meetingDate
addresses
categories
isVIP
product{
name
}
Expand Down
105 changes: 70 additions & 35 deletions packages/example-forms/lib/modules/customers/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ Define a sub-schema for addresses
export const addressSchema = new SimpleSchema({
street: {
type: String,
optional: true,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
optional: false,
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
max: 100, // limit street address to 100 characters
},
country: {
type: String,
optional: true,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
},
zipCode: {
type: Number,
optional: true,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
control: 'number',
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
input: 'number',
},
});

const schema = {
_id: {
type: String,
optional: true,
viewableBy: ['guests'],
canRead: ['guests'],
},
createdAt: {
type: Date,
optional: true,
onInsert: (document, currentUser) => {
onCreate: () => {
return new Date();
},
},
Expand All @@ -58,45 +58,57 @@ const schema = {
name: {
type: String,
optional: false,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
searchable: true, // make field searchable
},

notes: {
type: String,
optional: true,
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
input: 'textarea',
searchable: true, // make field searchable
},

stage: {
type: String,
optional: false,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
searchable: true,
control: 'FormFunnel', // use a custom `FormFunnel` form input component
input: 'FormFunnel', // use a custom `FormFunnel` form input component
},

meetingDate: {
type: Date,
optional: true,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
},

productId: {
type: String,
optional: true,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
query: `
ProductsList{
_id
name
products{
results{
_id
name
}
}
`,
options: props =>
props.data.ProductsList &&
props.data.ProductsList.map(product => ({
props.data.products &&
props.data.products.results.map(product => ({
value: product._id,
label: product.name,
})),
Expand All @@ -107,7 +119,30 @@ const schema = {
customer.productId && Products.loader.load(customer.productId),
addOriginalField: true,
},
control: 'select',
input: 'select',
},

isVIP: {
type: Boolean,
optional: true,
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
},

categories: {
type: Array,
optional: true,
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
options: [{ label: 'Tech', value: 'tech' }, { label: 'Finance', value: 'finance' }, { label: 'Medical', value: 'medical' }],
input: 'checkboxgroup',
},

'categories.$': {
type: String,
optional: true,
},

/*
Expand All @@ -118,9 +153,9 @@ const schema = {
*/
addresses: {
type: Array,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
group: addressGroup,
},

Expand Down
10 changes: 5 additions & 5 deletions packages/example-forms/lib/modules/products/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ const schema = {
_id: {
type: String,
optional: true,
viewableBy: ['guests'],
canRead: ['guests'],
},
createdAt: {
type: Date,
optional: true,
onInsert: (document, currentUser) => {
onCreate: () => {
return new Date();
},
},

name: {
type: String,
optional: false,
viewableBy: ['guests'],
editableBy: ['members'],
insertableBy: ['members'],
canRead: ['guests'],
canUpdate: ['members'],
canCreate: ['members'],
},
};

Expand Down
22 changes: 12 additions & 10 deletions packages/example-forum/lib/modules/categories/custom_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ Posts.addField([
fieldName: 'categoriesIds',
fieldSchema: {
type: Array,
control: 'checkboxgroup',
input: 'checkboxgroup',
optional: true,
insertableBy: ['members'],
editableBy: ['members'],
viewableBy: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
canRead: ['guests'],
options: props => {
return getCategoriesAsOptions(props.data.CategoriesList);
return getCategoriesAsOptions(props.data.categories.results);
},
query: `
CategoriesList{
_id
name
slug
order
categories{
results{
_id
name
slug
order
}
}
`,
resolveAs: {
Expand Down
62 changes: 32 additions & 30 deletions packages/example-forum/lib/modules/categories/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,65 +34,65 @@ export function getCategoriesAsNestedOptions (categories) {
const schema = {
_id: {
type: String,
viewableBy: ['guests'],
canRead: ['guests'],
optional: true,
},
name: {
type: String,
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
},
description: {
type: String,
optional: true,
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
form: {
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
inputProperties: {
rows: 3
}
},
order: {
type: Number,
optional: true,
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
},
slug: {
type: String,
optional: true,
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
onInsert: category => {
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
onCreate: ({category}) => {
// if no slug has been provided, generate one
const slug = category.slug || Utils.slugify(category.name);
return Utils.getUnusedSlugByCollectionName('Categories', slug);
},
onEdit: (modifier, category) => {
onUpdate: ({data, document: category}) => {
// if slug is changing
if (modifier.$set && modifier.$set.slug && modifier.$set.slug !== category.slug) {
const slug = modifier.$set.slug;
if (data.slug && data.slug !== category.slug) {
const slug = data.slug;
return Utils.getUnusedSlugByCollectionName('Categories', slug);
}
}
},
image: {
type: String,
optional: true,
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
},
parentId: {
type: String,
optional: true,
control: "select",
viewableBy: ['guests'],
insertableBy: ['members'],
editableBy: ['members'],
input: "select",
canRead: ['guests'],
canCreate: ['members'],
canUpdate: ['members'],
resolveAs: {
fieldName: 'parent',
type: 'Category',
Expand All @@ -104,14 +104,16 @@ const schema = {
addOriginalField: true
},
options: props => {
return getCategoriesAsOptions(props.data.CategoriesList);
return getCategoriesAsOptions(props.data.categories.results);
},
query: `
CategoriesList{
_id
name
slug
order
results{
_id
name
slug
order
}
}
`,
}
Expand Down
Loading

0 comments on commit 0e88e2b

Please sign in to comment.