mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-28 15:31:11 -04:00
(ts) migrate
This commit is contained in:
parent
943814ca6f
commit
f0a5c3fffc
@ -14,14 +14,17 @@
|
|||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import Vue from 'vue';
|
||||||
|
import { Example, Pronoun } from '../src/classes.ts';
|
||||||
|
|
||||||
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
example: { required: true },
|
example: { required: true, type: Example },
|
||||||
pronoun: { required: true },
|
pronoun: { required: true, type: Pronoun },
|
||||||
counter: { default: 0 },
|
counter: { default: 0, type: Number },
|
||||||
link: { type: Boolean },
|
link: { type: Boolean },
|
||||||
pronunciation: { type: Boolean },
|
pronunciation: { type: Boolean },
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,42 +1,43 @@
|
|||||||
<template>
|
<template>
|
||||||
<span
|
<span
|
||||||
:class="['morpheme', 'rounded', highlightedMorpheme == baseMorpheme ? 'bg-primary text-white' : '']"
|
:class="['morpheme', 'rounded', highlightedMorpheme === baseMorpheme ? 'bg-primary text-white' : '']"
|
||||||
@mouseenter="highlightMorpheme(baseMorpheme)"
|
@mouseenter="highlightMorpheme(baseMorpheme)"
|
||||||
@mouseleave="highlightMorpheme(null)"
|
@mouseleave="highlightMorpheme(null)"
|
||||||
@touchstart="highlightMorpheme(highlightedMorpheme == baseMorpheme ? null : baseMorpheme)"
|
@touchstart="highlightMorpheme(highlightedMorpheme === baseMorpheme ? null : baseMorpheme)"
|
||||||
><Spelling escape :text="prepend + pronoun.getMorpheme(morpheme, counter) + append" /></span>
|
><Spelling escape :text="prepend + pronoun.getMorpheme(morpheme, counter) + append" /></span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
import { mapState } from 'vuex';
|
import Vue from 'vue';
|
||||||
|
import { Pronoun } from '../src/classes.ts';
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
pronoun: { required: true },
|
pronoun: { required: true, type: Pronoun },
|
||||||
morpheme: { required: true },
|
morpheme: { required: true, type: String },
|
||||||
counter: { default: 0 },
|
counter: { default: 0, type: Number },
|
||||||
|
|
||||||
prepend: { default: '' },
|
prepend: { default: '', type: String },
|
||||||
append: { default: '' },
|
append: { default: '', type: String },
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
baseMorpheme: {
|
highlightedMorpheme() {
|
||||||
get() {
|
return this.$store.state.highlightedMorpheme;
|
||||||
if (this.morpheme[0] == '\'') {
|
},
|
||||||
|
baseMorpheme() {
|
||||||
|
if (this.morpheme.startsWith('\'')) {
|
||||||
return this.morpheme.substring(1);
|
return this.morpheme.substring(1);
|
||||||
} else {
|
} else {
|
||||||
return this.morpheme;
|
return this.morpheme;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
...mapState(['highlightedMorpheme']),
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
highlightMorpheme(morpheme) {
|
highlightMorpheme(morpheme: string | null): void {
|
||||||
this.$store.commit('highlightMorpheme', morpheme);
|
this.$store.commit('highlightMorpheme', morpheme);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,25 +1,33 @@
|
|||||||
<template>
|
<template>
|
||||||
<span v-if="pronoun.getMorpheme(morpheme, counter)">
|
<span v-if="pronoun.getMorpheme(morpheme, counter)">
|
||||||
<Morpheme :pronoun="pronoun" :morpheme="morpheme" :counter="counter" :prepend="prepend" :append="append" />
|
<Morpheme :pronoun="pronoun" :morpheme="morpheme" :counter="counter" :prepend="prepend" :append="append" />
|
||||||
<Pronunciation
|
<Pronunciation v-if="pronunciation" :pronunciation="pronunciation" text />
|
||||||
v-if="pronoun.pronounceable && pronoun.getPronunciation(morpheme, counter) && !pronoun.getPronunciation(morpheme, counter).startsWith('=')"
|
|
||||||
:pronunciation="`/${prependPr}${pronoun.getPronunciation(morpheme, counter)}${appendPr}/`"
|
|
||||||
text
|
|
||||||
/>
|
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
export default {
|
import Vue from 'vue';
|
||||||
props: {
|
import { Pronoun } from '../src/classes.ts';
|
||||||
pronoun: { required: true },
|
|
||||||
morpheme: { required: true },
|
|
||||||
counter: { default: 0 },
|
|
||||||
|
|
||||||
prepend: { default: '' },
|
export default Vue.extend({
|
||||||
prependPr: { default: '' },
|
props: {
|
||||||
append: { default: '' },
|
pronoun: { required: true, type: Pronoun },
|
||||||
appendPr: { default: '' },
|
morpheme: { required: true, type: String },
|
||||||
|
counter: { default: 0, type: Number },
|
||||||
|
|
||||||
|
prepend: { default: '', type: String },
|
||||||
|
prependPr: { default: '', type: String },
|
||||||
|
append: { default: '', type: String },
|
||||||
|
appendPr: { default: '', type: String },
|
||||||
},
|
},
|
||||||
};
|
computed: {
|
||||||
|
pronunciation(): string | null {
|
||||||
|
const pronunciation = this.pronoun.getPronunciation(this.morpheme, this.counter);
|
||||||
|
if (!this.pronoun.pronounceable || !pronunciation || pronunciation.startsWith('=')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return `/${this.prependPr}${this.pronoun.getPronunciation(this.morpheme, this.counter)}${this.appendPr}/`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -20,10 +20,11 @@
|
|||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script lang="ts">
|
||||||
|
import Vue from 'vue';
|
||||||
import { head } from '../src/helpers.ts';
|
import { head } from '../src/helpers.ts';
|
||||||
|
|
||||||
export default {
|
export default Vue.extend({
|
||||||
async asyncData({ app }) {
|
async asyncData({ app }) {
|
||||||
return {
|
return {
|
||||||
chart: await app.$axios.$get(`/admin/stats/users-chart/${process.env.LOCALE}`),
|
chart: await app.$axios.$get(`/admin/stats/users-chart/${process.env.LOCALE}`),
|
||||||
@ -34,5 +35,5 @@ export default {
|
|||||||
title: `${this.$t('admin.header')} • Profiles`,
|
title: `${this.$t('admin.header')} • Profiles`,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@ -4,7 +4,7 @@ import sha1 from 'sha1';
|
|||||||
import { ulid } from 'ulid';
|
import { ulid } from 'ulid';
|
||||||
import Papa from 'papaparse';
|
import Papa from 'papaparse';
|
||||||
import { groupBy, handleErrorAsync } from '../../src/helpers.ts';
|
import { groupBy, handleErrorAsync } from '../../src/helpers.ts';
|
||||||
import { intersection, difference } from '../../src/sets.js';
|
import { intersection, difference } from '../../src/sets.ts';
|
||||||
import { buildChart } from '../../src/stats.ts';
|
import { buildChart } from '../../src/stats.ts';
|
||||||
import auditLog from '../audit.ts';
|
import auditLog from '../audit.ts';
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set
|
||||||
|
|
||||||
export const isSuperset = (set, subset) => {
|
export const isSuperset = <T>(set: Set<T>, subset: Set<T>): boolean => {
|
||||||
for (const elem of subset) {
|
for (const elem of subset) {
|
||||||
if (!set.has(elem)) {
|
if (!set.has(elem)) {
|
||||||
return false;
|
return false;
|
||||||
@ -9,7 +9,7 @@ export const isSuperset = (set, subset) => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const union = (setA, setB) => {
|
export const union = <T>(setA: Set<T>, setB: Set<T>): Set<T> => {
|
||||||
const _union = new Set(setA);
|
const _union = new Set(setA);
|
||||||
for (const elem of setB) {
|
for (const elem of setB) {
|
||||||
_union.add(elem);
|
_union.add(elem);
|
||||||
@ -17,8 +17,8 @@ export const union = (setA, setB) => {
|
|||||||
return _union;
|
return _union;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const intersection = (setA, setB) => {
|
export const intersection = <T>(setA: Set<T>, setB: Set<T>): Set<T> => {
|
||||||
const _intersection = new Set();
|
const _intersection: Set<T> = new Set();
|
||||||
for (const elem of setB) {
|
for (const elem of setB) {
|
||||||
if (setA.has(elem)) {
|
if (setA.has(elem)) {
|
||||||
_intersection.add(elem);
|
_intersection.add(elem);
|
||||||
@ -27,7 +27,7 @@ export const intersection = (setA, setB) => {
|
|||||||
return _intersection;
|
return _intersection;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const symmetricDifference = (setA, setB) => {
|
export const symmetricDifference = <T>(setA: Set<T>, setB: Set<T>): Set<T> => {
|
||||||
const _difference = new Set(setA);
|
const _difference = new Set(setA);
|
||||||
for (const elem of setB) {
|
for (const elem of setB) {
|
||||||
if (_difference.has(elem)) {
|
if (_difference.has(elem)) {
|
||||||
@ -39,7 +39,7 @@ export const symmetricDifference = (setA, setB) => {
|
|||||||
return _difference;
|
return _difference;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const difference = (setA, setB) => {
|
export const difference = <T>(setA: Set<T>, setB: Set<T>): Set<T> => {
|
||||||
const _difference = new Set(setA);
|
const _difference = new Set(setA);
|
||||||
for (const elem of setB) {
|
for (const elem of setB) {
|
||||||
_difference.delete(elem);
|
_difference.delete(elem);
|
Loading…
x
Reference in New Issue
Block a user