Skip to content

Commit

Permalink
Correctly render many relationships in cells
Browse files Browse the repository at this point in the history
  • Loading branch information
jesstelford committed May 17, 2018
1 parent ae9f156 commit c68dbc6
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/fields/types/Relationship/views/Cell.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import React from 'react';
import React, { Fragment } from 'react';
import renderTemplate from '@keystonejs/ui/src/template';

export default ({ data, field, Link }) => {
if (!data) {
return null;
}
const refList = field.adminMeta.getListByKey(field.config.ref);
return (
<Link path={refList.path} id={data.id}>
{renderTemplate({ template: refList.displayTemplate, data })}
</Link>
<Fragment>
{(Array.isArray(data) ? data : [data]).filter(Boolean).map((item, index) =>
<Fragment key={item.id}>
{!!index ? ', ' : ''}
<Link path={refList.path} id={item.id}>
{renderTemplate({ template: refList.displayTemplate, data: item })}
</Link>
</Fragment>
)}
</Fragment>
);
};

0 comments on commit c68dbc6

Please sign in to comment.