#61 [english] wip
This commit is contained in:
parent
d20c24db25
commit
a5eef76670
|
@ -51,7 +51,7 @@
|
|||
<ul class="list-singular">
|
||||
<li v-for="w in s.el.masc">{{ w }}</li>
|
||||
</ul>
|
||||
<ul class="list-plural">
|
||||
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||
<li v-for="w in s.el.mascPl">{{ w }}</li>
|
||||
</ul>
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
<ul class="list-singular">
|
||||
<li v-for="w in nouns[s.el.base].masc">{{ w }}</li>
|
||||
</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>
|
||||
</ul>
|
||||
</small>
|
||||
|
@ -74,7 +74,7 @@
|
|||
<ul class="list-singular">
|
||||
<li v-for="w in s.el.fem">{{ w }}</li>
|
||||
</ul>
|
||||
<ul class="list-plural">
|
||||
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||
<li v-for="w in s.el.femPl">{{ w }}</li>
|
||||
</ul>
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
<ul class="list-singular">
|
||||
<li v-for="w in nouns[s.el.base].fem">{{ w }}</li>
|
||||
</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>
|
||||
</ul>
|
||||
</small>
|
||||
|
@ -91,12 +91,14 @@
|
|||
<td>
|
||||
<ul class="list-singular">
|
||||
<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>
|
||||
</ul>
|
||||
<ul class="list-plural">
|
||||
<ul v-if="config.nouns.plurals" class="list-plural">
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
|
@ -105,7 +107,7 @@
|
|||
<ul class="list-singular">
|
||||
<li v-for="w in nouns[s.el.base].neutr">{{ w }}</li>
|
||||
</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>
|
||||
</ul>
|
||||
</small>
|
||||
|
@ -146,11 +148,13 @@
|
|||
</template>
|
||||
</Table>
|
||||
|
||||
<template v-if="config.nouns.submit">
|
||||
<Separator icon="plus"/>
|
||||
|
||||
<div class="px-3">
|
||||
<NounSubmitForm ref="form"/>
|
||||
</div>
|
||||
</template>
|
||||
</Loading>
|
||||
</template>
|
||||
|
||||
|
@ -178,7 +182,7 @@
|
|||
if (this.nounsRaw !== undefined) {
|
||||
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) {
|
||||
this.filter = filter;
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
</div>
|
||||
<form v-else @submit.prevent="submit">
|
||||
<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>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th v-if="config.nouns.plurals"></th>
|
||||
<th class="text-nowrap">
|
||||
<Icon v="mars"/>
|
||||
<span class="d-none d-md-inline"><T>nouns.masculine</T></span>
|
||||
|
@ -37,7 +37,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<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-md-none">⋅ <T>nouns.singularShort</T></span>
|
||||
</th>
|
||||
|
@ -51,7 +51,7 @@
|
|||
<NounForm v-model="form.neutr"/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr v-if="config.nouns.plurals">
|
||||
<th class="text-nowrap">
|
||||
<span class="d-none d-md-inline">⁖ <T>nouns.plural</T></span>
|
||||
<span class="d-md-none">⁖ <T>nouns.pluralShort</T></span>
|
||||
|
@ -77,6 +77,7 @@
|
|||
</button>
|
||||
</div>
|
||||
|
||||
<template v-if="config.nouns.templates">
|
||||
<a v-if="!templateVisible" href="#" @click.prevent="templateVisible = true" class="btn btn-outline-primary btn-block">
|
||||
<Icon v="copy"/>
|
||||
<T>nouns.template</T>
|
||||
|
@ -99,6 +100,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<button class="btn btn-primary btn-block" :disabled="submitting">
|
||||
<template v-if="submitting">
|
||||
|
@ -116,6 +118,7 @@
|
|||
|
||||
<script>
|
||||
import { nounTemplates } from '../src/data';
|
||||
import config from "../data/config.suml";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
@ -139,7 +142,7 @@
|
|||
methods: {
|
||||
async submit(event) {
|
||||
this.submitting = true;
|
||||
await this.$axios.$post(`/nouns/submit`, {
|
||||
await this.$axios.$post(`/nouns/submit/${this.config.locale}`, {
|
||||
data: this.form,
|
||||
}, { headers: this.$auth() });
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@ nouns:
|
|||
enabled: true
|
||||
route: 'nouns'
|
||||
collapsable: false
|
||||
plurals: false
|
||||
declension: false
|
||||
submit: true
|
||||
templates: false
|
||||
|
||||
names:
|
||||
enabled: false
|
||||
|
|
|
@ -16,6 +16,10 @@ nouns:
|
|||
enabled: true
|
||||
route: 'rzeczowniki'
|
||||
collapsable: true
|
||||
plurals: true
|
||||
declension: true
|
||||
submit: true
|
||||
templates: true
|
||||
|
||||
names:
|
||||
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 isAdmin = user && user.authenticated && user.roles === 'admin';
|
||||
|
||||
if (req.method === 'GET' && req.url === '/all') {
|
||||
return renderJson(res, await db.all(`
|
||||
if (req.method === 'GET' && req.url.startsWith('/all/')) {
|
||||
const locale = req.url.substring(5);
|
||||
return renderJson(res, await db.all(SQL`
|
||||
SELECT * FROM nouns
|
||||
${isAdmin ? '' : 'WHERE approved = 1'}
|
||||
WHERE locale = ${locale}
|
||||
AND approved >= ${isAdmin ? 0 : 1}
|
||||
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)) {
|
||||
const id = ulid()
|
||||
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 (
|
||||
${id},
|
||||
${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('|')},
|
||||
0, ${req.body.data.base}
|
||||
0, ${req.body.data.base}, ${locale}
|
||||
)
|
||||
`);
|
||||
if (isAdmin) {
|
||||
|
|
Reference in New Issue