# HG changeset patch # User ymh # Date 1501746277 -7200 # Node ID 6f3078f7fd47da7d656873da3e32fdc0d8e6f090 # Parent 906a6c7c7943044a3391b479c5d5884afd6b17d3 Work on correct protocol propagation diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/actions/sessionsActions.js --- a/client/src/actions/sessionsActions.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/actions/sessionsActions.js Thu Aug 03 09:44:37 2017 +0200 @@ -3,7 +3,7 @@ import * as types from '../constants/actionTypes'; -export const createSession = (sessionId) => { +export const createSession = (sessionId, groupName, protocol) => { const newSession = { _id: sessionId, @@ -11,6 +11,8 @@ date: now(), title: '', description: '', + group: groupName, + protocol: protocol, action: ActionEnum.CREATED }; diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/components/SessionForm.js --- a/client/src/components/SessionForm.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/components/SessionForm.js Thu Aug 03 09:44:37 2017 +0200 @@ -27,7 +27,9 @@ onGroupChange = (e) => { const groupName = e.target.value; - this.props.sessionsActions.updateSession(this.props.currentSession, { group: groupName }); + const group = this.props.groups.find((g) => g.get('name') === groupName); + + this.props.sessionsActions.updateSession(this.props.currentSession, { group: groupName, protocol: group?group.get('protocol'):'' }); } componentWillUpdate = (nextProps, nextState) => { diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/components/SessionList.js --- a/client/src/components/SessionList.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/components/SessionList.js Thu Aug 03 09:44:37 2017 +0200 @@ -18,7 +18,15 @@ createSession = () => { const sessionId = uuidV1(); - this.props.sessionsActions.createSession(sessionId); + const groupName = (this.props.currentUser)?this.props.currentUser.get('default_group'):null; + let protocol = null; + if(groupName != null) { + const group = this.props.groups.find((g) => g.name === groupName); + if(group) { + protocol = group.get('protocol'); + } + } + this.props.sessionsActions.createSession(sessionId, groupName, protocol); this.props.history.push('/sessions/' + sessionId); } @@ -86,13 +94,15 @@ function mapStateToProps(state, props) { return { - sessions: state.get('sessions').filter(session => session.get('action') !== ActionEnum.DELETED) + sessions: state.get('sessions').filter(session => session.get('action') !== ActionEnum.DELETED), + currentUser: state.getIn(['authStatus', 'currentUser']), + groups: state.get('groups') }; } function mapDispatchToProps(dispatch) { return { - sessionsActions: bindActionCreators(sessionsActions, dispatch) + sessionsActions: bindActionCreators(sessionsActions, dispatch), } } diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/sagas/SessionSyncronizer.js --- a/client/src/sagas/SessionSyncronizer.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/sagas/SessionSyncronizer.js Thu Aug 03 09:44:37 2017 +0200 @@ -43,7 +43,7 @@ title: localObjInst.get('title'), description: localObjInst.get('description'), group: localObjInst.get('group'), - protocol: '' + protocol: localObjInst.get('protocol'), }; } diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/sagas/groupSaga.js --- a/client/src/sagas/groupSaga.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/sagas/groupSaga.js Thu Aug 03 09:44:37 2017 +0200 @@ -25,7 +25,7 @@ const actions = [ groupCreateSuccess(response), - updateSession(session, {group: response.name}) + updateSession(session, {group: response.name, protocol: response.protocol}) ]; yield all(actions.map(action => put(action))); diff -r 906a6c7c7943 -r 6f3078f7fd47 client/src/store/groupRecord.js --- a/client/src/store/groupRecord.js Tue Aug 01 12:20:14 2017 +0200 +++ b/client/src/store/groupRecord.js Thu Aug 03 09:44:37 2017 +0200 @@ -5,6 +5,7 @@ owner: '', isPersonal: false, - description:'' + description:'', + protocol: null }, 'Group'); diff -r 906a6c7c7943 -r 6f3078f7fd47 design/api/metacategory.apib --- a/design/api/metacategory.apib Tue Aug 01 12:20:14 2017 +0200 +++ b/design/api/metacategory.apib Thu Aug 03 09:44:37 2017 +0200 @@ -39,7 +39,7 @@ ## ProtocolRevisionFull (object) -- Include MetacategoryRevision +- Include ProtocolRevision - metacategories (array[MetacategoryRevision]) diff -r 906a6c7c7943 -r 6f3078f7fd47 design/api/metacategory.html --- a/design/api/metacategory.html Tue Aug 01 12:20:14 2017 +0200 +++ b/design/api/metacategory.html Thu Aug 03 09:44:37 2017 +0200 @@ -68,13 +68,10 @@ } } }
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
-  "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
-  "revision": 2,
-  "base": "ef14bcce-52ac-44ba-a7d1-f1441bab94de",
-  "name": "référence",
-  "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin massa nibh, hendrerit quis justo vitae, luctus tempor dolor. Nam quis fringilla diam.",
-  "color": "#2cbfff",
-  "has_comment": false,
+  "id": "a4977c1f-4752-4aff-b724-eec4033af25c",
+  "owner": "group1",
+  "revision": "1",
+  "description": "Cras rutrum lacinia pretium. Suspendisse justo est, tincidunt sed tellus a, sodales suscipit risus. Curabitur odio tortor, tincidunt sed est nec, ullamcorper sodales velit.",
   "metacategories": [
     {
       "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
@@ -93,24 +90,15 @@
     "id": {
       "type": "string"
     },
-    "revision": {
-      "type": "number"
-    },
-    "base": {
+    "owner": {
       "type": "string"
     },
-    "name": {
+    "revision": {
       "type": "string"
     },
     "description": {
       "type": "string"
     },
-    "color": {
-      "type": "string"
-    },
-    "has_comment": {
-      "type": "boolean"
-    },
     "metacategories": {
       "type": "array"
     }
@@ -227,13 +215,10 @@
     }
   }
 }
Response  201
HideShow
Headers
Content-Type: application/json
Body
{
-  "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
-  "revision": 2,
-  "base": "ef14bcce-52ac-44ba-a7d1-f1441bab94de",
-  "name": "référence",
-  "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin massa nibh, hendrerit quis justo vitae, luctus tempor dolor. Nam quis fringilla diam.",
-  "color": "#2cbfff",
-  "has_comment": false,
+  "id": "a4977c1f-4752-4aff-b724-eec4033af25c",
+  "owner": "group1",
+  "revision": "1",
+  "description": "Cras rutrum lacinia pretium. Suspendisse justo est, tincidunt sed tellus a, sodales suscipit risus. Curabitur odio tortor, tincidunt sed est nec, ullamcorper sodales velit.",
   "metacategories": [
     {
       "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
@@ -252,24 +237,15 @@
     "id": {
       "type": "string"
     },
-    "revision": {
-      "type": "number"
-    },
-    "base": {
+    "owner": {
       "type": "string"
     },
-    "name": {
+    "revision": {
       "type": "string"
     },
     "description": {
       "type": "string"
     },
-    "color": {
-      "type": "string"
-    },
-    "has_comment": {
-      "type": "boolean"
-    },
     "metacategories": {
       "type": "array"
     }
@@ -300,13 +276,10 @@
 

Example URI

GET /protocol/a4977c1f-4752-4aff-b724-eec4033af25c/2/
URI Parameters
HideShow
id
string (required) Example: a4977c1f-4752-4aff-b724-eec4033af25c

Identifiant d’un protocole

revision
number (required) Example: 2

Numéro de la révision

Response  200
HideShow
Headers
Content-Type: application/json
Body
{
-  "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
-  "revision": 2,
-  "base": "ef14bcce-52ac-44ba-a7d1-f1441bab94de",
-  "name": "référence",
-  "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin massa nibh, hendrerit quis justo vitae, luctus tempor dolor. Nam quis fringilla diam.",
-  "color": "#2cbfff",
-  "has_comment": false,
+  "id": "a4977c1f-4752-4aff-b724-eec4033af25c",
+  "owner": "group1",
+  "revision": "1",
+  "description": "Cras rutrum lacinia pretium. Suspendisse justo est, tincidunt sed tellus a, sodales suscipit risus. Curabitur odio tortor, tincidunt sed est nec, ullamcorper sodales velit.",
   "metacategories": [
     {
       "id": "e5712a76-857a-4769-b27e-a3ac3fb38b4d",
@@ -325,24 +298,15 @@
     "id": {
       "type": "string"
     },
-    "revision": {
-      "type": "number"
-    },
-    "base": {
+    "owner": {
       "type": "string"
     },
-    "name": {
+    "revision": {
       "type": "string"
     },
     "description": {
       "type": "string"
     },
-    "color": {
-      "type": "string"
-    },
-    "has_comment": {
-      "type": "boolean"
-    },
     "metacategories": {
       "type": "array"
     }
@@ -429,7 +393,7 @@
     }
   },
   "$schema": "http://json-schema.org/draft-04/schema#"
-}

Generated by aglio on 16 Jul 2017