From 79d02bddbe2b77574844b8ade7a09043c31b1c6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?marcin=20miko=C5=82ajczak?=
Date: Sun, 13 Feb 2022 19:07:49 +0100
Subject: [PATCH 1/3] Birthdays
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: marcin mikołajczak
---
src/components/settings_modal/tabs/profile_tab.js | 6 +++++-
.../settings_modal/tabs/profile_tab.scss | 5 +++++
src/components/settings_modal/tabs/profile_tab.vue | 12 ++++++++++++
src/components/user_profile/user_profile.js | 11 +++++++++--
src/components/user_profile/user_profile.vue | 14 ++++++++++++++
src/i18n/en.json | 5 +++++
src/i18n/pl.json | 9 +++++++--
.../entity_normalizer/entity_normalizer.service.js | 3 +++
8 files changed, 60 insertions(+), 5 deletions(-)
diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js
index 64079fcd..0ae95dbd 100644
--- a/src/components/settings_modal/tabs/profile_tab.js
+++ b/src/components/settings_modal/tabs/profile_tab.js
@@ -29,6 +29,8 @@ const ProfileTab = {
newLocked: this.$store.state.users.currentUser.locked,
newNoRichText: this.$store.state.users.currentUser.no_rich_text,
newDefaultScope: this.$store.state.users.currentUser.default_scope,
+ newBirthday: this.$store.state.users.currentUser.birthday,
+ showBirthday: this.$store.state.users.currentUser.show_birthday,
newFields: this.$store.state.users.currentUser.fields.map(field => ({ name: field.name, value: field.value })),
hideFollows: this.$store.state.users.currentUser.hide_follows,
hideFollowers: this.$store.state.users.currentUser.hide_followers,
@@ -132,7 +134,9 @@ const ProfileTab = {
allow_following_move: this.allowFollowingMove,
hide_follows_count: this.hideFollowsCount,
hide_followers_count: this.hideFollowersCount,
- show_role: this.showRole
+ show_role: this.showRole,
+ birthday: this.newBirthday || null,
+ show_birthday: this.showBirthday
/* eslint-enable camelcase */
} }).then((user) => {
this.newFields.splice(user.fields.length)
diff --git a/src/components/settings_modal/tabs/profile_tab.scss b/src/components/settings_modal/tabs/profile_tab.scss
index 111eaed3..24287511 100644
--- a/src/components/settings_modal/tabs/profile_tab.scss
+++ b/src/components/settings_modal/tabs/profile_tab.scss
@@ -124,4 +124,9 @@
padding: 0 0.5em;
}
}
+
+ .birthday-input {
+ display: block;
+ margin-bottom: 1em;
+ }
}
diff --git a/src/components/settings_modal/tabs/profile_tab.vue b/src/components/settings_modal/tabs/profile_tab.vue
index bb3c301d..9b92056d 100644
--- a/src/components/settings_modal/tabs/profile_tab.vue
+++ b/src/components/settings_modal/tabs/profile_tab.vue
@@ -95,6 +95,18 @@
{{ $t('settings.discoverable') }}
+
{{ $t('settings.profile_fields.label') }}
+
+
+ {{ $t('user_card.birthday', { birthday: formattedBirthday }) }}
+
{
} else {
output.role = 'member'
}
+
+ output.birthday = data.pleroma.birthday
}
if (data.source) {
@@ -128,6 +130,7 @@ export const parseUser = (data) => {
output.no_rich_text = data.source.pleroma.no_rich_text
output.show_role = data.source.pleroma.show_role
output.discoverable = data.source.pleroma.discoverable
+ output.show_birthday = data.pleroma.show_birthday
}
}
From dd97a23ce70fc564d3142eb9d218ff1a929107b1 Mon Sep 17 00:00:00 2001
From: tusooa
Date: Sun, 22 Jan 2023 11:15:52 -0500
Subject: [PATCH 2/3] Add birthday to registration form
---
src/boot/after_store.js | 2 ++
src/components/registration/registration.js | 27 +++++++++++++++-
src/components/registration/registration.vue | 34 ++++++++++++++++++++
src/i18n/en.json | 8 +++--
src/modules/instance.js | 2 ++
5 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 1fa9dd2a..d2e7f488 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -60,6 +60,8 @@ const getInstanceConfig = async ({ store }) => {
store.dispatch('setInstanceOption', { name: 'textlimit', value: textlimit })
store.dispatch('setInstanceOption', { name: 'accountApprovalRequired', value: data.approval_required })
+ store.dispatch('setInstanceOption', { name: 'birthdayRequired', value: !!data.pleroma.metadata.birthday_required })
+ store.dispatch('setInstanceOption', { name: 'birthdayMinAge', value: data.pleroma.metadata.birthday_min_age || 0 })
if (vapidPublicKey) {
store.dispatch('setInstanceOption', { name: 'vapidPublicKey', value: vapidPublicKey })
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 6eb316d0..3139bdd2 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -3,6 +3,7 @@ import { required, requiredIf, sameAs } from '@vuelidate/validators'
import { mapActions, mapState } from 'vuex'
import InterfaceLanguageSwitcher from '../interface_language_switcher/interface_language_switcher.vue'
import localeService from '../../services/locale/locale.service.js'
+import { DAY } from 'src/services/date_utils/date_utils.js'
const registration = {
setup () { return { v$: useVuelidate() } },
@@ -13,6 +14,7 @@ const registration = {
username: '',
password: '',
confirm: '',
+ birthday: '',
reason: '',
language: ''
},
@@ -32,6 +34,12 @@ const registration = {
required,
sameAs: sameAs(this.user.password)
},
+ birthday: {
+ required: requiredIf(() => this.birthdayRequired),
+ maxValue: value => {
+ return !this.birthdayRequired || new Date(value).getTime() <= this.birthdayMin.getTime()
+ }
+ },
reason: { required: requiredIf(() => this.accountApprovalRequired) },
language: {}
}
@@ -52,6 +60,21 @@ const registration = {
reasonPlaceholder () {
return this.replaceNewlines(this.$t('registration.reason_placeholder'))
},
+ birthdayMin () {
+ const minAge = this.birthdayMinAge
+ const today = new Date()
+ today.setUTCMilliseconds(0)
+ today.setUTCSeconds(0)
+ today.setUTCMinutes(0)
+ today.setUTCHours(0)
+ const minDate = new Date()
+ minDate.setTime(today.getTime() - minAge * DAY)
+ return minDate
+ },
+ birthdayMinFormatted () {
+ const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
+ return this.user.birthday && new Date(Date.parse(this.birthdayMin)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' })
+ },
...mapState({
registrationOpen: (state) => state.instance.registrationOpen,
signedIn: (state) => !!state.users.currentUser,
@@ -59,7 +82,9 @@ const registration = {
serverValidationErrors: (state) => state.users.signUpErrors,
termsOfService: (state) => state.instance.tos,
accountActivationRequired: (state) => state.instance.accountActivationRequired,
- accountApprovalRequired: (state) => state.instance.accountApprovalRequired
+ accountApprovalRequired: (state) => state.instance.accountApprovalRequired,
+ birthdayRequired: (state) => state.instance.birthdayRequired,
+ birthdayMinAge: (state) => state.instance.birthdayMinAge
})
},
methods: {
diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue
index a26162f0..6d7fe76e 100644
--- a/src/components/registration/registration.vue
+++ b/src/components/registration/registration.vue
@@ -167,6 +167,40 @@
+
+
+
+
+
+
Date: Sun, 22 Jan 2023 11:22:24 -0500
Subject: [PATCH 3/3] Make date picker aware of the birthday max value
---
src/components/registration/registration.js | 3 +++
src/components/registration/registration.vue | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js
index 3139bdd2..22ca6ad6 100644
--- a/src/components/registration/registration.js
+++ b/src/components/registration/registration.js
@@ -71,6 +71,9 @@ const registration = {
minDate.setTime(today.getTime() - minAge * DAY)
return minDate
},
+ birthdayMinAttr () {
+ return this.birthdayMin.toJSON().replace(/T.+$/, '')
+ },
birthdayMinFormatted () {
const browserLocale = localeService.internalToBrowserLocale(this.$i18n.locale)
return this.user.birthday && new Date(Date.parse(this.birthdayMin)).toLocaleDateString(browserLocale, { timeZone: 'UTC', day: 'numeric', month: 'long', year: 'numeric' })
diff --git a/src/components/registration/registration.vue b/src/components/registration/registration.vue
index 6d7fe76e..5701b05e 100644
--- a/src/components/registration/registration.vue
+++ b/src/components/registration/registration.vue
@@ -183,7 +183,7 @@
:disabled="isPending"
class="form-control"
type="date"
- max="birthdayMin"
+ :max="birthdayRequired ? birthdayMinAttr : undefined"
:aria-required="birthdayRequired"
>