#61 [english] wip
This commit is contained in:
parent
d20c24db25
commit
a5eef76670
|
@ -51,7 +51,7 @@
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in s.el.masc">{{ w }}</li>
|
<li v-for="w in s.el.masc">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in s.el.mascPl">{{ w }}</li>
|
<li v-for="w in s.el.mascPl">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in nouns[s.el.base].masc">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].masc">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in nouns[s.el.base].mascPl">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].mascPl">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</small>
|
</small>
|
||||||
|
@ -74,7 +74,7 @@
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in s.el.fem">{{ w }}</li>
|
<li v-for="w in s.el.fem">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in s.el.femPl">{{ w }}</li>
|
<li v-for="w in s.el.femPl">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in nouns[s.el.base].fem">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].fem">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in nouns[s.el.base].femPl">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].femPl">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</small>
|
</small>
|
||||||
|
@ -91,12 +91,14 @@
|
||||||
<td>
|
<td>
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in s.el.neutr">
|
<li v-for="w in s.el.neutr">
|
||||||
<Declension :word="w"/>
|
<Declension v-if="config.nouns.declension" :word="w"/>
|
||||||
|
<template v-else>{{w}}</template>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in s.el.neutrPl">
|
<li v-for="w in s.el.neutrPl">
|
||||||
<Declension :word="w" plural :singularOptions="s.el.neutr"/>
|
<Declension v-if="config.nouns.declension" :word="w" plural :singularOptions="s.el.neutr"/>
|
||||||
|
<template v-else>{{w}}</template>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
@ -105,7 +107,7 @@
|
||||||
<ul class="list-singular">
|
<ul class="list-singular">
|
||||||
<li v-for="w in nouns[s.el.base].neutr">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].neutr">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="list-plural">
|
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||||
<li v-for="w in nouns[s.el.base].neutrPl">{{ w }}</li>
|
<li v-for="w in nouns[s.el.base].neutrPl">{{ w }}</li>
|
||||||
</ul>
|
</ul>
|
||||||
</small>
|
</small>
|
||||||
|
@ -146,11 +148,13 @@
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</Table>
|
||||||
|
|
||||||
<Separator icon="plus"/>
|
<template v-if="config.nouns.submit">
|
||||||
|
<Separator icon="plus"/>
|
||||||
|
|
||||||
<div class="px-3">
|
<div class="px-3">
|
||||||
<NounSubmitForm ref="form"/>
|
<NounSubmitForm ref="form"/>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
</Loading>
|
</Loading>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -178,7 +182,7 @@
|
||||||
if (this.nounsRaw !== undefined) {
|
if (this.nounsRaw !== undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.nounsRaw = await this.$axios.$get(`/nouns/all`, { headers: this.$auth() });
|
this.nounsRaw = await this.$axios.$get(`/nouns/all/${this.config.locale}`, { headers: this.$auth() });
|
||||||
},
|
},
|
||||||
async setFilter(filter) {
|
async setFilter(filter) {
|
||||||
this.filter = filter;
|
this.filter = filter;
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
</div>
|
</div>
|
||||||
<form v-else @submit.prevent="submit">
|
<form v-else @submit.prevent="submit">
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-borderless table-sm table-fixed-4">
|
<table :class="'table table-borderless table-sm table-fixed-' + (config.nouns.plurals ? '4' : '3')">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th></th>
|
<th v-if="config.nouns.plurals"></th>
|
||||||
<th class="text-nowrap">
|
<th class="text-nowrap">
|
||||||
<Icon v="mars"/>
|
<Icon v="mars"/>
|
||||||
<span class="d-none d-md-inline"><T>nouns.masculine</T></span>
|
<span class="d-none d-md-inline"><T>nouns.masculine</T></span>
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-nowrap">
|
<th v-if="config.nouns.plurals" class="text-nowrap">
|
||||||
<span class="d-none d-md-inline">⋅ <T>nouns.singular</T></span>
|
<span class="d-none d-md-inline">⋅ <T>nouns.singular</T></span>
|
||||||
<span class="d-md-none">⋅ <T>nouns.singularShort</T></span>
|
<span class="d-md-none">⋅ <T>nouns.singularShort</T></span>
|
||||||
</th>
|
</th>
|
||||||
|
@ -51,7 +51,7 @@
|
||||||
<NounForm v-model="form.neutr"/>
|
<NounForm v-model="form.neutr"/>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr v-if="config.nouns.plurals">
|
||||||
<th class="text-nowrap">
|
<th class="text-nowrap">
|
||||||
<span class="d-none d-md-inline">⁖ <T>nouns.plural</T></span>
|
<span class="d-none d-md-inline">⁖ <T>nouns.plural</T></span>
|
||||||
<span class="d-md-none">⁖ <T>nouns.pluralShort</T></span>
|
<span class="d-md-none">⁖ <T>nouns.pluralShort</T></span>
|
||||||
|
@ -77,28 +77,30 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<a v-if="!templateVisible" href="#" @click.prevent="templateVisible = true" class="btn btn-outline-primary btn-block">
|
<template v-if="config.nouns.templates">
|
||||||
<Icon v="copy"/>
|
<a v-if="!templateVisible" href="#" @click.prevent="templateVisible = true" class="btn btn-outline-primary btn-block">
|
||||||
<T>nouns.template</T>
|
|
||||||
</a>
|
|
||||||
<div v-else class="card mb-3">
|
|
||||||
<a href="#" class="card-header" @click.prevent="templateVisible = false">
|
|
||||||
<Icon v="copy"/>
|
<Icon v="copy"/>
|
||||||
<T>nouns.template</T>
|
<T>nouns.template</T>
|
||||||
</a>
|
</a>
|
||||||
<div class="card-body">
|
<div v-else class="card mb-3">
|
||||||
<T>nouns.root</T>: <input class="form-control form-control-sm d-inline-block w-auto" v-model="templateBase" autofocus/>
|
<a href="#" class="card-header" @click.prevent="templateVisible = false">
|
||||||
|
<Icon v="copy"/>
|
||||||
|
<T>nouns.template</T>
|
||||||
|
</a>
|
||||||
|
<div class="card-body">
|
||||||
|
<T>nouns.root</T>: <input class="form-control form-control-sm d-inline-block w-auto" v-model="templateBase" autofocus/>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="template in templates" class="my-2">
|
<li v-for="template in templates" class="my-2">
|
||||||
{{ template.toString() }}
|
{{ template.toString() }}
|
||||||
<button type="button" class="btn btn-outline-primary btn-sm" @click="form = template.fill(templateBase)">
|
<button type="button" class="btn btn-outline-primary btn-sm" @click="form = template.fill(templateBase)">
|
||||||
<Icon v="copy"/>
|
<Icon v="copy"/>
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</template>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-block" :disabled="submitting">
|
<button class="btn btn-primary btn-block" :disabled="submitting">
|
||||||
<template v-if="submitting">
|
<template v-if="submitting">
|
||||||
|
@ -116,6 +118,7 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { nounTemplates } from '../src/data';
|
import { nounTemplates } from '../src/data';
|
||||||
|
import config from "../data/config.suml";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
@ -139,7 +142,7 @@
|
||||||
methods: {
|
methods: {
|
||||||
async submit(event) {
|
async submit(event) {
|
||||||
this.submitting = true;
|
this.submitting = true;
|
||||||
await this.$axios.$post(`/nouns/submit`, {
|
await this.$axios.$post(`/nouns/submit/${this.config.locale}`, {
|
||||||
data: this.form,
|
data: this.form,
|
||||||
}, { headers: this.$auth() });
|
}, { headers: this.$auth() });
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,10 @@ nouns:
|
||||||
enabled: true
|
enabled: true
|
||||||
route: 'nouns'
|
route: 'nouns'
|
||||||
collapsable: false
|
collapsable: false
|
||||||
|
plurals: false
|
||||||
|
declension: false
|
||||||
|
submit: true
|
||||||
|
templates: false
|
||||||
|
|
||||||
names:
|
names:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
|
@ -16,6 +16,10 @@ nouns:
|
||||||
enabled: true
|
enabled: true
|
||||||
route: 'rzeczowniki'
|
route: 'rzeczowniki'
|
||||||
collapsable: true
|
collapsable: true
|
||||||
|
plurals: true
|
||||||
|
declension: true
|
||||||
|
submit: true
|
||||||
|
templates: true
|
||||||
|
|
||||||
names:
|
names:
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Up
|
||||||
|
|
||||||
|
ALTER TABLE nouns ADD COLUMN locale TEXT NOT NULL DEFAULT 'pl';
|
||||||
|
|
||||||
|
-- Down
|
||||||
|
|
|
@ -62,24 +62,27 @@ export default async function (req, res, next) {
|
||||||
const user = authenticate(req);
|
const user = authenticate(req);
|
||||||
const isAdmin = user && user.authenticated && user.roles === 'admin';
|
const isAdmin = user && user.authenticated && user.roles === 'admin';
|
||||||
|
|
||||||
if (req.method === 'GET' && req.url === '/all') {
|
if (req.method === 'GET' && req.url.startsWith('/all/')) {
|
||||||
return renderJson(res, await db.all(`
|
const locale = req.url.substring(5);
|
||||||
|
return renderJson(res, await db.all(SQL`
|
||||||
SELECT * FROM nouns
|
SELECT * FROM nouns
|
||||||
${isAdmin ? '' : 'WHERE approved = 1'}
|
WHERE locale = ${locale}
|
||||||
|
AND approved >= ${isAdmin ? 0 : 1}
|
||||||
ORDER BY approved, masc
|
ORDER BY approved, masc
|
||||||
`));
|
`));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.method === 'POST' && req.url === '/submit') {
|
if (req.method === 'POST' && req.url.startsWith('/submit/')) {
|
||||||
|
const locale = req.url.substring(8);
|
||||||
if (isAdmin || !isTroll(req.body.data)) {
|
if (isAdmin || !isTroll(req.body.data)) {
|
||||||
const id = ulid()
|
const id = ulid()
|
||||||
await db.get(SQL`
|
await db.get(SQL`
|
||||||
INSERT INTO nouns (id, masc, fem, neutr, mascPl, femPl, neutrPl, approved, base_id)
|
INSERT INTO nouns (id, masc, fem, neutr, mascPl, femPl, neutrPl, approved, base_id, locale)
|
||||||
VALUES (
|
VALUES (
|
||||||
${id},
|
${id},
|
||||||
${req.body.data.masc.join('|')}, ${req.body.data.fem.join('|')}, ${req.body.data.neutr.join('|')},
|
${req.body.data.masc.join('|')}, ${req.body.data.fem.join('|')}, ${req.body.data.neutr.join('|')},
|
||||||
${req.body.data.mascPl.join('|')}, ${req.body.data.femPl.join('|')}, ${req.body.data.neutrPl.join('|')},
|
${req.body.data.mascPl.join('|')}, ${req.body.data.femPl.join('|')}, ${req.body.data.neutrPl.join('|')},
|
||||||
0, ${req.body.data.base}
|
0, ${req.body.data.base}, ${locale}
|
||||||
)
|
)
|
||||||
`);
|
`);
|
||||||
if (isAdmin) {
|
if (isAdmin) {
|
||||||
|
|
Reference in New Issue