@annotation-studio/redux
Advanced tools
Comparing version 1.0.0-next.f614ef8b to 1.0.0-next.f6b20da0
@@ -36,2 +36,12 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
export function isSavedDraft(annotation) { | ||
if (annotation.motivation !== 'http://www.digirati.com/ns/crowds#drafting') { | ||
return false; | ||
} | ||
if (Array.isArray(annotation.body)) { | ||
return false; | ||
} | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
export function createDraft(scope, emptyInput, template) { | ||
@@ -38,0 +48,0 @@ var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging'; |
import md5 from 'blueimp-md5'; | ||
import { getCollectionId, getServer } from '../query/elucidateQuery'; | ||
import { createElucidateCollection, sendAnnotationToServer, postAnnotation, putAnnotation } from '../lib/elucidate'; | ||
import { importDraft, isSavedDraft, changeFingerprintSource, changeFingerprintIdentity, changeFingerPrintCreator } from '@annotation-studio/redux/es/actions/drafts'; | ||
import Annotation from '../lib/annotation/Annotation'; | ||
@@ -65,3 +66,13 @@ export var ELUCIDATE_SET_SERVER = 'ELUCIDATE_SET_SERVER'; | ||
return postAnnotation(collection, annotation).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
if (isSavedDraft(annotation)) { | ||
var draft = JSON.parse(annotation.body.value); | ||
var id = annotation.id; | ||
var identity = id.substr(id.length - 1) === '/' ? id.substr(0, id.length - 1).split('/').pop() : id.split('/').pop(); | ||
if (draft) { | ||
dispatch(importDraft(identity, changeFingerPrintCreator(changeFingerprintIdentity(draft, identity), annotation.creator && annotation.creator.name ? annotation.creator.name : 'unknown'))); | ||
} | ||
} | ||
dispatch(addElucidateAnnotation(annotation)); | ||
return annotation; | ||
}); | ||
@@ -68,0 +79,0 @@ }; |
@@ -10,5 +10,5 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
// Draft value is {id: 'http://..'} | ||
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
export var FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
// Draft value is {label: 'human readable'} | ||
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
export var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
@@ -15,0 +15,0 @@ export function createCombinedAnnotationBody(captureModel, draft) { |
@@ -8,4 +8,4 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator'; | ||
var fetchPageCollection = function () { | ||
var _ref3 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref4, item; | ||
var _ref4 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref5, item; | ||
@@ -43,3 +43,3 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
case 8: | ||
_ref4 = _iterator2[_i2++]; | ||
_ref5 = _iterator2[_i2++]; | ||
_context2.next = 15; | ||
@@ -59,6 +59,6 @@ break; | ||
case 14: | ||
_ref4 = _i2.value; | ||
_ref5 = _i2.value; | ||
case 15: | ||
item = _ref4; | ||
item = _ref5; | ||
_context2.next = 18; | ||
@@ -87,4 +87,4 @@ return item; | ||
return function fetchPageCollection(_x5) { | ||
return _ref3.apply(this, arguments); | ||
return function fetchPageCollection(_x6) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -107,2 +107,5 @@ }(); | ||
var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}, | ||
withoutCredentials = _ref.withoutCredentials; | ||
return fetch(uri, { | ||
@@ -112,3 +115,3 @@ method: method, | ||
body: JSON.stringify(body), | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
@@ -128,3 +131,8 @@ redirect: 'follow' | ||
export function get(uri, body) { | ||
return makeRequest('GET', uri, body); | ||
try { | ||
return makeRequest('GET', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('GET', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -135,3 +143,8 @@ | ||
return makeRequest('POST', uri, body, headers); | ||
try { | ||
return makeRequest('POST', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -142,3 +155,8 @@ | ||
return makeRequest('PUT', uri, body, headers); | ||
try { | ||
return makeRequest('PUT', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -151,4 +169,4 @@ | ||
export var getAllAnnotationsFromCollection = function () { | ||
var _ref = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item; | ||
var _ref2 = _asyncGenerator.wrap( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item; | ||
@@ -185,3 +203,3 @@ return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
case 7: | ||
_ref2 = _iterator[_i++]; | ||
_ref3 = _iterator[_i++]; | ||
_context.next = 14; | ||
@@ -201,6 +219,6 @@ break; | ||
case 13: | ||
_ref2 = _i.value; | ||
_ref3 = _i.value; | ||
case 14: | ||
item = _ref2; | ||
item = _ref3; | ||
_context.next = 17; | ||
@@ -253,4 +271,4 @@ return item; | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return _ref.apply(this, arguments); | ||
return function getAllAnnotationsFromCollection(_x5) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
@@ -257,0 +275,0 @@ }(); |
@@ -16,3 +16,5 @@ { | ||
"editor.next": "Nesaf", | ||
"editor.save": "Arbed", | ||
"editor.save_in_progress": "Save work as in progress", | ||
"resourceNavigation.defaultTitle": "What do you want to tag (Default title)" | ||
} | ||
} |
@@ -17,3 +17,5 @@ { | ||
"editor.next": "Next", | ||
"editor.save": "Save", | ||
"editor.save_in_progress": "Save work as in progress", | ||
"resourceNavigation.defaultTitle": "What do you want to tag" | ||
} |
@@ -113,4 +113,10 @@ import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties'; | ||
var updater = { | ||
isConfirmed: (_isConfirmed2 = {}, _isConfirmed2[action.payload.scope] = { $set: false }, _isConfirmed2), | ||
list: { | ||
isConfirmed: (_isConfirmed2 = {}, _isConfirmed2[action.payload.scope] = { $set: false }, _isConfirmed2) | ||
}; | ||
if (action.payload.dry !== true) { | ||
var _updater$currentDraft; | ||
updater.currentDrafts = (_updater$currentDraft = {}, _updater$currentDraft[action.payload.scope] = { $set: null }, _updater$currentDraft); | ||
updater.list = { | ||
$apply: function $apply(obj) { | ||
@@ -122,8 +128,3 @@ var _ = obj[action.payload.id], | ||
} | ||
} | ||
}; | ||
if (action.payload.dry !== true) { | ||
var _updater$currentDraft; | ||
updater.currentDrafts = (_updater$currentDraft = {}, _updater$currentDraft[action.payload.scope] = { $set: null }, _updater$currentDraft); | ||
}; | ||
} | ||
@@ -130,0 +131,0 @@ |
@@ -15,2 +15,3 @@ 'use strict'; | ||
exports.generateDraftId = generateDraftId; | ||
exports.isSavedDraft = isSavedDraft; | ||
exports.createDraft = createDraft; | ||
@@ -90,2 +91,12 @@ exports.chooseDraftSelector = chooseDraftSelector; | ||
function isSavedDraft(annotation) { | ||
if (annotation.motivation !== 'http://www.digirati.com/ns/crowds#drafting') { | ||
return false; | ||
} | ||
if (Array.isArray(annotation.body)) { | ||
return false; | ||
} | ||
return annotation.body.purpose === 'editing'; | ||
}; | ||
function createDraft(scope, emptyInput, template) { | ||
@@ -92,0 +103,0 @@ var motivation = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'tagging'; |
@@ -24,2 +24,4 @@ 'use strict'; | ||
var _drafts = require('@annotation-studio/redux/es/actions/drafts'); | ||
var _Annotation = require('../lib/annotation/Annotation'); | ||
@@ -91,3 +93,13 @@ | ||
return (0, _elucidate.postAnnotation)(collection, annotation).then(function (annotation) { | ||
return dispatch(addElucidateAnnotation(annotation)); | ||
if ((0, _drafts.isSavedDraft)(annotation)) { | ||
var draft = JSON.parse(annotation.body.value); | ||
var id = annotation.id; | ||
var identity = id.substr(id.length - 1) === '/' ? id.substr(0, id.length - 1).split('/').pop() : id.split('/').pop(); | ||
if (draft) { | ||
dispatch((0, _drafts.importDraft)(identity, (0, _drafts.changeFingerPrintCreator)((0, _drafts.changeFingerprintIdentity)(draft, identity), annotation.creator && annotation.creator.name ? annotation.creator.name : 'unknown'))); | ||
} | ||
} | ||
dispatch(addElucidateAnnotation(annotation)); | ||
return annotation; | ||
}); | ||
@@ -94,0 +106,0 @@ }; |
@@ -48,5 +48,5 @@ 'use strict'; | ||
// Draft value is {id: 'http://..'} | ||
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
var FIELD_TYPES_THAT_ARE_ENTITIES = exports.FIELD_TYPES_THAT_ARE_ENTITIES = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
// Draft value is {label: 'human readable'} | ||
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions']; | ||
var FIELD_TYPES_THAT_ARE_HUMAN_READABLE = exports.FIELD_TYPES_THAT_ARE_HUMAN_READABLE = ['madoc:nullableCaptureModel', 'madoc:fallbackOptions', 'madoc:autocomplete']; | ||
@@ -53,0 +53,0 @@ function createCombinedAnnotationBody(captureModel, draft) { |
@@ -27,4 +27,4 @@ 'use strict'; | ||
var getAllAnnotationsFromCollection = exports.getAllAnnotationsFromCollection = function () { | ||
var _ref = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref2, item, collection, _item; | ||
var _ref2 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee(collectionResource) { | ||
var firstPage, _iterator, _isArray, _i, _ref3, item, collection, _item; | ||
@@ -61,3 +61,3 @@ return _regenerator2.default.wrap(function _callee$(_context) { | ||
case 7: | ||
_ref2 = _iterator[_i++]; | ||
_ref3 = _iterator[_i++]; | ||
_context.next = 14; | ||
@@ -77,6 +77,6 @@ break; | ||
case 13: | ||
_ref2 = _i.value; | ||
_ref3 = _i.value; | ||
case 14: | ||
item = _ref2; | ||
item = _ref3; | ||
_context.next = 17; | ||
@@ -129,4 +129,4 @@ return item; | ||
return function getAllAnnotationsFromCollection(_x4) { | ||
return _ref.apply(this, arguments); | ||
return function getAllAnnotationsFromCollection(_x5) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
@@ -136,4 +136,4 @@ }(); | ||
var fetchPageCollection = function () { | ||
var _ref3 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref4, item; | ||
var _ref4 = _asyncGenerator3.default.wrap( /*#__PURE__*/_regenerator2.default.mark(function _callee2(resource) { | ||
var currentPage, _iterator2, _isArray2, _i2, _ref5, item; | ||
@@ -171,3 +171,3 @@ return _regenerator2.default.wrap(function _callee2$(_context2) { | ||
case 8: | ||
_ref4 = _iterator2[_i2++]; | ||
_ref5 = _iterator2[_i2++]; | ||
_context2.next = 15; | ||
@@ -187,6 +187,6 @@ break; | ||
case 14: | ||
_ref4 = _i2.value; | ||
_ref5 = _i2.value; | ||
case 15: | ||
item = _ref4; | ||
item = _ref5; | ||
_context2.next = 18; | ||
@@ -215,4 +215,4 @@ return item; | ||
return function fetchPageCollection(_x5) { | ||
return _ref3.apply(this, arguments); | ||
return function fetchPageCollection(_x6) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
@@ -252,2 +252,5 @@ }(); | ||
var _ref = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {}, | ||
withoutCredentials = _ref.withoutCredentials; | ||
return fetch(uri, { | ||
@@ -257,3 +260,3 @@ method: method, | ||
body: JSON.stringify(body), | ||
credentials: process.env.NODE_ENV === 'production' ? 'include' : null, | ||
credentials: withoutCredentials ? null : process.env.NODE_ENV === 'production' ? 'include' : null, | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
@@ -273,3 +276,8 @@ redirect: 'follow' | ||
function get(uri, body) { | ||
return makeRequest('GET', uri, body); | ||
try { | ||
return makeRequest('GET', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('GET', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -280,3 +288,8 @@ | ||
return makeRequest('POST', uri, body, headers); | ||
try { | ||
return makeRequest('POST', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('POST', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -287,3 +300,8 @@ | ||
return makeRequest('PUT', uri, body, headers); | ||
try { | ||
return makeRequest('PUT', uri, body); | ||
} catch (e) { | ||
console.warn('Request failed, trying again without credentials', e); | ||
return makeRequest('PUT', uri, body, { withoutCredentials: true }); | ||
} | ||
} | ||
@@ -290,0 +308,0 @@ |
@@ -16,3 +16,5 @@ { | ||
"editor.next": "Nesaf", | ||
"editor.save": "Arbed", | ||
"editor.save_in_progress": "Save work as in progress", | ||
"resourceNavigation.defaultTitle": "What do you want to tag (Default title)" | ||
} | ||
} |
@@ -17,3 +17,5 @@ { | ||
"editor.next": "Next", | ||
"editor.save": "Save", | ||
"editor.save_in_progress": "Save work as in progress", | ||
"resourceNavigation.defaultTitle": "What do you want to tag" | ||
} |
@@ -127,4 +127,10 @@ 'use strict'; | ||
var updater = { | ||
isConfirmed: (_isConfirmed2 = {}, _isConfirmed2[action.payload.scope] = { $set: false }, _isConfirmed2), | ||
list: { | ||
isConfirmed: (_isConfirmed2 = {}, _isConfirmed2[action.payload.scope] = { $set: false }, _isConfirmed2) | ||
}; | ||
if (action.payload.dry !== true) { | ||
var _updater$currentDraft; | ||
updater.currentDrafts = (_updater$currentDraft = {}, _updater$currentDraft[action.payload.scope] = { $set: null }, _updater$currentDraft); | ||
updater.list = { | ||
$apply: function $apply(obj) { | ||
@@ -136,8 +142,3 @@ var _ = obj[action.payload.id], | ||
} | ||
} | ||
}; | ||
if (action.payload.dry !== true) { | ||
var _updater$currentDraft; | ||
updater.currentDrafts = (_updater$currentDraft = {}, _updater$currentDraft[action.payload.scope] = { $set: null }, _updater$currentDraft); | ||
}; | ||
} | ||
@@ -144,0 +145,0 @@ |
{ | ||
"name": "@annotation-studio/redux", | ||
"version": "1.0.0-next.f614ef8b", | ||
"version": "1.0.0-next.f6b20da0", | ||
"description": "Describe annotation-redux here", | ||
"main": "es/index.js", | ||
"main": "lib/index.js", | ||
"module": "es/index.js", | ||
@@ -13,4 +13,5 @@ "files": [ | ||
"scripts": { | ||
"watch": "./bin/watch", | ||
"watch": "nwb-watch-module", | ||
"build": "nwb build-web-module --copy-files", | ||
"build-quick": "nwb build-web-module --copy-files", | ||
"clean": "nwb clean-module", | ||
@@ -20,3 +21,3 @@ "test": "NODE_ENV=test jest", | ||
"test:watch": "npm run test -- --watch", | ||
"prepublish": "npm run build" | ||
"prepublish": "NODE_ENV=production npm run build" | ||
}, | ||
@@ -26,4 +27,2 @@ "dependencies": { | ||
"immutability-helper": "^2.1.2", | ||
"react-intl": "^2.4.0", | ||
"react-intl-redux": "^0.7.0", | ||
"react-redux": "^5.0.3", | ||
@@ -38,7 +37,7 @@ "redux": "^3.6.0", | ||
"peerDependencies": { | ||
"react-intl": "^2.2.2", | ||
"react-intl": "^2.4.0", | ||
"react-intl-redux": "^0.7.0" | ||
}, | ||
"devDependencies": { | ||
"@fesk/test-environment": "^1.0.0-next.f614ef8b", | ||
"@fesk/test-environment": "^1.0.0-next.f6b20da0", | ||
"babel-jest": "^20.0.3", | ||
@@ -48,6 +47,10 @@ "babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"babel-plugin-transform-regenerator": "^6.24.1", | ||
"create-nwb-webpack-config": "^1.0.0", | ||
"cross-spawn": "^6.0.5", | ||
"jest": "^20.0.0", | ||
"nwb": "^0.21.5", | ||
"nwb-watch": "^1.0.0-next.f6b20da0", | ||
"react-intl": "^2.2.2", | ||
"react-intl-redux": "^0.7.0" | ||
"react-intl-redux": "^0.7.0", | ||
"webpack-cli": "^2.0.11" | ||
}, | ||
@@ -54,0 +57,0 @@ "publishConfig": { |
332549
11
8678
13
- Removedreact-intl@^2.4.0
- Removedreact-intl-redux@^0.7.0