mirror of
https://github.com/IT4Change/gradido.git
synced 2026-02-06 01:46:07 +00:00
merge PublishNameType and GMSPublishNameType
This commit is contained in:
parent
3e4190d13a
commit
ac4723ecc5
@ -1,8 +1,8 @@
|
||||
import { User as dbUser } from '@entity/User'
|
||||
|
||||
import { GmsPublishLocationType } from '@/graphql/enum/GmsPublishLocationType'
|
||||
import { GmsPublishNameType } from '@/graphql/enum/GmsPublishNameType'
|
||||
import { GmsPublishPhoneType } from '@/graphql/enum/GmsPublishPhoneType'
|
||||
import { PublishNameType } from '@/graphql/enum/PublishNameType'
|
||||
|
||||
export class GmsUser {
|
||||
constructor(user: dbUser) {
|
||||
@ -44,7 +44,7 @@ export class GmsUser {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
user.alias &&
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS
|
||||
) {
|
||||
return user.alias
|
||||
}
|
||||
@ -53,32 +53,30 @@ export class GmsUser {
|
||||
private getGmsFirstName(user: dbUser): string | undefined {
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
(user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST ||
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL ||
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FULL)
|
||||
(user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST_INITIAL ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_FULL)
|
||||
) {
|
||||
return user.firstName
|
||||
}
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
((!user.alias &&
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS)
|
||||
((!user.alias && user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
) {
|
||||
return user.firstName.substring(0, 1)
|
||||
}
|
||||
}
|
||||
|
||||
private getGmsLastName(user: dbUser): string | undefined {
|
||||
if (user.gmsAllowed && user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FULL) {
|
||||
if (user.gmsAllowed && user.gmsPublishName === PublishNameType.PUBLISH_NAME_FULL) {
|
||||
return user.lastName
|
||||
}
|
||||
if (
|
||||
user.gmsAllowed &&
|
||||
((!user.alias &&
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL ||
|
||||
user.gmsPublishName === GmsPublishNameType.GMS_PUBLISH_NAME_INITIALS)
|
||||
((!user.alias && user.gmsPublishName === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS) ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_FIRST_INITIAL ||
|
||||
user.gmsPublishName === PublishNameType.PUBLISH_NAME_INITIALS)
|
||||
) {
|
||||
return user.lastName.substring(0, 1)
|
||||
}
|
||||
|
||||
@ -21,13 +21,16 @@ export class PublishNameLogic {
|
||||
) {
|
||||
return this.user.firstName
|
||||
}
|
||||
if (
|
||||
[PublishNameType.PUBLISH_NAME_INITIALS, PublishNameType.PUBLISH_NAME_INITIAL_LAST].includes(
|
||||
publishNameType,
|
||||
)
|
||||
) {
|
||||
if (PublishNameType.PUBLISH_NAME_INITIALS === publishNameType) {
|
||||
return this.user.firstName.substring(0, 1)
|
||||
}
|
||||
if (PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType) {
|
||||
if (this.user.alias) {
|
||||
return this.user.alias
|
||||
} else {
|
||||
return this.user.firstName.substring(0, 1)
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
@ -38,22 +41,21 @@ export class PublishNameLogic {
|
||||
* first initial from user.lastName for PUBLISH_NAME_FIRST_INITIAL, PUBLISH_NAME_INITIALS
|
||||
*/
|
||||
public getLastName(publishNameType: PublishNameType): string {
|
||||
if (
|
||||
[
|
||||
PublishNameType.PUBLISH_NAME_LAST,
|
||||
PublishNameType.PUBLISH_NAME_INITIAL_LAST,
|
||||
PublishNameType.PUBLISH_NAME_FULL,
|
||||
].includes(publishNameType)
|
||||
) {
|
||||
if (PublishNameType.PUBLISH_NAME_FULL === publishNameType) {
|
||||
return this.user.lastName
|
||||
}
|
||||
if (
|
||||
} else if (
|
||||
[PublishNameType.PUBLISH_NAME_FIRST_INITIAL, PublishNameType.PUBLISH_NAME_INITIALS].includes(
|
||||
publishNameType,
|
||||
)
|
||||
) {
|
||||
return this.user.lastName.substring(0, 1)
|
||||
} else if (
|
||||
PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS === publishNameType &&
|
||||
!this.user.alias
|
||||
) {
|
||||
return this.user.lastName.substring(0, 1)
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ 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 { PublishNameType } from '@enum/PublishNameType'
|
||||
import { Location } from '@model/Location'
|
||||
|
||||
@ -55,9 +54,9 @@ export class UpdateUserInfosArgs {
|
||||
@IsBoolean()
|
||||
gmsAllowed?: boolean
|
||||
|
||||
@Field(() => GmsPublishNameType, { nullable: true })
|
||||
@IsEnum(GmsPublishNameType)
|
||||
gmsPublishName?: GmsPublishNameType | null
|
||||
@Field(() => PublishNameType, { nullable: true })
|
||||
@IsEnum(PublishNameType)
|
||||
gmsPublishName?: PublishNameType | null
|
||||
|
||||
@Field(() => PublishNameType, { nullable: true })
|
||||
@IsEnum(PublishNameType)
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
import { registerEnumType } from 'type-graphql'
|
||||
|
||||
export enum GmsPublishNameType {
|
||||
GMS_PUBLISH_NAME_ALIAS_OR_INITALS = 0,
|
||||
GMS_PUBLISH_NAME_INITIALS = 1,
|
||||
GMS_PUBLISH_NAME_FIRST = 2,
|
||||
GMS_PUBLISH_NAME_FIRST_INITIAL = 3,
|
||||
GMS_PUBLISH_NAME_FULL = 4,
|
||||
}
|
||||
|
||||
registerEnumType(GmsPublishNameType, {
|
||||
name: 'GmsPublishNameType', // this one is mandatory
|
||||
description: 'Type of name publishing', // this one is optional
|
||||
})
|
||||
@ -1,19 +1,14 @@
|
||||
import { registerEnumType } from 'type-graphql'
|
||||
|
||||
/**
|
||||
* Enum for decide which parts from first- and last-name are allowed to be published in an extern service
|
||||
*/
|
||||
export enum PublishNameType {
|
||||
PUBLISH_NAME_NONE = 0,
|
||||
PUBLISH_NAME_ALIAS_OR_INITALS = 0,
|
||||
PUBLISH_NAME_INITIALS = 1,
|
||||
PUBLISH_NAME_FIRST = 2,
|
||||
PUBLISH_NAME_FIRST_INITIAL = 3,
|
||||
PUBLISH_NAME_LAST = 4,
|
||||
PUBLISH_NAME_INITIAL_LAST = 5,
|
||||
PUBLISH_NAME_FULL = 6,
|
||||
PUBLISH_NAME_FULL = 4,
|
||||
}
|
||||
|
||||
registerEnumType(PublishNameType, {
|
||||
name: 'PublishNameType', // this one is mandatory
|
||||
description: 'Type of first- and last-name publishing for extern service', // this one is optional
|
||||
description: 'Type of name publishing', // this one is optional
|
||||
})
|
||||
|
||||
@ -2,7 +2,6 @@ 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 { PublishNameType } from '@enum/PublishNameType'
|
||||
|
||||
import { KlickTipp } from './KlickTipp'
|
||||
@ -89,8 +88,8 @@ export class User {
|
||||
@Field(() => Boolean)
|
||||
gmsAllowed: boolean
|
||||
|
||||
@Field(() => GmsPublishNameType, { nullable: true })
|
||||
gmsPublishName: GmsPublishNameType | null
|
||||
@Field(() => PublishNameType, { nullable: true })
|
||||
gmsPublishName: PublishNameType | null
|
||||
|
||||
@Field(() => PublishNameType, { nullable: true })
|
||||
humhubPublishName: PublishNameType | null
|
||||
|
||||
@ -17,7 +17,6 @@ import { GraphQLError } from 'graphql'
|
||||
import { v4 as uuidv4, validate as validateUUID, version as versionUUID } from 'uuid'
|
||||
|
||||
import { GmsPublishLocationType } from '@enum/GmsPublishLocationType'
|
||||
import { GmsPublishNameType } from '@enum/GmsPublishNameType'
|
||||
import { OptInType } from '@enum/OptInType'
|
||||
import { PasswordEncryptionType } from '@enum/PasswordEncryptionType'
|
||||
import { RoleNames } from '@enum/RoleNames'
|
||||
@ -35,6 +34,7 @@ import {
|
||||
sendResetPasswordEmail,
|
||||
} from '@/emails/sendEmailVariants'
|
||||
import { EventType } from '@/event/Events'
|
||||
import { PublishNameType } from '@/graphql/enum/PublishNameType'
|
||||
import { SecretKeyCryptographyCreateKey } from '@/password/EncryptorUtils'
|
||||
import { encryptPassword } from '@/password/PasswordEncryptor'
|
||||
import { writeHomeCommunityEntry } from '@/seeds/community'
|
||||
@ -1232,7 +1232,7 @@ describe('UserResolver', () => {
|
||||
lastName: 'Blümchen',
|
||||
language: 'en',
|
||||
gmsAllowed: true,
|
||||
gmsPublishName: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishName: PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishLocation: GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM,
|
||||
}),
|
||||
])
|
||||
@ -1272,7 +1272,7 @@ describe('UserResolver', () => {
|
||||
expect.objectContaining({
|
||||
alias: 'bibi_Bloxberg',
|
||||
gmsAllowed: true,
|
||||
gmsPublishName: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishName: PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishLocation: GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM,
|
||||
}),
|
||||
])
|
||||
@ -1294,7 +1294,7 @@ describe('UserResolver', () => {
|
||||
await expect(User.find()).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
gmsAllowed: true,
|
||||
gmsPublishName: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishName: PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishLocation: GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM,
|
||||
}),
|
||||
])
|
||||
@ -1307,8 +1307,7 @@ describe('UserResolver', () => {
|
||||
mutation: updateUserInfos,
|
||||
variables: {
|
||||
gmsAllowed: false,
|
||||
gmsPublishName:
|
||||
GmsPublishNameType[GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL],
|
||||
gmsPublishName: PublishNameType[PublishNameType.PUBLISH_NAME_FIRST_INITIAL],
|
||||
gmsPublishLocation:
|
||||
GmsPublishLocationType[GmsPublishLocationType.GMS_LOCATION_TYPE_APPROXIMATE],
|
||||
},
|
||||
@ -1316,7 +1315,7 @@ describe('UserResolver', () => {
|
||||
await expect(User.find()).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
gmsAllowed: false,
|
||||
gmsPublishName: GmsPublishNameType.GMS_PUBLISH_NAME_FIRST_INITIAL,
|
||||
gmsPublishName: PublishNameType.PUBLISH_NAME_FIRST_INITIAL,
|
||||
gmsPublishLocation: GmsPublishLocationType.GMS_LOCATION_TYPE_APPROXIMATE,
|
||||
}),
|
||||
])
|
||||
@ -1332,8 +1331,7 @@ describe('UserResolver', () => {
|
||||
mutation: updateUserInfos,
|
||||
variables: {
|
||||
gmsAllowed: true,
|
||||
gmsPublishName:
|
||||
GmsPublishNameType[GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS],
|
||||
gmsPublishName: PublishNameType[PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS],
|
||||
gmsLocation: loc,
|
||||
gmsPublishLocation:
|
||||
GmsPublishLocationType[GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM],
|
||||
@ -1342,7 +1340,7 @@ describe('UserResolver', () => {
|
||||
await expect(User.find()).resolves.toEqual([
|
||||
expect.objectContaining({
|
||||
gmsAllowed: true,
|
||||
gmsPublishName: GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
gmsPublishName: PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS,
|
||||
location: Location2Point(loc),
|
||||
gmsPublishLocation: GmsPublishLocationType.GMS_LOCATION_TYPE_RANDOM,
|
||||
}),
|
||||
|
||||
@ -2,7 +2,7 @@ import { Point } from '@dbTools/typeorm'
|
||||
import { User as DbUser } from '@entity/User'
|
||||
|
||||
import { UpdateUserInfosArgs } from '@/graphql/arg/UpdateUserInfosArgs'
|
||||
import { GmsPublishNameType } from '@/graphql/enum/GmsPublishNameType'
|
||||
import { PublishNameType } from '@/graphql/enum/PublishNameType'
|
||||
import { LogError } from '@/server/LogError'
|
||||
import { backendLogger as logger } from '@/server/logger'
|
||||
|
||||
@ -22,11 +22,10 @@ export function compareGmsRelevantUserSettings(
|
||||
orgUser.alias !== updateUserInfosArgs.alias &&
|
||||
((updateUserInfosArgs.gmsPublishName &&
|
||||
updateUserInfosArgs.gmsPublishName.valueOf ===
|
||||
GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS.valueOf) ||
|
||||
PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS.valueOf) ||
|
||||
(!updateUserInfosArgs.gmsPublishName &&
|
||||
orgUser.gmsPublishName &&
|
||||
orgUser.gmsPublishName.valueOf ===
|
||||
GmsPublishNameType.GMS_PUBLISH_NAME_ALIAS_OR_INITALS.valueOf))
|
||||
orgUser.gmsPublishName.valueOf === PublishNameType.PUBLISH_NAME_ALIAS_OR_INITALS.valueOf))
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ export const updateUserInfos = gql`
|
||||
$hideAmountGDD: Boolean
|
||||
$hideAmountGDT: Boolean
|
||||
$gmsAllowed: Boolean
|
||||
$gmsPublishName: GmsPublishNameType
|
||||
$gmsPublishName: PublishNameType
|
||||
$gmsLocation: Location
|
||||
$gmsPublishLocation: GmsPublishLocationType
|
||||
) {
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import UserGMSNamingFormat from './UserGMSNamingFormat.vue'
|
||||
import { toastErrorSpy } from '@test/testSetup'
|
||||
|
||||
const mockAPIcall = jest.fn()
|
||||
|
||||
const storeCommitMock = jest.fn()
|
||||
|
||||
const localVue = global.localVue
|
||||
|
||||
describe('UserNamingFormat', () => {
|
||||
let wrapper
|
||||
beforeEach(() => {
|
||||
wrapper = mount(UserGMSNamingFormat, {
|
||||
mocks: {
|
||||
$t: (key) => key, // Mocking the translation function
|
||||
$store: {
|
||||
state: {
|
||||
gmsPublishName: null,
|
||||
},
|
||||
commit: storeCommitMock,
|
||||
},
|
||||
$apollo: {
|
||||
mutate: mockAPIcall,
|
||||
},
|
||||
},
|
||||
localVue,
|
||||
propsData: {
|
||||
selectedOption: 'GMS_PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
initialValue: 'GMS_PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
attrName: 'gmsPublishName',
|
||||
successMessage: 'success message',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
wrapper.destroy()
|
||||
})
|
||||
|
||||
it('renders the correct dropdown options', () => {
|
||||
const dropdownItems = wrapper.findAll('.dropdown-item')
|
||||
expect(dropdownItems.length).toBe(5)
|
||||
|
||||
const labels = dropdownItems.wrappers.map((item) => item.text())
|
||||
expect(labels).toEqual([
|
||||
'settings.GMS.publish-name.alias-or-initials',
|
||||
'settings.GMS.publish-name.initials',
|
||||
'settings.GMS.publish-name.first',
|
||||
'settings.GMS.publish-name.first-initial',
|
||||
'settings.GMS.publish-name.name-full',
|
||||
])
|
||||
})
|
||||
|
||||
it('updates selected option on click', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(3) // Click the fourth item
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().valueChanged).toBeTruthy()
|
||||
expect(wrapper.emitted().valueChanged.length).toBe(1)
|
||||
expect(wrapper.emitted().valueChanged[0]).toEqual(['GMS_PUBLISH_NAME_FIRST_INITIAL'])
|
||||
})
|
||||
|
||||
it('does not update when clicking on already selected option', async () => {
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(0) // Click the first item (which is already selected)
|
||||
await dropdownItem.trigger('click')
|
||||
|
||||
expect(wrapper.emitted().valueChanged).toBeFalsy()
|
||||
})
|
||||
|
||||
describe('update with error', () => {
|
||||
beforeEach(async () => {
|
||||
mockAPIcall.mockRejectedValue({
|
||||
message: 'Ouch',
|
||||
})
|
||||
const dropdownItem = wrapper.findAll('.dropdown-item').at(2) // Click the third item
|
||||
await dropdownItem.trigger('click')
|
||||
})
|
||||
|
||||
it('toasts an error message', () => {
|
||||
expect(toastErrorSpy).toBeCalledWith('Ouch')
|
||||
})
|
||||
})
|
||||
})
|
||||
@ -1,92 +0,0 @@
|
||||
<template>
|
||||
<div class="user-g-m-s-naming-format">
|
||||
<b-dropdown v-model="selectedOption">
|
||||
<template slot="button-content">{{ selectedOptionLabel }}</template>
|
||||
<b-dropdown-item
|
||||
v-for="option in dropdownOptions"
|
||||
@click.prevent="update(option)"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
:title="option.title"
|
||||
>
|
||||
{{ option.label }}
|
||||
</b-dropdown-item>
|
||||
</b-dropdown>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { updateUserInfos } from '@/graphql/mutations'
|
||||
|
||||
export default {
|
||||
name: 'UserGMSNamingFormat',
|
||||
props: {
|
||||
initialValue: { type: String, default: 'GMS_PUBLISH_NAME_ALIAS_OR_INITALS' },
|
||||
attrName: { type: String },
|
||||
successMessage: { type: String },
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
selectedOption: this.initialValue,
|
||||
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'),
|
||||
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'),
|
||||
title: this.$t('settings.GMS.publish-name.name-full-tooltip'),
|
||||
value: 'GMS_PUBLISH_NAME_FULL',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
selectedOptionLabel() {
|
||||
return this.dropdownOptions.find((option) => option.value === this.selectedOption).label
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async update(option) {
|
||||
if (option.value === this.selectedOption) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
const variables = []
|
||||
variables[this.attrName] = option.value
|
||||
await this.$apollo.mutate({
|
||||
mutation: updateUserInfos,
|
||||
variables,
|
||||
})
|
||||
this.toastSuccess(this.successMessage)
|
||||
this.selectedOption = option.value
|
||||
this.$store.commit(this.attrName, option.value)
|
||||
this.$emit('valueChanged', option.value)
|
||||
} catch (error) {
|
||||
this.toastError(error.message)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.user-g-m-s-naming-format > .dropdown,
|
||||
.user-g-m-s-naming-format > .dropdown > .dropdown-toggle > ul.dropdown-menu {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
@ -26,9 +26,9 @@ describe('UserNamingFormat', () => {
|
||||
},
|
||||
localVue,
|
||||
propsData: {
|
||||
selectedOption: 'PUBLISH_NAME_NONE',
|
||||
initialValue: 'PUBLISH_NAME_NONE',
|
||||
attrName: 'publishName',
|
||||
selectedOption: 'PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
initialValue: 'PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
attrName: 'gmsPublishName',
|
||||
successMessage: 'success message',
|
||||
},
|
||||
})
|
||||
@ -40,17 +40,15 @@ describe('UserNamingFormat', () => {
|
||||
|
||||
it('renders the correct dropdown options', () => {
|
||||
const dropdownItems = wrapper.findAll('.dropdown-item')
|
||||
expect(dropdownItems.length).toBe(7)
|
||||
expect(dropdownItems.length).toBe(5)
|
||||
|
||||
const labels = dropdownItems.wrappers.map((item) => item.text())
|
||||
expect(labels).toEqual([
|
||||
'settings.publish-name.none',
|
||||
'settings.publish-name.alias-or-initials',
|
||||
'settings.publish-name.initials',
|
||||
'settings.publish-name.first',
|
||||
'settings.publish-name.first-initial',
|
||||
'settings.publish-name.last',
|
||||
'settings.publish-name.last-initial',
|
||||
'settings.publish-name.full',
|
||||
'settings.publish-name.name-full',
|
||||
])
|
||||
})
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ import { updateUserInfos } from '@/graphql/mutations'
|
||||
export default {
|
||||
name: 'UserNamingFormat',
|
||||
props: {
|
||||
initialValue: { type: String, default: 'PUBLISH_NAME_NONE' },
|
||||
initialValue: { type: String, default: 'PUBLISH_NAME_ALIAS_OR_INITALS' },
|
||||
attrName: { type: String },
|
||||
successMessage: { type: String },
|
||||
},
|
||||
@ -29,9 +29,9 @@ export default {
|
||||
selectedOption: this.initialValue,
|
||||
dropdownOptions: [
|
||||
{
|
||||
label: this.$t('settings.publish-name.none'),
|
||||
title: this.$t('settings.publish-name.none-tooltip'),
|
||||
value: 'PUBLISH_NAME_NONE',
|
||||
label: this.$t('settings.publish-name.alias-or-initials'),
|
||||
title: this.$t('settings.publish-name.alias-or-initials-tooltip'),
|
||||
value: 'PUBLISH_NAME_ALIAS_OR_INITALS',
|
||||
},
|
||||
{
|
||||
label: this.$t('settings.publish-name.initials'),
|
||||
@ -49,18 +49,8 @@ export default {
|
||||
value: 'PUBLISH_NAME_FIRST_INITIAL',
|
||||
},
|
||||
{
|
||||
label: this.$t('settings.publish-name.last'),
|
||||
title: this.$t('settings.publish-name.last-tooltip'),
|
||||
value: 'PUBLISH_NAME_LAST',
|
||||
},
|
||||
{
|
||||
label: this.$t('settings.publish-name.last-initial'),
|
||||
title: this.$t('settings.publish-name.last-initial-tooltip'),
|
||||
value: 'PUBLISH_NAME_INITIAL_LAST',
|
||||
},
|
||||
{
|
||||
label: this.$t('settings.publish-name.full'),
|
||||
title: this.$t('settings.publish-name.full-tooltip'),
|
||||
label: this.$t('settings.publish-name.name-full'),
|
||||
title: this.$t('settings.publish-name.name-full-tooltip'),
|
||||
value: 'PUBLISH_NAME_FULL',
|
||||
},
|
||||
],
|
||||
|
||||
@ -36,7 +36,7 @@ export const updateUserInfos = gql`
|
||||
$hideAmountGDT: Boolean
|
||||
$gmsAllowed: Boolean
|
||||
$humhubAllowed: Boolean
|
||||
$gmsPublishName: GmsPublishNameType
|
||||
$gmsPublishName: PublishNameType
|
||||
$humhubPublishName: PublishNameType
|
||||
$gmsLocation: Location
|
||||
$gmsPublishLocation: GmsPublishLocationType
|
||||
|
||||
@ -325,16 +325,6 @@
|
||||
"updated": "Positionstyp für GMS aktualisiert"
|
||||
},
|
||||
"publish-name": {
|
||||
"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."
|
||||
@ -388,20 +378,16 @@
|
||||
"subtitle": "Wenn du dein Passwort vergessen hast, kannst du es hier zurücksetzen."
|
||||
},
|
||||
"publish-name": {
|
||||
"none": "Keine",
|
||||
"none-tooltip": "Vorname und Nachname bleiben leer",
|
||||
"alias-or-initials": "Benutzername oder Initialen (Default)",
|
||||
"alias-or-initials-tooltip": "Benutzername, falls vorhanden, oder die Initialen von Vorname und Nachname",
|
||||
"first": "Vorname",
|
||||
"first-tooltip": "Nur der Vornamen, z.B. Max",
|
||||
"first-initial": "Vorname und Initiale",
|
||||
"first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens, z.B. Max M.",
|
||||
"last": "Nachname",
|
||||
"last-tooltip": "Nur der Nachname, z.B. Mustermann",
|
||||
"last-initial": "Initiale und Nachname",
|
||||
"last-initial-tooltip": "Anfangsbuchstabe des Vornamen plus Nachname, z.B. M. Mustermann",
|
||||
"first-tooltip": "Nur der Vornamen",
|
||||
"first-initial": "Vorname und Initial",
|
||||
"first-initial-tooltip": "Vornamen plus Anfangsbuchstabe des Nachnamens",
|
||||
"initials": "Initialen",
|
||||
"initials-tooltip": "Nur die Initialen von Vor- und Nachname, z.B. M. M.",
|
||||
"full": "Ganzer Name",
|
||||
"full-tooltip": "Vollständiger Name: Vorname plus Nachname, z.B. Max Mustermann"
|
||||
"initials-tooltip": "Initialen von Vor- und Nachname unabhängig von der Existenz des Benutzernamens",
|
||||
"name-full": "Vorname und Nachname",
|
||||
"name-full-tooltip": "Vollständiger Name: Vorname plus Nachname"
|
||||
},
|
||||
"showAmountGDD": "Dein GDD Betrag ist sichtbar.",
|
||||
"showAmountGDT": "Dein GDT Betrag ist sichtbar.",
|
||||
|
||||
@ -325,16 +325,6 @@
|
||||
"updated": "format of location for GMS updated"
|
||||
},
|
||||
"publish-name": {
|
||||
"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",
|
||||
"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"
|
||||
@ -388,20 +378,16 @@
|
||||
"subtitle": "If you have forgotten your password, you can reset it here."
|
||||
},
|
||||
"publish-name": {
|
||||
"none": "None",
|
||||
"none-tooltip": "first name and last name are empty",
|
||||
"first": "first name",
|
||||
"first-tooltip": "the first name only",
|
||||
"first-initial": "first name and initial",
|
||||
"first-initial-tooltip": "first name plus initial of last name",
|
||||
"last": "last name",
|
||||
"last-tooltip": "last name only",
|
||||
"last-initial": "initial and last name",
|
||||
"last-initial-tooltip": "First letter of the first name plus last name",
|
||||
"initials": "initials",
|
||||
"initials-tooltip": "Initials of first name and last name",
|
||||
"full": "full name",
|
||||
"full-tooltip": "full name: firstname plus lastname"
|
||||
"alias-or-initials": "Username or initials (Default)",
|
||||
"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",
|
||||
"initials-tooltip": "Initials of firstname and lastname independent if username exists",
|
||||
"name-full": "firstname and lastname",
|
||||
"name-full-tooltip": "fullname: firstname plus lastname"
|
||||
},
|
||||
"showAmountGDD": "Your GDD amount is visible.",
|
||||
"showAmountGDT": "Your GDT amount is visible.",
|
||||
|
||||
@ -108,7 +108,7 @@
|
||||
{{ $t('settings.GMS.naming-format') }}
|
||||
</b-col>
|
||||
<b-col cols="12" md="6" lg="6">
|
||||
<user-g-m-s-naming-format
|
||||
<user-naming-format
|
||||
:initialValue="$store.state.gmsPublishName"
|
||||
:attrName="'gmsPublishName'"
|
||||
:successMessage="$t('settings.GMS.publish-name.updated')"
|
||||
@ -155,7 +155,7 @@
|
||||
/>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<b-row v-if="humhubAllowed" class="mb-4">
|
||||
<b-row v-if="humhubAllowed" class="mb-4 humhub-publish-name-row">
|
||||
<b-col cols="12" md="6" lg="6">
|
||||
{{ $t('settings.humhub.naming-format') }}
|
||||
</b-col>
|
||||
@ -182,7 +182,6 @@
|
||||
</template>
|
||||
<script>
|
||||
import UserNamingFormat from '@/components/UserSettings/UserNamingFormat'
|
||||
import UserGMSNamingFormat from '@/components/UserSettings/UserGMSNamingFormat'
|
||||
import UserGMSLocationFormat from '@/components/UserSettings/UserGMSLocationFormat'
|
||||
import UserGMSLocation from '@/components/UserSettings/UserGMSLocation'
|
||||
import UserName from '@/components/UserSettings/UserName.vue'
|
||||
@ -197,7 +196,6 @@ export default {
|
||||
name: 'Profile',
|
||||
components: {
|
||||
UserNamingFormat,
|
||||
UserGMSNamingFormat,
|
||||
UserGMSLocationFormat,
|
||||
UserGMSLocation,
|
||||
UserName,
|
||||
@ -293,6 +291,9 @@ export default {
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
.humhub-publish-name-row {
|
||||
min-height: 200px;
|
||||
}
|
||||
.card-border-radius {
|
||||
border-radius: 0px 5px 5px 0px !important;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user