@annotation-studio/redux
Advanced tools
Comparing version 1.0.0-pr.16a66bcc to 1.0.0-pr.173fc20b
@@ -11,3 +11,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { isSelecting, getCurrentSelector } from '../query/selectorQuery'; | ||
import { reset, moveForward } from './resources'; | ||
@@ -376,37 +375,6 @@ export var DRAFT_CREATE = 'DRAFT_CREATE'; | ||
markDraftAs(id, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ)(dispatch, getState); | ||
var state = getState(); | ||
var draft = getDraftById(state, id); | ||
// Select draft. | ||
dispatch({ type: DRAFT_SELECT, payload: { id: id, scope: scope } }); | ||
// Update selector. | ||
if (draft.isPreviewing === false && draft.selector && draft.selector.type && draft.selector.type.toLowerCase() !== 'wholecanvasselector') { | ||
dispatch(editCurrentDraftSelector(scope)); | ||
} | ||
}; | ||
} | ||
export function selectDraftAndNavigate(id) { | ||
return function (dispatch, getState) { | ||
var state = getState(); | ||
var draft = getDraftById(state, id); | ||
// Error. | ||
if (!draft) { | ||
return null; | ||
} | ||
// Go to path. | ||
if (draft.fingerprint.path.length) { | ||
dispatch(reset(draft.fingerprint.scope)); | ||
draft.fingerprint.path.forEach(function (forward) { | ||
return dispatch(moveForward(draft.fingerprint.scope, forward)); | ||
}); | ||
} | ||
// select draft. | ||
dispatch(selectDraft(draft.fingerprint.scope, id)); | ||
}; | ||
} | ||
export function previewDraft(id) { | ||
@@ -413,0 +381,0 @@ return function (dispatch, getState) { |
@@ -12,5 +12,3 @@ export var MANIFEST_ADD = 'MANIFEST_ADD'; | ||
dispatch({ type: MANIFEST_REQUEST, payload: { url: url } }); | ||
return fetch(url, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return fetch(url).then(function (response) { | ||
return response.json(); | ||
@@ -17,0 +15,0 @@ }).then(function (body) { |
@@ -115,3 +115,2 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
if (selector.type === 'WholeCanvasSelector') { | ||
console.warn('WARNING: `editCurrentDraftSelector` should never be called when whole canvas selector is chosen'); | ||
return dispatch(discardCurrentDraft(scope)); | ||
@@ -118,0 +117,0 @@ } |
@@ -14,3 +14,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { richAnnotationList } from './query/elucidateQuery'; | ||
import { currentManifest, currentCanvas } from './query/manifestQuery'; | ||
import { currentManifest } from './query/manifestQuery'; | ||
import { setViewer, withViewer } from './actions/viewer'; | ||
@@ -69,4 +69,2 @@ import { currentSelectorIsSecondary, isSelecting } from './query/selectorQuery'; | ||
currentSelector: currentSelector, | ||
elucidateServer: props.elucidateServer ? props.elucidateServer : state.elucidate ? state.elucidate.server : null, | ||
currentCanvas: currentCanvas(state), | ||
currentDraft: currentDraft, | ||
@@ -73,0 +71,0 @@ currentDrafts: state.drafts.currentDrafts, |
@@ -20,4 +20,5 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
var id = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var partOf = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
return new Annotation(id, label, new AnnotationBodyList(new AnnotationBody(null, JSON.stringify(json), 'text/json', 'TextualBody', 'editing')), target, 'http://www.digirati.com/ns/crowds#drafting', generator); | ||
return new Annotation(id, label, new AnnotationBodyList(new AnnotationBody(null, JSON.stringify(json), 'text/json', 'TextualBody', 'editing')), AnnotationSelector.fromTarget(target, json.selector || null, partOf), 'http://www.digirati.com/ns/crowds#drafting', generator); | ||
} | ||
@@ -185,3 +186,3 @@ | ||
export function createMultipleAnnotations(target, captureModel, draft) { | ||
export function createMultipleAnnotations(target, captureModel, draft, partOf) { | ||
var fieldKeys = Object.keys(draft.input); | ||
@@ -202,3 +203,6 @@ | ||
var captureModelField = captureModel.fields[field.id]; | ||
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) { | ||
var id = _ref2.id; | ||
return id === field.id; | ||
}); | ||
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) { | ||
@@ -228,3 +232,3 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField); | ||
return new Annotation(null, field.input, new AnnotationBodyList(new AnnotationBody(null, JSON.stringify(dataSet), 'text/plain', 'Dataset', purpose ? purpose.id : null)), AnnotationSelector.fromTarget(target, field.selector)); | ||
return new Annotation(null, field.input, new AnnotationBodyList(new AnnotationBody(null, JSON.stringify(dataSet), 'text/plain', 'Dataset', purpose ? purpose.id : null)), AnnotationSelector.fromTarget(target, field.selector, partOf)); | ||
}); | ||
@@ -291,8 +295,8 @@ } | ||
export function createAnnotationFromCaptureModelAndDraft(_ref2) { | ||
var target = _ref2.target, | ||
captureModel = _ref2.captureModel, | ||
draft = _ref2.draft, | ||
customDraftSelector = _ref2.customDraftSelector, | ||
partOf = _ref2.partOf; | ||
export function createAnnotationFromCaptureModelAndDraft(_ref3) { | ||
var target = _ref3.target, | ||
captureModel = _ref3.captureModel, | ||
draft = _ref3.draft, | ||
customDraftSelector = _ref3.customDraftSelector, | ||
partOf = _ref3.partOf; | ||
@@ -322,3 +326,3 @@ var bodies = []; | ||
if (combine === false) { | ||
return createMultipleAnnotations(target, captureModel, draft); | ||
return createMultipleAnnotations(target, captureModel, draft, partOf); | ||
} | ||
@@ -325,0 +329,0 @@ |
@@ -111,3 +111,2 @@ import _asyncIterator from 'babel-runtime/helpers/asyncIterator'; | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
redirect: 'follow' | ||
@@ -114,0 +113,0 @@ }).then(function (response) { |
@@ -41,3 +41,2 @@ 'use strict'; | ||
exports.selectDraft = selectDraft; | ||
exports.selectDraftAndNavigate = selectDraftAndNavigate; | ||
exports.previewDraft = previewDraft; | ||
@@ -66,4 +65,2 @@ exports.unpreviewDraft = unpreviewDraft; | ||
var _resources = require('./resources'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -433,37 +430,6 @@ | ||
markDraftAs(id, DRAFT_LIFECYCLE_NEW, DRAFT_LIFECYCLE_READ)(dispatch, getState); | ||
var state = getState(); | ||
var draft = (0, _draftQuery.getDraftById)(state, id); | ||
// Select draft. | ||
dispatch({ type: DRAFT_SELECT, payload: { id: id, scope: scope } }); | ||
// Update selector. | ||
if (draft.isPreviewing === false && draft.selector && draft.selector.type && draft.selector.type.toLowerCase() !== 'wholecanvasselector') { | ||
dispatch((0, _selectors2.editCurrentDraftSelector)(scope)); | ||
} | ||
}; | ||
} | ||
function selectDraftAndNavigate(id) { | ||
return function (dispatch, getState) { | ||
var state = getState(); | ||
var draft = (0, _draftQuery.getDraftById)(state, id); | ||
// Error. | ||
if (!draft) { | ||
return null; | ||
} | ||
// Go to path. | ||
if (draft.fingerprint.path.length) { | ||
dispatch((0, _resources.reset)(draft.fingerprint.scope)); | ||
draft.fingerprint.path.forEach(function (forward) { | ||
return dispatch((0, _resources.moveForward)(draft.fingerprint.scope, forward)); | ||
}); | ||
} | ||
// select draft. | ||
dispatch(selectDraft(draft.fingerprint.scope, id)); | ||
}; | ||
} | ||
function previewDraft(id) { | ||
@@ -470,0 +436,0 @@ return function (dispatch, getState) { |
@@ -20,5 +20,3 @@ 'use strict'; | ||
dispatch({ type: MANIFEST_REQUEST, payload: { url: url } }); | ||
return fetch(url, { | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache' | ||
}).then(function (response) { | ||
return fetch(url).then(function (response) { | ||
return response.json(); | ||
@@ -25,0 +23,0 @@ }).then(function (body) { |
@@ -139,3 +139,2 @@ 'use strict'; | ||
if (selector.type === 'WholeCanvasSelector') { | ||
console.warn('WARNING: `editCurrentDraftSelector` should never be called when whole canvas selector is chosen'); | ||
return dispatch((0, _drafts.discardCurrentDraft)(scope)); | ||
@@ -142,0 +141,0 @@ } |
@@ -93,4 +93,2 @@ 'use strict'; | ||
currentSelector: currentSelector, | ||
elucidateServer: props.elucidateServer ? props.elucidateServer : state.elucidate ? state.elucidate.server : null, | ||
currentCanvas: (0, _manifestQuery.currentCanvas)(state), | ||
currentDraft: currentDraft, | ||
@@ -97,0 +95,0 @@ currentDrafts: state.drafts.currentDrafts, |
@@ -58,4 +58,5 @@ 'use strict'; | ||
var id = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null; | ||
var partOf = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
return new _Annotation2.default(id, label, new _AnnotationBodyList2.default(new _AnnotationBody2.default(null, JSON.stringify(json), 'text/json', 'TextualBody', 'editing')), target, 'http://www.digirati.com/ns/crowds#drafting', generator); | ||
return new _Annotation2.default(id, label, new _AnnotationBodyList2.default(new _AnnotationBody2.default(null, JSON.stringify(json), 'text/json', 'TextualBody', 'editing')), _AnnotationSelector2.default.fromTarget(target, json.selector || null, partOf), 'http://www.digirati.com/ns/crowds#drafting', generator); | ||
} | ||
@@ -223,3 +224,3 @@ | ||
function createMultipleAnnotations(target, captureModel, draft) { | ||
function createMultipleAnnotations(target, captureModel, draft, partOf) { | ||
var fieldKeys = Object.keys(draft.input); | ||
@@ -240,3 +241,6 @@ | ||
var captureModelField = captureModel.fields[field.id]; | ||
var captureModelField = Object.values(captureModel.fields).find(function (_ref2) { | ||
var id = _ref2.id; | ||
return id === field.id; | ||
}); | ||
if (!(captureModelField && (captureModelField.metaData || captureModelField.omekaMeta))) { | ||
@@ -266,3 +270,3 @@ console.warn('createMultipleAnnotations', 'Looks like you have set derivedAnnoCombine to "False" without selectors on the fields, are you sure this is correct?', captureModelField); | ||
return new _Annotation2.default(null, field.input, new _AnnotationBodyList2.default(new _AnnotationBody2.default(null, JSON.stringify(dataSet), 'text/plain', 'Dataset', purpose ? purpose.id : null)), _AnnotationSelector2.default.fromTarget(target, field.selector)); | ||
return new _Annotation2.default(null, field.input, new _AnnotationBodyList2.default(new _AnnotationBody2.default(null, JSON.stringify(dataSet), 'text/plain', 'Dataset', purpose ? purpose.id : null)), _AnnotationSelector2.default.fromTarget(target, field.selector, partOf)); | ||
}); | ||
@@ -329,8 +333,8 @@ } | ||
function createAnnotationFromCaptureModelAndDraft(_ref2) { | ||
var target = _ref2.target, | ||
captureModel = _ref2.captureModel, | ||
draft = _ref2.draft, | ||
customDraftSelector = _ref2.customDraftSelector, | ||
partOf = _ref2.partOf; | ||
function createAnnotationFromCaptureModelAndDraft(_ref3) { | ||
var target = _ref3.target, | ||
captureModel = _ref3.captureModel, | ||
draft = _ref3.draft, | ||
customDraftSelector = _ref3.customDraftSelector, | ||
partOf = _ref3.partOf; | ||
@@ -360,3 +364,3 @@ var bodies = []; | ||
if (combine === false) { | ||
return createMultipleAnnotations(target, captureModel, draft); | ||
return createMultipleAnnotations(target, captureModel, draft, partOf); | ||
} | ||
@@ -363,0 +367,0 @@ |
@@ -252,3 +252,2 @@ 'use strict'; | ||
credentials: withoutCredentials ? 'omit' : process.env.NODE_ENV === 'production' ? 'include' : 'omit', | ||
cache: process.env.NODE_ENV === 'production' ? 'default' : 'force-cache', | ||
redirect: 'follow' | ||
@@ -255,0 +254,0 @@ }).then(function (response) { |
{ | ||
"name": "@annotation-studio/redux", | ||
"version": "1.0.0-pr.16a66bcc", | ||
"version": "1.0.0-pr.173fc20b", | ||
"description": "Describe annotation-redux here", | ||
@@ -38,3 +38,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@fesk/test-environment": "1.0.0-pr.16a66bcc", | ||
"@fesk/test-environment": "1.0.0-pr.173fc20b", | ||
"babel-jest": "^20.0.3", | ||
@@ -47,5 +47,5 @@ "babel-plugin-transform-async-to-generator": "^6.24.1", | ||
"fetch-mock": "^6.5.1", | ||
"jest": "^20.0.0", | ||
"jest": "^23.6.0", | ||
"nwb": "^0.21.5", | ||
"nwb-watch": "1.0.0-pr.16a66bcc", | ||
"nwb-watch": "1.0.0-pr.173fc20b", | ||
"react-intl": "^2.2.2", | ||
@@ -52,0 +52,0 @@ "react-intl-redux": "^0.7.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
352132
108
9260
9