Use withPagination on CollectionView
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Wed, 07 Jun 2017 14:18:32 +0200
changeset 228 9c2cc723db97
parent 227 d191f86135c0
child 229 584564700959
Use withPagination on CollectionView So pagination links are displayed on relations as well (i.e. for /etype/<eid>/rtype/).
src/components/Entity.js
--- a/src/components/Entity.js	Wed Jun 07 14:00:07 2017 +0200
+++ b/src/components/Entity.js	Wed Jun 07 14:18:32 2017 +0200
@@ -4,7 +4,7 @@
 
 import {PropTypesResourceModel} from '../model';
 import {PropTypeJsonaryWrapper} from '../jsonaryutils';
-import {ActionsDropDown, CollectionView} from './BaseViews';
+import {ActionsDropDown, withPagination, CollectionView} from './BaseViews';
 import {AttributeValue} from './Attribute';
 
 export function EntityAttributes(props) {
@@ -69,6 +69,8 @@
     data: PropTypeJsonaryWrapper.isRequired,
 };
 
+export const PaginatedCollectionView = withPagination(CollectionView);
+
 export function RelatedResources(props) {
     let actions = null;
     if (props.resource !== null && props.resource.allowedActions.length > 1) {
@@ -81,7 +83,8 @@
     } else if (props.resource.data.length() === 0) {
         related = <div className="panel-body text-muted">nothing related yet</div>;
     } else {
-        related = <CollectionView collection={props.resource.data} />;
+        related = <PaginatedCollectionView className="list-group" changeRoute={props.changeRoute}
+            resource={props.resource} collection={props.resource.data} />;
     }
 
     return (
@@ -101,6 +104,7 @@
 RelatedResources.propTypes = {
     title: PropTypes.string.isRequired,
     resource: PropTypesResourceModel.isRequired,
+    changeRoute: PropTypes.func.isRequired,
 };
 
 const uiSchema = {