From a8464d7536eb7c95a9b141aefb4acd6ed934d7d9 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 18 May 2021 11:06:02 +0200 Subject: [PATCH] fix: Transmit confidant_email on edit --- src/api.ts | 7 +++--- src/components/UserTable.vue | 8 +++++-- src/mixins.ts | 19 +++++++++++++++ src/views/MainPage.vue | 24 +++++++++++++------ userausfall/migrations/0004_user_confidant.py | 20 ++++++++++++++++ userausfall/models.py | 4 ++++ userausfall/rest_api/serializers.py | 21 ++++++++++++++-- 7 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 src/mixins.ts create mode 100644 userausfall/migrations/0004_user_confidant.py diff --git a/src/api.ts b/src/api.ts index d8a33ce..5c8f047 100644 --- a/src/api.ts +++ b/src/api.ts @@ -2,7 +2,7 @@ import Cookies from "js-cookie"; type HTTPMethod = "GET" | "POST" | "PUT" | "PATCH"; -class APIError extends Error { +export class APIError extends Error { constructor(message: string, public readonly errors: unknown) { super(message); } @@ -42,8 +42,8 @@ async function request( export class User { email: string | undefined; password: string | undefined; - private username: string | null = null; - private confidantEmail: string | null = null; + username: string | null = null; + confidantEmail: string | null = null; isAuthenticated = false; private token = ""; @@ -67,6 +67,7 @@ export class User { 200, { username: this.username, + confidant_email: this.confidantEmail, }, this.token ); diff --git a/src/components/UserTable.vue b/src/components/UserTable.vue index 696c59a..51e9491 100644 --- a/src/components/UserTable.vue +++ b/src/components/UserTable.vue @@ -24,11 +24,15 @@ Benutzername - + + + Vertrauensperson - + + + E-Mail-Adresse diff --git a/src/mixins.ts b/src/mixins.ts new file mode 100644 index 0000000..56575a2 --- /dev/null +++ b/src/mixins.ts @@ -0,0 +1,19 @@ +import Component from "vue-class-component"; +import Vue from "vue"; + +@Component +export class NotifyMixin extends Vue { + showError(): void { + this.$buefy.toast.open({ + message: "Es ist leider ein Fehler aufgetreten.", + type: "is-danger", + }); + } + + showSuccess(message: string): void { + this.$buefy.toast.open({ + message, + type: "is-success", + }); + } +} diff --git a/src/views/MainPage.vue b/src/views/MainPage.vue index 311ded9..7bd39ea 100644 --- a/src/views/MainPage.vue +++ b/src/views/MainPage.vue @@ -15,24 +15,34 @@