#111 fix cannot add "any" pronouns to profile
This commit is contained in:
parent
1f2d86b3dd
commit
4e8211e096
|
@ -5,7 +5,7 @@
|
||||||
<span v-else><Spelling>{{part.str}}</Spelling></span>
|
<span v-else><Spelling>{{part.str}}</Spelling></span>
|
||||||
</span>
|
</span>
|
||||||
<small v-if="link">
|
<small v-if="link">
|
||||||
(<nuxt-link :to="'/' + pronoun.canonicalName"><Spelling>{{ pronoun.canonicalName }}</Spelling></nuxt-link>)
|
(<nuxt-link :to="'/' + pronoun.canonicalName"><Spelling :text="pronoun.canonicalName"/></nuxt-link>)
|
||||||
</small>
|
</small>
|
||||||
<template v-if="config.pronunciation.enabled && pronounce && pronoun.pronounceable && example.pronounce(pronoun)">
|
<template v-if="config.pronunciation.enabled && pronounce && pronoun.pronounceable && example.pronounce(pronoun)">
|
||||||
<a v-for="(link, name) in pronunciationLinks"
|
<a v-for="(link, name) in pronunciationLinks"
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
|
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
<li v-for="{link, pronoun, opinion} in pronounOpinions">
|
<li v-for="{link, pronoun, opinion} in pronounOpinions">
|
||||||
<Opinion :word="pronoun.name(glue) + (pronoun.smallForm ? '/' + pronoun.morphemes[pronoun.smallForm] : '')" :opinion="opinion" :link="`/${link}`"/>
|
<Opinion :word="typeof pronoun === 'string' ? pronoun : (pronoun.name(glue) + (pronoun.smallForm ? '/' + pronoun.morphemes[pronoun.smallForm] : ''))" :opinion="opinion" :link="`/${link}`"/>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -179,6 +179,16 @@
|
||||||
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
|
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
|
||||||
.replace(new RegExp('^/'), '')
|
.replace(new RegExp('^/'), '')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (link === this.config.pronouns.any) {
|
||||||
|
pronounOpinions.push({
|
||||||
|
link,
|
||||||
|
pronoun: link,
|
||||||
|
opinion: this.profile.pronouns[pronoun],
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const pronounEntity = buildPronoun(pronouns, link);
|
const pronounEntity = buildPronoun(pronouns, link);
|
||||||
|
|
||||||
if (pronounEntity) {
|
if (pronounEntity) {
|
||||||
|
@ -195,6 +205,9 @@
|
||||||
let mainPronoun = buildPronoun(pronouns, this.config.profile.flags.defaultPronoun);
|
let mainPronoun = buildPronoun(pronouns, this.config.profile.flags.defaultPronoun);
|
||||||
let mainOpinion = -1;
|
let mainOpinion = -1;
|
||||||
for (let {pronoun, opinion} of this.pronounOpinions) {
|
for (let {pronoun, opinion} of this.pronounOpinions) {
|
||||||
|
if (typeof pronoun === 'string') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (opinion === 2) {
|
if (opinion === 2) {
|
||||||
opinion = 0.5;
|
opinion = 0.5;
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@
|
||||||
this.$router.push(`/@${this.$user().username}`)
|
this.$router.push(`/@${this.$user().username}`)
|
||||||
},
|
},
|
||||||
normalisePronoun(pronoun) {
|
normalisePronoun(pronoun) {
|
||||||
const link = decodeURIComponent(
|
return decodeURIComponent(
|
||||||
pronoun
|
pronoun
|
||||||
.toLowerCase()
|
.toLowerCase()
|
||||||
.trim()
|
.trim()
|
||||||
|
@ -251,11 +251,15 @@
|
||||||
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
|
.replace(new RegExp('^' + this.$base.replace(/^https?:\/\//, '')), '')
|
||||||
.replace(new RegExp('^/'), '')
|
.replace(new RegExp('^/'), '')
|
||||||
);
|
);
|
||||||
|
},
|
||||||
return buildPronoun(pronouns, link);
|
normaliseAndBuildPronoun(pronoun) {
|
||||||
|
return buildPronoun(pronouns, this.normalisePronoun(pronoun));
|
||||||
},
|
},
|
||||||
validatePronoun(pronoun) {
|
validatePronoun(pronoun) {
|
||||||
return this.normalisePronoun(pronoun) ? null : 'profile.pronounsNotFound'
|
pronoun = this.normalisePronoun(pronoun);
|
||||||
|
return pronoun === this.config.pronouns.any || buildPronoun(pronouns, pronoun)
|
||||||
|
? null
|
||||||
|
: 'profile.pronounsNotFound'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -267,7 +271,7 @@
|
||||||
opinion = 0.5;
|
opinion = 0.5;
|
||||||
}
|
}
|
||||||
if (opinion > mainOpinion) {
|
if (opinion > mainOpinion) {
|
||||||
const p = this.normalisePronoun(pronoun);
|
const p = this.normaliseAndBuildPronoun(pronoun);
|
||||||
if (p) {
|
if (p) {
|
||||||
mainPronoun = p;
|
mainPronoun = p;
|
||||||
mainOpinion = opinion;
|
mainOpinion = opinion;
|
||||||
|
|
Reference in New Issue