|
| 1 | +<template> |
| 2 | + <DataTable |
| 3 | + v-model:selection="selectedTemplate" |
| 4 | + :value="templates" |
| 5 | + striped-rows |
| 6 | + selection-mode="single" |
| 7 | + > |
| 8 | + <Column field="title" :header="t('g.title')"> |
| 9 | + <template #body="slotProps"> |
| 10 | + <span :title="getTemplateTitle(slotProps.data)">{{ |
| 11 | + getTemplateTitle(slotProps.data) |
| 12 | + }}</span> |
| 13 | + </template> |
| 14 | + </Column> |
| 15 | + <Column field="description" :header="t('g.description')"> |
| 16 | + <template #body="slotProps"> |
| 17 | + <span :title="slotProps.data.description.replace(/[-_]/g, ' ')"> |
| 18 | + {{ slotProps.data.description.replace(/[-_]/g, ' ') }} |
| 19 | + </span> |
| 20 | + </template> |
| 21 | + </Column> |
| 22 | + <Column field="actions" header="" class="w-12"> |
| 23 | + <template #body="slotProps"> |
| 24 | + <Button |
| 25 | + icon="pi pi-arrow-right" |
| 26 | + text |
| 27 | + rounded |
| 28 | + size="small" |
| 29 | + :loading="loading === slotProps.data.name" |
| 30 | + @click="emit('loadWorkflow', slotProps.data.name)" |
| 31 | + /> |
| 32 | + </template> |
| 33 | + </Column> |
| 34 | + </DataTable> |
| 35 | +</template> |
| 36 | + |
| 37 | +<script setup lang="ts"> |
| 38 | +import Button from 'primevue/button' |
| 39 | +import Column from 'primevue/column' |
| 40 | +import DataTable from 'primevue/datatable' |
| 41 | +import { ref } from 'vue' |
| 42 | +
|
| 43 | +import { st, t } from '@/i18n' |
| 44 | +import type { TemplateInfo } from '@/types/workflowTemplateTypes' |
| 45 | +import { normalizeI18nKey } from '@/utils/formatUtil' |
| 46 | +
|
| 47 | +const { sourceModule, categoryTitle, loading, templates } = defineProps<{ |
| 48 | + sourceModule: string |
| 49 | + categoryTitle: string |
| 50 | + loading: string | null |
| 51 | + templates: TemplateInfo[] |
| 52 | +}>() |
| 53 | +
|
| 54 | +const selectedTemplate = ref(null) |
| 55 | +
|
| 56 | +const emit = defineEmits<{ |
| 57 | + loadWorkflow: [name: string] |
| 58 | +}>() |
| 59 | +
|
| 60 | +const getTemplateTitle = (template: TemplateInfo) => { |
| 61 | + const fallback = template.title ?? template.name ?? `${sourceModule} Template` |
| 62 | + return sourceModule === 'default' |
| 63 | + ? st( |
| 64 | + `templateWorkflows.template.${normalizeI18nKey(categoryTitle)}.${normalizeI18nKey(template.name)}`, |
| 65 | + fallback |
| 66 | + ) |
| 67 | + : fallback |
| 68 | +} |
| 69 | +</script> |
0 commit comments