From 6e7cf0380b4271763fdd19e5572d5c96c98b382a Mon Sep 17 00:00:00 2001
From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com>
Date: Sat, 16 Apr 2022 11:33:01 +0200
Subject: [PATCH] Feature/export single draft (#835)
* Export single draft
* Update changelog
---
CHANGELOG.md | 8 ++++++-
.../accounts-table.component.html | 9 ++++----
.../components/admin-users/admin-users.html | 4 ++--
.../transactions-page.component.ts | 8 +++----
.../src/app/services/ics/ics.service.ts | 5 ++--
.../activities-table.component.html | 23 ++++++++++++++-----
.../activities-table.component.ts | 4 ++++
7 files changed, 42 insertions(+), 19 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 766834f67..f115e0206 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,11 +5,17 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## Unreleased
+
+### Added
+
+- Added support to export a single future activity (draft) as an `.ics` file
+
## 1.137.0 - 15.04.2022
### Added
-- Added support to export future activities (drafts) as `.ics` files
+- Added support to export future activities (drafts) as an `.ics` file
### Changed
diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.html b/apps/client/src/app/components/accounts-table/accounts-table.component.html
index 5e8fcdba9..cf8446e42 100644
--- a/apps/client/src/app/components/accounts-table/accounts-table.component.html
+++ b/apps/client/src/app/components/accounts-table/accounts-table.component.html
@@ -194,16 +194,17 @@
-
diff --git a/apps/client/src/app/components/admin-users/admin-users.html b/apps/client/src/app/components/admin-users/admin-users.html
index 9556f99cb..8982e2291 100644
--- a/apps/client/src/app/components/admin-users/admin-users.html
+++ b/apps/client/src/app/components/admin-users/admin-users.html
@@ -68,12 +68,12 @@
- Delete
+
+ Delete
diff --git a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
index 61683fd75..9e94b305e 100644
--- a/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
+++ b/apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
@@ -178,10 +178,10 @@ export class TransactionsPageComponent implements OnDestroy, OnInit {
content: this.icsService.transformActivitiesToIcsContent(
data.activities
),
- fileName: `ghostfolio-drafts-${format(
- parseISO(data.meta.date),
- 'yyyyMMddHHmm'
- )}.ics`,
+ contentType: 'text/calendar',
+ fileName: `ghostfolio-draft${
+ data.activities.length > 1 ? 's' : ''
+ }-${format(parseISO(data.meta.date), 'yyyyMMddHHmm')}.ics`,
format: 'string'
});
});
diff --git a/apps/client/src/app/services/ics/ics.service.ts b/apps/client/src/app/services/ics/ics.service.ts
index 7329ea663..bad9a514c 100644
--- a/apps/client/src/app/services/ics/ics.service.ts
+++ b/apps/client/src/app/services/ics/ics.service.ts
@@ -9,6 +9,7 @@ import { format, parseISO } from 'date-fns';
})
export class IcsService {
private readonly ICS_DATE_FORMAT = 'yyyyMMdd';
+ private readonly ICS_LINE_BREAK = '\r\n';
public constructor() {}
@@ -30,7 +31,7 @@ export class IcsService {
});
const footer = ['END:VCALENDAR'];
- return [...header, ...events, ...footer].join('\n');
+ return [...header, ...events, ...footer].join(this.ICS_LINE_BREAK);
}
private getEvent({
@@ -54,6 +55,6 @@ export class IcsService {
`DTEND;VALUE=DATE:${format(date, this.ICS_DATE_FORMAT)}`,
`SUMMARY:${capitalize(type)} ${symbol}`,
'END:VEVENT'
- ].join('\n');
+ ].join(this.ICS_LINE_BREAK);
}
}
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.html b/libs/ui/src/lib/activities-table/activities-table.component.html
index a7449a0be..cd21ca88c 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.html
+++ b/libs/ui/src/lib/activities-table/activities-table.component.html
@@ -387,14 +387,25 @@
-
- Edit
+
+
+ Edit
-
- Clone
+
+
+ Clone
-
- Delete
+
+
+ Export Draft as ICS
+
+
+
+ Delete
diff --git a/libs/ui/src/lib/activities-table/activities-table.component.ts b/libs/ui/src/lib/activities-table/activities-table.component.ts
index c76d4c6a8..3025bdc8b 100644
--- a/libs/ui/src/lib/activities-table/activities-table.component.ts
+++ b/libs/ui/src/lib/activities-table/activities-table.component.ts
@@ -200,6 +200,10 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
}
}
+ public onExportDraft(aActivityId: string) {
+ this.exportDrafts.emit([aActivityId]);
+ }
+
public onExportDrafts() {
this.exportDrafts.emit(
this.dataSource.filteredData