| author | ymh <ymh.work@gmail.com> |
| Tue, 01 Aug 2017 12:20:14 +0200 | |
| changeset 132 | 906a6c7c7943 |
| parent 129 | d48946d164c6 |
| permissions | -rw-r--r-- |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
import uuidV1 from 'uuid/v1'; |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
import * as types from '../constants/actionTypes'; |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
4 |
// import WebAnnotationSerializer from '../api/WebAnnotationSerializer'; |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
5 |
import { ActionEnum } from '../constants'; |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
|
| 15 | 7 |
export const addNote = (session, data) => { |
|
74
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
8 |
const noteId = uuidV1(); |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
9 |
const note = { |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
10 |
_id: noteId, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
11 |
session: session._id, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
12 |
raw: data.raw, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
13 |
plain: data.plain, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
14 |
html: data.html, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
15 |
startedAt: data.startedAt, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
16 |
finishedAt: data.finishedAt, |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
17 |
categories: data.categories, |
| 78 | 18 |
marginComment: data.marginComment, |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
19 |
action: ActionEnum.CREATED |
|
74
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
20 |
}; |
|
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
21 |
|
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
return { |
|
62
b2514a9bcd49
migrate to redux-offline + various optimisation
ymh <ymh.work@gmail.com>
parents:
59
diff
changeset
|
23 |
type: types.ADD_NOTE, |
|
74
043477fd5c5c
add api call to save notes. internally use ts for time data for notes and session
ymh <ymh.work@gmail.com>
parents:
66
diff
changeset
|
24 |
note, |
|
3
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
}; |
|
3b5d37d84cfe
Some code rename and reorg + basic tests
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
} |
|
79
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
27 |
|
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
28 |
export const deleteNote = (note) => { |
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
29 |
return { |
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
30 |
type: types.DELETE_NOTE, |
|
83
76a4e4b11762
add server request for note update and delete
ymh <ymh.work@gmail.com>
parents:
80
diff
changeset
|
31 |
note, |
|
79
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
32 |
}; |
|
772b73e31069
Introduce note editing, allow deleting note.
Alexandre Segura <mex.zktk@gmail.com>
parents:
78
diff
changeset
|
33 |
} |
|
80
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
34 |
|
|
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
35 |
export const updateNote = (note, data) => { |
|
83
76a4e4b11762
add server request for note update and delete
ymh <ymh.work@gmail.com>
parents:
80
diff
changeset
|
36 |
|
|
80
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
37 |
return { |
|
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
38 |
type: types.UPDATE_NOTE, |
|
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
39 |
note, |
|
83
76a4e4b11762
add server request for note update and delete
ymh <ymh.work@gmail.com>
parents:
80
diff
changeset
|
40 |
data, |
|
80
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
41 |
}; |
|
b3a02ea6d097
Implement note edition.
Alexandre Segura <mex.zktk@gmail.com>
parents:
79
diff
changeset
|
42 |
} |
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
43 |
|
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
44 |
export const doDeleteNote = (noteId) => { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
45 |
return { type: types.DO_DELETE_NOTE, noteId }; |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
46 |
} |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
47 |
|
|
132
906a6c7c7943
add group to sync + create groups + various component cleaning
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
48 |
export const doDeleteAllNote = () => { |
|
906a6c7c7943
add group to sync + create groups + various component cleaning
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
49 |
return { type: types.DO_DELETE_ALL_NOTE }; |
|
906a6c7c7943
add group to sync + create groups + various component cleaning
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
50 |
} |
|
906a6c7c7943
add group to sync + create groups + various component cleaning
ymh <ymh.work@gmail.com>
parents:
129
diff
changeset
|
51 |
|
|
129
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
52 |
export const loadNote = (note) => { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
53 |
return { type: types.LOAD_NOTE, note }; |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
54 |
} |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
55 |
|
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
56 |
export const resetActionNote = (note) => { |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
57 |
return { type: types.RESET_ACTION_NOTE, note }; |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
58 |
} |
|
d48946d164c6
Add a first version of synchronisation
ymh <ymh.work@gmail.com>
parents:
98
diff
changeset
|
59 |