From 1a7b13ab54219f43334ca688e810c3d6ffebef4b Mon Sep 17 00:00:00 2001 From: Brandon Stull Date: Tue, 17 Oct 2023 15:53:50 -0400 Subject: [PATCH] #554 Added source model to information available to nav items to enable variable substitution in the nav area. --- .../components/variables/constants.js | 3 ++ .../variables/variable-list-modal.js | 1 - .../variable-property/variable-value.js | 16 +++++++-- .../variable-property/variable-value.scss | 6 ++++ .../src/scripts/viewer/components/nav.js | 34 +++++++++++++++---- .../src/scripts/viewer/stores/nav-store.js | 3 +- 6 files changed, 53 insertions(+), 10 deletions(-) diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/constants.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/constants.js index d02705d01f..9e9d43f01d 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/constants.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/constants.js @@ -34,6 +34,8 @@ const mapTypeToDescription = { [PICK_LIST]: 'Generate a sub-list by randomly choosing from a list' } +const SERIES_TYPE_OPTIONS = ['', 'arithmetic', 'geometric'] + export { STATIC_VALUE, RANDOM_NUMBER, @@ -42,6 +44,7 @@ export { RANDOM_SEQUENCE, PICK_ONE, PICK_LIST, + SERIES_TYPE_OPTIONS, typeList, mapTypeToString, mapTypeToDescription diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-list-modal.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-list-modal.js index a4e01f1473..855a4cfef9 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-list-modal.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-list-modal.js @@ -6,7 +6,6 @@ import Common from 'obojobo-document-engine/src/scripts/common' import VariableProperty from './variable-property/variable-property' import NewVariable from './new-variable/new-variable' import VariableBlock from './variable-block' -import { RANDOM_NUMBER, RANDOM_LIST } from './constants' import { getParsedRange } from '../../../common/util/range-parsing' import { changeVariableToType, validateVariableValue, validateMultipleVariables } from './variable-util' diff --git a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-property/variable-value.js b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-property/variable-value.js index 9c41936299..e3922fcbea 100644 --- a/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-property/variable-value.js +++ b/packages/app/obojobo-document-engine/src/scripts/oboeditor/components/variables/variable-property/variable-value.js @@ -8,7 +8,8 @@ import { RANDOM_LIST, RANDOM_SEQUENCE, PICK_ONE, - PICK_LIST + PICK_LIST, + SERIES_TYPE_OPTIONS } from '../constants' const VariableValues = props => { @@ -93,6 +94,10 @@ const VariableValues = props => { return className } + const constrainSeriesTypeOption = value => { + return SERIES_TYPE_OPTIONS.includes(value) ? value : '' + } + switch (variable.type) { case STATIC_VALUE: return ( @@ -312,7 +317,7 @@ const VariableValues = props => { + {variable.errors + && variable.errors.seriesType + && (! SERIES_TYPE_OPTIONS.includes(variable.seriesType)) ? + + Invalid option "{variable.seriesType}" + + : null}