digirati-annotation-redux
Advanced tools
Comparing version 0.8.6 to 0.8.12
@@ -30,2 +30,3 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
@@ -43,3 +44,3 @@ return function (dispatch, getState) { | ||
if (currentTemplate.metaData && currentTemplate.metaData.selector) { | ||
dispatch(chooseSelector(currentTemplate.metaData.selector, { template: currentTemplate.id, scope: scope, draft: id })); | ||
dispatch(chooseSelector(currentTemplate.metaData.selector, { template: currentTemplate.id, scope: scope, draft: id }, immutableSelector, null, !!immutableSelector)); | ||
} else { | ||
@@ -186,3 +187,5 @@ dispatch(chooseSelector('WholeCanvasSelector', { template: currentTemplate.id, scope: scope, draft: id })); | ||
if (isSelecting(state)) { | ||
dispatch(commitToCurrentDraft(state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector')); | ||
dispatch(commitToCurrentDraft(true | ||
/* state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector', */ | ||
)); | ||
} | ||
@@ -189,0 +192,0 @@ dispatch({ type: DRAFT_PREVIEW, payload: { id: id } }); |
@@ -20,2 +20,4 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
export function chooseSelector(type, source, defaults, done) { | ||
var immediate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
// @todo find better way of Canvas relative vs Viewport relative inspections | ||
@@ -28,3 +30,3 @@ if (!defaults || type.toLowerCase() !== 'madoc:boxdraw') { | ||
}); | ||
if (type.toLowerCase() === 'wholecanvasselector') { | ||
if (type.toLowerCase() === 'wholecanvasselector' || immediate) { | ||
dispatch(commitToCurrentDraft(false)); | ||
@@ -120,3 +122,12 @@ } | ||
var selector = getCurrentSelector(state); | ||
if (!selector || !selector.source) { | ||
return null; | ||
} | ||
if (!selector.source.draft) { | ||
console.warn('commitToCurrentDraft', 'Selector with malformed source found.'); | ||
} | ||
var currentDraft = getDraftById(state, selector.source.draft); | ||
if (!currentDraft) { | ||
console.warn('commitToCurrentDraft', 'Draft (' + selector.source.draft + ') was not found in state.'); | ||
} | ||
if (selector.id) { | ||
@@ -123,0 +134,0 @@ return dispatch(commitToCurrentDraftField(selector.id)); |
@@ -70,2 +70,3 @@ 'use strict'; | ||
var draftDefaults = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null; | ||
var immutableSelector = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : null; | ||
@@ -83,3 +84,3 @@ return function (dispatch, getState) { | ||
if (currentTemplate.metaData && currentTemplate.metaData.selector) { | ||
dispatch((0, _selectors2.chooseSelector)(currentTemplate.metaData.selector, { template: currentTemplate.id, scope: scope, draft: id })); | ||
dispatch((0, _selectors2.chooseSelector)(currentTemplate.metaData.selector, { template: currentTemplate.id, scope: scope, draft: id }, immutableSelector, null, !!immutableSelector)); | ||
} else { | ||
@@ -226,3 +227,5 @@ dispatch((0, _selectors2.chooseSelector)('WholeCanvasSelector', { template: currentTemplate.id, scope: scope, draft: id })); | ||
if ((0, _selectorQuery.isSelecting)(state)) { | ||
dispatch((0, _selectors2.commitToCurrentDraft)(state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector')); | ||
dispatch((0, _selectors2.commitToCurrentDraft)(true | ||
/* state.selector.currentSelector.type.toLowerCase() === 'wholecanvasselector', */ | ||
)); | ||
} | ||
@@ -229,0 +232,0 @@ dispatch({ type: DRAFT_PREVIEW, payload: { id: id } }); |
@@ -44,2 +44,4 @@ 'use strict'; | ||
function chooseSelector(type, source, defaults, done) { | ||
var immediate = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false; | ||
// @todo find better way of Canvas relative vs Viewport relative inspections | ||
@@ -52,3 +54,3 @@ if (!defaults || type.toLowerCase() !== 'madoc:boxdraw') { | ||
}); | ||
if (type.toLowerCase() === 'wholecanvasselector') { | ||
if (type.toLowerCase() === 'wholecanvasselector' || immediate) { | ||
dispatch(commitToCurrentDraft(false)); | ||
@@ -144,3 +146,12 @@ } | ||
var selector = (0, _selectorQuery.getCurrentSelector)(state); | ||
if (!selector || !selector.source) { | ||
return null; | ||
} | ||
if (!selector.source.draft) { | ||
console.warn('commitToCurrentDraft', 'Selector with malformed source found.'); | ||
} | ||
var currentDraft = (0, _draftQuery.getDraftById)(state, selector.source.draft); | ||
if (!currentDraft) { | ||
console.warn('commitToCurrentDraft', 'Draft (' + selector.source.draft + ') was not found in state.'); | ||
} | ||
if (selector.id) { | ||
@@ -147,0 +158,0 @@ return dispatch(commitToCurrentDraftField(selector.id)); |
{ | ||
"name": "digirati-annotation-redux", | ||
"version": "0.8.6", | ||
"version": "0.8.12", | ||
"description": "Describe annotation-redux here", | ||
@@ -5,0 +5,0 @@ "main": "es/index.js", |
201991
5006