PropTypesEntityModel/EntitiesModel extend PropTypesResourceModel
authorFrank Bessou <frank.bessou@logilab.fr>
Tue, 04 Apr 2017 16:20:04 +0200
changeset 75 8ef8d6f31fca
parent 74 0cd81011cef3
child 76 0aff36e8062a
PropTypesEntityModel/EntitiesModel extend PropTypesResourceModel
src/model.js
--- a/src/model.js	Tue Apr 04 15:34:25 2017 +0200
+++ b/src/model.js	Tue Apr 04 16:20:04 2017 +0200
@@ -1,4 +1,5 @@
 import React from 'react';
+import {merge} from 'lodash';
 import {PropTypeJsonaryWrapper} from './jsonaryutils';
 
 
@@ -9,19 +10,21 @@
         'delete',
     ]);
 
-export const PropTypesEntityModel = React.PropTypes.shape({
+const RESOURCE_PROPERTIES = {
     url: React.PropTypes.string.isRequired,
-    route: React.PropTypes.string.isRequired,
-    etype: React.PropTypes.string.isRequired,
-    eid: React.PropTypes.string.isRequired,
     data: PropTypeJsonaryWrapper.isRequired,
     allowedActions: React.PropTypes.arrayOf(PropTypeAction).isRequired,
-});
+};
+
+export const PropTypesResourceModel = React.PropTypes.shape(RESOURCE_PROPERTIES);
 
-export const PropTypesEntitiesModel = React.PropTypes.shape({
-    url: React.PropTypes.string.isRequired,
+export const PropTypesEntityModel = React.PropTypes.shape(merge({
+    etype: React.PropTypes.string.isRequired,
+    eid: React.PropTypes.string.isRequired,
     route: React.PropTypes.string.isRequired,
+}, RESOURCE_PROPERTIES));
+
+export const PropTypesEntitiesModel = React.PropTypes.shape(merge({
     etype: React.PropTypes.string.isRequired,
-    data: PropTypeJsonaryWrapper.isRequired,
-    allowedActions: React.PropTypes.arrayOf(PropTypeAction).isRequired,
-});
+    route: React.PropTypes.string.isRequired,
+}, RESOURCE_PROPERTIES));