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