diff --git a/app/components/widgets/forms/link-field.hbs b/app/components/widgets/forms/link-field.hbs index 9f73ab34f33..2348b4d3095 100644 --- a/app/components/widgets/forms/link-field.hbs +++ b/app/components/widgets/forms/link-field.hbs @@ -6,6 +6,7 @@ { */ fixValue(value: string): string { const splitted = value.split(this.prefix); + if (!splitted[1]) { + const extraPrefix = socialMediaExtraPrefixes[this.prefix]; + const extraSplit = value.split(extraPrefix); + if (extraSplit[1]) { + return extraSplit[1]; + } + } return splitted[1] || splitted[0]; } @@ -63,4 +71,10 @@ export default class LinkField extends Component { this.args.onChange(this.finalValue); } + @action + valueUpdated(): void { + this.value = this.parseValue(); + this.args.onChange(this.finalValue); + } + } diff --git a/app/models/social-link.js b/app/models/social-link.js index 79f6799ac3b..fb9e14ac5dd 100644 --- a/app/models/social-link.js +++ b/app/models/social-link.js @@ -13,7 +13,11 @@ export default ModelBase.extend({ event: belongsTo('event'), - normalizedName: computed('name', function() { + normalizedName: computed('site', function() { + return this.site === 'website' ? 'globe' : this.site; + }), + + site: computed('name', function() { // Even though name is required for social links and is non-nullable // and non-null name is being sent from API, for some reason, for certain events, // this throws an error, so we check first if name exists @@ -21,7 +25,7 @@ export default ModelBase.extend({ const normalizedName = this.name?.trim().toLowerCase(); if (!socialMediaIdentifiers.includes(normalizedName)) { - return 'globe'; + return 'website'; } return normalizedName; }), diff --git a/app/templates/components/forms/wizard/other-details-step.hbs b/app/templates/components/forms/wizard/other-details-step.hbs index 7a478da3d7d..0d8dc0c3cdc 100644 --- a/app/templates/components/forms/wizard/other-details-step.hbs +++ b/app/templates/components/forms/wizard/other-details-step.hbs @@ -14,7 +14,7 @@ {{#each this.socialMediaLinks as |socialLink|}} @@ -36,7 +36,7 @@ {{#each this.customLinks as |socialLink|}} diff --git a/app/utils/dictionary/social-media.ts b/app/utils/dictionary/social-media.ts index 8e23fd8f861..e89d04284ad 100644 --- a/app/utils/dictionary/social-media.ts +++ b/app/utils/dictionary/social-media.ts @@ -31,3 +31,8 @@ export const socialMediaMap: SocialMediaMap = socialMediaIdentifiers.reduce((obj obj[identifier] = socialMediaSites[index]; return obj; }, {}); + +export const socialMediaExtraPrefixes = Object.values(socialMediaMap).reduce((obj: { [key: string]: string}, media: SocialMedia) => { + obj[media.prefix ?? media.identifier] = `https://www.${media.identifier}.com/`; + return obj; +}, {});