2020-08-04 07:15:41 -07:00
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<div v-if="afterSubmit" class="alert alert-success text-center">
|
|
|
|
<p>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.submit.thanks</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<button class="btn btn-success" @click="afterSubmit = false">
|
|
|
|
<Icon v="plus"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.submit.another</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<form v-else @submit.prevent="submit">
|
|
|
|
<div class="table-responsive">
|
2020-10-31 05:10:25 -07:00
|
|
|
<table :class="'table table-borderless table-sm table-fixed-' + (config.nouns.plurals ? '4' : '3')">
|
2020-08-04 07:15:41 -07:00
|
|
|
<thead>
|
|
|
|
<tr>
|
2020-10-31 05:10:25 -07:00
|
|
|
<th v-if="config.nouns.plurals"></th>
|
2020-08-04 07:15:41 -07:00
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="mars"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<span class="d-none d-md-inline"><T>nouns.masculine</T></span>
|
|
|
|
<span class="d-md-none"><T>nouns.masculineShort</T></span>
|
2020-08-04 07:15:41 -07:00
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="venus"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<span class="d-none d-md-inline"><T>nouns.feminine</T></span>
|
|
|
|
<span class="d-md-none"><T>nouns.feminineShort</T></span>
|
2020-08-04 07:15:41 -07:00
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="neuter"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<span class="d-none d-md-inline"><T>nouns.neuter</T></span>
|
|
|
|
<span class="d-md-none"><T>nouns.neuterShort</T></span>
|
2020-08-04 07:15:41 -07:00
|
|
|
</th>
|
2020-10-15 11:55:24 -07:00
|
|
|
<th v-if="$admin()"></th>
|
2020-08-04 07:15:41 -07:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2020-10-31 05:10:25 -07:00
|
|
|
<th v-if="config.nouns.plurals" class="text-nowrap">
|
2020-09-28 08:51:26 -07:00
|
|
|
<span class="d-none d-md-inline">⋅ <T>nouns.singular</T></span>
|
|
|
|
<span class="d-md-none">⋅ <T>nouns.singularShort</T></span>
|
2020-08-04 07:15:41 -07:00
|
|
|
</th>
|
|
|
|
<td>
|
2020-11-25 15:14:16 -08:00
|
|
|
<NounForm v-model="form.masc" required/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-11-25 15:14:16 -08:00
|
|
|
<NounForm v-model="form.fem" required/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-11-25 15:14:16 -08:00
|
|
|
<NounForm v-model="form.neutr" required/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
</tr>
|
2020-10-31 05:10:25 -07:00
|
|
|
<tr v-if="config.nouns.plurals">
|
2020-08-04 07:15:41 -07:00
|
|
|
<th class="text-nowrap">
|
2020-09-28 08:51:26 -07:00
|
|
|
<span class="d-none d-md-inline">⁖ <T>nouns.plural</T></span>
|
|
|
|
<span class="d-md-none">⁖ <T>nouns.pluralShort</T></span>
|
2020-08-04 07:15:41 -07:00
|
|
|
</th>
|
|
|
|
<td>
|
2020-11-25 15:05:39 -08:00
|
|
|
<NounForm v-model="form.mascPl" :required="config.nouns.pluralsRequired"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-11-25 15:05:39 -08:00
|
|
|
<NounForm v-model="form.femPl" :required="config.nouns.pluralsRequired"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
<td>
|
2020-11-25 15:05:39 -08:00
|
|
|
<NounForm v-model="form.neutrPl" :required="config.nouns.pluralsRequired"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="alert alert-info" v-if="form.base">
|
|
|
|
<Icon v="info-circle"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.editing</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
<button class="btn btn-sm float-right" @click="form.base = null">
|
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2020-10-31 05:10:25 -07:00
|
|
|
<template v-if="config.nouns.templates">
|
|
|
|
<a v-if="!templateVisible" href="#" @click.prevent="templateVisible = true" class="btn btn-outline-primary btn-block">
|
2020-08-04 07:15:41 -07:00
|
|
|
<Icon v="copy"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.template</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
</a>
|
2020-10-31 05:10:25 -07:00
|
|
|
<div v-else class="card mb-3">
|
|
|
|
<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/>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-31 05:10:25 -07:00
|
|
|
<ul>
|
|
|
|
<li v-for="template in templates" class="my-2">
|
|
|
|
{{ template.toString() }}
|
|
|
|
<button type="button" class="btn btn-outline-primary btn-sm" @click="form = template.fill(templateBase)">
|
|
|
|
<Icon v="copy"/>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
2020-08-04 07:15:41 -07:00
|
|
|
</div>
|
2020-10-31 05:10:25 -07:00
|
|
|
</template>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-09-11 03:10:49 -07:00
|
|
|
<button class="btn btn-primary btn-block" :disabled="submitting">
|
2020-08-04 07:15:41 -07:00
|
|
|
<template v-if="submitting">
|
|
|
|
<Icon v="circle-notch fa-spin"/>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<Icon v="plus"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.submit.actionLong</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
</template>
|
|
|
|
</button>
|
2020-09-28 08:51:26 -07:00
|
|
|
<p class="small text-muted mt-1"><T>nouns.submit.moderation</T></p>
|
2020-08-04 07:15:41 -07:00
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-08-05 11:24:05 -07:00
|
|
|
import { nounTemplates } from '../src/data';
|
2020-08-04 07:15:41 -07:00
|
|
|
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
form: {
|
|
|
|
masc: [''],
|
|
|
|
fem: [''],
|
|
|
|
neutr: [''],
|
2020-11-25 15:05:39 -08:00
|
|
|
mascPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
femPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
neutrPl: this.config.nouns.pluralsRequired ? [''] : [],
|
2020-08-04 07:15:41 -07:00
|
|
|
base: null,
|
|
|
|
},
|
|
|
|
submitting: false,
|
|
|
|
afterSubmit: false,
|
2020-08-05 11:24:05 -07:00
|
|
|
templates: nounTemplates,
|
2020-08-04 07:15:41 -07:00
|
|
|
templateBase: '',
|
|
|
|
templateVisible: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async submit(event) {
|
|
|
|
this.submitting = true;
|
2020-11-09 15:50:39 -08:00
|
|
|
await this.$axios.$post(`/nouns/submit`, this.form);
|
2020-08-04 07:15:41 -07:00
|
|
|
|
|
|
|
this.submitting = false;
|
|
|
|
this.afterSubmit = true;
|
|
|
|
this.form = {
|
|
|
|
masc: [''],
|
|
|
|
fem: [''],
|
|
|
|
neutr: [''],
|
2020-11-25 15:05:39 -08:00
|
|
|
mascPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
femPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
neutrPl: this.config.nouns.pluralsRequired ? [''] : [],
|
2020-08-04 07:15:41 -07:00
|
|
|
base: null,
|
|
|
|
};
|
|
|
|
this.templateVisible = false;
|
|
|
|
this.templateBase = '';
|
|
|
|
},
|
|
|
|
edit(word) {
|
|
|
|
this.form = {
|
|
|
|
masc: word.masc,
|
|
|
|
fem: word.fem,
|
|
|
|
neutr: word.neutr,
|
|
|
|
mascPl: word.mascPl,
|
|
|
|
femPl: word.femPl,
|
|
|
|
neutrPl: word.neutrPl,
|
|
|
|
base: word.id,
|
|
|
|
}
|
|
|
|
this.$el.scrollIntoView();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|