mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
make movies package work independently; nova:base-routes -> nova:routing
This commit is contained in:
parent
dfe2d2d0df
commit
395a5926be
37 changed files with 369 additions and 139 deletions
|
@ -6,21 +6,22 @@ nova:core # do not remove!
|
|||
|
||||
# nova:settings
|
||||
nova:users
|
||||
nova:posts
|
||||
nova:comments
|
||||
nova:newsletter
|
||||
nova:search
|
||||
nova:notifications
|
||||
nova:getting-started
|
||||
nova:categories
|
||||
nova:voting
|
||||
# nova:posts
|
||||
# nova:comments
|
||||
# nova:newsletter
|
||||
# nova:search
|
||||
# nova:notifications
|
||||
# nova:getting-started
|
||||
# nova:categories
|
||||
# nova:voting
|
||||
nova:forms
|
||||
nova:embedly
|
||||
nova:api
|
||||
nova:email
|
||||
nova:rss
|
||||
# nova:embedly
|
||||
# nova:api
|
||||
# nova:email
|
||||
# nova:rss
|
||||
# nova:subscribe
|
||||
# nova:cloudinary
|
||||
nova:routing
|
||||
|
||||
############ Data Layer Package ##############
|
||||
|
||||
|
@ -28,10 +29,10 @@ nova:apollo # do not remove!
|
|||
|
||||
############ Customizable Packages ############
|
||||
|
||||
nova:base-components # default ui components
|
||||
# nova:base-components # default ui components
|
||||
nova:base-styles # default styling
|
||||
nova:base-routes # default routes
|
||||
nova:email-templates # default email templates for notifications
|
||||
|
||||
# nova:email-templates # default email templates for notifications
|
||||
nova:i18n-en-us # default language translation
|
||||
|
||||
accounts-password@1.3.3
|
||||
|
@ -40,7 +41,7 @@ accounts-password@1.3.3
|
|||
|
||||
############ Debug Packages ############
|
||||
|
||||
nova:debug
|
||||
# nova:debug
|
||||
# nova:kadira
|
||||
|
||||
############ Your Packages ############
|
||||
|
|
|
@ -18,7 +18,7 @@ caching-compiler@1.1.9
|
|||
callback-hook@1.0.10
|
||||
check@1.2.4
|
||||
chuangbo:cookie@1.1.0
|
||||
coffeescript@1.11.1_4
|
||||
coffeescript@1.0.17
|
||||
custom-collection-demo@0.27.4-nova
|
||||
dburles:collection-helpers@1.1.0
|
||||
ddp@1.2.5
|
||||
|
@ -32,7 +32,6 @@ ecmascript@0.6.1
|
|||
ecmascript-runtime@0.3.15
|
||||
ejson@1.0.13
|
||||
email@1.1.18
|
||||
fortawesome:fontawesome@4.7.0
|
||||
fourseven:scss@3.10.1
|
||||
geojson-utils@1.0.10
|
||||
hot-code-push@1.0.4
|
||||
|
@ -55,7 +54,6 @@ meteorhacks:inject-data@2.0.1-nova-patch
|
|||
meteorhacks:inject-initial@1.0.4
|
||||
meteorhacks:meteorx@1.4.1
|
||||
meteorhacks:picker@1.0.3
|
||||
meteorhacks:subs-manager@1.6.4
|
||||
minifier-css@1.2.15
|
||||
minifier-js@1.2.15
|
||||
minimongo@1.0.19
|
||||
|
@ -63,30 +61,16 @@ modules@0.7.7
|
|||
modules-runtime@0.7.7
|
||||
mongo@1.1.14
|
||||
mongo-id@1.0.6
|
||||
nova:api@0.27.4-nova
|
||||
nova:apollo@0.27.4-nova
|
||||
nova:base-components@0.27.4-nova
|
||||
nova:base-routes@0.27.4-nova
|
||||
nova:base-styles@0.27.4-nova
|
||||
nova:categories@0.27.4-nova
|
||||
nova:comments@0.27.4-nova
|
||||
nova:core@0.27.4-nova
|
||||
nova:debug@0.27.4-nova
|
||||
nova:email@0.27.4-nova
|
||||
nova:email-templates@0.27.4-nova
|
||||
nova:embedly@0.27.4-nova
|
||||
nova:events@0.27.4-nova
|
||||
nova:forms@0.27.4-nova
|
||||
nova:getting-started@0.27.4-nova
|
||||
nova:i18n-en-us@0.27.4-nova
|
||||
nova:lib@0.27.4-nova
|
||||
nova:newsletter@0.27.4-nova
|
||||
nova:notifications@0.27.4-nova
|
||||
nova:posts@0.27.4-nova
|
||||
nova:rss@0.27.4-nova
|
||||
nova:search@0.27.4-nova
|
||||
nova:routing@0.27.4-nova
|
||||
nova:users@0.27.4-nova
|
||||
nova:voting@0.27.4-nova
|
||||
npm-bcrypt@0.9.2
|
||||
npm-mongo@2.2.11_2
|
||||
observe-sequence@1.0.14
|
||||
|
@ -107,7 +91,7 @@ service-configuration@1.0.11
|
|||
session@1.1.7
|
||||
sha@1.0.9
|
||||
shell-server@0.2.1
|
||||
softwarerero:accounts-t9n@1.3.5
|
||||
softwarerero:accounts-t9n@1.3.6
|
||||
spacebars@1.0.13
|
||||
spacebars-compiler@1.0.13
|
||||
srp@1.0.10
|
||||
|
@ -120,6 +104,5 @@ tracker@1.1.1
|
|||
ui@1.0.12
|
||||
underscore@1.0.10
|
||||
url@1.0.11
|
||||
utilities:react-list-container@0.1.14
|
||||
webapp@1.3.12
|
||||
webapp-hashing@1.0.9
|
||||
|
|
63
packages/custom-collection-demo/lib/components/Accounts.jsx
Normal file
63
packages/custom-collection-demo/lib/components/Accounts.jsx
Normal file
|
@ -0,0 +1,63 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import { Button, FormControl } from 'react-bootstrap';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { withApollo } from 'react-apollo';
|
||||
|
||||
Accounts.ui.config({
|
||||
passwordSignupFields: 'USERNAME_AND_EMAIL',
|
||||
});
|
||||
|
||||
const AccountsComponent = ({client}) => {
|
||||
return (
|
||||
<div>
|
||||
<Accounts.ui.LoginForm
|
||||
onPostSignUpHook={() => client.resetStore()}
|
||||
onSignedInHook={() => client.resetStore()}
|
||||
onSignedOutHook={() => client.resetStore()}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
class AccountsButton extends Accounts.ui.Button {
|
||||
render () {
|
||||
const {label, href, type, disabled, className, onClick} = this.props;
|
||||
if (type === 'link') {
|
||||
return <a href={ href } className={ className } onClick={ onClick }>{ label }</a>;
|
||||
}
|
||||
return <Button
|
||||
bsStyle="primary"
|
||||
className={ className }
|
||||
type={ type }
|
||||
disabled={ disabled }
|
||||
onClick={ onClick }>{ label }
|
||||
</Button>;
|
||||
}
|
||||
}
|
||||
|
||||
class AccountsField extends Accounts.ui.Field {
|
||||
|
||||
// see https://github.com/studiointeract/accounts-ui/issues/60
|
||||
triggerUpdate () {
|
||||
const { onChange } = this.props
|
||||
if (this.input) {
|
||||
onChange({ target: { value: this.input.value } })
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { id, hint, label, type = 'text', onChange, className = "field", defaultValue = "" } = this.props;
|
||||
const { mount = true } = this.state;
|
||||
return mount ? (
|
||||
<div className={ className }>
|
||||
<FormControl id={ id } type={ type } onChange={ onChange } placeholder={ hint } defaultValue={ defaultValue } />
|
||||
</div>
|
||||
) : null;
|
||||
}
|
||||
}
|
||||
|
||||
Accounts.ui.Button = AccountsButton;
|
||||
Accounts.ui.Field = AccountsField;
|
||||
|
||||
export default withApollo(AccountsComponent);
|
83
packages/custom-collection-demo/lib/components/App.jsx
Normal file
83
packages/custom-collection-demo/lib/components/App.jsx
Normal file
|
@ -0,0 +1,83 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
import Users from 'meteor/nova:users';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import { IntlProvider, intlShape} from 'react-intl';
|
||||
import { graphql } from 'react-apollo';
|
||||
import gql from 'graphql-tag';
|
||||
import Loading from './Loading.jsx';
|
||||
import Layout from './Layout.jsx';
|
||||
|
||||
class App extends Component {
|
||||
|
||||
getLocale() {
|
||||
return Telescope.settings.get("locale", "en");
|
||||
}
|
||||
|
||||
getChildContext() {
|
||||
|
||||
const messages = Telescope.strings[this.getLocale()] || {};
|
||||
const intlProvider = new IntlProvider({locale: this.getLocale()}, messages);
|
||||
|
||||
const { intl } = intlProvider.getChildContext();
|
||||
|
||||
return { intl };
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<IntlProvider locale={this.getLocale()} messages={Telescope.strings[this.getLocale()]}>
|
||||
{
|
||||
this.props.loading ?
|
||||
<Loading /> :
|
||||
<div>{this.props.children}</div>
|
||||
}
|
||||
</IntlProvider>
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
App.propTypes = {
|
||||
loading: React.PropTypes.bool,
|
||||
currentUser: React.PropTypes.object,
|
||||
actions: React.PropTypes.object,
|
||||
}
|
||||
|
||||
App.childContextTypes = {
|
||||
currentUser: React.PropTypes.object,
|
||||
actions: React.PropTypes.object,
|
||||
intl: intlShape,
|
||||
}
|
||||
|
||||
// we are not "forced" to use the containers helpers to run specific queries like `getCurrentUser` which doesn't take any argument
|
||||
const currentUserContainer = graphql(
|
||||
gql`query getCurrentUser {
|
||||
currentUser {
|
||||
_id
|
||||
username
|
||||
createdAt
|
||||
isAdmin
|
||||
__bio
|
||||
__displayName
|
||||
__email
|
||||
__emailHash
|
||||
__groups
|
||||
__htmlBio
|
||||
__karma
|
||||
__slug
|
||||
__twitterUsername
|
||||
__website
|
||||
}
|
||||
}
|
||||
`, {
|
||||
props(props) {
|
||||
const {data: {loading, currentUser}} = props;
|
||||
return {
|
||||
loading,
|
||||
currentUser,
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
Telescope.registerComponent('App', App, currentUserContainer);
|
14
packages/custom-collection-demo/lib/components/Icon.jsx
Normal file
14
packages/custom-collection-demo/lib/components/Icon.jsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
import React from 'react';
|
||||
|
||||
const Icon = ({ name, iconClass }) => {
|
||||
const icons = Telescope.utils.icons;
|
||||
const iconCode = !!icons[name] ? icons[name] : name;
|
||||
iconClass = (typeof iconClass === 'string') ? ' '+iconClass : '';
|
||||
const c = 'icon fa fa-fw fa-' + iconCode + ' icon-' + name + iconClass;
|
||||
return <i className={c} aria-hidden="true"></i>;
|
||||
}
|
||||
|
||||
Icon.displayName = "Icon";
|
||||
|
||||
Telescope.registerComponent('Icon', Icon);
|
30
packages/custom-collection-demo/lib/components/Layout.jsx
Normal file
30
packages/custom-collection-demo/lib/components/Layout.jsx
Normal file
|
@ -0,0 +1,30 @@
|
|||
// /*
|
||||
|
||||
// Wrapper for the Movies components
|
||||
|
||||
// */
|
||||
|
||||
// import Telescope from 'meteor/nova:lib';
|
||||
// import React, { PropTypes, Component } from 'react';
|
||||
// import { Accounts } from 'meteor/std:accounts-ui';
|
||||
// import { FlashContainer } from "meteor/nova:core";
|
||||
|
||||
// const Layout = props => {
|
||||
// return (
|
||||
// <div className="wrapper">
|
||||
|
||||
// <div style={{maxWidth: "300px"}}>
|
||||
// <Accounts.ui.LoginForm />
|
||||
// </div>
|
||||
|
||||
// <FlashContainer component={Telescope.components.FlashMessages}/>
|
||||
|
||||
// <div className="main">
|
||||
// {this.props.children}
|
||||
// </div>
|
||||
|
||||
// </div>
|
||||
// )
|
||||
// }
|
||||
|
||||
// export default Layout;
|
18
packages/custom-collection-demo/lib/components/Loading.jsx
Normal file
18
packages/custom-collection-demo/lib/components/Loading.jsx
Normal file
|
@ -0,0 +1,18 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
|
||||
const Loading = props => {
|
||||
return (
|
||||
<div className="spinner">
|
||||
<div className="bounce1"></div>
|
||||
<div className="bounce2"></div>
|
||||
<div className="bounce3"></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Loading.displayName = "Loading";
|
||||
|
||||
Telescope.registerComponent('Loading', Loading);
|
||||
|
||||
export default Loading;
|
|
@ -17,10 +17,7 @@ const MoviesEditForm = (props, context) => {
|
|||
<NovaForm
|
||||
collection={Movies}
|
||||
currentUser={props.currentUser}
|
||||
documentId={props.documentId}
|
||||
successCallback={document => {
|
||||
context.closeCallback();
|
||||
}}
|
||||
documentId={props.documentId}
|
||||
queryName="moviesListQuery"
|
||||
showRemove={true}
|
||||
/>
|
||||
|
|
|
@ -9,7 +9,6 @@ import Telescope from 'meteor/nova:lib';
|
|||
import React, { PropTypes, Component } from 'react';
|
||||
import Users from "meteor/nova:users";
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { ModalTrigger } from 'meteor/nova:core';
|
||||
import MoviesEditForm from './MoviesEditForm.jsx';
|
||||
import MoviesDetails from './MoviesDetails.jsx';
|
||||
|
|
|
@ -9,7 +9,6 @@ import Telescope from 'meteor/nova:lib';
|
|||
import React, { PropTypes, Component } from 'react';
|
||||
import NovaForm from "meteor/nova:forms";
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { ModalTrigger } from "meteor/nova:core";
|
||||
import MoviesItem from './MoviesItem.jsx';
|
||||
import Movies from '../collection.js';
|
||||
|
@ -17,6 +16,7 @@ import MoviesNewForm from './MoviesNewForm.jsx';
|
|||
import { compose } from 'react-apollo';
|
||||
import { withCurrentUser, withList } from 'meteor/nova:core';
|
||||
import fragments from '../fragments.js';
|
||||
import Layout from './Layout.jsx';
|
||||
|
||||
const LoadMore = props => <a href="#" className="load-more button button--primary" onClick={props.loadMore}>Load More ({props.count}/{props.totalCount})</a>
|
||||
|
||||
|
@ -40,13 +40,16 @@ class MoviesList extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
|
||||
const canCreateNewMovie = Movies.options.mutations.new.check(this.props.currentUser);
|
||||
|
||||
if (this.props.loading) {
|
||||
return <div className="movies"><p>Loading…</p></div>
|
||||
} else {
|
||||
const hasMore = this.props.totalCount > this.props.results.length;
|
||||
return (
|
||||
<div className="movies">
|
||||
{this.renderNew()}
|
||||
{canCreateNewMovie ? this.renderNew() : null}
|
||||
{this.props.results.map(movie => <MoviesItem key={movie._id} {...movie} currentUser={this.props.currentUser}/>)}
|
||||
{hasMore ? <LoadMore {...this.props}/> : <p>No more movies</p>}
|
||||
</div>
|
||||
|
|
|
@ -13,13 +13,7 @@ const MoviesNewForm = (props, context) => {
|
|||
return (
|
||||
<NovaForm
|
||||
collection={Movies}
|
||||
currentUser={props.currentUser}
|
||||
successCallback={document => {
|
||||
context.closeCallback();
|
||||
}}
|
||||
removeSuccessCallback={({ documentId, documentTitle }) => {
|
||||
context.closeCallback();
|
||||
}}
|
||||
currentUser={props.currentUser}
|
||||
queryName="moviesListQuery"
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -6,10 +6,10 @@ Wrapper for the Movies components
|
|||
|
||||
import Telescope from 'meteor/nova:lib';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import NovaForm from "meteor/nova:forms";
|
||||
import NovaForm from 'meteor/nova:forms';
|
||||
import { Button } from 'react-bootstrap';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { ModalTrigger, Messages, FlashContainer } from "meteor/nova:core";
|
||||
import { FlashContainer } from 'meteor/nova:core';
|
||||
import Accounts from './Accounts.jsx';
|
||||
import MoviesList from './MoviesList.jsx';
|
||||
|
||||
class MoviesWrapper extends Component {
|
||||
|
@ -17,12 +17,9 @@ class MoviesWrapper extends Component {
|
|||
return (
|
||||
<div className="wrapper">
|
||||
|
||||
{/*<div style={{maxWidth: "300px"}}>
|
||||
<Accounts.ui.LoginForm />
|
||||
</div>
|
||||
|
||||
<FlashContainer component={Telescope.components.FlashMessages}/>
|
||||
*/}
|
||||
<div className="header">
|
||||
<Accounts />
|
||||
</div>
|
||||
|
||||
<div className="main">
|
||||
<MoviesList />
|
||||
|
|
|
@ -3,3 +3,7 @@ import './i18n.js';
|
|||
import './permissions.js';
|
||||
import './routes.js';
|
||||
import './schema.js';
|
||||
|
||||
import './components/App.jsx';
|
||||
import './components/Icon.jsx';
|
||||
import './components/Loading.jsx';
|
||||
|
|
|
@ -24,7 +24,8 @@ const mutations = {
|
|||
collection: context.Movies,
|
||||
document: document,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +51,8 @@ const mutations = {
|
|||
set: set,
|
||||
unset: unset,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,8 @@ const mutations = {
|
|||
collection: context.Movies,
|
||||
documentId: documentId,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -64,4 +64,22 @@ const schema = {
|
|||
}
|
||||
};
|
||||
|
||||
export default schema;
|
||||
export default schema;
|
||||
|
||||
|
||||
const termsSchema = `
|
||||
input Terms {
|
||||
view: String
|
||||
userId: String
|
||||
cat: String
|
||||
date: String
|
||||
after: String
|
||||
before: String
|
||||
enableCache: Boolean
|
||||
listId: String
|
||||
query: String # search query
|
||||
postId: String
|
||||
}
|
||||
`;
|
||||
|
||||
Telescope.graphQL.addSchema(termsSchema);
|
||||
|
|
|
@ -50,6 +50,15 @@ const seedData = [
|
|||
];
|
||||
|
||||
Meteor.startup(function () {
|
||||
if (Users.find().fetch().length === 0) {
|
||||
Accounts.createUser({
|
||||
username: 'DemoUser',
|
||||
email: 'dummyuser@telescopeapp.org',
|
||||
profile: {
|
||||
isDummy: true
|
||||
}
|
||||
});
|
||||
}
|
||||
const currentUser = Users.findOne();
|
||||
if (Movies.find().fetch().length === 0) {
|
||||
seedData.forEach(document => {
|
||||
|
|
4
packages/custom-collection-demo/lib/style.css
Normal file
4
packages/custom-collection-demo/lib/style.css
Normal file
|
@ -0,0 +1,4 @@
|
|||
.accounts-ui{
|
||||
border: 1px solid #ccc;
|
||||
margin-bottom: 20px;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
Package.describe({
|
||||
name: "custom-collection-demo",
|
||||
summary: "Telescope components package",
|
||||
version: "0.27.4-nova",
|
||||
git: "https://github.com/TelescopeJS/Telescope.git"
|
||||
name: 'custom-collection-demo',
|
||||
summary: 'Telescope components package',
|
||||
version: '0.27.4-nova',
|
||||
git: 'https://github.com/TelescopeJS/Telescope.git'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
|
@ -11,9 +11,14 @@ Package.onUse(function (api) {
|
|||
|
||||
api.use([
|
||||
'nova:core@0.27.4-nova',
|
||||
'nova:forms@0.27.4-nova',
|
||||
|
||||
'std:accounts-ui@1.2.9',
|
||||
]);
|
||||
|
||||
api.mainModule("server.js", "server");
|
||||
api.mainModule("client.js", "client");
|
||||
api.addFiles('lib/style.css', 'client');
|
||||
|
||||
api.mainModule('server.js', 'server');
|
||||
api.mainModule('client.js', 'client');
|
||||
|
||||
});
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
import './components.js';
|
||||
import './config.js';
|
||||
import './routes.js';
|
||||
|
|
12
packages/nova-base-components/lib/routes.js
Normal file
12
packages/nova-base-components/lib/routes.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
|
||||
Telescope.routes.indexRoute = { name: 'posts.list', component: Telescope.components.PostsHome };
|
||||
|
||||
Telescope.routes.add([
|
||||
{name:'posts.daily', path:'daily', component: Telescope.components.PostsDaily},
|
||||
{name:'posts.single', path:'posts/:_id(/:slug)', component: Telescope.components.PostsSingle},
|
||||
{name:'users.single', path:'users/:slug', component: Telescope.components.UsersSingle},
|
||||
{name:'users.account', path:'account', component: Telescope.components.UsersAccount},
|
||||
{name:'resetPassword', path:'reset-password/:token', component: Telescope.components.UsersResetPassword},
|
||||
{name:'users.edit', path:'users/:slug/edit', component: Telescope.components.UsersAccount},
|
||||
]);
|
|
@ -1,2 +1,3 @@
|
|||
import './components.js';
|
||||
import './config.js';
|
||||
import './routes.js';
|
||||
|
|
|
@ -2,7 +2,6 @@ import Telescope from 'meteor/nova:lib';
|
|||
import React, { PropTypes, Component } from 'react';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { Dropdown, MenuItem } from 'react-bootstrap';
|
||||
import { LinkContainer } from 'react-router-bootstrap';
|
||||
import Users from 'meteor/nova:users';
|
||||
|
|
|
@ -5,7 +5,6 @@ import { Modal } from 'react-bootstrap';
|
|||
import NovaForm from "meteor/nova:forms";
|
||||
import { withRouter } from 'react-router'
|
||||
import Users from 'meteor/nova:users';
|
||||
import { Accounts } from 'meteor/std:accounts-ui';
|
||||
import { withCurrentUser } from 'meteor/nova:core';
|
||||
|
||||
const UsersProfileCheckModal = ({show, router, currentUser}, context) => {
|
||||
|
|
|
@ -24,7 +24,8 @@ const mutations = {
|
|||
collection: context.Categories,
|
||||
document: document,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +51,8 @@ const mutations = {
|
|||
set: set,
|
||||
unset: unset,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,8 @@ const mutations = {
|
|||
collection: context.Categories,
|
||||
documentId: documentId,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -24,7 +24,8 @@ const mutations = {
|
|||
collection: context.Comments,
|
||||
document: document,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +51,8 @@ const mutations = {
|
|||
set: set,
|
||||
unset: unset,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,8 @@ const mutations = {
|
|||
collection: context.Comments,
|
||||
documentId: documentId,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ export default function withList (options) {
|
|||
options(ownProps) {
|
||||
return {
|
||||
variables: {
|
||||
terms: ownProps.terms,
|
||||
terms: ownProps.terms || {},
|
||||
offset: 0,
|
||||
limit: 5
|
||||
},
|
||||
|
|
|
@ -9,8 +9,6 @@ export default function withNew(WrappedComponent) {
|
|||
|
||||
const WithNew = props => {
|
||||
|
||||
console.log(props)
|
||||
|
||||
const collection = props.collection,
|
||||
collectionName = collection._name,
|
||||
mutationName = collection.options.mutations.new.name,
|
||||
|
@ -19,15 +17,16 @@ export default function withNew(WrappedComponent) {
|
|||
listResolverName = collection.options.resolvers.list.name,
|
||||
totalResolverName = collection.options.resolvers.total.name;
|
||||
|
||||
const updateQueries = {};
|
||||
updateQueries[props.queryName] = (prev, { mutationResult }) => {
|
||||
const newDocument = mutationResult.data[mutationName];
|
||||
const newList = update(prev, {
|
||||
[listResolverName]: { $unshift: [newDocument] },
|
||||
[totalResolverName]: { $set: prev[totalResolverName] + 1 }
|
||||
});
|
||||
return newList;
|
||||
};
|
||||
const updateQueries = {
|
||||
[props.queryName]: (prev, { mutationResult }) => {
|
||||
const newDocument = mutationResult.data[mutationName];
|
||||
const newList = update(prev, {
|
||||
[listResolverName]: { $unshift: [newDocument] },
|
||||
[totalResolverName]: { $set: prev[totalResolverName] + 1 }
|
||||
});
|
||||
return newList;
|
||||
}
|
||||
}
|
||||
|
||||
const ComponentWithNew = graphql(gql`
|
||||
mutation ${mutationName}($document: ${collectionName}Input) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import Telescope from 'meteor/nova:lib';
|
||||
import React, { PropTypes, Component } from 'react';
|
||||
import { FormattedMessage, intlShape } from 'react-intl';
|
||||
import Formsy from 'formsy-react';
|
||||
|
@ -411,10 +412,11 @@ class FormWithMutations extends Component{
|
|||
if (window.confirm(deleteDocumentConfirm)) {
|
||||
this.props.removeMutation({documentId})
|
||||
.then((mutationResult) => { // the mutation result looks like {data:{collectionRemove: null}} if succeeded
|
||||
this.props.removeSuccessCallback({documentId, documentTitle});
|
||||
if (this.props.removeSuccessCallback) this.props.removeSuccessCallback({documentId, documentTitle});
|
||||
if (this.context.closeCallback) this.context.closeCallback();
|
||||
})
|
||||
.catch(() => {
|
||||
console.log('Something went bad when removing the document', documentId);
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -425,9 +427,6 @@ class FormWithMutations extends Component{
|
|||
|
||||
render() {
|
||||
|
||||
console.log('// FormWithMutations')
|
||||
console.log(this)
|
||||
|
||||
const fieldGroups = this.getFieldGroups();
|
||||
const collectionName = this.props.collection._name;
|
||||
|
||||
|
|
|
@ -37,9 +37,11 @@ class FormWithSingle extends Component{
|
|||
relevantFields = _.intersection(relevantFields, fields);
|
||||
}
|
||||
|
||||
// fields with resolvers should be treated as arrays of _ids
|
||||
// fields with resolvers that contain "[" should be treated as arrays of _ids
|
||||
// TODO: find a cleaner way to handle this
|
||||
relevantFields = relevantFields.map(fieldName => {
|
||||
return this.getSchema()[fieldName].resolveAs ? `${fieldName}{_id}` : fieldName;
|
||||
const resolveAs = this.getSchema()[fieldName].resolveAs;
|
||||
return resolveAs && resolveAs.indexOf('[') > -1 ? `${fieldName}{_id}` : fieldName;
|
||||
});
|
||||
|
||||
// generate fragment based on the fields that can be edited. Note: always add _id.
|
||||
|
@ -78,9 +80,9 @@ class FormWithSingle extends Component{
|
|||
fragment: this.getFragment(),
|
||||
}
|
||||
|
||||
// create a stateless component that's wrapped with withSingle,
|
||||
// create a stateless loader component that's wrapped with withSingle,
|
||||
// displays the loading state if needed, and passes on loading and document
|
||||
const ComponentWithSingle = withSingle(withSingleOptions)(({ document, loading }) => {
|
||||
const loader = ({ document, loading }) => {
|
||||
return loading ?
|
||||
<Telescope.components.Loading /> :
|
||||
<FormWithMutations
|
||||
|
@ -89,7 +91,9 @@ class FormWithSingle extends Component{
|
|||
{...childProps}
|
||||
{...parentProps}
|
||||
/>;
|
||||
});
|
||||
}
|
||||
loader.displayName = `withLoader(FormWithMutations)`;
|
||||
const ComponentWithSingle = withSingle(withSingleOptions)(loader);
|
||||
|
||||
// if this is an edit from, load the necessary data using the withSingle HoC
|
||||
return this.getFormType() === 'edit' ?
|
||||
|
|
|
@ -69,14 +69,14 @@ var createDummyUsers = function () {
|
|||
username: 'Arnold',
|
||||
email: 'dummyuser2@telescopeapp.org',
|
||||
profile: {
|
||||
isDummy: true
|
||||
__isDummy: true
|
||||
}
|
||||
});
|
||||
Accounts.createUser({
|
||||
username: 'Julia',
|
||||
email: 'dummyuser3@telescopeapp.org',
|
||||
profile: {
|
||||
isDummy: true
|
||||
__isDummy: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import Telescope from './config.js';
|
||||
|
||||
/*
|
||||
|
||||
Mutations have four steps:
|
||||
|
@ -29,7 +31,7 @@ to the client.
|
|||
*/
|
||||
|
||||
|
||||
const newMutation = ({ collection, document, currentUser, validate }) => {
|
||||
const newMutation = ({ collection, document, currentUser, validate, context }) => {
|
||||
|
||||
console.log("// newMutation")
|
||||
console.log(collection._name)
|
||||
|
@ -50,7 +52,7 @@ const newMutation = ({ collection, document, currentUser, validate }) => {
|
|||
// check that the current user has permission to insert each field
|
||||
_.keys(document).forEach(function (fieldName) {
|
||||
var field = schema[fieldName];
|
||||
if (!Users.canSubmitField (currentUser, field)) {
|
||||
if (!context.Users.canSubmitField (currentUser, field)) {
|
||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||
}
|
||||
});
|
||||
|
@ -87,7 +89,7 @@ const newMutation = ({ collection, document, currentUser, validate }) => {
|
|||
return document;
|
||||
}
|
||||
|
||||
const editMutation = ({ collection, documentId, set, unset, currentUser, validate }) => {
|
||||
const editMutation = ({ collection, documentId, set, unset, currentUser, validate, context }) => {
|
||||
|
||||
console.log("// editMutation")
|
||||
console.log(collection._name)
|
||||
|
@ -111,7 +113,7 @@ const editMutation = ({ collection, documentId, set, unset, currentUser, validat
|
|||
const modifiedProperties = _.keys(set).concat(_.keys(unset));
|
||||
modifiedProperties.forEach(function (fieldName) {
|
||||
var field = schema[fieldName];
|
||||
if (!Users.canEditField(currentUser, field, document)) {
|
||||
if (!context.Users.canEditField(currentUser, field, document)) {
|
||||
throw new Meteor.Error('disallowed_property', `disallowed_property_detected: ${fieldName}`);
|
||||
}
|
||||
});
|
||||
|
@ -141,7 +143,7 @@ const editMutation = ({ collection, documentId, set, unset, currentUser, validat
|
|||
return newDocument;
|
||||
}
|
||||
|
||||
const removeMutation = ({ collection, documentId, currentUser, validate }) => {
|
||||
const removeMutation = ({ collection, documentId, currentUser, validate, context }) => {
|
||||
|
||||
console.log("// removeMutation")
|
||||
console.log(collection._name)
|
||||
|
|
|
@ -24,7 +24,8 @@ const mutations = {
|
|||
collection: context.Posts,
|
||||
document: document,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +51,8 @@ const mutations = {
|
|||
set: set,
|
||||
unset: unset,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,8 @@ const mutations = {
|
|||
collection: context.Posts,
|
||||
documentId: documentId,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -13,21 +13,6 @@ import {getDataFromTree} from "react-apollo/server";
|
|||
import { meteorClientConfig } from 'meteor/nova:apollo';
|
||||
import { configureStore } from "./store.js";
|
||||
|
||||
/*
|
||||
Routes definition
|
||||
*/
|
||||
|
||||
Telescope.routes.indexRoute = { name: "posts.list", component: Telescope.components.PostsHome };
|
||||
|
||||
Telescope.routes.add([
|
||||
{name:"posts.daily", path:"daily", component: Telescope.components.PostsDaily},
|
||||
{name:"posts.single", path:"posts/:_id(/:slug)", component: Telescope.components.PostsSingle},
|
||||
{name:"users.single", path:"users/:slug", component: Telescope.components.UsersSingle},
|
||||
{name:"users.account", path:"account", component: Telescope.components.UsersAccount},
|
||||
{name:"resetPassword", path:"reset-password/:token", component: Telescope.components.UsersResetPassword},
|
||||
{name:"users.edit", path:"users/:slug/edit", component: Telescope.components.UsersAccount},
|
||||
]);
|
||||
|
||||
Meteor.startup(function initNovaRoutesAndApollo() {
|
||||
|
||||
Telescope.routes.add({name:"app.notfound", path:"*", component:Telescope.components.Error404});
|
|
@ -1,6 +1,6 @@
|
|||
Package.describe({
|
||||
name: "nova:base-routes",
|
||||
summary: "Nova routes package",
|
||||
name: "nova:routing",
|
||||
summary: "Nova router package",
|
||||
version: "0.27.4-nova",
|
||||
git: "https://github.com/TelescopeJS/Telescope.git"
|
||||
});
|
||||
|
@ -10,17 +10,9 @@ Package.onUse(function (api) {
|
|||
api.versionsFrom(['METEOR@1.0']);
|
||||
|
||||
api.use([
|
||||
|
||||
// Nova packages
|
||||
|
||||
'nova:core@0.27.4-nova',
|
||||
'nova:posts@0.27.4-nova',
|
||||
'nova:users@0.27.4-nova',
|
||||
'nova:comments@0.27.4-nova',
|
||||
|
||||
// third-party packages
|
||||
|
||||
'utilities:react-list-container@0.1.10'
|
||||
'nova:apollo@0.27.4-nova',
|
||||
]);
|
||||
|
||||
api.addFiles([
|
|
@ -24,7 +24,8 @@ const mutations = {
|
|||
collection: context.Users,
|
||||
document: document,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -50,7 +51,8 @@ const mutations = {
|
|||
set: set,
|
||||
unset: unset,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -74,7 +76,8 @@ const mutations = {
|
|||
collection: context.Users,
|
||||
documentId: documentId,
|
||||
currentUser: context.currentUser,
|
||||
validate: true
|
||||
validate: true,
|
||||
context,
|
||||
});
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue