Browse Source

Feature/export single draft (#835)

* Export single draft

* Update changelog
pull/836/head^2
Thomas Kaul 3 years ago
committed by GitHub
parent
commit
6e7cf0380b
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      CHANGELOG.md
  2. 9
      apps/client/src/app/components/accounts-table/accounts-table.component.html
  3. 4
      apps/client/src/app/components/admin-users/admin-users.html
  4. 8
      apps/client/src/app/pages/portfolio/transactions/transactions-page.component.ts
  5. 5
      apps/client/src/app/services/ics/ics.service.ts
  6. 23
      libs/ui/src/lib/activities-table/activities-table.component.html
  7. 4
      libs/ui/src/lib/activities-table/activities-table.component.ts

8
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/), 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). 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 ## 1.137.0 - 15.04.2022
### Added ### Added
- Added support to export future activities (drafts) as `.ics` files - Added support to export future activities (drafts) as an `.ics` file
### Changed ### Changed

9
apps/client/src/app/components/accounts-table/accounts-table.component.html

@ -194,16 +194,17 @@
<ion-icon name="ellipsis-vertical"></ion-icon> <ion-icon name="ellipsis-vertical"></ion-icon>
</button> </button>
<mat-menu #accountMenu="matMenu" xPosition="before"> <mat-menu #accountMenu="matMenu" xPosition="before">
<button i18n mat-menu-item (click)="onUpdateAccount(element)"> <button mat-menu-item (click)="onUpdateAccount(element)">
Edit <ion-icon class="mr-2" name="create-outline"></ion-icon>
<span i18n>Edit</span>
</button> </button>
<button <button
i18n
mat-menu-item mat-menu-item
[disabled]="element.isDefault || element.Order?.length > 0" [disabled]="element.isDefault || element.Order?.length > 0"
(click)="onDeleteAccount(element.id)" (click)="onDeleteAccount(element.id)"
> >
Delete <ion-icon class="mr-2" name="trash-outline"></ion-icon>
<span i18n>Delete</span>
</button> </button>
</mat-menu> </mat-menu>
</td> </td>

4
apps/client/src/app/components/admin-users/admin-users.html

@ -68,12 +68,12 @@
</button> </button>
<mat-menu #accountMenu="matMenu" xPosition="before"> <mat-menu #accountMenu="matMenu" xPosition="before">
<button <button
i18n
mat-menu-item mat-menu-item
[disabled]="userItem.id === user?.id" [disabled]="userItem.id === user?.id"
(click)="onDeleteUser(userItem.id)" (click)="onDeleteUser(userItem.id)"
> >
Delete <ion-icon class="mr-2" name="trash-outline"></ion-icon>
<span i18n>Delete</span>
</button> </button>
</mat-menu> </mat-menu>
</td> </td>

8
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( content: this.icsService.transformActivitiesToIcsContent(
data.activities data.activities
), ),
fileName: `ghostfolio-drafts-${format( contentType: 'text/calendar',
parseISO(data.meta.date), fileName: `ghostfolio-draft${
'yyyyMMddHHmm' data.activities.length > 1 ? 's' : ''
)}.ics`, }-${format(parseISO(data.meta.date), 'yyyyMMddHHmm')}.ics`,
format: 'string' format: 'string'
}); });
}); });

5
apps/client/src/app/services/ics/ics.service.ts

@ -9,6 +9,7 @@ import { format, parseISO } from 'date-fns';
}) })
export class IcsService { export class IcsService {
private readonly ICS_DATE_FORMAT = 'yyyyMMdd'; private readonly ICS_DATE_FORMAT = 'yyyyMMdd';
private readonly ICS_LINE_BREAK = '\r\n';
public constructor() {} public constructor() {}
@ -30,7 +31,7 @@ export class IcsService {
}); });
const footer = ['END:VCALENDAR']; const footer = ['END:VCALENDAR'];
return [...header, ...events, ...footer].join('\n'); return [...header, ...events, ...footer].join(this.ICS_LINE_BREAK);
} }
private getEvent({ private getEvent({
@ -54,6 +55,6 @@ export class IcsService {
`DTEND;VALUE=DATE:${format(date, this.ICS_DATE_FORMAT)}`, `DTEND;VALUE=DATE:${format(date, this.ICS_DATE_FORMAT)}`,
`SUMMARY:${capitalize(type)} ${symbol}`, `SUMMARY:${capitalize(type)} ${symbol}`,
'END:VEVENT' 'END:VEVENT'
].join('\n'); ].join(this.ICS_LINE_BREAK);
} }
} }

23
libs/ui/src/lib/activities-table/activities-table.component.html

@ -387,14 +387,25 @@
<ion-icon name="ellipsis-vertical"></ion-icon> <ion-icon name="ellipsis-vertical"></ion-icon>
</button> </button>
<mat-menu #activityMenu="matMenu" xPosition="before"> <mat-menu #activityMenu="matMenu" xPosition="before">
<button i18n mat-menu-item (click)="onUpdateActivity(element)"> <button mat-menu-item (click)="onUpdateActivity(element)">
Edit <ion-icon class="mr-2" name="create-outline"></ion-icon>
<span i18n>Edit</span>
</button> </button>
<button i18n mat-menu-item (click)="onCloneActivity(element)"> <button mat-menu-item (click)="onCloneActivity(element)">
Clone <ion-icon class="mr-2" name="copy-outline"></ion-icon>
<span i18n>Clone</span>
</button> </button>
<button i18n mat-menu-item (click)="onDeleteActivity(element.id)"> <button
Delete mat-menu-item
[disabled]="!element.isDraft"
(click)="onExportDraft(element.id)"
>
<ion-icon class="mr-2" name="calendar-clear-outline"></ion-icon>
<span i18n>Export Draft as ICS</span>
</button>
<button mat-menu-item (click)="onDeleteActivity(element.id)">
<ion-icon class="mr-2" name="trash-outline"></ion-icon>
<span i18n>Delete</span>
</button> </button>
</mat-menu> </mat-menu>
</td> </td>

4
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() { public onExportDrafts() {
this.exportDrafts.emit( this.exportDrafts.emit(
this.dataSource.filteredData this.dataSource.filteredData

Loading…
Cancel
Save