client/src/components/Session.js
changeset 138 a1fb2ced3049
parent 137 279e1dffa213
child 143 cfcbf4bc66f1
equal deleted inserted replaced
137:279e1dffa213 138:a1fb2ced3049
    11 import * as sessionsActions from '../actions/sessionsActions';
    11 import * as sessionsActions from '../actions/sessionsActions';
    12 import * as notesActions from '../actions/notesActions';
    12 import * as notesActions from '../actions/notesActions';
    13 import * as userActions from '../actions/userActions';
    13 import * as userActions from '../actions/userActions';
    14 import { getSession, getSessionNotes } from '../selectors/coreSelectors';
    14 import { getSession, getSessionNotes } from '../selectors/coreSelectors';
    15 import { getAutoSubmit } from '../selectors/authSelectors';
    15 import { getAutoSubmit } from '../selectors/authSelectors';
       
    16 import { extractAnnotationCategories, defaultAnnotationsCategories } from '../constants';
    16 
    17 
    17 class Session extends Component {
    18 class Session extends Component {
    18   render() {
    19   render() {
    19     return (
    20     return (
    20       <div>
    21       <div>
    29               <hr />
    30               <hr />
    30               <NotesList
    31               <NotesList
    31                 notes={this.props.notes}
    32                 notes={this.props.notes}
    32                 deleteNote={this.props.notesActions.deleteNote}
    33                 deleteNote={this.props.notesActions.deleteNote}
    33                 updateNote={this.props.notesActions.updateNote}
    34                 updateNote={this.props.notesActions.updateNote}
       
    35                 annotationCategories={this.props.annotationCategories}
    34               />
    36               />
    35             </div>
    37             </div>
    36           </div>
    38           </div>
    37           <section className="editor-fixed">
    39           <section className="editor-fixed">
    38             <Grid fluid>
    40             <Grid fluid>
    40                 <Col md={9} mdOffset={3}>
    42                 <Col md={9} mdOffset={3}>
    41                   <NoteInput
    43                   <NoteInput
    42                     session={this.props.currentSession}
    44                     session={this.props.currentSession}
    43                     autoSubmit={this.props.autoSubmit}
    45                     autoSubmit={this.props.autoSubmit}
    44                     addNote={this.props.notesActions.addNote}
    46                     addNote={this.props.notesActions.addNote}
    45                     setAutoSubmit={this.props.userActions.setAutoSubmit} />
    47                     setAutoSubmit={this.props.userActions.setAutoSubmit}
       
    48                     annotationCategories={this.props.annotationCategories}/>
    46                 </Col>
    49                 </Col>
    47               </Row>
    50               </Row>
    48             </Grid>
    51             </Grid>
    49           </section>
    52           </section>
    50         </div>
    53         </div>
    58   const sessionId = props.match.params.id;
    61   const sessionId = props.match.params.id;
    59 
    62 
    60   const autoSubmit = getAutoSubmit(state);
    63   const autoSubmit = getAutoSubmit(state);
    61   const currentSession = getSession(sessionId, state);
    64   const currentSession = getSession(sessionId, state);
    62   const currentNotes = getSessionNotes(sessionId, state);
    65   const currentNotes = getSessionNotes(sessionId, state);
       
    66   const annotationCategories = currentSession?extractAnnotationCategories(currentSession.get('protocol')):defaultAnnotationsCategories;
    63 
    67 
    64   return {
    68   return {
    65     currentSession,
    69     currentSession,
    66     notes: currentNotes,
    70     notes: currentNotes,
    67     autoSubmit
    71     autoSubmit,
       
    72     annotationCategories
    68   };
    73   };
    69 }
    74 }
    70 
    75 
    71 function mapDispatchToProps(dispatch) {
    76 function mapDispatchToProps(dispatch) {
    72   return {
    77   return {