diff --git a/components/Login.vue b/components/Login.vue index e86715c6..992ba3b7 100644 --- a/components/Login.vue +++ b/components/Login.vue @@ -12,7 +12,7 @@
-
diff --git a/components/PropagateCheckbox.vue b/components/PropagateCheckbox.vue new file mode 100644 index 00000000..c9cb54c1 --- /dev/null +++ b/components/PropagateCheckbox.vue @@ -0,0 +1,37 @@ + + + diff --git a/locale/_base/translations.suml b/locale/_base/translations.suml index 93d6876d..7a6e4587 100644 --- a/locale/_base/translations.suml +++ b/locale/_base/translations.suml @@ -551,6 +551,7 @@ profile: header: 'Card editor' save: 'Save your card' defaults: 'Restore defaults' + propagate: 'Propagate this change to your cards in all languages' opinion: yes: 'Yes' jokingly: 'Jokingly' diff --git a/locale/de/translations.suml b/locale/de/translations.suml index 54c06830..8698f50c 100644 --- a/locale/de/translations.suml +++ b/locale/de/translations.suml @@ -443,6 +443,7 @@ profile: header: 'Visitenkarte-Editor' save: 'Visitenkarte speichern' defaults: 'Standardwerte wiederherstellen' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Ja' jokingly: 'Scherzhaft' diff --git a/locale/en/translations.suml b/locale/en/translations.suml index 4ab8f40e..ede1fcf4 100644 --- a/locale/en/translations.suml +++ b/locale/en/translations.suml @@ -552,6 +552,7 @@ profile: header: 'Card editor' save: 'Save your card' defaults: 'Restore defaults' + propagate: 'Propagate this change to your cards in all languages' opinion: yes: 'Yes' jokingly: 'Jokingly' diff --git a/locale/es/translations.suml b/locale/es/translations.suml index dd73d8ef..93446b6d 100644 --- a/locale/es/translations.suml +++ b/locale/es/translations.suml @@ -456,6 +456,7 @@ profile: header: 'Editor de tarjetas' save: 'Guarda tu tarjeta' defaults: 'Restaurar valores predeterminados' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Sí' jokingly: 'En broma' diff --git a/locale/fr/translations.suml b/locale/fr/translations.suml index 247d18a1..9e5f388b 100644 --- a/locale/fr/translations.suml +++ b/locale/fr/translations.suml @@ -449,6 +449,7 @@ profile: header: 'Éditeur de carte' save: 'Sauvegarder votre carte' defaults: 'Restaurer les valeurs par défaut' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Oui' jokingly: 'Pour plaisanter' diff --git a/locale/gl/translations.suml b/locale/gl/translations.suml index 4eae49ca..be79e8d9 100644 --- a/locale/gl/translations.suml +++ b/locale/gl/translations.suml @@ -455,6 +455,7 @@ profile: header: 'Editor de cartões' save: 'Salve o cartão' defaults: 'Restaurar valores padrão' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Sim' jokingly: 'É brincadeira' diff --git a/locale/ja/translations.suml b/locale/ja/translations.suml index a963b184..8a453426 100644 --- a/locale/ja/translations.suml +++ b/locale/ja/translations.suml @@ -457,6 +457,7 @@ profile: header: 'カード編集' save: 'カード保存' defaults: '既定に復元' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: '好き' jokingly: '冗談っぽく' diff --git a/locale/nl/translations.suml b/locale/nl/translations.suml index a9bb5d84..ed53ab2f 100644 --- a/locale/nl/translations.suml +++ b/locale/nl/translations.suml @@ -449,6 +449,7 @@ profile: header: 'Kaart editor' save: 'Sla jouw kaart op' defaults: 'Zet terug naar standaardwaarden' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Ja' jokingly: 'Voor de grap' diff --git a/locale/no/translations.suml b/locale/no/translations.suml index 93fb8e51..a51eaa19 100644 --- a/locale/no/translations.suml +++ b/locale/no/translations.suml @@ -453,6 +453,7 @@ profile: header: 'Kort redigerer' save: 'Lagre kort' defaults: 'Restaurer originale' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Ja' jokingly: 'På tull' diff --git a/locale/pl/translations.suml b/locale/pl/translations.suml index aa9c9af9..1b3a7654 100644 --- a/locale/pl/translations.suml +++ b/locale/pl/translations.suml @@ -1245,6 +1245,7 @@ profile: header: 'Edytor wizytówki' save: 'Zapisz wizytówkę' defaults: 'Przywróć domyślne' + propagate: 'Zapisz tę zmianę we wszystkich swoich wizytówkach, w każdym języku' opinion: yes: 'Tak' jokingly: 'Żartobliwie' diff --git a/locale/pt/translations.suml b/locale/pt/translations.suml index cc6ca813..4333f12b 100644 --- a/locale/pt/translations.suml +++ b/locale/pt/translations.suml @@ -451,6 +451,7 @@ profile: header: 'Editor de cartões' save: 'Salve o cartão' defaults: 'Restaurar valores padrão' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Sim' jokingly: 'É brincadeira' @@ -626,7 +627,7 @@ terms: Oi! Lhe escrevemos para informar que atualizámos nossos termos de serviço. changes: - > - Em janeiro vamos começar a vamos deletar em breve as contas não usadas para previr a acumulação dos nomes + Em janeiro vamos começar a vamos deletar em breve as contas não usadas para previr a acumulação dos nomes (quando não há nem carta nem entrada por um mês). - > Gostávamos de oferecer um espaço seguro para toda a gente queer independentemente de sua idade @@ -640,7 +641,7 @@ terms: Todas estas traduções são auxiliares, a versão inglesa continua sendo a única juricamente vinculativa. - > Apesar de queerfobia, transfobia, exclusionismo queer e trolling - sempre terem sido compreendidos como infrangimentos de Termos de Serviço como «infringir as regras sociais», + sempre terem sido compreendidos como infrangimentos de Termos de Serviço como «infringir as regras sociais», daqui por diante enlistamos todas elas como proibidas. admin: diff --git a/locale/ru/translations.suml b/locale/ru/translations.suml index 57f6e389..2c64b244 100644 --- a/locale/ru/translations.suml +++ b/locale/ru/translations.suml @@ -482,6 +482,7 @@ profile: header: 'Редактор карточек' save: 'Сохранить Вашу карточку' defaults: 'Вернуть слова по умолчанию' + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'Да' jokingly: 'В шутку' diff --git a/locale/yi/translations.suml b/locale/yi/translations.suml index a4d5113e..4b1c681a 100644 --- a/locale/yi/translations.suml +++ b/locale/yi/translations.suml @@ -456,6 +456,7 @@ profile: header: 'רעדאַקציע פון די װיזיט־⁠קאַרטל' save: 'Save your card' defaults: 'Restore defaults' # TODO + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: 'יאָ' jokingly: 'אין אַ שפּאַס' diff --git a/locale/zh/translations.suml b/locale/zh/translations.suml index e40aac20..f77e24cf 100644 --- a/locale/zh/translations.suml +++ b/locale/zh/translations.suml @@ -435,6 +435,7 @@ profile: header: '卡編輯' save: '保存卡' defaults: 'Restore defaults' # TODO + propagate: 'Propagate this change to your cards in all languages' # TODO opinion: yes: '至愛' jokingly: '諧謔' diff --git a/routes/profileEditor.vue b/routes/profileEditor.vue index db18adb8..8d6c95c7 100644 --- a/routes/profileEditor.vue +++ b/routes/profileEditor.vue @@ -30,6 +30,7 @@
+

@@ -44,6 +45,7 @@
+
@@ -96,6 +98,7 @@ profile.names +
@@ -131,6 +134,7 @@ +
@@ -140,7 +144,7 @@
- + @@ -152,6 +156,7 @@ +

profile.linksRecommended @@ -179,6 +184,7 @@

+
@@ -223,6 +229,73 @@ } })) + const buildProfile = (profiles, currentLocale) => { + for (let locale in profiles) { + if (!profiles.hasOwnProperty(locale)) { + continue; + } + if (locale === currentLocale) { + const profile = profiles[locale]; + return { + names: dictToList(profile.names), + pronouns: dictToList(profile.pronouns), + description: profile.description, + birthday: profile.birthday, + links: Object.keys(profile.links).length ? profile.links : [], + flags: profile.flags, + customFlags: profile.customFlags, + words: profile.words.map(x => dictToList(x)), + teamName: profile.teamName, + footerName: profile.footerName, + footerAreas: profile.footerAreas, + credentials: profile.credentials, + credentialsLevel: profile.credentialsLevel, + credentialsName: profile.credentialsName, + }; + } + } + + for (let locale in profiles) { + if (!profiles.hasOwnProperty(locale)) { + continue; + } + const profile = profiles[locale]; + return { + names: dictToList(profile.names), + pronouns: [], + description: '', + birthday: profile.birthday, + links: Object.keys(profile.links).length ? profile.links : [], + flags: profile.flags.filter(f => !f.startsWith('-')), + customFlags: profile.customFlags, + words: [...defaultWords], + teamName: profile.teamName, + footerName: profile.footerName, + footerAreas: [], + credentials: [], + credentialsLevel: null, + credentialsName: null, + }; + } + + return { + names: [], + pronouns: [], + description: '', + birthday: null, + links: [], + flags: [], + customFlags: {}, + words: [...defaultWords], + teamName: '', + footerName: '', + footerAreas: [], + credentials: [], + credentialsLevel: null, + credentialsName: null, + }; + }; + export default { mixins: [link], data() { @@ -232,6 +305,7 @@ to: minBirthdate, from: maxBirthdate, }, + propagate: [], }; }, async asyncData({ app, store }) { @@ -243,69 +317,12 @@ authorization: 'Bearer ' + store.state.token, } })).profiles; - for (let locale in profiles) { - if (!profiles.hasOwnProperty(locale)) { - continue; - } - if (locale === app.context.env.LOCALE) { - const profile = profiles[locale]; - return { - names: dictToList(profile.names), - pronouns: dictToList(profile.pronouns), - description: profile.description, - birthday: profile.birthday, - links: Object.keys(profile.links).length ? profile.links : [], - flags: profile.flags, - customFlags: profile.customFlags, - words: profile.words.map(x => dictToList(x)), - teamName: profile.teamName, - footerName: profile.footerName, - footerAreas: profile.footerAreas, - credentials: profile.credentials, - credentialsLevel: profile.credentialsLevel, - credentialsName: profile.credentialsName, - }; - } - } - - for (let locale in profiles) { - if (!profiles.hasOwnProperty(locale)) { - continue; - } - const profile = profiles[locale]; - return { - names: dictToList(profile.names), - pronouns: [], - description: '', - birthday: profile.birthday, - links: Object.keys(profile.links).length ? profile.links : [], - flags: profile.flags.filter(f => !f.startsWith('-')), - customFlags: profile.customFlags, - words: [...defaultWords], - teamName: profile.teamName, - footerName: profile.footerName, - footerAreas: [], - credentials: [], - credentialsLevel: null, - credentialsName: null, - }; - } + const profile = buildProfile(profiles, app.context.env.LOCALE); return { - names: [], - pronouns: [], - description: '', - birthday: null, - links: [], - flags: [], - customFlags: {}, - words: [...defaultWords], - teamName: '', - footerName: '', - footerAreas: [], - credentials: [], - credentialsLevel: null, - credentialsName: null, + ...profile, + beforeChanges: JSON.parse(JSON.stringify(profile)), + otherProfiles: Object.keys(profiles).filter(l => l !== app.context.env.LOCALE).length, }; }, mounted() { @@ -327,12 +344,15 @@ flags: [...this.flags], customFlags: {...this.customFlags}, words: this.words.map(x => listToDict(x)), + teamName: this.teamName, footerName: this.footerName, footerAreas: this.footerAreas, credentials: this.credentials, credentialsLevel: this.credentialsLevel, credentialsName: this.credentialsName, + + propagate: this.propagate, }); this.$router.push(`/@${this.$user().username}`); } finally { @@ -365,7 +385,13 @@ await this.$confirm(); this.words = [...defaultWords]; - } + }, + propagateChanged(field, checked) { + this.propagate = this.propagate.filter(f => f !== field); + if (checked) { + this.propagate.push(field); + } + }, }, computed: { mainPronoun() { diff --git a/server/routes/profile.js b/server/routes/profile.js index 53828c57..f1d32d08 100644 --- a/server/routes/profile.js +++ b/server/routes/profile.js @@ -200,6 +200,62 @@ router.post('/profile/save', handleErrorAsync(async (req, res) => { )`); } + if ((req.body.propagate || []).includes('teamName')) { + await req.db.get(SQL`UPDATE profiles + SET teamName = ${req.isGranted() ? req.body.teamName || null : ''} + WHERE userId = ${req.user.id} AND teamName != '' AND teamName IS NOT NULL; + `); + } + + if ((req.body.propagate || []).includes('footerName')) { + await req.db.get(SQL`UPDATE profiles + SET footerName = ${req.isGranted() ? req.body.footerName || null : ''} + WHERE userId = ${req.user.id} AND footerName != '' AND footerName IS NOT NULL; + `); + } + + if ((req.body.propagate || []).includes('names')) { + await req.db.get(SQL`UPDATE profiles + SET names = ${JSON.stringify(req.body.names)} + WHERE userId = ${req.user.id}; + `); + } + + if ((req.body.propagate || []).includes('flags')) { + await req.db.get(SQL`UPDATE profiles + SET flags = ${JSON.stringify(req.body.flags)} + WHERE userId = ${req.user.id}; + `); + } + + if ((req.body.propagate || []).includes('customFlags')) { + await req.db.get(SQL`UPDATE profiles + customFlags = ${JSON.stringify(req.body.customFlags)} + WHERE userId = ${req.user.id}; + `); + } + + if ((req.body.propagate || []).includes('links')) { + await req.db.get(SQL`UPDATE profiles + SET links = ${JSON.stringify(req.body.links.filter(x => !!x))} + WHERE userId = ${req.user.id}; + `); + } + + if ((req.body.propagate || []).includes('links')) { + await req.db.get(SQL`UPDATE profiles + SET links = ${JSON.stringify(req.body.links.filter(x => !!x))} + WHERE userId = ${req.user.id}; + `); + } + + if ((req.body.propagate || []).includes('birthday')) { + await req.db.get(SQL`UPDATE profiles + SET birthday = ${sanitiseBirthday(req.body.birthday || null)} + WHERE userId = ${req.user.id}; + `); + } + const sus = [...isSuspicious(req.body)]; if (sus.length && !await hasAutomatedReports(req.db, req.user.id)) { await req.db.get(SQL`