Make CollectionItemLink use the id's title to render a title
authorFrank Bessou <frank.bessou@logilab.fr>
Mon, 18 Dec 2017 18:10:54 +0100
changeset 256 46911701ee61
parent 255 ba56a53b0abd
child 257 3ebd6a8d8f30
Make CollectionItemLink use the id's title to render a title The CollectionitemLink could only render lists of items with a 'title' property. Related collections now only contain an 'id' field, with a corresponding schema containing its title. When it is available, use this title instead.
src/components/BaseViews.js
--- a/src/components/BaseViews.js	Mon Dec 18 16:10:33 2017 +0100
+++ b/src/components/BaseViews.js	Mon Dec 18 18:10:54 2017 +0100
@@ -7,9 +7,10 @@
 
 export function CollectionItemLink({item}) {
     const itemRoute = item.getLink('item').href;
+    const title = item.property('id').schemas().title() || item.get('/title');
     return (
         <Link to={`${itemRoute}`}>
-            {item.get('/title')}
+            {title}
         </Link>
     );
 }