#161 [sources] save source key
This commit is contained in:
parent
2f74d42a17
commit
3b1b8f82d7
|
@ -51,6 +51,11 @@
|
||||||
{{p}}
|
{{p}}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="list-inline-item" v-if="source.key">
|
||||||
|
<span class="badge badge-primary">
|
||||||
|
<T>sources.submit.key</T>: {{source.key}}
|
||||||
|
</span>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul v-if="source.fragments.length">
|
<ul v-if="source.fragments.length">
|
||||||
<li v-for="fragment in source.fragments">
|
<li v-for="fragment in source.fragments">
|
||||||
|
|
|
@ -77,6 +77,12 @@
|
||||||
<input type="url" id="link" class="form-control" v-model="form.link"
|
<input type="url" id="link" class="form-control" v-model="form.link"
|
||||||
maxlength="255"/>
|
maxlength="255"/>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group" v-if="$isGranted('sources')">
|
||||||
|
<label for="key"><T>sources.submit.key</T></label>
|
||||||
|
<input type="text" id="key" class="form-control" v-model="form.key"
|
||||||
|
maxlength="255"/>
|
||||||
|
<p class="small text-muted"><T>sources.submit.keyInfo</T></p>
|
||||||
|
</div>
|
||||||
<div class="alert alert-info" v-if="form.base">
|
<div class="alert alert-info" v-if="form.base">
|
||||||
<Icon v="info-circle"/>
|
<Icon v="info-circle"/>
|
||||||
<T>nouns.editing</T>
|
<T>nouns.editing</T>
|
||||||
|
@ -110,6 +116,7 @@
|
||||||
fragments: [],
|
fragments: [],
|
||||||
comment: '',
|
comment: '',
|
||||||
link: '',
|
link: '',
|
||||||
|
key: null,
|
||||||
base: null,
|
base: null,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -136,6 +143,7 @@
|
||||||
fragments: [],
|
fragments: [],
|
||||||
comment: '',
|
comment: '',
|
||||||
link: '',
|
link: '',
|
||||||
|
key: null,
|
||||||
base: null,
|
base: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -150,6 +158,7 @@
|
||||||
fragments: source.fragments,
|
fragments: source.fragments,
|
||||||
comment: source.comment,
|
comment: source.comment,
|
||||||
link: source.link,
|
link: source.link,
|
||||||
|
key: source.key,
|
||||||
base: source.id,
|
base: source.id,
|
||||||
}
|
}
|
||||||
this.afterSubmit = false;
|
this.afterSubmit = false;
|
||||||
|
|
|
@ -94,6 +94,9 @@ sources:
|
||||||
thanks: 'Thanks for contributing!'
|
thanks: 'Thanks for contributing!'
|
||||||
another: 'Submit another one'
|
another: 'Submit another one'
|
||||||
moderation: 'Submissions will have to get approved before getting published.'
|
moderation: 'Submissions will have to get approved before getting published.'
|
||||||
|
key: 'Key'
|
||||||
|
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary'
|
||||||
|
|
||||||
|
|
||||||
nouns:
|
nouns:
|
||||||
header: 'Dictionary'
|
header: 'Dictionary'
|
||||||
|
|
|
@ -94,6 +94,8 @@ sources:
|
||||||
thanks: '¡Gracias por contribuir!'
|
thanks: '¡Gracias por contribuir!'
|
||||||
another: 'Enviar otro'
|
another: 'Enviar otro'
|
||||||
moderation: 'Los envíos deben ser aprobados antes de ser publicados.'
|
moderation: 'Los envíos deben ser aprobados antes de ser publicados.'
|
||||||
|
key: 'Key' # TODO
|
||||||
|
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary' # TODO
|
||||||
|
|
||||||
nouns:
|
nouns:
|
||||||
header: 'Diccionario'
|
header: 'Diccionario'
|
||||||
|
|
|
@ -193,6 +193,8 @@ sources:
|
||||||
thanks: 'Dziękujemy za zgłoszenie!'
|
thanks: 'Dziękujemy za zgłoszenie!'
|
||||||
another: 'Zgłoś kolejne źródło'
|
another: 'Zgłoś kolejne źródło'
|
||||||
moderation: 'Propozycje będą musiały zostać zatwierdzone przed opublikowaniem.'
|
moderation: 'Propozycje będą musiały zostać zatwierdzone przed opublikowaniem.'
|
||||||
|
key: 'Klucz'
|
||||||
|
keyInfo: 'Identyfikator do łączenia tekstów między wersjami językowymi i łączenia ze słownikiem'
|
||||||
|
|
||||||
nouns:
|
nouns:
|
||||||
header: 'Słowniki'
|
header: 'Słowniki'
|
||||||
|
|
|
@ -92,6 +92,8 @@ sources:
|
||||||
thanks: '感謝您的貢獻!'
|
thanks: '感謝您的貢獻!'
|
||||||
another: '提交另一個'
|
another: '提交另一個'
|
||||||
moderation: '提交的內容必須先獲得批准才能發布。'
|
moderation: '提交的內容必須先獲得批准才能發布。'
|
||||||
|
key: 'Key' # TODO
|
||||||
|
keyInfo: 'Identifier for linking sources between language versions and linking with the dictionary' # TODO
|
||||||
|
|
||||||
nouns:
|
nouns:
|
||||||
header: '字典'
|
header: '字典'
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
-- Up
|
||||||
|
|
||||||
|
ALTER TABLE sources ADD COLUMN key TEXT NULL DEFAULT NULL;
|
||||||
|
|
||||||
|
-- Down
|
|
@ -44,11 +44,11 @@ router.get('/sources/:id', async (req, res) => {
|
||||||
router.post('/sources/submit', async (req, res) => {
|
router.post('/sources/submit', async (req, res) => {
|
||||||
const id = ulid();
|
const id = ulid();
|
||||||
await req.db.get(SQL`
|
await req.db.get(SQL`
|
||||||
INSERT INTO sources (id, locale, pronouns, type, author, title, extra, year, fragments, comment, link, submitter_id, base_id)
|
INSERT INTO sources (id, locale, pronouns, type, author, title, extra, year, fragments, comment, link, key, submitter_id, base_id)
|
||||||
VALUES (
|
VALUES (
|
||||||
${id}, ${req.config.locale}, ${req.body.pronouns.join(';')},
|
${id}, ${req.config.locale}, ${req.body.pronouns.join(';')},
|
||||||
${req.body.type}, ${req.body.author}, ${req.body.title}, ${req.body.extra}, ${req.body.year},
|
${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},
|
${req.body.fragments.join('@').replace(/\n/g, '|')}, ${req.body.comment}, ${req.body.link}, ${req.body.key || null},
|
||||||
${req.user ? req.user.id : null}, ${req.body.base}
|
${req.user ? req.user.id : null}, ${req.body.base}
|
||||||
)
|
)
|
||||||
`);
|
`);
|
||||||
|
|
|
@ -99,7 +99,7 @@ function clone(mainObject) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Source {
|
export class Source {
|
||||||
constructor ({id, pronouns, type, author, title, extra, year, fragments = '', comment = null, link = null, submitter = null, approved, base_id = null,}) {
|
constructor ({id, pronouns, type, author, title, extra, year, fragments = '', comment = null, link = null, key = null, submitter = null, approved, base_id = null,}) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pronouns = pronouns ? pronouns.split(';') : [];
|
this.pronouns = pronouns ? pronouns.split(';') : [];
|
||||||
this.type = type;
|
this.type = type;
|
||||||
|
@ -110,6 +110,7 @@ export class Source {
|
||||||
this.fragments = fragments ? fragments.replace(/\|/g, '\n').split('@') : [];
|
this.fragments = fragments ? fragments.replace(/\|/g, '\n').split('@') : [];
|
||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
this.link = link;
|
this.link = link;
|
||||||
|
this.key = key;
|
||||||
this.submitter = submitter;
|
this.submitter = submitter;
|
||||||
this.approved = approved;
|
this.approved = approved;
|
||||||
this.base_id = base_id;
|
this.base_id = base_id;
|
||||||
|
|
Reference in New Issue