2 import { getCreatedSessions, getUpdatedSessions, getDeletedSessions } from '../selectors/coreSelectors'; |
2 import { getCreatedSessions, getUpdatedSessions, getDeletedSessions } from '../selectors/coreSelectors'; |
3 import { ActionEnum } from '../constants'; |
3 import { ActionEnum } from '../constants'; |
4 import moment from 'moment'; |
4 import moment from 'moment'; |
5 import SessionRecord from '../store/sessionRecord'; |
5 import SessionRecord from '../store/sessionRecord'; |
6 import { doDeleteSession, loadSession, resetActionSession } from '../actions/sessionsActions'; |
6 import { doDeleteSession, loadSession, resetActionSession } from '../actions/sessionsActions'; |
7 import Immutable from 'immutable'; |
|
8 import SyncMixin from './BaseSyncronizer'; |
7 import SyncMixin from './BaseSyncronizer'; |
|
8 import * as R from 'ramda'; |
9 |
9 |
10 class SessionSyncBase { |
10 class SessionSyncBase { |
11 |
11 |
12 // local diffs (immutable) |
|
13 * getLocalDiffs() { |
12 * getLocalDiffs() { |
14 return Immutable.Map({ |
13 return { |
15 created: yield select(getCreatedSessions), |
14 created: yield select(getCreatedSessions), |
16 updated: yield select(getUpdatedSessions), |
15 updated: yield select(getUpdatedSessions), |
17 deleted: yield select(getDeletedSessions) |
16 deleted: yield select(getDeletedSessions) |
18 }) |
17 } |
19 } |
18 } |
20 |
19 |
21 // remote urls |
20 // remote urls |
22 getRemoteLoadUrl() { |
21 getRemoteLoadUrl() { |
23 return "/api/notes/sessions/"; |
22 return "/api/notes/sessions/"; |
24 } |
23 } |
25 |
24 |
26 getRemoteDeleteUrl(localObjInst) { |
25 getRemoteDeleteUrl(localObjInst) { |
27 return `/api/notes/sessions/${localObjInst.get('_id')}/`; |
26 return `/api/notes/sessions/${R.prop('_id',localObjInst)}/`; |
28 } |
27 } |
29 |
28 |
30 getRemoteCreateUrl(localObjInst) { |
29 getRemoteCreateUrl(localObjInst) { |
31 return "/api/notes/sessions/"; |
30 return "/api/notes/sessions/"; |
32 } |
31 } |
33 |
32 |
34 getRemoteUpdateUrl(localObjInst) { |
33 getRemoteUpdateUrl(localObjInst) { |
35 return `/api/notes/sessions/${localObjInst.get('_id')}/`; |
34 return `/api/notes/sessions/${R.prop('_id',localObjInst)}/`; |
36 } |
35 } |
37 |
36 |
38 // build remote json message |
37 // build remote json message |
39 getRemoteData(localObjInst) { |
38 getRemoteData(localObjInst) { |
40 return { |
39 return { |
41 ext_id: localObjInst.get('_id'), |
40 ext_id: R.prop('_id', localObjInst), |
42 date: localObjInst.get('date'), |
41 date: R.prop('date', localObjInst), |
43 title: localObjInst.get('title'), |
42 title: R.prop('title', localObjInst), |
44 description: localObjInst.get('description'), |
43 description: R.prop('description', localObjInst), |
45 group: localObjInst.get('group'), |
44 group: R.prop('group', localObjInst), |
46 protocol: localObjInst.get('protocol'), |
45 protocol: R.prop('protocol', localObjInst), |
47 }; |
46 }; |
48 } |
47 } |
49 |
48 |
50 getLocalRecord(remoteObj) { |
49 getLocalRecord(remoteObj) { |
51 return SessionRecord({ |
50 return SessionRecord({ |