diff --git a/components/Table.vue b/components/Table.vue new file mode 100644 index 000000000..611853e3c --- /dev/null +++ b/components/Table.vue @@ -0,0 +1,104 @@ + + + + + diff --git a/locale/pl/translations.suml b/locale/pl/translations.suml index 66387a7a8..94b980abc 100644 --- a/locale/pl/translations.suml +++ b/locale/pl/translations.suml @@ -744,3 +744,6 @@ terms: header: 'Regulamin' lastUpdate: 'Ostatnia aktualizacja' consent: 'Zakładając konto, akceptujesz' + +table: + empty: 'Pusto…' diff --git a/routes/nouns.vue b/routes/nouns.vue index eafb363c9..9ee379db8 100644 --- a/routes/nouns.vue +++ b/routes/nouns.vue @@ -23,8 +23,8 @@
- {{ nounsCountApproved }} nouns.approved, - {{ nounsCountPending }} nouns.pending. + {{ nounsCountApproved() }} nouns.approved, + {{ nounsCountPending() }} nouns.pending.
@@ -50,150 +50,122 @@ -
- - - - - - - - - - - - - - - - - - -
- - nouns.masculine - - - nouns.feminine - - - nouns.neuter -
- -
-
+ + @@ -221,7 +193,6 @@ return { filter: '', nounsRaw: undefined, - page: 0, } }, mounted() { @@ -278,6 +249,17 @@ delete this.nouns[noun.id]; this.$forceUpdate(); }, + + // those must be methods, not computed, because when modified, they don't get updated in the view for some reason + visibleNouns() { + return Object.values(this.nouns).filter(n => n.matches(this.filter)); + }, + nounsCountApproved() { + return Object.values(this.nouns).filter(n => n.approved).length; + }, + nounsCountPending() { + return Object.values(this.nouns).filter(n => !n.approved).length; + }, }, computed: { nouns() { @@ -300,36 +282,6 @@ } }, this); }, - visibleNouns() { - return Object.values(this.nouns).filter(n => n.matches(this.filter)); - }, - visibleNounsPage() { - return this.visibleNouns.slice(this.page * PER_PAGE, (this.page + 1) * PER_PAGE); - }, - pages() { - return Math.ceil(this.visibleNouns.length / PER_PAGE); - }, - pagesRange() { - const vPages = []; - vPages.push({page: 0, text: '«', enabled: this.page > 0}); - vPages.push({page: this.page - 1, text: '‹', enabled: this.page > 0}); - for (let i = 0; i < this.pages; i++) { - if (i <= 4 || (this.page - 3 <= i && i <= this.page + 3) || i >= this.pages - 3) { - vPages.push({page: i, text: i + 1, enabled: true}); - } else if (vPages[vPages.length - 1].text !== '…') { - vPages.push({text: '…', enabled: false}); - } - } - vPages.push({page: this.page + 1, text: '›', enabled: this.page < this.pages - 1}); - vPages.push({page: this.pages - 1, text: '»', enabled: this.page < this.pages - 1}); - return vPages; - }, - nounsCountApproved() { - return Object.values(this.nouns).filter(n => n.approved).length; - }, - nounsCountPending() { - return Object.values(this.nouns).filter(n => !n.approved).length; - }, }, watch: { filter() { @@ -339,12 +291,10 @@ } else { history.pushState('', document.title, window.location.pathname + window.location.search); } - this.page = 0; - setTimeout(_ => { - if (this.$refs.thead) { - this.$refs.thead.scrollIntoView(); - } - }, 300); + if (this.$refs.dictionarytable) { + this.$refs.dictionarytable.reset(); + this.$refs.dictionarytable.focus(); + } } } }, @@ -388,10 +338,6 @@ } } - .mark-left { - border-left: 3px solid $primary; - } - tr { .hover-show { opacity: 0;