diff --git a/packages/client/hmi-client/src/components/drilldown/tera-drilldown-section.vue b/packages/client/hmi-client/src/components/drilldown/tera-drilldown-section.vue index 5fc7a232c3..e6cee184ad 100644 --- a/packages/client/hmi-client/src/components/drilldown/tera-drilldown-section.vue +++ b/packages/client/hmi-client/src/components/drilldown/tera-drilldown-section.vue @@ -53,6 +53,7 @@ section { flex-direction: column; gap: 0.75rem; overflow: hidden; + height: 100%; } main { display: flex; diff --git a/packages/client/hmi-client/src/components/drilldown/tera-drilldown.vue b/packages/client/hmi-client/src/components/drilldown/tera-drilldown.vue index 4a993b4776..3768e9b519 100644 --- a/packages/client/hmi-client/src/components/drilldown/tera-drilldown.vue +++ b/packages/client/hmi-client/src/components/drilldown/tera-drilldown.vue @@ -180,21 +180,6 @@ than the main application behind the modal when these render issues come, howeve } } -main { - flex-grow: 1; - padding: 0; - gap: var(--gap); -} - -main > :deep(*) { - display: grid; - grid-auto-flow: column; - height: 100%; - grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); - gap: 0.5rem; - overflow: hidden; -} - footer { padding: 0 1.5rem 1rem 1.5rem; display: flex; diff --git a/packages/client/hmi-client/src/components/model/petrinet/model-configurations/tera-stratified-matrix-modal.vue b/packages/client/hmi-client/src/components/model/petrinet/model-configurations/tera-stratified-matrix-modal.vue index 0ed1bfcba2..ee2ee37340 100644 --- a/packages/client/hmi-client/src/components/model/petrinet/model-configurations/tera-stratified-matrix-modal.vue +++ b/packages/client/hmi-client/src/components/model/petrinet/model-configurations/tera-stratified-matrix-modal.vue @@ -3,7 +3,7 @@ @@ -123,7 +128,7 @@ import Column from 'primevue/column'; import { MiraModel, MiraTemplateParams } from '@/model-representation/mira/mira-common'; import { emptyMiraModel } from '@/model-representation/mira/mira'; import { getMMT } from '@/services/model'; -import TeraInitialsMetadata from '@/components/model/tera-initials-metadata.vue'; +import TeraStatesMetadata from '@/components/model/tera-states-metadata.vue'; import TeraParametersMetadata from '@/components/model//tera-parameters-metadata.vue'; import TeraOtherConceptsTable from './tera-other-concepts-table.vue'; @@ -132,7 +137,7 @@ const props = defineProps<{ readonly?: boolean; }>(); -const emit = defineEmits(['update-model', 'update-initial-metadata', 'update-parameter']); +const emit = defineEmits(['update-model', 'update-state', 'update-parameter']); const mmt = ref(emptyMiraModel()); const mmtParams = ref({}); diff --git a/packages/client/hmi-client/src/components/model/regnet/tera-regnet-tables.vue b/packages/client/hmi-client/src/components/model/regnet/tera-regnet-tables.vue index c5b86305ed..c9ebc442e8 100644 --- a/packages/client/hmi-client/src/components/model/regnet/tera-regnet-tables.vue +++ b/packages/client/hmi-client/src/components/model/regnet/tera-regnet-tables.vue @@ -64,7 +64,10 @@ diff --git a/packages/client/hmi-client/src/components/model/stockflow/tera-stockflow-tables.vue b/packages/client/hmi-client/src/components/model/stockflow/tera-stockflow-tables.vue index 6a91ac4037..f203fe28a4 100644 --- a/packages/client/hmi-client/src/components/model/stockflow/tera-stockflow-tables.vue +++ b/packages/client/hmi-client/src/components/model/stockflow/tera-stockflow-tables.vue @@ -4,9 +4,11 @@ - @@ -14,7 +16,10 @@ Parameters({{ parametersLength }}) @@ -142,15 +147,15 @@ import Column from 'primevue/column'; import { MiraModel, MiraTemplateParams } from '@/model-representation/mira/mira-common'; import { emptyMiraModel } from '@/model-representation/mira/mira'; import { getMMT } from '@/services/model'; +import TeraStatesMetadata from '@/components/model/tera-states-metadata.vue'; import TeraParametersMetadata from '../tera-parameters-metadata.vue'; -import TeraInitialsMetadata from '../tera-initials-metadata.vue'; const props = defineProps<{ model: Model; readonly?: boolean; }>(); -const emit = defineEmits(['update-initial-metadata', 'update-parameter']); +const emit = defineEmits(['update-state', 'update-parameter']); const mmt = ref(emptyMiraModel()); const mmtParams = ref({}); diff --git a/packages/client/hmi-client/src/components/model/tera-initial-metadata-entry.vue b/packages/client/hmi-client/src/components/model/tera-initial-metadata-entry.vue deleted file mode 100644 index 4a160c3948..0000000000 --- a/packages/client/hmi-client/src/components/model/tera-initial-metadata-entry.vue +++ /dev/null @@ -1,75 +0,0 @@ - - - - - diff --git a/packages/client/hmi-client/src/components/model/tera-initials-metadata.vue b/packages/client/hmi-client/src/components/model/tera-initials-metadata.vue deleted file mode 100644 index 326da1808e..0000000000 --- a/packages/client/hmi-client/src/components/model/tera-initials-metadata.vue +++ /dev/null @@ -1,32 +0,0 @@ - - - - - diff --git a/packages/client/hmi-client/src/components/model/tera-model-semantic-tables.vue b/packages/client/hmi-client/src/components/model/tera-model-semantic-tables.vue index 97cbe484b9..b2b3556c16 100644 --- a/packages/client/hmi-client/src/components/model/tera-model-semantic-tables.vue +++ b/packages/client/hmi-client/src/components/model/tera-model-semantic-tables.vue @@ -4,7 +4,7 @@ :model="transientModel" :readonly="readonly" @update-model="$emit('update-model', $event)" - @update-initial-metadata="onUpdateInitialMetadata" + @update-state="onUpdateState" @update-parameter="onUpdateParameter" /> @@ -18,7 +18,12 @@ import TeraRegnetTables from '@/components/model/regnet/tera-regnet-tables.vue'; import TeraStockflowTables from '@/components/model/stockflow/tera-stockflow-tables.vue'; import { AMRSchemaNames } from '@/types/common'; import { getModelType } from '@/services/model'; -import { updateInitialMetadata, updateParameter } from '@/model-representation/service'; +import { + updateState, + updateInitialMetadata, + updateParameter, + updateParameterMetadata +} from '@/model-representation/service'; const props = defineProps<{ model: Model; @@ -44,14 +49,22 @@ const tables = computed(() => { } }); -function onUpdateInitialMetadata(event: any) { - const { target, key, value } = event; - updateInitialMetadata(transientModel.value, target, key, value); +function onUpdateState(event: any) { + const { id, key, value, isMetadata } = event; + if (isMetadata) { + updateInitialMetadata(transientModel.value, id, key, value); // For now we only have metadata for initials so just save it there + } else { + updateState(transientModel.value, id, key, value); + } } function onUpdateParameter(event: any) { - const { parameterId, key, value } = event; - updateParameter(transientModel.value, parameterId, key, value); + const { parameterId, key, value, isMetadata } = event; + if (isMetadata) { + updateParameterMetadata(transientModel.value, parameterId, key, value); + } else { + updateParameter(transientModel.value, parameterId, key, value); + } } // Apply changes to the model when the component unmounts or the user navigates away diff --git a/packages/client/hmi-client/src/components/model/tera-parameter-metadata-entry.vue b/packages/client/hmi-client/src/components/model/tera-parameter-metadata-entry.vue index 9ba4e51f73..99c2d87b12 100644 --- a/packages/client/hmi-client/src/components/model/tera-parameter-metadata-entry.vue +++ b/packages/client/hmi-client/src/components/model/tera-parameter-metadata-entry.vue @@ -1,5 +1,5 @@ @@ -36,12 +47,16 @@ import type { ModelParameter } from '@/types/Types'; import TeraInput from '@/components/widgets/tera-input.vue'; import { getCurieFromGroundingIdentifier, getNameOfCurieCached } from '@/services/concept'; +import Button from 'primevue/button'; const props = defineProps<{ parameter: ModelParameter; + isBase?: boolean; + isStratified?: boolean; + showStratifiedVariables?: boolean; }>(); -defineEmits(['update-parameter']); +defineEmits(['update-parameter', 'toggle-stratified-variables', 'open-matrix']); const { id, name, description, grounding, units } = props.parameter; @@ -51,14 +66,35 @@ section { display: grid; grid-template-areas: 'symbol name description description' - 'unit unit concept .'; + 'unit unit concept .'; grid-template-columns: max-content 30% 30% auto; gap: var(--gap-small); align-items: center; } +section.has-toggle { + grid-template-areas: + 'symbol name description description' + 'toggle unit concept open-matrix'; + grid-template-columns: max-content 30% auto 8rem; +} + +section.no-second-row { + gap: 0 var(--gap-small); +} + h6 { grid-area: symbol; + justify-self: center; +} + +.toggle { + grid-area: toggle; + margin-left: auto; +} + +[label='Open Matrix'] { + grid-area: open-matrix; } :deep([label='Name']) { diff --git a/packages/client/hmi-client/src/components/model/tera-parameters-metadata.vue b/packages/client/hmi-client/src/components/model/tera-parameters-metadata.vue index c708806ac0..e134210f8c 100644 --- a/packages/client/hmi-client/src/components/model/tera-parameters-metadata.vue +++ b/packages/client/hmi-client/src/components/model/tera-parameters-metadata.vue @@ -1,36 +1,114 @@ diff --git a/packages/client/hmi-client/src/components/model/tera-state-metadata-entry.vue b/packages/client/hmi-client/src/components/model/tera-state-metadata-entry.vue new file mode 100644 index 0000000000..9d6f42a2ed --- /dev/null +++ b/packages/client/hmi-client/src/components/model/tera-state-metadata-entry.vue @@ -0,0 +1,102 @@ + + + + + diff --git a/packages/client/hmi-client/src/components/model/tera-states-metadata.vue b/packages/client/hmi-client/src/components/model/tera-states-metadata.vue new file mode 100644 index 0000000000..381992125e --- /dev/null +++ b/packages/client/hmi-client/src/components/model/tera-states-metadata.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/packages/client/hmi-client/src/components/widgets/tera-columnar-panel.vue b/packages/client/hmi-client/src/components/widgets/tera-columnar-panel.vue index 976c29241e..016576eb23 100644 --- a/packages/client/hmi-client/src/components/widgets/tera-columnar-panel.vue +++ b/packages/client/hmi-client/src/components/widgets/tera-columnar-panel.vue @@ -4,14 +4,14 @@ - - diff --git a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue index 5368522a26..9f0e8c053f 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/model-config/tera-model-config.vue @@ -127,7 +127,7 @@ - - -
- -
+ @@ -24,7 +23,7 @@ import TeraDrilldown from '@/components/drilldown/tera-drilldown.vue'; import { ModelOperationState } from './model-operation'; -const props = defineProps<{ +defineProps<{ node: WorkflowNode; }>(); diff --git a/packages/client/hmi-client/src/model-representation/service.ts b/packages/client/hmi-client/src/model-representation/service.ts index 72442d62b2..0fa0b5713e 100644 --- a/packages/client/hmi-client/src/model-representation/service.ts +++ b/packages/client/hmi-client/src/model-representation/service.ts @@ -213,7 +213,7 @@ export function updateParameter(model: Model, parameterId: string, key: string, if (!obj.units) obj.units = { expression: '', expression_mathml: '' }; obj.units.expression = value; obj.units.expression_mathml = `${value}`; - } else { + } else if (obj[key]) { obj[key] = value; } } @@ -230,6 +230,38 @@ export function updateParameter(model: Model, parameterId: string, key: string, updateProperty(auxiliary); } +// Gets states, vertices, stocks +export function getStates(model: Model): any[] { + const modelType = getModelType(model); + switch (modelType) { + case AMRSchemaNames.REGNET: + return model.model?.vertices ?? []; + case AMRSchemaNames.PETRINET: + return model.model?.states ?? []; + case AMRSchemaNames.STOCKFLOW: + return model.model?.stocks ?? []; + default: + return []; + } +} + +export function updateState(model: Model, id: string, key: string, value: any) { + function updateProperty(obj: ModelParameter | any /** There is no auxiliary type yet */) { + // TODO: Add support for editing concept/grounding + if (key === 'initial') { + if (!obj.initial) obj.initial = { expression: '', expression_mathml: '' }; + obj.initial.expression = value; + obj.initial.expression_mathml = `${value}`; + } else if (obj[key]) { + obj[key] = value; + } + } + const states = getStates(model); + const state = states.find((i: any) => i.id === id); + if (!state) return; + updateProperty(state); +} + /** * Retrieves the metadata for a specific initial in the model. * @param {Model} model - The model object. @@ -306,6 +338,7 @@ export function getInitial(model: Model, target: string): Initial | undefined { } } +// TODO: These updateMetadata functions and even the updateParameter function share similar logic and can be refactored /** * Updates the metadata for a specific parameter in the model. * @param {Model} model - The model object. @@ -323,8 +356,19 @@ export function updateParameterMetadata( model.metadata ??= {}; model.metadata.parameters ??= {}; model.metadata.parameters[parameterId] ??= {}; + model.metadata.parameters[parameterId].id = parameterId; + } + const parameterMetadata = model.metadata.parameters[parameterId]; + + // TODO: Add support for editing concept metadata + if (key === 'units') { + if (!parameterMetadata.units) + parameterMetadata.units = { expression: '', expression_mathml: '' }; + parameterMetadata.units.expression = value; + parameterMetadata.units.expression_mathml = `${value}`; + } else { + parameterMetadata[key] = value; } - model.metadata.parameters[parameterId][key] = value; } /** @@ -339,14 +383,17 @@ export function updateInitialMetadata(model: Model, target: string, key: string, model.metadata ??= {}; model.metadata.initials ??= {}; model.metadata.initials[target] ??= {}; + model.metadata.initials[target].id = target; } + const initialMetadata = model.metadata.initials[target]; // TODO: Add support for editing concept metadata - if (key === 'units') { - if (!initialMetadata.units) initialMetadata.units = { expression: '', expression_mathml: '' }; - initialMetadata.units.expression = value; - initialMetadata.units.expression_mathml = `${value}`; + if (key === 'initial') { + if (!initialMetadata.initial) + initialMetadata.initial = { expression: '', expression_mathml: '' }; + initialMetadata.initial.expression = value; + initialMetadata.initial.expression_mathml = `${value}`; } else { initialMetadata[key] = value; }