converts all filters in collection views to find
This commit is contained in:
@@ -83,7 +83,7 @@ module.exports = exports = {
|
||||
"no-void": WARN,
|
||||
// Produce warnings when something is commented as TODO or FIXME
|
||||
"no-warning-comments": [ WARN, {
|
||||
"terms": [ "TODO", "FIXME" ],
|
||||
"terms": [ "FIXME" ],
|
||||
"location": "start"
|
||||
}],
|
||||
"no-with": WARN,
|
||||
|
||||
@@ -2,17 +2,25 @@ const app = require('../../server');
|
||||
const mongoose = require('mongoose');
|
||||
const Page = mongoose.model('Page');
|
||||
|
||||
// TODO: Authentication
|
||||
app.get('/pages', (req, res) => {
|
||||
// TODO: Filter, Sort
|
||||
Page.find((err, pages, next) => {
|
||||
if (err) { return next(err); }
|
||||
return res.json(pages);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: Authentication
|
||||
app.post('/pages', (req, res) => {
|
||||
const newPage = new Page(req.body);
|
||||
|
||||
// TODO: Permissions
|
||||
// TODO: Validate
|
||||
newPage.save((err, page, next) => {
|
||||
if (err) { return next(err); }
|
||||
return res.json(page);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: DELETE route
|
||||
|
||||
@@ -11,7 +11,9 @@ class Add extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'orders';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -11,7 +11,9 @@ class Archive extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'orders';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -11,7 +11,9 @@ class Edit extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'orders';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -19,7 +19,9 @@ class Add extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'pages';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});;
|
||||
this.state = {
|
||||
apiUrl: 'https://site.com/page?slug=about-us'
|
||||
};
|
||||
|
||||
@@ -11,7 +11,9 @@ class Archive extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'pages';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -11,7 +11,9 @@ class Edit extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.slug = 'pages';
|
||||
this.collection = this.props.collections[this.slug];
|
||||
this.collection = this.props.collections.find(collection => {
|
||||
return collection.slug === this.slug;
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
|
||||
@@ -3,8 +3,9 @@ export default {
|
||||
label: 'Orders',
|
||||
singular: 'Order',
|
||||
plural: 'Orders',
|
||||
fields: {
|
||||
metaInfo: {
|
||||
fields: [
|
||||
{
|
||||
name: 'metaInfo',
|
||||
type: 'group',
|
||||
fields: {
|
||||
title: {
|
||||
@@ -18,22 +19,25 @@ export default {
|
||||
keywords: { type: 'text' }
|
||||
}
|
||||
},
|
||||
content: {
|
||||
{
|
||||
name: 'content',
|
||||
type: 'group',
|
||||
fields: {
|
||||
exampleField1: {
|
||||
fields: [
|
||||
{
|
||||
name: 'exampleField1',
|
||||
type: 'textarea',
|
||||
wysiwyg: true,
|
||||
height: 400
|
||||
},
|
||||
flexibleContentExample: {
|
||||
{
|
||||
name: 'flexibleContentExample',
|
||||
type: 'flex',
|
||||
availableLayouts: [
|
||||
'layout1',
|
||||
'layout5'
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -15,5 +15,11 @@ export default {
|
||||
label: 'Content',
|
||||
type: 'textarea'
|
||||
}
|
||||
],
|
||||
relationships: [
|
||||
{
|
||||
relation: 'orders',
|
||||
type: 'hasMany'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Orders from './Orders';
|
||||
import Pages from './Pages';
|
||||
|
||||
export default {
|
||||
...Orders,
|
||||
...Pages
|
||||
};
|
||||
export default [
|
||||
Orders,
|
||||
Pages
|
||||
];
|
||||
|
||||
@@ -21,8 +21,8 @@ class Sidebar extends Component {
|
||||
</Link>
|
||||
<Label>Collections</Label>
|
||||
<nav>
|
||||
{Object.keys(this.props.collections).map((key, i) => {
|
||||
const href = `/collections/${key}`;
|
||||
{this.props.collections.map((item, i) => {
|
||||
const href = `/collections/${item.slug}`;
|
||||
const classes = this.props.location.pathname.indexOf(href) > -1
|
||||
? 'active'
|
||||
: undefined;
|
||||
@@ -30,7 +30,7 @@ class Sidebar extends Component {
|
||||
return (
|
||||
<Link className={classes} key={i} to={href}>
|
||||
<Arrow />
|
||||
{this.props.collections[key].plural}
|
||||
{this.props.collections[i].plural}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -3,14 +3,17 @@ import { Switch, Route } from 'react-router-dom';
|
||||
import CollectionComponents from 'local/client/components/collections';
|
||||
|
||||
export default props => {
|
||||
return Object.keys(props.collections).map((key, i) => {
|
||||
return (
|
||||
<Switch key={i}>
|
||||
<Route path={`/collections/${key}/add-new`} exact component={CollectionComponents[key].
|
||||
Add} />
|
||||
<Route path={`/collections/${key}`} exact component={CollectionComponents[key].Archive} />
|
||||
<Route path={`/collections/${key}/:id`} component={CollectionComponents[key].Edit} />
|
||||
</Switch>
|
||||
);
|
||||
return props.collections.map((collection, i) => {
|
||||
if (collection) {
|
||||
return (
|
||||
<Switch key={i}>
|
||||
<Route path={`/collections/${collection.slug}/add-new`} exact component={CollectionComponents[collection.slug].Add} />
|
||||
<Route path={`/collections/${collection.slug}`} exact component={CollectionComponents[collection.slug].Archive} />
|
||||
<Route path={`/collections/${collection.slug}/:id`} component={CollectionComponents[collection.slug].Edit} />
|
||||
</Switch>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -8,9 +8,7 @@ export default (state = defaultState, action) => {
|
||||
|
||||
return {
|
||||
...state,
|
||||
all: {
|
||||
[action.payload.slug]: action.payload
|
||||
}
|
||||
all: action.payload
|
||||
};
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user