[sources] spoiler checkbox

This commit is contained in:
Andrea 2022-02-28 13:07:39 +01:00
parent d71bf43a08
commit ab241275aa
24 changed files with 61 additions and 17 deletions

View File

@ -58,14 +58,22 @@
</span>
</li>
</ul>
<div v-if="source.images.length" class="source-images">
<ImageThumb v-for="image in source.images" :key="image" :id="image" class="m-2" size="8rem"/>
<div v-if="source.spoiler && !showSpoiler" class="py-3">
<button type="button" class="btn btn-outline-primary" @click="showSpoiler = true">
<Icon v="eye-slash"/>
<T>sources.submit.spoiler</T>
</button>
</div>
<div v-else>
<div v-if="source.images.length" class="source-images">
<ImageThumb v-for="image in source.images" :key="image" :id="image" class="m-2" size="8rem"/>
</div>
<ul v-if="source.fragments.length">
<li v-for="fragment in source.fragments" class="text-break">
<T>quotation.start</T><Spelling :text="addMarks(fragment.replace(/\n/g, '<br/>'))"></Spelling><T>quotation.end</T>
</li>
</ul>
</div>
<ul v-if="source.fragments.length">
<li v-for="fragment in source.fragments" class="text-break">
<T>quotation.start</T><Spelling :text="addMarks(fragment.replace(/\n/g, '<br/>'))"></Spelling><T>quotation.end</T>
</li>
</ul>
<div v-if="source.versions.length" class="my-3">
<p>
<button :class="['btn', versionsShown ? 'btn-primary' : 'btn-outline-primary', 'btn-sm']" @click="versionsShown = !versionsShown">
@ -104,6 +112,7 @@
pronounLibrary,
deleted: false,
versionsShown: false,
showSpoiler: false,
}
},
methods: {

View File

@ -51,6 +51,14 @@
<textarea v-model="s.val" class="form-control" rows="3" @keyup="s.update(s.val)" required></textarea>
</ListInput>
</div>
<div class="form-group">
<div class="form-check form-switch my-2">
<label>
<input class="form-check-input" type="checkbox" v-model="form.spoiler">
<T>sources.submit.spoiler</T>
</label>
</div>
</div>
<div class="form-group">
<label for="pronouns" class="required"><T>sources.submit.pronouns</T></label>
<p class="small text-muted mb-0">
@ -128,6 +136,7 @@
comment: '',
images: [],
link: '',
spoiler: false,
key: null,
base: null,
},
@ -158,6 +167,7 @@
comment: '',
images: [],
link: '',
spoiler: false,
key: null,
base: null,
}
@ -177,6 +187,7 @@
comment: source.comment,
images: source.images,
link: source.link,
spoiler: source.spoiler,
key: source.key,
base: source.id,
}

View File

@ -119,10 +119,10 @@ sources:
key: 'Key'
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary'
images: 'Images'
spoiler: 'Spoiler' # TODO
otherVersions: 'In other languages'
referenced: 'Examples of use'
nouns:
header: 'Dictionary'
headerLong: 'Dictionary of neutral nouns'

View File

@ -113,6 +113,7 @@ sources:
key: 'Schlüssel'
keyInfo: 'Kennzeichen, um Quellen zwischen Sprachversionen und dem Wörterbuch zu verbinden'
images: 'Bilder'
spoiler: 'Spoiler' # TODO
otherVersions: 'In anderen Sprachen'
referenced: 'Beispiele zur Benutzung'

View File

@ -120,10 +120,10 @@ sources:
key: 'Key'
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary'
images: 'Images'
spoiler: 'Spoiler'
otherVersions: 'In other languages'
referenced: 'Examples of use'
nouns:
header: 'Dictionary'
headerLong: 'Dictionary of neutral nouns'

View File

@ -107,6 +107,7 @@ sources:
key: 'Ŝlosilo'
keyInfo: 'Identigilo por ligi fontojn inter lingvoversiojn kaj ligado al la vortaro'
images: 'Bildoj'
spoiler: 'Spoiler' # TODO
otherVersions: 'En aliaj lingvoj'
referenced: 'Ekzemploj de uzo'

View File

@ -118,6 +118,7 @@ sources:
key: 'Clave'
keyInfo: 'Identificador para vincular fuentes entre versiones en varios idiomas y vincularlas con el diccionario'
images: 'Imágenes'
spoiler: 'Spoiler' # TODO
otherVersions: 'En otros idiomas'
referenced: 'Ejemplos del uso'

View File

@ -116,6 +116,7 @@ sources:
key: 'Key'
keyInfo: 'Identifiant pour relier les sources entre les versions linguistiques et établir des liens avec le dictionnaire'
images: 'Images'
spoiler: 'Spoiler' # TODO
otherVersions: 'Dans dautres langues'
referenced: 'Exemples dusage'

View File

@ -116,6 +116,7 @@ sources:
key: 'Chave'
keyInfo: 'Identificador para conectar fontes entre versões e conectar com dicionário'
images: 'Imagens'
spoiler: 'Spoiler' # TODO
otherVersions: 'Em outros idiomas'
referenced: 'Exemplos de uso'

View File

@ -119,6 +119,7 @@ sources:
key: 'Key'
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary'
images: 'Images'
spoiler: 'Spoiler' # TODO
otherVersions: 'In other languages'
referenced: 'Examples of use'

View File

@ -116,6 +116,7 @@ sources:
key: 'キー'
keyInfo: '言語間、及び辞書とリンクするのための識別子'
images: '画像'
spoiler: 'Spoiler' # TODO
otherVersions: '他の言語で'
referenced: '使用例'

View File

@ -118,6 +118,7 @@ sources:
key: '키'
keyInfo: '언어 버전 간 소스 연결 및 사전 연결 식별자'
images: '이미지'
spoiler: 'Spoiler' # TODO
otherVersions: '다른 언어'
referenced: '사용 예'

View File

@ -118,6 +118,7 @@ sources:
key: 'Yave'
keyInfo: 'Identifiador para atar fuentes entre versiones en varias linguas i atarlas kon el diksionaryo'
images: 'Imajes'
spoiler: 'Spoiler' # TODO
otherVersions: 'En otras linguas'
referenced: 'Enshemplos del uzo'

View File

@ -117,6 +117,7 @@ sources:
key: 'Sleutel'
keyInfo: 'Identifier om bronnen te linken tussen verschillende vertalingen van de website en om met het woordenboek te linken'
images: 'Afbeeldingen'
spoiler: 'Spoiler' # TODO
otherVersions: 'In andere talen'
referenced: 'Gebruiksvoorbeelden'

View File

@ -117,6 +117,7 @@ sources:
key: 'Nøkkel'
keyInfo: 'identifiserer for å linke kilder mellom språk versjoner og linker med ordboken'
images: 'Bilder'
spoiler: 'Spoiler' # TODO
otherVersions: 'På andre språk'
referenced: 'Eksempler på bruk i setninger'

View File

@ -132,6 +132,7 @@ sources:
key: 'Klucz'
keyInfo: 'Identyfikator do łączenia tekstów między wersjami językowymi i łączenia ze słownikiem'
images: 'Obrazki'
spoiler: 'Spoiler'
otherVersions: 'W innych językach'
referenced: 'Przykłady użycia'

View File

@ -117,6 +117,7 @@ sources:
key: 'Chave'
keyInfo: 'Identificador para conectar fontes entre versões e conectar com dicionário'
images: 'Imagens'
spoiler: 'Spoiler' # TODO
otherVersions: 'Em outros idiomas'
referenced: 'Exemplos de uso'

View File

@ -108,6 +108,7 @@ sources:
key: 'Ключ'
keyInfo: 'Идентификатор, используемый для связки источников из разных языковых версий и связки со словарём'
images: 'Изображения'
spoiler: 'Spoiler' # TODO
otherVersions: 'На других языках'
referenced: 'Примеры употребления'

View File

@ -120,6 +120,7 @@ sources:
key: 'Nyckel'
keyInfo: 'Identifierare för att länka källor mellan språkversioner och länka till ordbok'
images: 'Bilder'
spoiler: 'Spoiler' # TODO
otherVersions: 'På andra språk'
referenced: 'Exempel på användning'

View File

@ -116,6 +116,7 @@ sources:
key: 'Key'
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary'
images: 'Images'
spoiler: 'Spoiler' # TODO
otherVersions: 'In other languages'
referenced: 'Examples of use'

View File

@ -114,6 +114,7 @@ sources:
key: '键'
keyInfo: '用于在语言版本之间链接源并与字典链接的标识符'
images: '意象'
spoiler: 'Spoiler' # TODO
otherVersions: '在其他語言'
referenced: '榜樣'

View File

@ -0,0 +1,6 @@
-- Up
ALTER TABLE sources ADD COLUMN spoiler INTEGER NOT NULL DEFAULT 0;
-- Down

View File

@ -89,12 +89,12 @@ router.post('/sources/submit', handleErrorAsync(async (req, res) => {
const id = ulid();
await req.db.get(SQL`
INSERT INTO sources (id, locale, pronouns, type, author, title, extra, year, fragments, comment, link, key, images, submitter_id, base_id)
INSERT INTO sources (id, locale, pronouns, type, author, title, extra, year, fragments, comment, link, key, images, spoiler, submitter_id, base_id)
VALUES (
${id}, ${global.config.locale}, ${req.body.pronouns.join(';')},
${req.body.type}, ${req.body.author}, ${req.body.title}, ${req.body.extra}, ${req.body.year},
${req.body.fragments.join('@').replace(/\n/g, '|')}, ${req.body.comment}, ${req.body.link},
${clearKey(req.body.key)}, ${req.body.images || null},
${clearKey(req.body.key)}, ${req.body.images || null}, ${req.body.spoiler ? 1 : 0},
${req.user ? req.user.id : null}, ${req.body.base}
)
`);

View File

@ -101,7 +101,7 @@ function clone(mainObject) {
export class Source {
constructor ({
id, pronouns, type, author, title, extra, year, fragments = '',
comment = null, link = null,
comment = null, link = null, spoiler = false,
submitter = null, approved, base_id = null,
key = null, versions = [], locale = config.locale,
images = null,
@ -118,6 +118,7 @@ export class Source {
: [];
this.comment = comment;
this.link = link;
this.spoiler = !!spoiler;
this.submitter = submitter;
this.approved = approved;
this.base_id = base_id;