2016-11-18 16:01:27 +09:00
|
|
|
|
import Telescope from 'meteor/nova:lib';
|
|
|
|
|
import React, { PropTypes, Component } from 'react';
|
|
|
|
|
import NovaForm from "meteor/nova:forms";
|
2016-11-21 19:23:43 +09:00
|
|
|
|
import Users from "meteor/nova:users";
|
2016-11-18 16:01:27 +09:00
|
|
|
|
import { Button } from 'react-bootstrap';
|
|
|
|
|
import { Accounts } from 'meteor/std:accounts-ui';
|
|
|
|
|
import { ModalTrigger } from "meteor/nova:core";
|
|
|
|
|
import Movies from '../collection.js';
|
2016-11-21 19:23:43 +09:00
|
|
|
|
import { withCurrentUser } from 'meteor/nova:core';
|
2016-11-18 16:01:27 +09:00
|
|
|
|
|
|
|
|
|
class Movie extends Component {
|
|
|
|
|
|
|
|
|
|
renderEdit() {
|
|
|
|
|
|
|
|
|
|
const movie = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="item-actions">
|
2016-11-21 19:23:43 +09:00
|
|
|
|
<ModalTrigger
|
|
|
|
|
label="Edit Movie"
|
|
|
|
|
component={<Button bsStyle="primary">Edit Movie</Button>}
|
|
|
|
|
>
|
|
|
|
|
<NovaForm
|
|
|
|
|
collection={Movies}
|
|
|
|
|
currentUser={this.props.currentUser}
|
|
|
|
|
document={movie}
|
|
|
|
|
mutationName="moviesEdit"
|
|
|
|
|
/>
|
|
|
|
|
</ModalTrigger>
|
2016-11-18 16:01:27 +09:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
|
|
const movie = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div key={movie.name} style={{paddingBottom: "15px",marginBottom: "15px", borderBottom: "1px solid #ccc"}}>
|
|
|
|
|
<h2>{movie.name} ({movie.year})</h2>
|
2016-11-19 20:01:17 +01:00
|
|
|
|
<p>{movie.review} – by <strong>{movie.user && movie.user.__displayName}</strong></p>
|
2016-11-21 19:23:43 +09:00
|
|
|
|
{Movies.options.mutations.edit.check(this.props.currentUser, movie) ? this.renderEdit() : null}
|
2016-11-18 16:01:27 +09:00
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-21 19:23:43 +09:00
|
|
|
|
export default withCurrentUser(Movie);
|