(de)(pronouns) fix comprehensive switch on any rout

This commit is contained in:
Valentyne Stigloher 2024-05-01 14:42:13 +02:00
parent f87123faf7
commit cedbbc9bee

View File

@ -7,7 +7,7 @@
<Icon v="tag" />
<T>pronouns.intro</T><T>quotation.colon</T>
</span>
<ComprehensiveSwitch @update:comprehensive="updated => comprehensive = updated" />
<ComprehensiveSwitch v-model="comprehensive" />
</h2>
<section>
@ -89,8 +89,6 @@ export default {
exampleCategories: ExampleCategory.from(examples, this.$config),
short,
pronounGroups,
comprehensive: false,
};
},
head() {
@ -100,6 +98,24 @@ export default {
});
},
computed: {
comprehensive: {
get() {
return Object.hasOwn(this.$route.query, this.$config.pronouns.comprehensive);
},
set(value) {
if (value === this.comprehensive) {
// prevent warning that $router.replace has no effect
return;
}
const query = structuredClone(this.$route.query);
if (value) {
query[this.$config.pronouns.comprehensive] = null;
} else {
delete query[this.$config.pronouns.comprehensive];
}
this.$router.replace({ query });
},
},
pronounsChoice() {
if (!this.pronounGroups.length) {
return Object.values(pronouns);