2020-12-18 08:32:18 -08:00
|
|
|
<template>
|
|
|
|
<section>
|
|
|
|
<div v-if="afterSubmit" class="alert alert-success text-center">
|
|
|
|
<p>
|
|
|
|
<T>nouns.submit.thanks</T>
|
|
|
|
</p>
|
|
|
|
<p>
|
|
|
|
<button class="btn btn-success" @click="afterSubmit = false">
|
|
|
|
<Icon v="plus"/>
|
|
|
|
<T>nouns.submit.another</T>
|
|
|
|
</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<form v-else @submit.prevent="submit">
|
|
|
|
<div class="table-responsive">
|
|
|
|
<table class="table table-borderless table-sm table-fixed-3">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>nouns.terms.term</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>nouns.terms.original</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<T>nouns.terms.definition</T>
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>
|
2021-01-19 11:40:14 -08:00
|
|
|
<NounForm v-model="form.term" required maxlength="48"/>
|
2020-12-18 08:32:18 -08:00
|
|
|
</td>
|
|
|
|
<td>
|
2021-01-19 13:21:39 -08:00
|
|
|
<NounForm v-model="form.original" maxlength="1024"/>
|
2020-12-18 08:32:18 -08:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<textarea v-model="form.definition" class="form-control form-control-sm" required rows="3"></textarea>
|
|
|
|
</td>
|
|
|
|
</tr>
|
2020-12-30 15:03:30 -08:00
|
|
|
<tr v-if="$isGranted('terms')">
|
2021-01-17 10:41:07 -08:00
|
|
|
<td :colspan="$isGranted('terms') ? 1 : 3">
|
|
|
|
<T>nouns.terms.category</T>
|
|
|
|
<select v-model="form.category" class="form-control form-control-sm">
|
|
|
|
<option value=""></option>
|
|
|
|
<option v-for="category in config.nouns.terms.categories" :value="category">{{category}}</option>
|
|
|
|
</select>
|
|
|
|
</td>
|
|
|
|
<td v-if="$isGranted('terms')">
|
2020-12-21 10:33:41 -08:00
|
|
|
<T>profile.flags</T>
|
|
|
|
<ListInput v-model="form.flags" v-slot="s"/>
|
|
|
|
</td>
|
2021-01-17 10:41:07 -08:00
|
|
|
<td v-if="$isGranted('terms')">
|
|
|
|
<T>nouns.terms.images</T>
|
|
|
|
<ImageWidget v-model="form.images" multiple/>
|
|
|
|
</td>
|
2020-12-21 10:33:41 -08:00
|
|
|
</tr>
|
2020-12-18 08:32:18 -08:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="alert alert-info" v-if="form.base">
|
|
|
|
<Icon v="info-circle"/>
|
|
|
|
<T>nouns.editing</T>
|
|
|
|
<button class="btn btn-sm float-right" @click="form.base = null">
|
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="btn btn-primary btn-block" :disabled="submitting">
|
|
|
|
<template v-if="submitting">
|
|
|
|
<Icon v="circle-notch fa-spin"/>
|
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<Icon v="plus"/>
|
|
|
|
<T>nouns.submit.actionLong</T>
|
|
|
|
</template>
|
|
|
|
</button>
|
|
|
|
<p class="small text-muted mt-1"><T>nouns.submit.moderation</T></p>
|
|
|
|
</form>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
form: {
|
|
|
|
term: [''],
|
|
|
|
original: [],
|
|
|
|
definition: '',
|
2021-01-17 10:41:07 -08:00
|
|
|
category: '',
|
2020-12-21 10:33:41 -08:00
|
|
|
flags: [],
|
2021-01-17 10:41:07 -08:00
|
|
|
images: [],
|
2020-12-18 08:32:18 -08:00
|
|
|
base: null,
|
|
|
|
},
|
|
|
|
submitting: false,
|
|
|
|
afterSubmit: false,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async submit(event) {
|
|
|
|
this.submitting = true;
|
|
|
|
await this.$axios.$post(`/terms/submit`, this.form);
|
|
|
|
|
|
|
|
this.submitting = false;
|
|
|
|
this.afterSubmit = true;
|
|
|
|
this.form = {
|
|
|
|
term: [''],
|
|
|
|
original: [],
|
|
|
|
definition: '',
|
2021-01-17 10:41:07 -08:00
|
|
|
category: '',
|
2020-12-21 10:33:41 -08:00
|
|
|
flags: [],
|
2021-01-17 10:41:07 -08:00
|
|
|
images: [],
|
2020-12-18 08:32:18 -08:00
|
|
|
base: null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
edit(word) {
|
|
|
|
this.form = {
|
|
|
|
term: word.term,
|
|
|
|
original: word.original,
|
|
|
|
definition: word.definition,
|
2021-01-17 10:41:07 -08:00
|
|
|
category: word.category,
|
2020-12-21 10:33:41 -08:00
|
|
|
flags: word.flags,
|
2021-01-17 10:41:07 -08:00
|
|
|
images: word.images,
|
2020-12-18 08:32:18 -08:00
|
|
|
base: word.id,
|
|
|
|
}
|
|
|
|
this.afterSubmit = false;
|
|
|
|
this.$el.scrollIntoView();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|