From 03c566919cb59203b300d40ec40608b55e426f93 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 14:06:13 +0100 Subject: [PATCH] add gms switch and name type --- .../src/graphql/arg/UpdateUserInfosArgs.ts | 12 +- backend/src/graphql/model/User.ts | 8 + backend/src/graphql/resolver/UserResolver.ts | 23 +-- .../UserSettings/UserGMSNamingFormat.vue | 84 ++++++++ .../components/UserSettings/UserGMSSwitch.vue | 45 ++++ frontend/src/graphql/mutations.js | 4 +- frontend/src/locales/de.json | 16 ++ frontend/src/locales/en.json | 16 ++ frontend/src/pages/Settings.vue | 192 +++++++++++------- frontend/src/store/store.js | 12 ++ 10 files changed, 317 insertions(+), 95 deletions(-) create mode 100644 frontend/src/components/UserSettings/UserGMSNamingFormat.vue create mode 100644 frontend/src/components/UserSettings/UserGMSSwitch.vue diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index 0920fb3bc..22b548f91 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -1,6 +1,7 @@ -import { IsBoolean, IsInt, IsString } from 'class-validator' +import { IsBoolean, IsEnum, IsInt, IsString } from 'class-validator' import { ArgsType, Field, InputType, Int } from 'type-graphql' +import { GmsPublishNameType } from '@enum/GmsPublishNameType' import { Location } from '@model/Location' import { isValidLocation } from '@/graphql/validator/Location' @@ -48,9 +49,12 @@ export class UpdateUserInfosArgs { @IsBoolean() gmsAllowed?: boolean - @Field(() => Int, { nullable: true, defaultValue: 0 }) - @IsInt() - gmsPublishName?: number | null + @Field(() => GmsPublishNameType, { + nullable: true, + defaultValue: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS, + }) + @IsEnum(GmsPublishNameType) + gmsPublishName?: GmsPublishNameType | null @Field(() => Location, { nullable: true }) @isValidLocation() diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index d24a717c4..0d3cfccc7 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -29,6 +29,8 @@ export class User { this.hasElopage = null this.hideAmountGDD = user.hideAmountGDD this.hideAmountGDT = user.hideAmountGDT + this.gmsAllowed = user.gmsAllowed + this.gmsPublishName = user.gmsPublishName } } @@ -74,6 +76,12 @@ export class User { @Field(() => Boolean) hideAmountGDT: boolean + @Field(() => Boolean) + gmsAllowed: boolean + + @Field(() => Int, { nullable: true }) + gmsPublishName: number | null + // This is not the users publisherId, but the one of the users who recommend him @Field(() => Int, { nullable: true }) publisherId: number | null diff --git a/backend/src/graphql/resolver/UserResolver.ts b/backend/src/graphql/resolver/UserResolver.ts index 3f70ce112..8f6b36652 100644 --- a/backend/src/graphql/resolver/UserResolver.ts +++ b/backend/src/graphql/resolver/UserResolver.ts @@ -561,17 +561,6 @@ export class UserResolver { logger.info( `updateUserInfos(${firstName}, ${lastName}, ${alias}, ${language}, ***, ***, ${hideAmountGDD}, ${hideAmountGDT}, ${gmsAllowed}, ${gmsPublishName}, ${gmsLocation}, ${gmsPublishLocation})...`, ) - // check default arg settings - if (gmsAllowed === null || gmsAllowed === undefined) { - gmsAllowed = true - } - if (!gmsPublishName) { - gmsPublishName = GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS - } - if (!gmsPublishLocation) { - gmsPublishLocation = GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM - } - const user = getUser(context) // try { if (firstName) { @@ -620,12 +609,18 @@ export class UserResolver { user.hideAmountGDT = hideAmountGDT } - user.gmsAllowed = gmsAllowed - user.gmsPublishName = gmsPublishName + if (gmsAllowed) { + user.gmsAllowed = gmsAllowed + } + if (gmsPublishName) { + user.gmsPublishName = gmsPublishName + } if (gmsLocation) { user.location = Location2Point(gmsLocation) } - user.gmsPublishLocation = gmsPublishLocation + if (gmsPublishLocation) { + user.gmsPublishLocation = gmsPublishLocation + } // } catch (err) { // console.log('error:', err) // } diff --git a/frontend/src/components/UserSettings/UserGMSNamingFormat.vue b/frontend/src/components/UserSettings/UserGMSNamingFormat.vue new file mode 100644 index 000000000..d12dde0ce --- /dev/null +++ b/frontend/src/components/UserSettings/UserGMSNamingFormat.vue @@ -0,0 +1,84 @@ + + + diff --git a/frontend/src/components/UserSettings/UserGMSSwitch.vue b/frontend/src/components/UserSettings/UserGMSSwitch.vue new file mode 100644 index 000000000..6958f4e57 --- /dev/null +++ b/frontend/src/components/UserSettings/UserGMSSwitch.vue @@ -0,0 +1,45 @@ + + diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index cade098da..184a712ab 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -35,7 +35,7 @@ export const updateUserInfos = gql` $hideAmountGDD: Boolean $hideAmountGDT: Boolean $gmsAllowed: Boolean - $gmsPublishName: Int + $gmsPublishName: GmsPublishNameType $gmsLocation: Location $gmsPublishLocation: Int ) { @@ -172,6 +172,8 @@ export const login = gql` klickTipp { newsletterState } + gmsAllowed + gmsPublishName hasElopage publisherId roles diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 337722940..f1ba3b2f7 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -5,8 +5,10 @@ "1000thanks": "1000 Dank, weil du bei uns bist!", "125": "125%", "85": "85%", + "ExternServices": "Verknüpfte Dienste", "GDD": "GDD", "GDT": "GDT", + "GMS": "Gradido Karte", "PersonalDetails": "Persönliche Angaben", "advanced-calculation": "Vorausberechnung", "asterisks": "****", @@ -290,6 +292,20 @@ }, "settings": { "emailInfo": "Kann aktuell noch nicht geändert werden.", + "GMS": { + "disabled": "Daten werden nicht nach GMS exportiert", + "enabled": "Daten werden nach GMS exportiert", + "naming-format": "Namensformat im GMS", + "publish-name": { + "alias-or-initials": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", + "first": "nur Vornamen", + "first-initial": "Vorname plus Anfangsbuchstabe des Nachnamens", + "initials": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens", + "name-full": "vollständiger Name: Vorname plus Nachname", + "updated": "Namensformat für GMS aktualisiert" + }, + "switch": "Erlaubnis Daten nach GMS zu exportieren." + }, "hideAmountGDD": "Dein GDD Betrag ist versteckt.", "hideAmountGDT": "Dein GDT Betrag ist versteckt.", "info": "Transaktionen können nun per Benutzername oder E-Mail-Adresse getätigt werden.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 982d22159..4756c00bf 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -5,8 +5,10 @@ "1000thanks": "1000 thanks for being with us!", "125": "125%", "85": "85%", + "ExternServices": "Extern Services", "GDD": "GDD", "GDT": "GDT", + "GMS": "Gradido Map", "PersonalDetails": "Personal details", "advanced-calculation": "Advanced calculation", "asterisks": "****", @@ -290,6 +292,20 @@ }, "settings": { "emailInfo": "Cannot be changed at this time.", + "GMS": { + "disabled": "Data not exported to GMS", + "enabled": "Data exported to GMS", + "naming-format": "Format of name in GMS", + "publish-name": { + "alias-or-initials": "username if exists or Initials of firstname and lastname", + "first": "firstname only", + "first-initial": "firstname plus initial of lastname", + "initials": "Initials of firstname and lastname independent if username exists", + "name-full": "fullname: firstname plus lastname", + "updated": "format of name for GMS updated" + }, + "switch": "Allow data export to GMS" + }, "hideAmountGDD": "Your GDD amount is hidden.", "hideAmountGDT": "Your GDT amount is hidden.", "info": "Transactions can now be made by username or email address.", diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index 1530e5e97..38a3317bf 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -1,81 +1,113 @@