digirati-annotation-redux
Advanced tools
Comparing version 0.2.16 to 0.2.17-alpha.3d93a0d3
@@ -53,7 +53,7 @@ import md5 from 'blueimp-md5'; | ||
export function sendAnnotation(body, target, motivation) { | ||
export function sendAnnotation(body, target, motivation, label) { | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation } } }); | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } }); | ||
var collection = getCollectionId(state()); | ||
return sendAnnotationToServer(collection, body, target, motivation).then(function (annotation) { | ||
return sendAnnotationToServer(collection, body, target, motivation, label).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
@@ -60,0 +60,0 @@ }); |
@@ -8,3 +8,4 @@ import * as logging from './logging'; | ||
import * as manifest from './manifest'; | ||
import * as viewer from './viewer'; | ||
export { logging, annotations, selectors, drafts, resourceTemplate, elucidate, manifest }; | ||
export { logging, annotations, selectors, drafts, resourceTemplate, elucidate, manifest, viewer }; |
@@ -10,2 +10,3 @@ import { connect } from 'react-redux'; | ||
import { richAnnotationList } from './query/elucidateQuery'; | ||
import { setViewer, withViewer } from './actions/viewer'; | ||
@@ -43,2 +44,4 @@ export default connect(function (state) { | ||
unpreviewDraft: unpreviewDraft, | ||
setViewer: setViewer, | ||
withViewer: withViewer, | ||
setServer: setServer, | ||
@@ -45,0 +48,0 @@ createCollection: createCollection, |
@@ -294,6 +294,7 @@ import _regeneratorRuntime from 'babel-runtime/regenerator'; | ||
export function sendAnnotationToServer(server, body, target, motivation) { | ||
export function sendAnnotationToServer(server, body, target, motivation, label) { | ||
return post(server, { | ||
'@context': CONTEXT, | ||
type: 'Annotation', | ||
label: label, | ||
body: body, | ||
@@ -300,0 +301,0 @@ target: target, |
@@ -6,3 +6,3 @@ import thunk from 'redux-thunk'; | ||
return function (action) { | ||
if (typeof action !== 'function' && process.env.__DEV__ == true) { | ||
if (typeof action !== 'function' && process.env.__DEV__ === true) { | ||
// console.log('dispatching', action); | ||
@@ -15,2 +15,18 @@ } | ||
export default [logger, thunk]; | ||
var ViewerStore = { viewer: null }; | ||
var viewerAware = function viewerAware(store) { | ||
return function (next) { | ||
return function (action) { | ||
if (action.type === 'VIEWER_MUTATION') { | ||
ViewerStore.viewer = action.payload.viewer; | ||
} | ||
if (action.type === 'VIEWER_ACCESS') { | ||
return action.payload.func(ViewerStore.viewer, store.dispatch, store.getState); | ||
} | ||
return next(action); | ||
}; | ||
}; | ||
}; | ||
export default [logger, thunk, viewerAware]; |
@@ -71,7 +71,7 @@ 'use strict'; | ||
function sendAnnotation(body, target, motivation) { | ||
function sendAnnotation(body, target, motivation, label) { | ||
return function (dispatch, state) { | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation } } }); | ||
dispatch({ type: ELUCIDATE_SEND_ANNOTATION, payload: { annotation: { body: body, target: target, motivation: motivation, label: label } } }); | ||
var collection = (0, _elucidateQuery.getCollectionId)(state()); | ||
return (0, _elucidate.sendAnnotationToServer)(collection, body, target, motivation).then(function (annotation) { | ||
return (0, _elucidate.sendAnnotationToServer)(collection, body, target, motivation, label).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
@@ -78,0 +78,0 @@ }); |
'use strict'; | ||
exports.__esModule = true; | ||
exports.manifest = exports.elucidate = exports.resourceTemplate = exports.drafts = exports.selectors = exports.annotations = exports.logging = undefined; | ||
exports.viewer = exports.manifest = exports.elucidate = exports.resourceTemplate = exports.drafts = exports.selectors = exports.annotations = exports.logging = undefined; | ||
@@ -34,2 +34,6 @@ var _logging = require('./logging'); | ||
var _viewer = require('./viewer'); | ||
var viewer = _interopRequireWildcard(_viewer); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -43,2 +47,3 @@ | ||
exports.elucidate = elucidate; | ||
exports.manifest = manifest; | ||
exports.manifest = manifest; | ||
exports.viewer = viewer; |
@@ -23,2 +23,4 @@ 'use strict'; | ||
var _viewer = require('./actions/viewer'); | ||
exports.default = (0, _reactRedux.connect)(function (state) { | ||
@@ -55,2 +57,4 @@ var annotationList = (0, _elucidateQuery.richAnnotationList)(state); | ||
unpreviewDraft: _drafts.unpreviewDraft, | ||
setViewer: _viewer.setViewer, | ||
withViewer: _viewer.withViewer, | ||
setServer: _elucidate.setServer, | ||
@@ -57,0 +61,0 @@ createCollection: _elucidate.createCollection, |
@@ -322,6 +322,7 @@ 'use strict'; | ||
function sendAnnotationToServer(server, body, target, motivation) { | ||
function sendAnnotationToServer(server, body, target, motivation, label) { | ||
return post(server, { | ||
'@context': CONTEXT, | ||
type: 'Annotation', | ||
label: label, | ||
body: body, | ||
@@ -328,0 +329,0 @@ target: target, |
@@ -14,3 +14,3 @@ 'use strict'; | ||
return function (action) { | ||
if (typeof action !== 'function' && process.env.__DEV__ == true) { | ||
if (typeof action !== 'function' && process.env.__DEV__ === true) { | ||
// console.log('dispatching', action); | ||
@@ -23,3 +23,19 @@ } | ||
exports.default = [logger, _reduxThunk2.default]; | ||
var ViewerStore = { viewer: null }; | ||
var viewerAware = function viewerAware(store) { | ||
return function (next) { | ||
return function (action) { | ||
if (action.type === 'VIEWER_MUTATION') { | ||
ViewerStore.viewer = action.payload.viewer; | ||
} | ||
if (action.type === 'VIEWER_ACCESS') { | ||
return action.payload.func(ViewerStore.viewer, store.dispatch, store.getState); | ||
} | ||
return next(action); | ||
}; | ||
}; | ||
}; | ||
exports.default = [logger, _reduxThunk2.default, viewerAware]; | ||
module.exports = exports['default']; |
{ | ||
"name": "digirati-annotation-redux", | ||
"version": "0.2.16", | ||
"version": "0.2.17-alpha.3d93a0d3", | ||
"description": "Describe annotation-redux here", | ||
@@ -5,0 +5,0 @@ "main": "es/index.js", |
94997
58
2474