Skip to content

Commit

Permalink
feat: topsheet title comes from title/title_en/title_de fields
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Jul 9, 2021
1 parent f67f38c commit 3d7e25f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/components/TopSheet/TopSheet.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
<i18n>
en:
title: 'Key Performance Indicators'
de:
title: 'Key Performance Indicators'
</i18n>

<template lang="pug">
.topsheet.curate-content(v-if="table.length")
h3.curate-heading {{ $t('title') }}
h3.curate-heading {{ title }}

.output-table
.row(v-for="row,i in entries" :key="'entry'+i")
Expand Down Expand Up @@ -50,6 +43,7 @@ export default class VueComponent extends Vue {
private table: TableRow[] = []
private entries: { key: string; title: string; value: any }[] = []
private title = 'Topsheet'
private formattedValue(value: any) {
if (!isNaN(value)) return value.toLocaleString([this.$store.state.locale, 'en'])
Expand Down Expand Up @@ -95,6 +89,8 @@ export default class VueComponent extends Vue {
yaml: this.yaml,
})
this.title = await this.solverThread.getTitle(this.$store.state.locale)
const outputRows = await this.solverThread.getTextEntryFields()
this.entries = outputRows
} catch (e) {
Expand Down
13 changes: 13 additions & 0 deletions src/components/TopSheet/TopSheetWorker.thread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ type TableRow = {
}

type TopsheetYaml = {
title?: string
title_en?: string
title_de?: string
files: {
[id: string]: { file: string; useLastRow?: boolean; xmlElements: string }
}
Expand Down Expand Up @@ -64,6 +67,16 @@ expose({
return outputs
},

getTitle(locale: string) {
console.log('getTitle locale', locale)
let title = 'Topsheet'

if (locale === 'en') title = _yaml.title_en || _yaml.title || _yaml.title_de || 'Topsheet'
else title = _yaml.title_de || _yaml.title || _yaml.title_en || 'Topsheet'

return title
},

getTextEntryFields() {
const boxes = _yaml.userEntries
if (!boxes) return []
Expand Down

0 comments on commit 3d7e25f

Please sign in to comment.