@wmfs/cardscript-extract-defaults
Advanced tools
Comparing version 1.6.0 to 1.7.0
@@ -0,1 +1,8 @@ | ||
# [1.7.0](https://github.com/wmfs/cardscript-extract-defaults/compare/v1.6.0...v1.7.0) (2019-07-22) | ||
### ✨ Features | ||
* allow for Input.ApiLookup results card ([0a1d5cc](https://github.com/wmfs/cardscript-extract-defaults/commit/0a1d5cc)) | ||
# [1.6.0](https://github.com/wmfs/cardscript-extract-defaults/compare/v1.5.0...v1.6.0) (2019-07-18) | ||
@@ -2,0 +9,0 @@ |
@@ -43,9 +43,15 @@ module.exports = function extractDefaults (cardscript) { | ||
apiLookupPath.push(element.id) | ||
defaultValues.rootView[element.id].params = {} | ||
if (element.parametersCard) { | ||
apiLookupPath.push(element.id) | ||
defaultValues.rootView[element.id].params = {} | ||
element.parametersCard.body.forEach(parseElement) | ||
apiLookupPath.pop() | ||
} | ||
if (element.resultsCard) { | ||
element.resultsCard.body.forEach(parseElement) | ||
} | ||
apiLookupPath.pop() | ||
if (element.selectionType === 'single') { | ||
@@ -144,2 +150,26 @@ defaultValues.rootView[element.id].selected = {} | ||
break | ||
case 'List': | ||
if (element.selectionType === 'single' || element.selectionType === 'multi') { | ||
const defaultValue = element.selectionType === 'single' ? {} : [] | ||
if (cardListPath.length === 0) { | ||
if (apiLookupPath.length === 0) { | ||
defaultValues.rootView[element.id] = defaultValue | ||
} else { | ||
const apiLookupId = apiLookupPath[apiLookupPath.length - 1] | ||
defaultValues.rootView[apiLookupId].params[element.id] = defaultValue | ||
} | ||
} else { | ||
if (apiLookupPath.length === 0) { | ||
const cardListId = cardListPath[cardListPath.length - 1] | ||
defaultValues.cardLists[cardListId][element.id] = defaultValue | ||
} else { | ||
// TODO: not sure about this... | ||
const apiLookupId = apiLookupPath[apiLookupPath.length - 1] | ||
const cardListId = cardListPath[cardListPath.length - 1] | ||
defaultValues.cardLists[apiLookupId].params[cardListId][element.id] = defaultValue | ||
} | ||
} | ||
} | ||
break | ||
} | ||
@@ -146,0 +176,0 @@ } |
{ | ||
"name": "@wmfs/cardscript-extract-defaults", | ||
"description": "Extracts sensible defaults from some Cardscript.", | ||
"version": "1.6.0", | ||
"version": "1.7.0", | ||
"author": "West Midlands Fire Service", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
21991
336