From 941579f4d3e55144ba6a9688d125ec07a71f71e1 Mon Sep 17 00:00:00 2001 From: Avris Date: Mon, 21 Dec 2020 19:33:41 +0100 Subject: [PATCH] #145 [terms] flags in glossary --- components/TermsDictionary.vue | 8 ++++++++ components/TermsSubmitForm.vue | 11 +++++++++++ migrations/013-terms-flags.sql | 6 ++++++ server/routes/terms.js | 5 +++-- src/classes.js | 3 ++- 5 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 migrations/013-terms-flags.sql diff --git a/components/TermsDictionary.vue b/components/TermsDictionary.vue index ed8fd5e8..24d92863 100644 --- a/components/TermsDictionary.vue +++ b/components/TermsDictionary.vue @@ -43,6 +43,10 @@ – {{s.el.definition}}

+

+ +

+

nouns.edited:

@@ -261,4 +265,8 @@ } } } + + .flag { + height: 96px; + } diff --git a/components/TermsSubmitForm.vue b/components/TermsSubmitForm.vue index da0f5f6b..f0bb40bd 100644 --- a/components/TermsSubmitForm.vue +++ b/components/TermsSubmitForm.vue @@ -39,10 +39,18 @@ + + + profile.flags + + + + +
nouns.editing @@ -73,6 +81,7 @@ term: [''], original: [], definition: '', + flags: [], base: null, }, submitting: false, @@ -90,6 +99,7 @@ term: [''], original: [], definition: '', + flags: [], base: null, }; }, @@ -98,6 +108,7 @@ term: word.term, original: word.original, definition: word.definition, + flags: word.flags, base: word.id, } this.afterSubmit = false; diff --git a/migrations/013-terms-flags.sql b/migrations/013-terms-flags.sql new file mode 100644 index 00000000..31744b4f --- /dev/null +++ b/migrations/013-terms-flags.sql @@ -0,0 +1,6 @@ +-- Up + +ALTER TABLE terms ADD COLUMN flags TEXT NOT NULL DEFAULT '[]'; + +-- Down + diff --git a/server/routes/terms.js b/server/routes/terms.js index 6e3dc1d6..1b1fffcd 100644 --- a/server/routes/terms.js +++ b/server/routes/terms.js @@ -52,11 +52,12 @@ router.post('/terms/submit', async (req, res) => { const id = ulid(); await req.db.get(SQL` - INSERT INTO terms (id, term, original, definition, approved, base_id, locale, author_id) + INSERT INTO terms (id, term, original, definition, approved, base_id, locale, author_id, flags) VALUES ( ${id}, ${req.body.term.join('|')}, ${req.body.original.join('|')}, ${req.body.definition}, - 0, ${req.body.base}, ${req.config.locale}, ${req.user ? req.user.id : null} + 0, ${req.body.base}, ${req.config.locale}, ${req.user ? req.user.id : null}, + ${JSON.stringify(req.body.flags)} ) `); diff --git a/src/classes.js b/src/classes.js index 7ae42e57..23c70b16 100644 --- a/src/classes.js +++ b/src/classes.js @@ -676,11 +676,12 @@ export class InclusiveEntry { } export class TermsEntry { - constructor({id, term, original, definition, approved = true, base_id = null}) { + constructor({id, term, original, definition, flags = '[]', approved = true, base_id = null}) { this.id = id; this.term = term.split('|'); this.original = original ? original.split('|') : []; this.definition = definition; + this.flags = JSON.parse(flags); this.approved = !!approved; this.base = base_id; }