Commit c02d20ee authored by Manuel Tancoigne's avatar Manuel Tancoigne

Create components to display available templates

parent b75b9e98
<template>
<i-list-group size="sm">
<i-list-group-item>
<i-button-group size="sm">
<i-button v-for="locale in locales"
:key="locale"
:active="activeTab === locale"
@click="activeTab = locale">
{{ locale === 'none' ? $t('template_list.unlocalized') : $t(`locales.${locale}`) }}
<i-badge size="sm" variant="primary">
{{ list[locale] | count }}
</i-badge>
</i-button>
</i-button-group>
</i-list-group-item>
<template-list-item v-for="(template, filename) in list[activeTab]"
:key="filename"
:file="filename"
:locale="activeTab"
:template="template" />
</i-list-group>
</template>
<script>
import list from '../templates'
import TemplateListItem from './TemplateListItem'
export default {
name: 'TemplateList',
components: { TemplateListItem },
data () {
return {
list,
locales: Object.keys(list).sort(),
activeTab: list.hasOwnProperty(this.$root.$i18n.locale) ? this.$root.$i18n.locale : 'en',
}
},
computed: {},
methods: {},
filters: {
count: list => Object.keys(list).length,
},
}
</script>
<template>
<i-list-group-item>
<h4>
<router-link :to="{ name: 'renderer', params: { content: file} }">{{ template.name }}</router-link>
</h4>
<dl class="infos infos--inline">
<div v-if="showLanguage" class="infos-item">
<dt>{{ $t('template_list.item.language') }}</dt>
<dd>{{ locale !== 'none' ? $t(`locales.${locale}`) : '-' }}</dd>
</div>
</dl>
<div>{{ template.description }}</div>
</i-list-group-item>
</template>
<script>
export default {
name: 'TemplateListItem',
props: {
file: { required: true, type: String },
locale: { required: false, type: String, default: 'none' },
template: { required: true, type: Object },
showLanguage: { required: false, type: Boolean, default: true },
},
}
</script>
<style lang="scss">
dl.infos {
margin: 0;
&--inline {
dt {
margin-right: .5rem;
}
dd {
margin: 0;
}
dt,
dd {
display: inline-block;
padding: 0;
}
}
}
</style>
......@@ -41,5 +41,11 @@
"name": "Name:",
"sections": "Sections",
"variables": "Variables"
},
"template_list": {
"item": {
"language": "Language:"
},
"unlocalized": "Misc."
}
}
......@@ -41,5 +41,11 @@
"name": "Nom:",
"sections": "Sections",
"variables": "Variables"
},
"template_list": {
"item": {
"language": "Langue:"
},
"unlocalized": "Autres"
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment