Commit b582844bebaf83ef3e4a9d393d81fc72b74736a1

Authored by themeteorchef
Exists in master

Merge branch 'master' of https://github.com/PaulSavignano/base into PaulSavignano-master

imports/ui/components/DocumentsList.js
1 1 import React from 'react';
  2 +import { browserHistory } from 'react-router';
2 3 import { ListGroup, ListGroupItem, Alert } from 'react-bootstrap';
3 4  
  5 +const handleNav = (_id) => {
  6 + browserHistory.push(`/documents/${_id}`);
  7 +}
  8 +
4 9 const DocumentsList = ({ documents }) => (
5 10 documents.length > 0 ? <ListGroup className="DocumentsList">
6 11 {documents.map(({ _id, title }) => (
7   - <ListGroupItem key={ _id } href={`/documents/${_id}`}>{ title }</ListGroupItem>
  12 + <ListGroupItem key={ _id } onClick={ () => handleNav(_id) }>
  13 + { title }
  14 + </ListGroupItem>
8 15 ))}
9 16 </ListGroup> :
10 17 <Alert bsStyle="warning">No documents yet.</Alert>
... ...
imports/ui/pages/Documents.js
1 1 import React from 'react';
  2 +import { Link } from 'react-router';
2 3 import { Row, Col, Button } from 'react-bootstrap';
3 4 import DocumentsList from '../containers/DocumentsList.js';
4 5  
... ... @@ -8,11 +9,12 @@ const Documents = () =&gt; (
8 9 <Col xs={ 12 }>
9 10 <div className="page-header clearfix">
10 11 <h4 className="pull-left">Documents</h4>
11   - <Button
12   - bsStyle="success"
13   - className="pull-right"
14   - href="/documents/new"
15   - >New Document</Button>
  12 + <Link to="/documents/new">
  13 + <Button
  14 + bsStyle="success"
  15 + className="pull-right"
  16 + >New Document</Button>
  17 + </Link>
16 18 </div>
17 19 <DocumentsList />
18 20 </Col>
... ...
imports/ui/pages/ViewDocument.js
... ... @@ -4,6 +4,10 @@ import { browserHistory } from &#39;react-router&#39;;
4 4 import { Bert } from 'meteor/themeteorchef:bert';
5 5 import { removeDocument } from '../../api/documents/methods.js';
6 6  
  7 +const handleEdit = (_id) => {
  8 + browserHistory.push(`/documents/${_id}/edit`);
  9 +}
  10 +
7 11 const handleRemove = (_id) => {
8 12 if (confirm('Are you sure? This is permanent!')) {
9 13 removeDocument.call({ _id }, (error) => {
... ... @@ -23,7 +27,7 @@ const ViewDocument = ({ doc }) =&gt; (
23 27 <h4 className="pull-left">{ doc.title }</h4>
24 28 <ButtonToolbar className="pull-right">
25 29 <ButtonGroup bsSize="small">
26   - <Button href={`/documents/${doc._id}/edit`}>Edit</Button>
  30 + <Button onClick={ () => handleEdit(doc._id) }>Edit</Button>
27 31 <Button onClick={ () => handleRemove(doc._id) } className="text-danger">Delete</Button>
28 32 </ButtonGroup>
29 33 </ButtonToolbar>
... ...