From e69f3452260a0a66adde0c7abf933722587c4235 Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Mon, 26 Feb 2024 18:49:42 +0100 Subject: [PATCH] add location and location format --- .../src/graphql/arg/UpdateUserInfosArgs.ts | 12 ++- backend/src/graphql/model/User.ts | 11 ++- .../UserSettings/UserGMSLocation.vue | 8 ++ .../UserSettings/UserGMSLocationFormat.vue | 85 +++++++++++++++++++ .../UserSettings/UserGMSNamingFormat.vue | 21 ++++- .../components/UserSettings/UserGMSSwitch.vue | 14 +-- frontend/src/graphql/mutations.js | 3 +- frontend/src/locales/de.json | 26 ++++-- frontend/src/locales/en.json | 23 ++++- frontend/src/pages/Settings.vue | 34 ++++++-- frontend/src/store/store.js | 16 ++-- 11 files changed, 211 insertions(+), 42 deletions(-) create mode 100644 frontend/src/components/UserSettings/UserGMSLocation.vue create mode 100644 frontend/src/components/UserSettings/UserGMSLocationFormat.vue diff --git a/backend/src/graphql/arg/UpdateUserInfosArgs.ts b/backend/src/graphql/arg/UpdateUserInfosArgs.ts index 22b548f91..4eade8f2f 100644 --- a/backend/src/graphql/arg/UpdateUserInfosArgs.ts +++ b/backend/src/graphql/arg/UpdateUserInfosArgs.ts @@ -1,6 +1,7 @@ import { IsBoolean, IsEnum, IsInt, IsString } from 'class-validator' import { ArgsType, Field, InputType, Int } from 'type-graphql' +import { GmsPublishLocationType } from '@enum/GmsPublishLocationType' import { GmsPublishNameType } from '@enum/GmsPublishNameType' import { Location } from '@model/Location' @@ -49,10 +50,7 @@ export class UpdateUserInfosArgs { @IsBoolean() gmsAllowed?: boolean - @Field(() => GmsPublishNameType, { - nullable: true, - defaultValue: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS, - }) + @Field(() => GmsPublishNameType, { nullable: true }) @IsEnum(GmsPublishNameType) gmsPublishName?: GmsPublishNameType | null @@ -60,7 +58,7 @@ export class UpdateUserInfosArgs { @isValidLocation() gmsLocation?: Location | null - @Field(() => Int, { nullable: true, defaultValue: 2 }) - @IsInt() - gmsPublishLocation?: number | null + @Field(() => GmsPublishLocationType, { nullable: true }) + @IsEnum(GmsPublishLocationType) + gmsPublishLocation?: GmsPublishLocationType | null } diff --git a/backend/src/graphql/model/User.ts b/backend/src/graphql/model/User.ts index 0d3cfccc7..166367fd1 100644 --- a/backend/src/graphql/model/User.ts +++ b/backend/src/graphql/model/User.ts @@ -1,6 +1,9 @@ import { User as dbUser } from '@entity/User' import { ObjectType, Field, Int } from 'type-graphql' +import { GmsPublishLocationType } from '@enum/GmsPublishLocationType' +import { GmsPublishNameType } from '@enum/GmsPublishNameType' + import { KlickTipp } from './KlickTipp' @ObjectType() @@ -31,6 +34,7 @@ export class User { this.hideAmountGDT = user.hideAmountGDT this.gmsAllowed = user.gmsAllowed this.gmsPublishName = user.gmsPublishName + this.gmsPublishLocation = user.gmsPublishLocation } } @@ -79,8 +83,11 @@ export class User { @Field(() => Boolean) gmsAllowed: boolean - @Field(() => Int, { nullable: true }) - gmsPublishName: number | null + @Field(() => GmsPublishNameType, { nullable: true }) + gmsPublishName: GmsPublishNameType | null + + @Field(() => GmsPublishLocationType, { nullable: true }) + gmsPublishLocation: GmsPublishLocationType | null // This is not the users publisherId, but the one of the users who recommend him @Field(() => Int, { nullable: true }) diff --git a/frontend/src/components/UserSettings/UserGMSLocation.vue b/frontend/src/components/UserSettings/UserGMSLocation.vue new file mode 100644 index 000000000..0d7fe9ab7 --- /dev/null +++ b/frontend/src/components/UserSettings/UserGMSLocation.vue @@ -0,0 +1,8 @@ + + diff --git a/frontend/src/components/UserSettings/UserGMSLocationFormat.vue b/frontend/src/components/UserSettings/UserGMSLocationFormat.vue new file mode 100644 index 000000000..169a69cae --- /dev/null +++ b/frontend/src/components/UserSettings/UserGMSLocationFormat.vue @@ -0,0 +1,85 @@ + + + diff --git a/frontend/src/components/UserSettings/UserGMSNamingFormat.vue b/frontend/src/components/UserSettings/UserGMSNamingFormat.vue index d12dde0ce..0ef008b43 100644 --- a/frontend/src/components/UserSettings/UserGMSNamingFormat.vue +++ b/frontend/src/components/UserSettings/UserGMSNamingFormat.vue @@ -7,6 +7,7 @@ @click.prevent="update(option)" :key="option.value" :value="option.value" + :title="option.title" > {{ option.label }} @@ -24,29 +25,43 @@ export default { dropdownOptions: [ { label: this.$t('settings.GMS.publish-name.alias-or-initials'), + title: this.$t('settings.GMS.publish-name.alias-or-initials-tooltip'), value: 'GMS_PUBLISH_NAME_ALIAS_OR_INITALS', }, { label: this.$t('settings.GMS.publish-name.initials'), + title: this.$t('settings.GMS.publish-name.initials-tooltip'), value: 'GMS_PUBLISH_NAME_INITIALS', }, - { label: this.$t('settings.GMS.publish-name.first'), value: 'GMS_PUBLISH_NAME_FIRST' }, + { + label: this.$t('settings.GMS.publish-name.first'), + title: this.$t('settings.GMS.publish-name.first-tooltip'), + value: 'GMS_PUBLISH_NAME_FIRST', + }, { label: this.$t('settings.GMS.publish-name.first-initial'), + title: this.$t('settings.GMS.publish-name.first-initial-tooltip'), value: 'GMS_PUBLISH_NAME_FIRST_INITIAL', }, - { label: this.$t('settings.GMS.publish-name.name-full'), value: 'GMS_PUBLISH_NAME_FULL' }, + { + label: this.$t('settings.GMS.publish-name.name-full'), + title: this.$t('settings.GMS.publish-name.name-full-tooltip'), + value: 'GMS_PUBLISH_NAME_FULL', + }, ], } }, computed: { selectedOptionLabel() { const selected = this.dropdownOptions.find((option) => option.value === this.selectedOption) - return selected ? selected.label : 'Select Option' + return selected ? selected.label : this.selectedOption }, }, methods: { async update(option) { + if (option === this.selectedOption) { + return + } try { await this.$apollo.mutate({ mutation: updateUserInfos, diff --git a/frontend/src/components/UserSettings/UserGMSSwitch.vue b/frontend/src/components/UserSettings/UserGMSSwitch.vue index 6958f4e57..cc9a344a5 100644 --- a/frontend/src/components/UserSettings/UserGMSSwitch.vue +++ b/frontend/src/components/UserSettings/UserGMSSwitch.vue @@ -2,7 +2,7 @@
{ - this.$store.commit('gmsState', this.gmsState) - this.$emit('gmsStateSwitch', this.gmsState) + this.$store.commit('gmsState', this.gmsAllowed) + this.$emit('gmsStateSwitch', this.gmsAllowed) this.toastSuccess( - this.gmsState ? this.$t('settings.GMS.enabled') : this.$t('settings.GMS.disabled'), + this.gmsAllowed ? this.$t('settings.GMS.enabled') : this.$t('settings.GMS.disabled'), ) }) .catch((error) => { - this.gmsState = this.$store.state.gmsState + this.gmsAllowed = this.$store.state.gmsAllowed this.toastError(error.message) }) }, diff --git a/frontend/src/graphql/mutations.js b/frontend/src/graphql/mutations.js index 184a712ab..8d28bbff6 100644 --- a/frontend/src/graphql/mutations.js +++ b/frontend/src/graphql/mutations.js @@ -37,7 +37,7 @@ export const updateUserInfos = gql` $gmsAllowed: Boolean $gmsPublishName: GmsPublishNameType $gmsLocation: Location - $gmsPublishLocation: Int + $gmsPublishLocation: GmsPublishLocationType ) { updateUserInfos( firstName: $firstName @@ -174,6 +174,7 @@ export const login = gql` } gmsAllowed gmsPublishName + gmsPublishLocation hasElopage publisherId roles diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index f1ba3b2f7..715a9b7e4 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -295,13 +295,29 @@ "GMS": { "disabled": "Daten werden nicht nach GMS exportiert", "enabled": "Daten werden nach GMS exportiert", + "location": { + "label": "Positionsbestimmung", + "button": "Klick mich!" + }, + "location-format": "Positionstyp", "naming-format": "Namensformat im GMS", + "publish-location": { + "exact": "Genaue Position", + "approximate": "Ungefähre Position", + "random": "Zufallsposition", + "updated":"Positionstyp für GMS aktualisiert" + }, "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", + "alias-or-initials": "Benutzername oder Initialen", + "alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname", + "first": "Vorname", + "first-tooltip": "Nur der Vornamen", + "first-initial": "Vorname und Initiale", + "first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens", + "initials": "Initialen", + "initials-tooltip": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens", + "name-full": "Ganzer Name", + "name-full-tooltip": "Vollständiger Name: Vorname plus Nachname", "updated": "Namensformat für GMS aktualisiert" }, "switch": "Erlaubnis Daten nach GMS zu exportieren." diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 4756c00bf..81c37733a 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -295,13 +295,28 @@ "GMS": { "disabled": "Data not exported to GMS", "enabled": "Data exported to GMS", + "location": { + "label": "pinpoint location", + "button": "click me!" + }, + "location-format": "location type", "naming-format": "Format of name in GMS", + "publish-location": { + "exact": "exact position", + "approximate": "approximate position", + "random": "random position" + }, "publish-name": { - "alias-or-initials": "username if exists or Initials of firstname and lastname", - "first": "firstname only", - "first-initial": "firstname plus initial of lastname", + "alias-or-initials": "Username or initials", + "alias-or-initials-tooltip": "username if exists or Initials of firstname and lastname", + "first": "firstname", + "first-tooltip": "the firstname only", + "first-initial": "firstname and initial", + "first-initial-tooltip": "firstname plus initial of lastname", "initials": "Initials of firstname and lastname independent if username exists", - "name-full": "fullname: firstname plus lastname", + "initials-tooltip": "Initials of firstname and lastname independent if username exists", + "name-full": "fullname", + "name-full-tooltip": "fullname: firstname plus lastname", "updated": "format of name for GMS updated" }, "switch": "Allow data export to GMS" diff --git a/frontend/src/pages/Settings.vue b/frontend/src/pages/Settings.vue index 38a3317bf..b1706906b 100644 --- a/frontend/src/pages/Settings.vue +++ b/frontend/src/pages/Settings.vue @@ -86,24 +86,38 @@ {{ $t('settings.GMS.switch') }}
- {{ gmsState ? $t('settings.GMS.enabled') : $t('settings.GMS.disabled') }} + {{ gmsAllowed ? $t('settings.GMS.enabled') : $t('settings.GMS.disabled') }}
-
- +
+ {{ $t('settings.GMS.naming-format') }} - - - + + + + {{ $t('settings.GMS.location-format') }} + + + + + + + + {{ $t('settings.GMS.location.label') }} + + + + +
@@ -119,6 +133,8 @@