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>
|
|
|
|
</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>
|
2021-01-05 11:11:41 -08:00
|
|
|
<div v-if="$isGranted('sources')" class="form-group">
|
|
|
|
<label><strong><T>sources.referenced</T>:</strong></label>
|
|
|
|
<ListInput v-model="form.sources"/>
|
|
|
|
</div>
|
2020-08-04 07:15:41 -07:00
|
|
|
<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>
|
2021-01-22 14:54:24 -08:00
|
|
|
<button class="btn btn-sm float-end" @click="form.base = null">
|
2020-08-04 07:15:41 -07:00
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
2020-10-31 05:10:25 -07:00
|
|
|
<template v-if="config.nouns.templates">
|
2021-07-03 04:30:29 -07:00
|
|
|
<a v-if="!templateVisible" href="#" @click.prevent="templateVisible = true" class="btn btn-outline-primary w-100 mb-3">
|
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
|
|
|
|
2021-01-22 14:54:24 -08:00
|
|
|
<button class="btn btn-primary w-100" :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 ? [''] : [],
|
2021-01-05 11:11:41 -08:00
|
|
|
sources: [],
|
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;
|
2021-06-09 09:06:32 -07:00
|
|
|
try {
|
|
|
|
await this.$post(`/nouns/submit`, this.form);
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2021-06-09 09:06:32 -07:00
|
|
|
this.afterSubmit = true;
|
|
|
|
this.form = {
|
|
|
|
masc: [''],
|
|
|
|
fem: [''],
|
|
|
|
neutr: [''],
|
|
|
|
mascPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
femPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
neutrPl: this.config.nouns.pluralsRequired ? [''] : [],
|
|
|
|
sources: [],
|
|
|
|
base: null,
|
|
|
|
};
|
|
|
|
this.templateVisible = false;
|
|
|
|
this.templateBase = '';
|
|
|
|
} finally {
|
|
|
|
this.submitting = false;
|
|
|
|
}
|
2020-08-04 07:15:41 -07:00
|
|
|
},
|
|
|
|
edit(word) {
|
|
|
|
this.form = {
|
|
|
|
masc: word.masc,
|
|
|
|
fem: word.fem,
|
|
|
|
neutr: word.neutr,
|
|
|
|
mascPl: word.mascPl,
|
|
|
|
femPl: word.femPl,
|
|
|
|
neutrPl: word.neutrPl,
|
2021-01-05 11:11:41 -08:00
|
|
|
sources: word.sources,
|
2020-08-04 07:15:41 -07:00
|
|
|
base: word.id,
|
|
|
|
}
|
2020-12-03 06:01:26 -08:00
|
|
|
this.afterSubmit = false;
|
2020-08-04 07:15:41 -07:00
|
|
|
this.$el.scrollIntoView();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|