diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5644055..74c2781 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+
+
+# 1.6.2 (2021-12-07)
+
+### Fix
+
+- native file system export PDF type
+
# 1.6.1 (2021-12-07)
diff --git a/package-lock.json b/package-lock.json
index 0655791..19d423b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "tietracker",
- "version": "1.6.1",
+ "version": "1.6.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
diff --git a/package.json b/package.json
index a53e254..8b66e9a 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "tietracker",
- "version": "1.6.1",
+ "version": "1.6.2",
"private": true,
"dependencies": {
"@capacitor/android": "^2.4.6",
diff --git a/src/services/backup/backup.service.ts b/src/services/backup/backup.service.ts
index 36c8528..412380a 100644
--- a/src/services/backup/backup.service.ts
+++ b/src/services/backup/backup.service.ts
@@ -75,7 +75,7 @@ export class BackupService {
exportNativeFileSystem(currency: Currency, vat: number | undefined, signature: string | undefined): Promise {
return new Promise(async (resolve, reject) => {
try {
- const fileHandle: FileSystemFileHandle = await getNewFileHandle();
+ const fileHandle: FileSystemFileHandle = await getNewFileHandle('xlsx');
if (!fileHandle) {
reject('Cannot access filesystem.');
diff --git a/src/services/export/export.service.ts b/src/services/export/export.service.ts
index 32a74f5..51175e8 100644
--- a/src/services/export/export.service.ts
+++ b/src/services/export/export.service.ts
@@ -35,7 +35,8 @@ export class ExportService {
currency: Currency,
vat: number | undefined,
bill: boolean,
- type: 'xlsx' | 'pdf', signature: string | undefined
+ type: 'xlsx' | 'pdf',
+ signature: string | undefined
): Promise {
return new Promise(async (resolve, reject) => {
if (invoice === undefined || invoice.project_id === undefined) {
@@ -51,7 +52,7 @@ export class ExportService {
}
try {
- const fileHandle: FileSystemFileHandle = await getNewFileHandle();
+ const fileHandle: FileSystemFileHandle = await getNewFileHandle(type);
if (!fileHandle) {
reject('Cannot access filesystem.');
@@ -81,7 +82,8 @@ export class ExportService {
currency: Currency,
vat: number | undefined,
bill: boolean,
- type: 'xlsx' | 'pdf', signature: string | undefined
+ type: 'xlsx' | 'pdf',
+ signature: string | undefined
): Promise {
return new Promise(async (resolve, reject) => {
if (invoice === undefined || invoice.project_id === undefined) {
@@ -175,7 +177,15 @@ export class ExportService {
return `${name}${from ? '-' + format(from, 'yyyy-MM-dd') : ''}${to ? '-' + format(to, 'yyyy-MM-dd') : ''}.${type}`;
}
- private async postMessage(invoice: Invoice, invoices: string[], currency: Currency, vat: number | undefined, bill: boolean, type: 'xlsx' | 'pdf', signature: string | undefined) {
+ private async postMessage(
+ invoice: Invoice,
+ invoices: string[],
+ currency: Currency,
+ vat: number | undefined,
+ bill: boolean,
+ type: 'xlsx' | 'pdf',
+ signature: string | undefined
+ ) {
await i18next.loadNamespaces('export');
this.exportWorker.postMessage({
@@ -188,7 +198,7 @@ export class ExportService {
bill: bill,
i18n: exportLabels(),
type,
- signature
+ signature,
});
}
}
diff --git a/src/utils/utils.filesystem.ts b/src/utils/utils.filesystem.ts
index f4da270..22e8c63 100644
--- a/src/utils/utils.filesystem.ts
+++ b/src/utils/utils.filesystem.ts
@@ -4,8 +4,8 @@ import {DirectoryEntry, File} from '@ionic-native/file';
import {SocialSharing} from '@ionic-native/social-sharing';
-export async function getNewFileHandle(): Promise {
- const opts: SaveFilePickerOptions = {
+export async function getNewFileHandle(type: 'pdf' | 'xlsx'): Promise {
+ const xlsxOpts: SaveFilePickerOptions = {
types: [
{
description: 'Excel Files',
@@ -16,7 +16,18 @@ export async function getNewFileHandle(): Promise {
],
};
- return showSaveFilePicker(opts);
+ const pdfOpts: SaveFilePickerOptions = {
+ types: [
+ {
+ description: 'PDF Files',
+ accept: {
+ 'application/pdf': ['.pdf'],
+ },
+ },
+ ],
+ };
+
+ return showSaveFilePicker(type === 'pdf' ? pdfOpts : xlsxOpts);
}
export async function writeFile(fileHandle: FileSystemFileHandle, contents: string | BufferSource | Blob) {