2020-11-17 10:21:49 -08:00
|
|
|
<template>
|
|
|
|
<Loading :value="entriesRaw">
|
2020-12-30 15:03:30 -08:00
|
|
|
<section v-if="$isGranted('inclusive')" class="px-3">
|
2020-11-17 10:21:49 -08:00
|
|
|
<div class="alert alert-info">
|
|
|
|
<strong>{{ entriesCountApproved() }}</strong> <T>nouns.approved</T>,
|
|
|
|
<strong>{{ entriesCountPending() }}</strong> <T>nouns.pending</T>.
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="sticky-top">
|
2021-05-18 09:53:07 -07:00
|
|
|
<div class="input-group bg-white text-filter">
|
2021-01-22 14:54:24 -08:00
|
|
|
<span class="input-group-text">
|
|
|
|
<Icon v="filter"/>
|
|
|
|
</span>
|
2020-11-17 10:21:49 -08:00
|
|
|
<input class="form-control border-primary" v-model="filter" :placeholder="$t('crud.filterLong')" ref="filter"/>
|
2021-01-22 14:54:24 -08:00
|
|
|
<button v-if="filter" class="btn btn-outline-danger" @click="filter = ''; $refs.filter.focus()">
|
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
2021-07-29 12:42:11 -07:00
|
|
|
<button class="btn btn-outline-success" @click="$refs.form.$el.scrollIntoView({block: 'center'})">
|
2021-01-22 14:54:24 -08:00
|
|
|
<Icon v="plus-circle"/>
|
|
|
|
<T>nouns.submit.action</T>
|
|
|
|
</button>
|
2020-11-17 10:21:49 -08:00
|
|
|
</div>
|
2021-07-29 14:40:55 -07:00
|
|
|
<div class="btn-group mb-3 d-none d-md-flex bg-white category-filter">
|
2021-08-28 14:44:30 -07:00
|
|
|
<button v-for="category in config.inclusive.categories"
|
2021-05-18 09:53:07 -07:00
|
|
|
:class="['btn btn-sm', filter === ':' + category ? 'btn-primary' : 'btn-outline-primary']"
|
|
|
|
@click="filter = filter === ':' + category ? '' : ':' + category"
|
|
|
|
>
|
|
|
|
{{ category }}
|
|
|
|
</button>
|
|
|
|
</div>
|
2020-11-17 10:21:49 -08:00
|
|
|
</section>
|
|
|
|
|
2021-07-24 10:18:39 -07:00
|
|
|
<Table :data="visibleEntries()" :columns="3" :marked="(el) => !el.approved" fixed ref="dictionarytable">
|
2020-11-17 10:21:49 -08:00
|
|
|
<template v-slot:header>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="comment-times"/>
|
2021-08-28 14:44:30 -07:00
|
|
|
<T>inclusive.insteadOf</T>
|
2020-11-17 10:21:49 -08:00
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="comment-check"/>
|
2021-08-28 14:44:30 -07:00
|
|
|
<T>inclusive.say</T>
|
2020-11-17 10:21:49 -08:00
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="comment-dots"/>
|
2021-08-28 14:44:30 -07:00
|
|
|
<T>inclusive.because</T>
|
2020-11-17 10:21:49 -08:00
|
|
|
</th>
|
2020-12-03 06:01:26 -08:00
|
|
|
<th></th>
|
2020-11-17 10:21:49 -08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:row="s"><template v-if="s">
|
|
|
|
<td>
|
|
|
|
<ul class="list-untyled">
|
2021-07-02 13:32:23 -07:00
|
|
|
<li v-for="w in s.el.insteadOf" class="text-strike"><LinkedText :text="w" noicons/></li>
|
2020-11-17 10:21:49 -08:00
|
|
|
</ul>
|
|
|
|
|
2020-12-03 06:01:26 -08:00
|
|
|
<ul class="list-inline">
|
|
|
|
<li v-for="category in s.el.categories" class="list-inline-item">
|
2021-07-30 03:51:12 -07:00
|
|
|
<a :href="`#:${category}`" class="badge bg-primary text-white" @click.prevent="filter = ':' + category">
|
2020-12-03 06:01:26 -08:00
|
|
|
{{category}}
|
2021-07-30 03:51:12 -07:00
|
|
|
</a>
|
2020-12-03 06:01:26 -08:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2021-07-29 14:40:55 -07:00
|
|
|
<div v-if="s.el.base && entries[s.el.base]" class="small">
|
2020-11-17 10:21:49 -08:00
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
|
|
|
<ul class="list-untyled">
|
2021-07-02 13:32:23 -07:00
|
|
|
<li v-for="w in entries[s.el.base].insteadOf" class="text-strike"><LinkedText :text="w" noicons/></li>
|
2020-11-17 10:21:49 -08:00
|
|
|
</ul>
|
|
|
|
|
2020-12-03 06:01:26 -08:00
|
|
|
<ul class="list-inline">
|
|
|
|
<li v-for="category in entries[s.el.base].categories" class="list-inline-item">
|
2021-04-01 09:24:47 -07:00
|
|
|
<span class="badge bg-primary text-white">
|
2020-12-03 06:01:26 -08:00
|
|
|
{{category}}
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2021-07-29 14:40:55 -07:00
|
|
|
</div>
|
2020-11-17 10:21:49 -08:00
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<ul class="list-untyled">
|
2021-07-02 13:32:23 -07:00
|
|
|
<li v-for="w in s.el.say"><LinkedText :text="w" noicons/></li>
|
2020-11-17 10:21:49 -08:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<small v-if="s.el.base && entries[s.el.base]">
|
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
|
|
|
<ul class="list-untyled">
|
2021-07-02 13:32:23 -07:00
|
|
|
<li v-for="w in entries[s.el.base].say"><LinkedText :text="w" noicons/></li>
|
2020-11-17 10:21:49 -08:00
|
|
|
</ul>
|
|
|
|
</small>
|
|
|
|
</td>
|
|
|
|
<td>
|
2021-07-02 13:32:23 -07:00
|
|
|
<p v-for="p in s.el.because.split('\n\n')"><LinkedText :text="p" noicons/></p>
|
2020-11-17 10:21:49 -08:00
|
|
|
|
2020-12-03 06:01:26 -08:00
|
|
|
<ul class="list-unstyled small">
|
|
|
|
<li v-for="link in s.el.links">
|
|
|
|
<a :href="link" target="_blank" rel="noopener">
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
{{clearUrl(link)}}
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
2020-11-17 10:21:49 -08:00
|
|
|
<small v-if="s.el.base && entries[s.el.base]">
|
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
2021-07-02 13:32:23 -07:00
|
|
|
<p v-for="p in entries[s.el.base].because.split('\n\n')"><LinkedText :text="p" noicons/></p>
|
2020-12-03 06:01:26 -08:00
|
|
|
|
|
|
|
<ul class="list-unstyled small">
|
|
|
|
<li v-for="link in entries[s.el.base].links">
|
|
|
|
<a :href="link" target="_blank" rel="noopener">
|
|
|
|
<Icon v="external-link"/>
|
|
|
|
{{clearUrl(link)}}
|
|
|
|
</a>
|
|
|
|
</li>
|
2020-11-17 10:21:49 -08:00
|
|
|
</ul>
|
|
|
|
</small>
|
|
|
|
</td>
|
2020-12-03 06:01:26 -08:00
|
|
|
<td>
|
|
|
|
<ul class="list-unstyled list-btn-concise">
|
2021-07-24 12:55:33 -07:00
|
|
|
<template v-if="$isGranted('inclusive')">
|
|
|
|
<li v-if="s.el.author" class="small">
|
|
|
|
<nuxt-link :to="`/@${s.el.author}`" class="btn btn-concise btn-outline-dark btn-sm m-1">
|
|
|
|
<Icon v="user"/>
|
|
|
|
<span class="btn-label">
|
2020-12-03 06:01:26 -08:00
|
|
|
<T>crud.author</T>:
|
|
|
|
@{{s.el.author}}
|
|
|
|
</span>
|
2021-07-24 12:55:33 -07:00
|
|
|
</nuxt-link>
|
|
|
|
</li>
|
2020-12-03 06:01:26 -08:00
|
|
|
<li v-if="!s.el.approved">
|
|
|
|
<button class="btn btn-concise btn-success btn-sm m-1" @click="approve(s.el)">
|
|
|
|
<Icon v="check"/>
|
|
|
|
<span class="btn-label"><T>crud.approve</T></span>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li v-else @click="hide(s.el)">
|
|
|
|
<button class="btn btn-concise btn-outline-secondary btn-sm m-1">
|
|
|
|
<Icon v="times"/>
|
|
|
|
<span class="btn-label"><T>crud.hide</T></span>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button class="btn btn-concise btn-outline-danger btn-sm m-1" @click="remove(s.el)">
|
|
|
|
<Icon v="trash"/>
|
|
|
|
<span class="btn-label"><T>crud.remove</T></span>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</template>
|
2020-11-17 10:21:49 -08:00
|
|
|
<li>
|
2020-12-03 06:01:26 -08:00
|
|
|
<button class="btn btn-concise btn-outline-primary btn-sm m-1" @click="edit(s.el)">
|
2020-11-17 10:21:49 -08:00
|
|
|
<Icon v="pen"/>
|
2020-12-03 06:01:26 -08:00
|
|
|
<span class="btn-label">
|
2020-12-30 15:03:30 -08:00
|
|
|
<T v-if="$isGranted('inclusive')">crud.edit</T>
|
2020-12-03 06:01:26 -08:00
|
|
|
<T v-else>nouns.edit</T>
|
|
|
|
</span>
|
2020-11-17 10:21:49 -08:00
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</td>
|
|
|
|
</template></template>
|
|
|
|
|
|
|
|
<template v-slot:empty>
|
|
|
|
<Icon v="search"/>
|
|
|
|
<T>nouns.empty</T>
|
|
|
|
</template>
|
|
|
|
</Table>
|
|
|
|
|
2021-11-27 15:01:19 -08:00
|
|
|
<Separator icon="plus"/>
|
2020-11-17 10:21:49 -08:00
|
|
|
|
2021-11-27 15:01:19 -08:00
|
|
|
<div class="px-3">
|
|
|
|
<InclusiveSubmitForm ref="form"/>
|
|
|
|
</div>
|
2020-11-17 10:21:49 -08:00
|
|
|
</Loading>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { InclusiveEntry } from "~/src/classes";
|
2021-07-03 04:19:43 -07:00
|
|
|
import { buildDict, clearUrl, clearLinkedText } from "../src/helpers";
|
2020-12-18 08:32:18 -08:00
|
|
|
import hash from "../plugins/hash";
|
2020-11-17 10:21:49 -08:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
load: {type: Boolean}
|
|
|
|
},
|
2020-12-18 08:32:18 -08:00
|
|
|
mixins: [ hash ],
|
2020-11-17 10:21:49 -08:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
filter: '',
|
|
|
|
entriesRaw: undefined,
|
2020-12-03 06:01:26 -08:00
|
|
|
clearUrl,
|
2020-11-17 10:21:49 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
if (this.load) {
|
|
|
|
this.loadEntries();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
async loadEntries() {
|
|
|
|
if (this.entriesRaw !== undefined) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.entriesRaw = await this.$axios.$get(`/inclusive`);
|
|
|
|
},
|
|
|
|
async setFilter(filter) {
|
|
|
|
this.filter = filter;
|
|
|
|
await this.loadEntries();
|
2021-07-10 03:32:53 -07:00
|
|
|
if (filter) {
|
|
|
|
this.focus();
|
|
|
|
}
|
2020-11-17 10:21:49 -08:00
|
|
|
},
|
|
|
|
focus() {
|
|
|
|
this.$el.focus();
|
|
|
|
this.$el.scrollIntoView();
|
|
|
|
setTimeout(_ => {
|
|
|
|
this.$el.scrollIntoView();
|
|
|
|
}, 1000);
|
|
|
|
},
|
|
|
|
edit(entry) {
|
|
|
|
this.$refs.form.edit(entry);
|
|
|
|
},
|
|
|
|
async approve(entry) {
|
2021-06-09 09:06:32 -07:00
|
|
|
await this.$post(`/inclusive/approve/${entry.id}`);
|
2020-11-17 10:21:49 -08:00
|
|
|
if (entry.base) {
|
|
|
|
delete this.entries[entry.base];
|
|
|
|
}
|
|
|
|
entry.approved = true;
|
|
|
|
entry.base = null;
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
async hide(entry) {
|
2021-06-09 09:06:32 -07:00
|
|
|
await this.$post(`/inclusive/hide/${entry.id}`);
|
2020-11-17 10:21:49 -08:00
|
|
|
entry.approved = false;
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
async remove(entry) {
|
2020-12-05 11:37:10 -08:00
|
|
|
await this.$confirm(this.$t('crud.removeConfirm'), 'danger');
|
|
|
|
|
2021-06-09 09:06:32 -07:00
|
|
|
await this.$post(`/inclusive/remove/${entry.id}`);
|
2020-11-17 10:21:49 -08:00
|
|
|
delete this.entries[entry.id];
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
|
|
|
|
// those must be methods, not computed, because when modified, they don't get updated in the view for some reason
|
|
|
|
visibleEntries() {
|
|
|
|
return Object.values(this.entries).filter(n => n.matches(this.filter));
|
|
|
|
},
|
|
|
|
entriesCountApproved() {
|
|
|
|
return Object.values(this.entries).filter(n => n.approved).length;
|
|
|
|
},
|
|
|
|
entriesCountPending() {
|
|
|
|
return Object.values(this.entries).filter(n => !n.approved).length;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
entries() {
|
|
|
|
if (this.entriesRaw === undefined) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
|
|
|
return buildDict(function* (that) {
|
|
|
|
const sorted = that.entriesRaw.sort((a, b) => {
|
|
|
|
if (a.approved && !b.approved) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!a.approved && b.approved) {
|
|
|
|
return -1;
|
|
|
|
}
|
2021-07-03 04:19:43 -07:00
|
|
|
return clearLinkedText(a.insteadOf.toLowerCase()).localeCompare(clearLinkedText(b.insteadOf.toLowerCase()));
|
2020-11-17 10:21:49 -08:00
|
|
|
});
|
|
|
|
for (let w of sorted) {
|
|
|
|
yield [w.id, new InclusiveEntry(w)];
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filter() {
|
2021-08-28 14:44:30 -07:00
|
|
|
this.setHash(this.config.inclusive.hashNamespace || '', this.filter);
|
2020-12-18 08:32:18 -08:00
|
|
|
if (this.$refs.dictionarytable) {
|
|
|
|
this.$refs.dictionarytable.reset();
|
|
|
|
this.$refs.dictionarytable.focus();
|
2020-11-17 10:21:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import "assets/variables";
|
|
|
|
|
|
|
|
tr {
|
|
|
|
.hover-show {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
&:hover .hover-show {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
2020-12-03 06:01:26 -08:00
|
|
|
|
|
|
|
.btn-concise {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
@include media-breakpoint-up('md', $grid-breakpoints) {
|
|
|
|
.list-btn-concise {
|
|
|
|
min-width: 3rem;
|
|
|
|
|
|
|
|
li {
|
|
|
|
height: 2.5rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.btn-concise {
|
|
|
|
position: absolute;
|
|
|
|
|
|
|
|
.btn-label {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
&:hover .btn-label {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-18 09:53:07 -07:00
|
|
|
|
2021-07-29 14:40:55 -07:00
|
|
|
@include media-breakpoint-up('md', $grid-breakpoints) {
|
|
|
|
.text-filter {
|
|
|
|
* {
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
}
|
2021-05-18 09:53:07 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.category-filter {
|
|
|
|
margin-top: -1px;
|
|
|
|
.btn {
|
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-top-right-radius: 0;
|
|
|
|
}
|
|
|
|
}
|
2020-11-17 10:21:49 -08:00
|
|
|
</style>
|