From 02f3da8abe85f591fc74f45e8a46a95357a783a4 Mon Sep 17 00:00:00 2001 From: Avris Date: Thu, 29 Jul 2021 23:40:55 +0200 Subject: [PATCH] #230 [pl][terms] multiple categories for terms glossary --- components/InclusiveDictionary.vue | 16 ++++---- components/TermsDictionary.vue | 42 +++++++++++++++++++- components/TermsSubmitForm.vue | 20 +++++----- locale/pl/config.suml | 1 - migrations/033-terms-multiple-categories.sql | 7 ++++ server/routes/terms.js | 2 +- src/classes.js | 6 ++- 7 files changed, 73 insertions(+), 21 deletions(-) create mode 100644 migrations/033-terms-multiple-categories.sql diff --git a/components/InclusiveDictionary.vue b/components/InclusiveDictionary.vue index 93942c48..e1990a5e 100644 --- a/components/InclusiveDictionary.vue +++ b/components/InclusiveDictionary.vue @@ -21,7 +21,7 @@ nouns.submit.action -
+
+
+ +
@@ -43,6 +51,14 @@

+ +

@@ -62,6 +78,14 @@

+ +
@@ -283,4 +307,20 @@ .flag { height: 96px; } + + @include media-breakpoint-up('md', $grid-breakpoints) { + .text-filter { + * { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + } + } + } + .category-filter { + margin-top: -1px; + .btn { + border-top-left-radius: 0; + border-top-right-radius: 0; + } + } diff --git a/components/TermsSubmitForm.vue b/components/TermsSubmitForm.vue index 9df23585..6e29c405 100644 --- a/components/TermsSubmitForm.vue +++ b/components/TermsSubmitForm.vue @@ -39,13 +39,13 @@
- - + + + {{ category }} +
@@ -102,7 +102,7 @@ term: [''], original: [], definition: '', - category: '', + categories: [], flags: [], images: [], base: null, @@ -122,7 +122,7 @@ term: [''], original: [], definition: '', - category: '', + categories: [], flags: [], images: [], base: null, @@ -136,7 +136,7 @@ term: word.term, original: word.original, definition: word.definition, - category: word.category, + categories: word.categories, flags: word.flags, images: word.images, base: word.id, diff --git a/locale/pl/config.suml b/locale/pl/config.suml index 2b912b5e..2a6f4580 100644 --- a/locale/pl/config.suml +++ b/locale/pl/config.suml @@ -93,7 +93,6 @@ nouns: - 'orientacja seksualna' - 'orientacja romantyczna' - 'orientacja tertiarna' - - 'określenie orientacji romantycznej i seksualnej' - 'płeć' - 'ekspresja płciowa' - 'model relacji' diff --git a/migrations/033-terms-multiple-categories.sql b/migrations/033-terms-multiple-categories.sql new file mode 100644 index 00000000..e938e05f --- /dev/null +++ b/migrations/033-terms-multiple-categories.sql @@ -0,0 +1,7 @@ +-- Up + +UPDATE terms SET category = 'orientacja seksualna,orientacja romantyczna' WHERE category='określenie orientacji romantycznej i seksualnej'; + +-- Down + +UPDATE terms SET category = 'określenie orientacji romantycznej i seksualnej' WHERE category='orientacja seksualna,orientacja romantyczna'; diff --git a/server/routes/terms.js b/server/routes/terms.js index 208e0ac7..c5cdf3b5 100644 --- a/server/routes/terms.js +++ b/server/routes/terms.js @@ -63,7 +63,7 @@ router.post('/terms/submit', handleErrorAsync(async (req, res) => { ${id}, ${req.body.term.join('|')}, ${req.body.original.join('|')}, ${req.body.definition}, 0, ${req.body.base}, ${global.config.locale}, ${req.user ? req.user.id : null}, - ${req.body.category}, ${JSON.stringify(req.body.flags)}, ${req.body.images} + ${req.body.categories.join(',')}, ${JSON.stringify(req.body.flags)}, ${req.body.images} ) `); diff --git a/src/classes.js b/src/classes.js index 61910aa5..1414c6d4 100644 --- a/src/classes.js +++ b/src/classes.js @@ -725,7 +725,7 @@ export class TermsEntry { this.original = original ? original.split('|') : []; this.definition = definition; this.author = author; - this.category = category; + this.categories = category ? category.split(',') : []; this.flags = JSON.parse(flags); this.images = images ? images.split(',') : []; this.approved = !!approved; @@ -737,6 +737,10 @@ export class TermsEntry { return true; } + if (filter.startsWith(':')) { + return this.categories.includes(filter.substring(1)); + } + for (let field of ['term', 'original']) { for (let value of this[field]) { if (value.toLowerCase().indexOf(filter.toLowerCase()) > -1) {