@annotation-studio/plugin-core
Advanced tools
Comparing version 1.0.0-next.dc218a5f to 1.0.0-next.de7bb2aa
@@ -11,3 +11,3 @@ var _class, _temp2; | ||
import { connector } from '@annotation-studio/redux'; | ||
import { changeFingerprintSource, changeFingerprintIdentity, changeFingerPrintCreator } from '@annotation-studio/redux/es/actions/drafts'; | ||
import { isSavedDraft, changeFingerprintSource, changeFingerprintIdentity, changeFingerPrintCreator } from '@annotation-studio/redux/es/actions/drafts'; | ||
import { getAllAnnotationsFromCollection } from '@annotation-studio/redux/es/lib/elucidate/index'; | ||
@@ -39,3 +39,5 @@ import { asyncForEach } from './core.utils'; | ||
}, _this.warnUser = function (event) { | ||
var drafts = _this.props.drafts; | ||
var _this$props = _this.props, | ||
drafts = _this$props.drafts, | ||
disableCloseWarning = _this$props.disableCloseWarning; | ||
@@ -45,3 +47,11 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) { | ||
}) : []; | ||
if (changes.length) { | ||
var changedValues = Object.values(drafts).map(function (draft) { | ||
return Object.values(draft.input).filter(function (e) { | ||
return e; | ||
}); | ||
}).filter(function (e) { | ||
return e.length; | ||
}); | ||
if (changes.length && changedValues.length && disableCloseWarning === false) { | ||
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';; | ||
@@ -112,12 +122,2 @@ event.preventDefault(); | ||
var isSavedDraft = 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'; | ||
}; | ||
// Set collection. | ||
@@ -124,0 +124,0 @@ createCollection(subject, subject).then(function (c) { |
@@ -17,4 +17,5 @@ function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
elucidateServer = _ref.elucidateServer, | ||
disableCloseWarning = _ref.disableCloseWarning, | ||
locale = _ref.locale, | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']); | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']); | ||
@@ -27,2 +28,3 @@ unknownPropertyWarning(unknownProps); | ||
var savedDraftList = localstorage.get('annotation-studio/' + url) || {}; | ||
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false; | ||
@@ -33,2 +35,3 @@ var store = createStore(reducers, [], locale); | ||
manifest: manifest, | ||
disableCloseWarning: disableCloseWarningBoolean, | ||
savedDraftList: savedDraftList, | ||
@@ -35,0 +38,0 @@ elucidateServer: elucidateServer, |
@@ -51,3 +51,5 @@ 'use strict'; | ||
}, _this.warnUser = function (event) { | ||
var drafts = _this.props.drafts; | ||
var _this$props = _this.props, | ||
drafts = _this$props.drafts, | ||
disableCloseWarning = _this$props.disableCloseWarning; | ||
@@ -57,3 +59,11 @@ var changes = drafts ? Object.values(drafts).filter(function (draft) { | ||
}) : []; | ||
if (changes.length) { | ||
var changedValues = Object.values(drafts).map(function (draft) { | ||
return Object.values(draft.input).filter(function (e) { | ||
return e; | ||
}); | ||
}).filter(function (e) { | ||
return e.length; | ||
}); | ||
if (changes.length && changedValues.length && disableCloseWarning === false) { | ||
var message = 'You have ' + changes + ' unsaved annotation' + (changes.length > 1 ? 's' : null) + ', if you leave the page they will be lost.';; | ||
@@ -124,12 +134,2 @@ event.preventDefault(); | ||
var isSavedDraft = 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'; | ||
}; | ||
// Set collection. | ||
@@ -140,3 +140,3 @@ createCollection(subject, subject).then(function (c) { | ||
return (0, _core.asyncForEach)(iterable, function (i) { | ||
if (isSavedDraft(i)) { | ||
if ((0, _drafts.isSavedDraft)(i)) { | ||
var draft = JSON.parse(i.body.value); | ||
@@ -143,0 +143,0 @@ var identity = i.id.substr(i.id.length - 1) === '/' ? i.id.substr(0, i.id.length - 1).split('/').pop() : i.id.split('/').pop(); |
@@ -38,4 +38,5 @@ 'use strict'; | ||
elucidateServer = _ref.elucidateServer, | ||
disableCloseWarning = _ref.disableCloseWarning, | ||
locale = _ref.locale, | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'locale']); | ||
unknownProps = _objectWithoutProperties(_ref, ['manifest', 'canvas', 'elucidateServer', 'disableCloseWarning', 'locale']); | ||
@@ -48,2 +49,3 @@ (0, _core.unknownPropertyWarning)(unknownProps); | ||
var savedDraftList = _store2.default.get('annotation-studio/' + url) || {}; | ||
var disableCloseWarningBoolean = disableCloseWarning ? disableCloseWarning === 'true' : false; | ||
@@ -54,2 +56,3 @@ var store = (0, _redux.createStore)(_redux.reducers, [], locale); | ||
manifest: manifest, | ||
disableCloseWarning: disableCloseWarningBoolean, | ||
savedDraftList: savedDraftList, | ||
@@ -56,0 +59,0 @@ elucidateServer: elucidateServer, |
{ | ||
"name": "@annotation-studio/plugin-core", | ||
"version": "1.0.0-next.dc218a5f", | ||
"version": "1.0.0-next.de7bb2aa", | ||
"description": "Annotation studio core plugin", | ||
@@ -13,3 +13,3 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"watch": "./bin/watch", | ||
"watch": "nwb-watch-module", | ||
"build": "nwb build-web-module --copy-files", | ||
@@ -20,15 +20,15 @@ "clean": "nwb clean-module", | ||
"test:watch": "echo \"No tests in this package\"", | ||
"prepublish": "npm run build" | ||
"prepublish": "NODE_ENV=production npm run build" | ||
}, | ||
"dependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-next.dc218a5f", | ||
"@annotation-studio/redux": "^1.0.0-next.dc218a5f" | ||
}, | ||
"peerDependencies": { | ||
"moment": "*", | ||
"react": "*", | ||
"react-dom": "*", | ||
"@annotation-studio/bridge": "^1.0.0-rc.14", | ||
"@annotation-studio/redux": "^1.0.0-rc.14", | ||
"moment": "^2.20.1", | ||
"react": "^15.6.2", | ||
"react-dom": "^15.6.2", | ||
"react-redux": "*" | ||
}, | ||
"devDependencies": { | ||
"@annotation-studio/bridge": "^1.0.0-next.de7bb2aa", | ||
"@annotation-studio/redux": "^1.0.0-next.de7bb2aa", | ||
"babel-cli": "^6.24.1", | ||
@@ -42,4 +42,5 @@ "babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"nwb": "^0.21.5", | ||
"react": "*", | ||
"react-dom": "*", | ||
"nwb-watch": "^1.0.0-next.de7bb2aa", | ||
"react": "^15.6.2", | ||
"react-dom": "^15.6.2", | ||
"react-redux": "*" | ||
@@ -46,0 +47,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
35527
736
14
15
+ Addedasap@2.0.6(transitive)
+ Addedcore-js@1.2.7(transitive)
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedpromise@7.3.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-dom@15.7.0(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedua-parser-js@0.7.39(transitive)
- Removedreact@16.14.0(transitive)
- Removedreact-dom@19.0.0(transitive)
- Removedscheduler@0.25.0(transitive)