2020-08-04 07:15:41 -07:00
|
|
|
<template>
|
|
|
|
<div class="container">
|
2020-09-11 03:17:29 -07:00
|
|
|
<h2>
|
2020-08-04 07:15:41 -07:00
|
|
|
<Icon v="atom-alt"/>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.headerLong</T>
|
2020-09-11 03:17:29 -07:00
|
|
|
</h2>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
|
|
|
<section>
|
2020-09-28 08:51:26 -07:00
|
|
|
<T>nouns.intro</T>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-12 02:46:26 -07:00
|
|
|
<Share :title="$t('nouns.headerLong')"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</section>
|
|
|
|
|
2020-10-12 11:28:20 -07:00
|
|
|
<NounsExtra/>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-09 15:13:00 -07:00
|
|
|
<Loading :value="nounsRaw">
|
2020-10-15 11:55:24 -07:00
|
|
|
<section v-if="$admin()">
|
2020-10-09 15:13:00 -07:00
|
|
|
<div class="alert alert-info">
|
|
|
|
<strong>{{ nounsCountApproved() }}</strong> <T>nouns.approved</T>,
|
|
|
|
<strong>{{ nounsCountPending() }}</strong> <T>nouns.pending</T>.
|
2020-08-06 06:33:38 -07:00
|
|
|
</div>
|
2020-10-09 15:13:00 -07:00
|
|
|
</section>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-09 15:13:00 -07:00
|
|
|
<section class="sticky-top">
|
|
|
|
<div class="input-group mb-3 bg-white">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text">
|
|
|
|
<Icon v="filter"/>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<input class="form-control border-primary" v-model="filter" :placeholder="$t('crud.filterLong')" ref="filter"/>
|
|
|
|
<div class="input-group-append" v-if="filter">
|
|
|
|
<button class="btn btn-outline-danger" @click="filter = ''; $refs.filter.focus()">
|
|
|
|
<Icon v="times"/>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="input-group-append">
|
|
|
|
<button class="btn btn-outline-success" @click="$refs.form.$el.scrollIntoView()">
|
|
|
|
<Icon v="plus-circle"/>
|
|
|
|
<T>nouns.submit.action</T>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-09 15:13:00 -07:00
|
|
|
<section class="table-responsive">
|
2020-10-15 11:55:24 -07:00
|
|
|
<table :class="'table table-striped table-hover table-fixed-' + ($admin() ? 4 : 3)">
|
2020-10-09 15:13:00 -07:00
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="mars"/>
|
|
|
|
<T>nouns.masculine</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="venus"/>
|
|
|
|
<T>nouns.feminine</T>
|
|
|
|
</th>
|
|
|
|
<th class="text-nowrap">
|
|
|
|
<Icon v="neuter"/>
|
|
|
|
<T>nouns.neuter</T>
|
|
|
|
</th>
|
2020-10-15 11:55:24 -07:00
|
|
|
<th v-if="$admin()"></th>
|
2020-10-09 15:13:00 -07:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<template v-if="visibleNouns().length">
|
2020-10-11 05:50:33 -07:00
|
|
|
<tr v-for="noun in visibleNouns()" :class="{'mark-left': !noun.approved}" :key="noun.id">
|
2020-10-09 15:13:00 -07:00
|
|
|
<td>
|
2020-08-04 07:15:41 -07:00
|
|
|
<ul class="list-singular">
|
2020-10-09 15:13:00 -07:00
|
|
|
<li v-for="w in noun.masc">{{ w }}</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
2020-10-09 15:13:00 -07:00
|
|
|
<li v-for="w in noun.mascPl">{{ w }}</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
|
|
|
|
2020-10-09 15:13:00 -07:00
|
|
|
<small v-if="noun.base && nouns[noun.base]">
|
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
|
|
|
<ul class="list-singular">
|
|
|
|
<li v-for="w in nouns[noun.base].masc">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
|
|
|
<li v-for="w in nouns[noun.base].mascPl">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
</small>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-15 11:55:24 -07:00
|
|
|
<button v-if="!$admin()" class="btn btn-outline-primary btn-sm m-1 hover-show" @click="edit(noun)">
|
2020-10-09 15:13:00 -07:00
|
|
|
<Icon v="pen"/>
|
|
|
|
<T>nouns.edit</T>
|
|
|
|
</button>
|
|
|
|
</td>
|
|
|
|
<td>
|
2020-08-04 07:15:41 -07:00
|
|
|
<ul class="list-singular">
|
2020-10-09 15:13:00 -07:00
|
|
|
<li v-for="w in noun.fem">{{ w }}</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
2020-10-09 15:13:00 -07:00
|
|
|
<li v-for="w in noun.femPl">{{ w }}</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
|
|
|
|
2020-10-09 15:13:00 -07:00
|
|
|
<small v-if="noun.base && nouns[noun.base]">
|
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
|
|
|
<ul class="list-singular">
|
|
|
|
<li v-for="w in nouns[noun.base].fem">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
|
|
|
<li v-for="w in nouns[noun.base].femPl">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
</small>
|
|
|
|
</td>
|
|
|
|
<td>
|
2020-08-04 07:15:41 -07:00
|
|
|
<ul class="list-singular">
|
2020-10-11 05:50:33 -07:00
|
|
|
<li v-for="w in noun.neutr">
|
|
|
|
<Declension :word="w"/>
|
|
|
|
</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
2020-10-11 05:50:33 -07:00
|
|
|
<li v-for="w in noun.neutrPl">
|
|
|
|
<Declension :word="w" plural :singularOptions="noun.neutr"/>
|
|
|
|
</li>
|
2020-10-09 15:13:00 -07:00
|
|
|
</ul>
|
|
|
|
|
|
|
|
<small v-if="noun.base && nouns[noun.base]">
|
|
|
|
<p><strong><T>nouns.edited</T>:</strong></p>
|
|
|
|
<ul class="list-singular">
|
|
|
|
<li v-for="w in nouns[noun.base].neutr">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
<ul class="list-plural">
|
|
|
|
<li v-for="w in nouns[noun.base].neutrPl">{{ w }}</li>
|
|
|
|
</ul>
|
|
|
|
</small>
|
|
|
|
</td>
|
2020-10-15 11:55:24 -07:00
|
|
|
<td v-if="$admin()">
|
2020-10-09 15:13:00 -07:00
|
|
|
<ul class="list-unstyled">
|
|
|
|
<li v-if="!noun.approved">
|
|
|
|
<button class="btn btn-success btn-sm m-1" @click="approve(noun)">
|
|
|
|
<Icon v="check"/>
|
|
|
|
<T>crud.approve</T>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li v-else @click="hide(noun)">
|
|
|
|
<button class="btn btn-outline-secondary btn-sm m-1">
|
|
|
|
<Icon v="times"/>
|
|
|
|
<T>crud.hide</T>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button class="btn btn-outline-danger btn-sm m-1" @click="remove(noun)">
|
|
|
|
<Icon v="trash"/>
|
|
|
|
<T>crud.remove</T>
|
|
|
|
</button>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<button class="btn btn-outline-primary btn-sm m-1" @click="edit(noun)">
|
|
|
|
<Icon v="pen"/>
|
|
|
|
<T>crud.edit</T>
|
|
|
|
</button>
|
|
|
|
</li>
|
2020-08-04 07:15:41 -07:00
|
|
|
</ul>
|
2020-08-06 06:33:38 -07:00
|
|
|
</td>
|
|
|
|
</tr>
|
2020-10-09 15:13:00 -07:00
|
|
|
</template>
|
|
|
|
<template v-else>
|
|
|
|
<tr>
|
2020-10-15 11:55:24 -07:00
|
|
|
<td :colspan="$admin() ? 4 : 3" class="text-center">
|
2020-10-09 15:13:00 -07:00
|
|
|
<Icon v="search"/>
|
|
|
|
<T>nouns.empty</T>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</section>
|
|
|
|
</Loading>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-09-11 03:10:49 -07:00
|
|
|
<Separator icon="plus"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
|
2020-10-15 11:55:24 -07:00
|
|
|
<NounSubmitForm ref="form"/>
|
2020-08-04 07:15:41 -07:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { Noun } from "~/src/classes";
|
|
|
|
import { buildDict } from "../src/helpers";
|
2020-09-23 12:29:55 -07:00
|
|
|
import { head } from "../src/helpers";
|
2020-10-12 11:28:20 -07:00
|
|
|
import NounsExtra from "../data/nouns/NounsExtra.vue";
|
2020-08-04 07:15:41 -07:00
|
|
|
|
|
|
|
export default {
|
2020-10-12 11:28:20 -07:00
|
|
|
components: { NounsExtra },
|
2020-08-04 07:15:41 -07:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
filter: '',
|
2020-10-09 15:13:00 -07:00
|
|
|
nounsRaw: undefined,
|
2020-08-04 07:15:41 -07:00
|
|
|
}
|
|
|
|
},
|
2020-08-05 03:04:31 -07:00
|
|
|
mounted() {
|
2020-10-09 15:13:00 -07:00
|
|
|
if (process.client) {
|
2020-10-15 11:55:24 -07:00
|
|
|
this.$axios.$get(`/nouns/all`, { headers: this.$auth() }).then(data => {
|
2020-10-09 15:13:00 -07:00
|
|
|
this.nounsRaw = data;
|
|
|
|
});
|
|
|
|
if (window.location.hash) {
|
2020-10-12 12:07:10 -07:00
|
|
|
const anchor = decodeURIComponent(window.location.hash.substr(1));
|
|
|
|
this.$nextTick(_ => {
|
|
|
|
const $anchor = document.getElementById(anchor);
|
|
|
|
if ($anchor) {
|
|
|
|
$anchor.scrollIntoView();
|
|
|
|
} else {
|
|
|
|
this.filter = anchor;
|
|
|
|
this.$refs.filter.focus();
|
|
|
|
this.$refs.filter.scrollIntoView();
|
|
|
|
setTimeout(_ => {
|
|
|
|
this.$refs.filter.scrollIntoView();
|
|
|
|
}, 1000);
|
|
|
|
}
|
|
|
|
})
|
2020-10-09 15:13:00 -07:00
|
|
|
}
|
2020-08-05 03:04:31 -07:00
|
|
|
}
|
|
|
|
},
|
2020-08-04 07:15:41 -07:00
|
|
|
methods: {
|
|
|
|
edit(noun) {
|
|
|
|
this.$refs.form.edit(noun);
|
|
|
|
},
|
|
|
|
async approve(noun) {
|
2020-10-15 11:55:24 -07:00
|
|
|
await this.$axios.$post(`/nouns/approve/${noun.id}`, {}, { headers: this.$auth() });
|
2020-08-04 07:15:41 -07:00
|
|
|
if (noun.base) {
|
|
|
|
delete this.nouns[noun.base];
|
|
|
|
}
|
|
|
|
noun.approved = true;
|
|
|
|
noun.base = null;
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
async hide(noun) {
|
2020-10-15 11:55:24 -07:00
|
|
|
await this.$axios.$post(`/nouns/hide/${noun.id}`, {}, { headers: this.$auth() });
|
2020-08-04 07:15:41 -07:00
|
|
|
noun.approved = false;
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
|
|
|
async remove(noun) {
|
|
|
|
if (!confirm('Czy na pewno usunąć ten wpis?')) {
|
|
|
|
return false;
|
|
|
|
}
|
2020-10-15 11:55:24 -07:00
|
|
|
await this.$axios.$post(`/nouns/remove/${noun.id}`, {}, { headers: this.$auth() });
|
2020-08-04 07:15:41 -07:00
|
|
|
delete this.nouns[noun.id];
|
|
|
|
this.$forceUpdate();
|
|
|
|
},
|
2020-08-06 06:33:38 -07:00
|
|
|
visibleNouns() {
|
|
|
|
return Object.values(this.nouns).filter(n => n.matches(this.filter));
|
|
|
|
},
|
2020-08-05 13:24:59 -07:00
|
|
|
nounsCountApproved() {
|
|
|
|
return Object.values(this.nouns).filter(n => n.approved).length;
|
|
|
|
},
|
|
|
|
nounsCountPending() {
|
|
|
|
return Object.values(this.nouns).filter(n => !n.approved).length;
|
|
|
|
},
|
2020-08-04 07:15:41 -07:00
|
|
|
},
|
2020-08-06 07:56:39 -07:00
|
|
|
computed: {
|
|
|
|
nouns() {
|
2020-10-09 15:13:00 -07:00
|
|
|
if (this.nounsRaw === undefined) {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2020-08-06 07:56:39 -07:00
|
|
|
return buildDict(function* (that) {
|
2020-08-13 00:45:27 -07:00
|
|
|
const sorted = that.nounsRaw.sort((a, b) => {
|
2020-08-15 00:34:21 -07:00
|
|
|
if (a.approved && !b.approved) {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!a.approved && b.approved) {
|
|
|
|
return -1;
|
|
|
|
}
|
2020-08-13 00:45:27 -07:00
|
|
|
return a.masc.toLowerCase().localeCompare(b.masc.toLowerCase());
|
|
|
|
});
|
|
|
|
for (let w of sorted) {
|
2020-08-06 07:56:39 -07:00
|
|
|
yield [w.id, new Noun(w)];
|
|
|
|
}
|
|
|
|
}, this);
|
|
|
|
},
|
|
|
|
},
|
2020-08-05 03:04:31 -07:00
|
|
|
watch: {
|
|
|
|
filter() {
|
|
|
|
if (process.client) {
|
|
|
|
if (this.filter) {
|
|
|
|
window.location.hash = this.filter;
|
|
|
|
} else {
|
|
|
|
history.pushState('', document.title, window.location.pathname + window.location.search);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2020-08-04 07:15:41 -07:00
|
|
|
head() {
|
2020-09-23 12:29:55 -07:00
|
|
|
return head({
|
2020-09-28 10:22:36 -07:00
|
|
|
title: this.$t('nouns.headerLong'),
|
|
|
|
description: this.$t('nouns.description'),
|
2020-09-23 12:29:55 -07:00
|
|
|
banner: 'bannerNouns.png',
|
|
|
|
});
|
2020-08-04 07:15:41 -07:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import "assets/style";
|
|
|
|
|
|
|
|
.list-singular {
|
|
|
|
padding-left: 0;
|
|
|
|
list-style: none;
|
|
|
|
li {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2020-10-11 05:50:33 -07:00
|
|
|
>li:before {
|
2020-08-04 07:15:41 -07:00
|
|
|
content: "⋅";
|
|
|
|
display: inline-block;
|
|
|
|
width: $fa-fw-width;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.list-plural {
|
|
|
|
padding-left: 0;
|
|
|
|
list-style: none;
|
|
|
|
li {
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
2020-10-11 05:50:33 -07:00
|
|
|
>li:before {
|
2020-08-04 07:15:41 -07:00
|
|
|
content: "⁖";
|
|
|
|
display: inline-block;
|
|
|
|
width: $fa-fw-width;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.mark-left {
|
2020-09-11 03:10:49 -07:00
|
|
|
border-left: 3px solid $primary;
|
2020-08-04 07:15:41 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
tr {
|
|
|
|
.hover-show {
|
|
|
|
opacity: 0;
|
|
|
|
}
|
|
|
|
&:hover .hover-show {
|
|
|
|
opacity: 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|