From c70e6227bae8fecbdbe430b886bd72ae58cf1762 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Wed, 10 Apr 2019 13:35:24 +0200 Subject: [PATCH 01/31] first implementation - unclear if specifications are correct --- backend/src/middleware/userMiddleware.js | 3 +- webapp/locales/de.json | 6 +- webapp/locales/en.json | 6 +- webapp/locales/it.json | 4 +- webapp/locales/pl.json | 4 +- webapp/locales/pt.json | 4 +- webapp/pages/profile/_id/_slug.vue | 199 ++++++----------------- webapp/pages/settings/index.vue | 2 +- 8 files changed, 67 insertions(+), 161 deletions(-) diff --git a/backend/src/middleware/userMiddleware.js b/backend/src/middleware/userMiddleware.js index 2979fdadf..b3fc1bf2c 100644 --- a/backend/src/middleware/userMiddleware.js +++ b/backend/src/middleware/userMiddleware.js @@ -1,6 +1,7 @@ -import createOrUpdateLocations from './nodes/locations' import dotenv from 'dotenv' +import createOrUpdateLocations from './nodes/locations' + dotenv.config() export default { diff --git a/webapp/locales/de.json b/webapp/locales/de.json index 6e47d7122..801b01e27 100644 --- a/webapp/locales/de.json +++ b/webapp/locales/de.json @@ -15,7 +15,8 @@ "followers": "Folgen", "following": "Folgt", "shouted": "Empfohlen", - "commented": "Kommentiert" + "commented": "Kommentiert", + "userAnonym": "Anonymus" }, "search": { "placeholder": "Suchen", @@ -27,6 +28,7 @@ "data": { "name": "Deine Daten", "labelName": "Dein Name", + "namePlaceholder": "Anonymus", "labelCity": "Deine Stadt oder Region", "labelBio": "Über dich" }, @@ -202,4 +204,4 @@ "shoutButton": { "shouted": "empfohlen" } -} +} \ No newline at end of file diff --git a/webapp/locales/en.json b/webapp/locales/en.json index 62c8f3e19..1e46664f1 100644 --- a/webapp/locales/en.json +++ b/webapp/locales/en.json @@ -15,7 +15,8 @@ "followers": "Followers", "following": "Following", "shouted": "Shouted", - "commented": "Commented" + "commented": "Commented", + "userAnonym": "Anonymous" }, "search": { "placeholder": "Search", @@ -27,6 +28,7 @@ "data": { "name": "Your data", "labelName": "Your Name", + "namePlaceholder": "Anonymous", "labelCity": "Your City or Region", "labelBio": "About You" }, @@ -202,4 +204,4 @@ "shoutButton": { "shouted": "shouted" } -} +} \ No newline at end of file diff --git a/webapp/locales/it.json b/webapp/locales/it.json index 0225babad..25005a07a 100644 --- a/webapp/locales/it.json +++ b/webapp/locales/it.json @@ -15,13 +15,15 @@ "followers": "Seguenti", "following": "Seguendo", "shouted": "Gridato", - "commented": "Commentato" + "commented": "Commentato", + "userAnonym": "Anonymous" }, "settings": { "name": "Impostazioni", "data": { "name": "I tuoi dati", "labelName": "Nome", + "namePlaceholder": "Anonymous", "labelCity": "La tua città o regione", "labelBio": "Su di te" }, diff --git a/webapp/locales/pl.json b/webapp/locales/pl.json index 0f2147996..506a04f1b 100644 --- a/webapp/locales/pl.json +++ b/webapp/locales/pl.json @@ -15,13 +15,15 @@ "followers": "Obserwujący", "following": "Obserwowani", "shouted": "Krzyknij", - "commented": "Skomentuj" + "commented": "Skomentuj", + "userAnonym": "Anonymous" }, "settings": { "name": "Ustawienia", "data": { "name": "Twoje dane", "labelName": "Twoje dane", + "namePlaceholder": "Anonymous", "labelCity": "Twoje miasto lub region", "labelBio": "O Tobie" }, diff --git a/webapp/locales/pt.json b/webapp/locales/pt.json index 4151f49c7..0636ba6f9 100644 --- a/webapp/locales/pt.json +++ b/webapp/locales/pt.json @@ -15,13 +15,15 @@ "followers": "Seguidores", "following": "Seguindo", "shouted": "Aclamou", - "commented": "Comentou" + "commented": "Comentou", + "userAnonym": "Anonymous" }, "settings": { "name": "Configurações", "data": { "name": "Seus dados", "labelName": "Seu nome", + "namePlaceholder": "Anonymous", "labelCity": "Sua cidade ou estado", "labelBio": "Sobre você" }, diff --git a/webapp/pages/profile/_id/_slug.vue b/webapp/pages/profile/_id/_slug.vue index a3b10529e..f4367d0be 100644 --- a/webapp/pages/profile/_id/_slug.vue +++ b/webapp/pages/profile/_id/_slug.vue @@ -3,23 +3,14 @@

PROFILE IMAGE

- - + + - + - - {{ user.name }} - - - {{ user.location.name }} + {{ userName() }} + + + {{ user.location.name }} - {{ $t('profile.memberSince') }} {{ user.createdAt | date('MMMM yyyy') }} - + >{{ $t('profile.memberSince') }} {{ user.createdAt | date('MMMM yyyy') }} - - + + - + - + - + - - - Netzwerk - + + Netzwerk - - - Wem folgt {{ user.name | truncate(15) }}? - + + Wem folgt {{ userName(15) }}? - + - - - Wer folgt {{ user.name | truncate(15) }}? - + + Wer folgt {{ userName(15) }}? - + @@ -219,10 +124,7 @@ - + @@ -232,10 +134,7 @@ - + @@ -245,10 +144,7 @@ - + @@ -273,25 +169,16 @@ :key="post.id" :width="{ base: '100%', md: '100%', xl: '50%' }" > - + - + @@ -395,6 +282,14 @@ export default { }, fetchPolicy: 'cache-and-network' }) + }, + userName(maxLength) { + // Return Anonymous if no Username is given + if (!this.user.name) { + return this.$t('profile.userAnonym') + } + // Return full Username or truncated Username + return maxLength ? this.user.name.substring(0, maxLength) : this.user.name } }, apollo: { diff --git a/webapp/pages/settings/index.vue b/webapp/pages/settings/index.vue index 5ff7c171e..3acaf9c4c 100644 --- a/webapp/pages/settings/index.vue +++ b/webapp/pages/settings/index.vue @@ -9,7 +9,7 @@ model="name" icon="user" :label="$t('settings.data.labelName')" - :placeholder="$t('settings.data.labelName')" + :placeholder="$t('settings.data.namePlaceholder')" /> Date: Wed, 17 Apr 2019 14:49:03 +0200 Subject: [PATCH 02/31] match specification of Dennis - minimum 3 characters for username, no hint for user to change the username to "Anonymous", Toast error if userdata cannot be changed due to username restrictions, display "Anonymous" if no username is found in database (even tho this is against implemented rules) --- backend/src/middleware/userMiddleware.js | 5 ++ webapp/components/User/index.vue | 87 ++++++++---------------- webapp/locales/de.json | 5 +- webapp/locales/en.json | 5 +- webapp/pages/settings/index.vue | 44 +++++------- 5 files changed, 58 insertions(+), 88 deletions(-) diff --git a/backend/src/middleware/userMiddleware.js b/backend/src/middleware/userMiddleware.js index b3fc1bf2c..4789b4cbd 100644 --- a/backend/src/middleware/userMiddleware.js +++ b/backend/src/middleware/userMiddleware.js @@ -1,4 +1,5 @@ import dotenv from 'dotenv' +import { UserInputError } from 'apollo-server' import createOrUpdateLocations from './nodes/locations' @@ -12,6 +13,10 @@ export default { return result }, UpdateUser: async (resolve, root, args, context, info) => { + const USERNAME_MIN_LENGTH = 3 // TODO move to the correct place + if (!args.name || args.name.length < USERNAME_MIN_LENGTH) { + throw new UserInputError(`Username must be at least ${USERNAME_MIN_LENGTH} characters long!`) + } const result = await resolve(root, args, context, info) await createOrUpdateLocations(args.id, args.locationName, context.driver) return result diff --git a/webapp/components/User/index.vue b/webapp/components/User/index.vue index 6b0731981..2a3904763 100644 --- a/webapp/components/User/index.vue +++ b/webapp/components/User/index.vue @@ -3,65 +3,35 @@
- +
- Anonymus + {{ $t('profile.userAnonym') }}
- -