From 0e29278e965ea341fd0b5219233b3f7be55f6418 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Sat, 27 Aug 2022 11:29:09 +0200 Subject: [PATCH] Feature/add alias to access (#1193) * Add alias to access * Update changelog --- CHANGELOG.md | 1 + apps/api/src/app/access/access.controller.ts | 10 ++- apps/api/src/app/access/create-access.dto.ts | 12 +++- .../src/app/portfolio/portfolio.controller.ts | 1 + apps/api/src/app/user/user.service.ts | 2 +- .../access-table/access-table.component.html | 11 +++- .../access-table/access-table.component.ts | 2 +- .../pages/account/account-page.component.ts | 3 +- .../create-or-update-access-dialog.html | 11 ++++ .../create-or-update-access-dialog.module.ts | 2 + .../src/app/pages/public/public-page.html | 3 +- apps/client/src/locales/messages.de.xlf | 64 +++++++++++-------- apps/client/src/locales/messages.xlf | 61 ++++++++++-------- .../src/lib/interfaces/access.interface.ts | 3 +- .../portfolio-public-details.interface.ts | 1 + .../migration.sql | 2 + prisma/schema.prisma | 1 + 17 files changed, 129 insertions(+), 61 deletions(-) create mode 100644 prisma/migrations/20220827074920_added_alias_to_access/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 74fe7db59..183ead51b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added the alias to the `Access` database schema - Added support for translated time distances ### Changed diff --git a/apps/api/src/app/access/access.controller.ts b/apps/api/src/app/access/access.controller.ts index a778d8b57..dd40a19f4 100644 --- a/apps/api/src/app/access/access.controller.ts +++ b/apps/api/src/app/access/access.controller.ts @@ -42,14 +42,16 @@ export class AccessController { return accessesWithGranteeUser.map((access) => { if (access.GranteeUser) { return { - granteeAlias: access.GranteeUser?.alias, + alias: access.alias, + grantee: access.GranteeUser?.id, id: access.id, type: 'RESTRICTED_VIEW' }; } return { - granteeAlias: 'Public', + alias: access.alias, + grantee: 'Public', id: access.id, type: 'PUBLIC' }; @@ -71,6 +73,10 @@ export class AccessController { } return this.accessService.createAccess({ + alias: data.alias || undefined, + GranteeUser: data.granteeUserId + ? { connect: { id: data.granteeUserId } } + : undefined, User: { connect: { id: this.request.user.id } } }); } diff --git a/apps/api/src/app/access/create-access.dto.ts b/apps/api/src/app/access/create-access.dto.ts index 672e195c2..055cb6610 100644 --- a/apps/api/src/app/access/create-access.dto.ts +++ b/apps/api/src/app/access/create-access.dto.ts @@ -1 +1,11 @@ -export class CreateAccessDto {} +import { IsOptional, IsString } from 'class-validator'; + +export class CreateAccessDto { + @IsOptional() + @IsString() + alias?: string; + + @IsOptional() + @IsString() + granteeUserId?: string; +} diff --git a/apps/api/src/app/portfolio/portfolio.controller.ts b/apps/api/src/app/portfolio/portfolio.controller.ts index 00919b835..5172b8071 100644 --- a/apps/api/src/app/portfolio/portfolio.controller.ts +++ b/apps/api/src/app/portfolio/portfolio.controller.ts @@ -349,6 +349,7 @@ export class PortfolioController { const portfolioPublicDetails: PortfolioPublicDetails = { hasDetails, + alias: access.alias, holdings: {} }; diff --git a/apps/api/src/app/user/user.service.ts b/apps/api/src/app/user/user.service.ts index 213351ede..57e3ba80d 100644 --- a/apps/api/src/app/user/user.service.ts +++ b/apps/api/src/app/user/user.service.ts @@ -62,7 +62,7 @@ export class UserService { tags, access: access.map((accessItem) => { return { - alias: accessItem.User.alias, + alias: accessItem.alias, id: accessItem.id }; }), diff --git a/apps/client/src/app/components/access-table/access-table.component.html b/apps/client/src/app/components/access-table/access-table.component.html index 93c9356c3..5b54156ce 100644 --- a/apps/client/src/app/components/access-table/access-table.component.html +++ b/apps/client/src/app/components/access-table/access-table.component.html @@ -1,8 +1,15 @@
Alias | ++ {{ element.alias }} + | +Grantee | - {{ element.granteeAlias }} + {{ element.grantee }} |
---|