Fix links in collections
authorFrank Bessou <frank.bessou@logilab.fr>
Wed, 05 Apr 2017 11:47:12 +0200
changeset 81 d7da436b1dbc
parent 80 225e9a1e59d6
child 82 afe799818c78
Fix links in collections
src/components/BaseViews.js
--- a/src/components/BaseViews.js	Wed Apr 05 11:44:18 2017 +0200
+++ b/src/components/BaseViews.js	Wed Apr 05 11:47:12 2017 +0200
@@ -2,32 +2,32 @@
 import {Link} from 'react-router';
 import {isEmpty} from 'lodash/lang';
 import {PropTypeAction, PropTypesEntitiesModel, PropTypesResourceModel} from '../model';
+import {PropTypeJsonaryWrapper} from '../jsonaryutils';
 import {appendPath} from '../utils';
 
-export function OneLineView({entity}) {
+export function OneLineView({entity, etype}) {
+    // XXX Use schema link when it becomes available
+    const id = entity.get('/id');
     return (
-        <Link to={`${entity.cw_etype}/${entity.id}`}>
-            {entity.title}
+        <Link to={`${etype}/${id}`}>
+            {entity.get('/title')}
         </Link>
     );
 }
 
 OneLineView.propTypes = {
-    entity: React.PropTypes.shape({
-        // XXX JSON schema
-        id: React.PropTypes.string.isRequired,
-        title: React.PropTypes.string.isRequired,
-    }),
+    entity: PropTypeJsonaryWrapper.isRequired,
+    etype: React.PropTypes.string.isRequired,
 };
 
 export function ListView(props) {
     return (
         <ul className="list-group">
             {
-                props.entities.data.value().map(
+                props.entities.data.mapItems(
                     entity => (
                         <li className="list-group-item" key={entity.id}>
-                            <OneLineView entity={entity} />
+                            <OneLineView entity={entity} etype={props.entities.etype} />
                         </li>
                         )
                 )