[inclusive] clarification

This commit is contained in:
Andrea 2022-05-20 14:29:18 +02:00
parent da1fd91a00
commit cc7ccf2435
6 changed files with 44 additions and 8 deletions

View File

@ -54,6 +54,10 @@
<li v-for="w in s.el.insteadOf" class="text-strike"><LinkedText :text="w" noicons/></li> <li v-for="w in s.el.insteadOf" class="text-strike"><LinkedText :text="w" noicons/></li>
</ul> </ul>
<div v-if="s.el.clarification" class="alert alert-warning px-2 py-1 small">
<LinkedText :text="s.el.clarification"/>
</div>
<ul class="list-inline"> <ul class="list-inline">
<li v-for="category in s.el.categories" class="list-inline-item"> <li v-for="category in s.el.categories" class="list-inline-item">
<a :href="`#:${category}`" class="badge bg-primary text-white" @click.prevent="filter = ':' + category"> <a :href="`#:${category}`" class="badge bg-primary text-white" @click.prevent="filter = ':' + category">

View File

@ -20,6 +20,14 @@
<T>inclusive.insteadOf</T> <T>inclusive.insteadOf</T>
</strong></label> </strong></label>
<NounForm v-model="form.insteadOf" maxlength="128"/> <NounForm v-model="form.insteadOf" maxlength="128"/>
<div class="mt-2">
<label>
<input class="form-check-input" type="checkbox" v-model="clarification">
<T>inclusive.clarification</T>
</label>
<input class="form-control" v-model="form.clarification" v-show="clarification"/>
</div>
</div> </div>
</div> </div>
<div class="col-12 col-lg-6"> <div class="col-12 col-lg-6">
@ -95,10 +103,12 @@
because: '', because: '',
categories: [], categories: [],
links: [], links: [],
clarification: null,
base: null, base: null,
}, },
submitting: false, submitting: false,
afterSubmit: false, afterSubmit: false,
clarification: false,
} }
}, },
methods: { methods: {
@ -113,8 +123,10 @@
because: '', because: '',
categories: [], categories: [],
links: [], links: [],
clarification: null,
base: null, base: null,
}; };
this.clarification = false;
} finally { } finally {
this.submitting = false; this.submitting = false;
} }
@ -126,11 +138,22 @@
because: word.because, because: word.because,
categories: word.categories, categories: word.categories,
links: word.links, links: word.links,
clarification: word.clarification,
base: word.id, base: word.id,
} }
this.clarification = !!word.clarification;
this.afterSubmit = false; this.afterSubmit = false;
this.$el.scrollIntoView(); this.$el.scrollIntoView();
} }
}, },
watch: {
clarification(v) {
if (v) {
this.form.clarification = this.$t('inclusive.clarificationDefault');
} else {
this.form.clarification = null;
}
}
},
}; };
</script> </script>

View File

@ -334,6 +334,8 @@ inclusive:
jakich konstrukcji lepiej unikać i dlatego, oraz czym je zastępować. jakich konstrukcji lepiej unikać i dlatego, oraz czym je zastępować.
categories: 'Kategorie' categories: 'Kategorie'
sources: 'Linki źródłowe' sources: 'Linki źródłowe'
clarification: 'Załącz wyjaśnienie'
clarificationDefault: 'Chodzi oczywiście o użycie w tym pejoratywnym znaczeniu. Nie mówimy, żeby zupełnie nie używać tego słowa.'
terminology: terminology:
header: 'Terminologia' header: 'Terminologia'

View File

@ -0,0 +1,6 @@
-- Up
ALTER TABLE inclusive ADD COLUMN clarification TEXT NULL;
-- Down

View File

@ -59,12 +59,12 @@ router.post('/inclusive/submit', handleErrorAsync(async (req, res) => {
const id = ulid(); const id = ulid();
await req.db.get(SQL` await req.db.get(SQL`
INSERT INTO inclusive (id, insteadOf, say, because, approved, base_id, locale, author_id, categories, links) INSERT INTO inclusive (id, insteadOf, say, because, approved, base_id, locale, author_id, categories, links, clarification)
VALUES ( VALUES (
${id}, ${id},
${req.body.insteadOf.join('|')}, ${req.body.say.join('|')}, ${req.body.because}, ${req.body.insteadOf.join('|')}, ${req.body.say.join('|')}, ${req.body.because},
0, ${req.body.base}, ${global.config.locale}, ${req.user ? req.user.id : null}, 0, ${req.body.base}, ${global.config.locale}, ${req.user ? req.user.id : null},
${req.body.categories.join(',')}, ${JSON.stringify(req.body.links)} ${req.body.categories.join(',')}, ${JSON.stringify(req.body.links)}, ${req.body.clarification || null}
) )
`); `);

View File

@ -715,7 +715,7 @@ export class NounDeclension {
export class InclusiveEntry { export class InclusiveEntry {
constructor({id, insteadOf, say, because, author, approved = true, base_id = null, categories = '', links = '[]'}) { constructor({id, insteadOf, say, because, author, approved = true, base_id = null, categories = '', links = '[]', clarification = null}) {
this.id = id; this.id = id;
this.insteadOf = insteadOf.split('|'); this.insteadOf = insteadOf.split('|');
this.say = say.split('|'); this.say = say.split('|');
@ -725,6 +725,7 @@ export class InclusiveEntry {
this.base = base_id; this.base = base_id;
this.categories = categories ? categories.split(',') : []; this.categories = categories ? categories.split(',') : [];
this.links = JSON.parse(links); this.links = JSON.parse(links);
this.clarification = clarification || null;
} }
matches(filter) { matches(filter) {