Skip to content

Commit

Permalink
Feat: Multiple File Extensions for CDOGS Print (bcgov#1395)
Browse files Browse the repository at this point in the history
* testing xlsx

* fixed file extension select dropdown

* fix extension error

* fix prettier

* reset file extension

* added internationalization

* fix disabled template print button issue
  • Loading branch information
vijaivir committed Jun 26, 2024
1 parent 73d0a9a commit 5678ae2
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 19 deletions.
49 changes: 48 additions & 1 deletion app/frontend/src/components/forms/PrintOptions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export default {
displayTemplatePrintButton: false,
isValidFile: true,
validFileExtensions: ['txt', 'docx', 'html', 'odt', 'pptx', 'xlsx'],
defaultExportFileTypes: ['pdf'],
uploadExportFileTypes: ['pdf'],
};
},
computed: {
Expand Down Expand Up @@ -88,11 +90,16 @@ export default {
this.templateForm.outputFileName = name;
}
this.templateForm.contentFileType = extension;
if (!this.uploadExportFileTypes.includes(extension)) {
this.uploadExportFileTypes.push(extension);
}
}
},
selectedOption() {
if (this.selectedOption === 'default') {
this.displayTemplatePrintButton = true;
} else if (this.selectedOption === 'upload') {
this.displayTemplatePrintButton = this.templateForm.files.length > 0;
} else {
this.displayTemplatePrintButton = false;
}
Expand Down Expand Up @@ -191,7 +198,7 @@ export default {
async generate() {
try {
this.loading = true;
const outputFileType = 'pdf';
let outputFileType = this.templateForm.outputFileType || 'pdf';
let content = '';
let contentFileType = '';
let outputFileName = '';
Expand Down Expand Up @@ -290,6 +297,10 @@ export default {
this.defaultTemplateExtension = extension;
this.defaultReportname = name;
this.defaultTemplateDate = response2.data.createdAt.split('T')[0];
if (!this.defaultExportFileTypes.includes(extension)) {
this.defaultExportFileTypes.push(extension);
}
}
} catch (e) {
this.addNotification({
Expand All @@ -305,12 +316,28 @@ export default {
validateFileExtension(event) {
if (event.length > 0) {
const fileExtension = event[0].name.split('.').pop();
// reset the outputFileName when a new file is uploaded
this.templateForm.outputFileName = event[0].name
.split('.')
.slice(0, -1)
.join('.');
// reset uploadExportFileTypes when a new file is uploaded
this.uploadExportFileTypes = ['pdf'];
// reset the v-select value
this.templateForm.outputFileType = null;
if (this.validFileExtensions.includes(fileExtension)) {
this.isValidFile = true;
} else {
this.isValidFile = false;
}
} else {
// Remove the file extension from uploadExportFileTypes when the file input is cleared
const fileExtension = this.templateForm.contentFileType;
if (fileExtension && fileExtension !== 'pdf') {
this.uploadExportFileTypes = this.uploadExportFileTypes.filter(
(type) => type !== fileExtension
);
}
this.isValidFile = true;
}
},
Expand Down Expand Up @@ -430,6 +457,16 @@ export default {
</tr>
</tbody>
</v-table>
<!-- dropdown list -->
<v-select
v-if="selectedOption === 'default'"
v-model="templateForm.outputFileType"
variant="outlined"
:items="defaultExportFileTypes"
:label="$t('trans.printOptions.selectExportFileType')"
style="width: 220px"
class="mx-10"
/>
</v-skeleton-loader>
<!-- Radio 2 -->
Expand All @@ -454,6 +491,16 @@ export default {
:disabled="selectedOption !== 'upload'"
@update:model-value="validateFileExtension($event)"
/>
<v-select
v-if="selectedOption === 'upload'"
v-model="templateForm.outputFileType"
variant="outlined"
:items="uploadExportFileTypes"
label="Select export filetype"
style="width: 220px"
class="mx-10"
>
</v-select>
</v-radio-group>
<v-card-actions>
<v-tooltip location="top">
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/ar/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "استخدام قالب CDOGS الافتراضي",
"fileName": "اسم الملف",
"uploadDate": "تاريخ التحميل",
"upload": "تحميل"
"upload": "تحميل",
"selectExportFileType": "اختر نوع ملف التصدير"
},
"proactiveHelpDialog": {
"componentInfoLink": "رابط معلومات المكون",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/de/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,8 @@
"defaultCdogsTemplate": "Standard-CDOGS-Vorlage verwenden",
"fileName": "Dateiname",
"uploadDate": "Hochladedatum",
"upload": "Hochladen"
"upload": "Hochladen",
"selectExportFileType": "Exportdateityp auswählen"
},
"proactiveHelpDialog": {
"componentInfoLink": "Link zu Komponenteninformationen",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@
"defaultCdogsTemplate": "Use default CDOGS template",
"fileName": "File Name",
"uploadDate": "Upload Date",
"upload": "Upload"
"upload": "Upload",
"selectExportFileType": "Select export filetype"
},
"proactiveHelpDialog": {
"componentInfoLink": "Component Information Link",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/es/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Usar plantilla CDOGS predeterminada",
"fileName": "Nombre del archivo",
"uploadDate": "Fecha de subida",
"upload": "Subir"
"upload": "Subir",
"selectExportFileType": "Seleccionar tipo de archivo de exportación"
},
"proactiveHelpDialog": {
"componentInfoLink": "Enlace de información del componente",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/fa/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "استفاده از قالب پیش‌فرض CDOGS",
"fileName": "نام فایل",
"uploadDate": "تاریخ بارگذاری",
"upload": "بارگذاری"
"upload": "بارگذاری",
"selectExportFileType": "نوع فایل صادرات را انتخاب کنید"
},
"proactiveHelpDialog": {
"componentInfoLink": "لینک اطلاعات کامپوننت",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/fr/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Utiliser le modèle CDOGS par défaut",
"fileName": "Nom de fichier",
"uploadDate": "Date de téléchargement",
"upload": "Télécharger"
"upload": "Télécharger",
"selectExportFileType": "Sélectionner le type de fichier à exporter"
},
"proactiveHelpDialog": {
"componentInfoLink": "Lien d'informations sur les composants",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/hi/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "डिफ़ॉल्ट CDOGS टेम्पलेट का प्रयोग करें",
"fileName": "फ़ाइल का नाम",
"uploadDate": "अपलोड दिनांक",
"upload": "अपलोड करें"
"upload": "अपलोड करें",
"selectExportFileType": "निर्यात फ़ाइल प्रकार चुनें"
},
"proactiveHelpDialog": {
"componentInfoLink": "घटक सूचना लिंक",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/it/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Usa template CDOGS predefinito",
"fileName": "Nome del file",
"uploadDate": "Data di caricamento",
"upload": "Carica"
"upload": "Carica",
"selectExportFileType": "Seleziona il tipo di file di esportazione"
},
"proactiveHelpDialog": {
"componentInfoLink": "Collegamento alle informazioni sui componenti",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/ja/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "デフォルトのCDOGSテンプレートを使用する",
"fileName": "ファイル名",
"uploadDate": "アップロード日",
"upload": "アップロード"
"upload": "アップロード",
"selectExportFileType": "エクスポートファイルタイプを選択"
},
"proactiveHelpDialog": {
"componentInfoLink": "コンポーネント情報リンク",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/ko/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "기본 CDOGS 템플릿 사용",
"fileName": "파일 이름",
"uploadDate": "업로드 날짜",
"upload": "업로드"
"upload": "업로드",
"selectExportFileType": "내보낼 파일 유형 선택"
},
"proactiveHelpDialog": {
"componentInfoLink": "구성품 정보 링크",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/pa/pa.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "ਮੂਲ CDOGS ਟੈਂਪਲੇਟ ਵਰਤੋ",
"fileName": "ਫਾਈਲ ਦਾ ਨਾਂ",
"uploadDate": "ਅੱਪਲੋਡ ਮਿਤੀ",
"upload": "ਅੱਪਲੋਡ ਕਰੋ"
"upload": "ਅੱਪਲੋਡ ਕਰੋ",
"selectExportFileType": "ਨਿਰਯਾਤ ਫਾਈਲ ਦੀ ਕਿਸਮ ਚੁਣੋ"
},
"proactiveHelpDialog": {
"componentInfoLink": "ਕੰਪੋਨੈਂਟ ਜਾਣਕਾਰੀ ਲਿੰਕ",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/pt/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Usar modelo padrão CDOGS",
"fileName": "Nome do arquivo",
"uploadDate": "Data de upload",
"upload": "Carregar"
"upload": "Carregar",
"selectExportFileType": "Selecionar tipo de arquivo de exportação"
},
"proactiveHelpDialog": {
"componentInfoLink": "Link de informações do componente",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/ru/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Использовать стандартный шаблон CDOGS",
"fileName": "Имя файла",
"uploadDate": "Дата загрузки",
"upload": "Загрузить"
"upload": "Загрузить",
"selectExportFileType": "Выберите тип файла экспорта"
},
"proactiveHelpDialog": {
"componentInfoLink": "Ссылка на информацию о компоненте",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/tl/tl.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Gamitin ang default na Template ng CDOGS",
"fileName": "Pangalan ng File",
"uploadDate": "Petsa ng Pag-upload",
"upload": "I-upload"
"upload": "I-upload",
"selectExportFileType": "Piliin ang uri ng file na i-export"
},
"proactiveHelpDialog": {
"componentInfoLink": "Link ng Impormasyon ng Bahagi",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/uk/uk.json
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@
"defaultCdogsTemplate": "Використовувати стандартний шаблон CDOGS",
"fileName": "Назва файлу",
"uploadDate": "Дата завантаження",
"upload": "Завантажити"
"upload": "Завантажити",
"selectExportFileType": "Виберіть тип файлу для експорту"
},
"proactiveHelpDialog": {
"componentInfoLink": "Інформаційне посилання на компонент",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/vi/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "Sử dụng mẫu CDOGS mặc định",
"fileName": "Tên tệp",
"uploadDate": "Ngày tải lên",
"upload": "Tải lên"
"upload": "Tải lên",
"selectExportFileType": "Chọn loại file xuất"
},
"proactiveHelpDialog": {
"componentInfoLink": "Liên kết thông tin thành phần",
Expand Down
3 changes: 2 additions & 1 deletion app/frontend/src/internationalization/trans/chefs/zh/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "使用默认CDOGS模板",
"fileName": "文件名",
"uploadDate": "上传日期",
"upload": "上传"
"upload": "上传",
"selectExportFileType": "选择导出文件类型"
},
"proactiveHelpDialog": {
"componentInfoLink": "组件信息链接",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,8 @@
"defaultCdogsTemplate": "使用預設CDOGS範本",
"fileName": "檔案名稱",
"uploadDate": "上傳日期",
"upload": "上傳"
"upload": "上傳",
"selectExportFileType": "選擇導出文件類型"
},
"proactiveHelpDialog": {
"componentInfoLink": "組件信息鏈接",
Expand Down

0 comments on commit 5678ae2

Please sign in to comment.