Migrated fields to embedded property calculations
This commit is contained in:
@@ -0,0 +1,52 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<markdown-text
|
||||||
|
:markdown="computedValue"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
MarkdownText,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
string: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
calculations: {
|
||||||
|
type: Array,
|
||||||
|
default(){
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
computedValue(){
|
||||||
|
if (!this.string) return '';
|
||||||
|
let index = 0;
|
||||||
|
return this.string.replace(/\{([^{}]*)\}/g, () => {
|
||||||
|
let comp = this.calculations && this.calculations[index++];
|
||||||
|
return comp && comp.result;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css">
|
||||||
|
.computed {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
.computed.symbols-are-errors .math-symbol {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
.computed.code {
|
||||||
|
font-family: monospace,monospace;
|
||||||
|
}
|
||||||
|
.computed .math-binary-operator {
|
||||||
|
margin: 0 6px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -12,8 +12,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<v-card-text v-if="model.summary">
|
<v-card-text v-if="model.summary">
|
||||||
<computed
|
<computed
|
||||||
embedded
|
:string="model.summary"
|
||||||
:value="model.summary"
|
:calculations="model.summaryCalculations"
|
||||||
/>
|
/>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</toolbar-card>
|
</toolbar-card>
|
||||||
@@ -21,12 +21,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
||||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
import EmbedInlineComputations from '/imports/ui/components/computation/EmbedInlineComputations.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ToolbarCard,
|
ToolbarCard,
|
||||||
Computed: ComputedForCreature,
|
Computed: EmbedInlineComputations,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
model: {
|
model: {
|
||||||
|
|||||||
Reference in New Issue
Block a user