From f922b2fd7072ace8211467e3627f2a44a5c09fe3 Mon Sep 17 00:00:00 2001 From: Christopher Ng Date: Thu, 11 Aug 2022 05:54:08 +0000 Subject: Remake locale saving with Vue Signed-off-by: Christopher Ng --- .../PersonalInfo/LocaleSection/Locale.vue | 208 +++++++++++++++++++++ .../PersonalInfo/LocaleSection/LocaleSection.vue | 88 +++++++++ .../src/constants/AccountPropertyConstants.js | 2 + apps/settings/src/main-personal-info.js | 3 + apps/settings/src/utils/validate.js | 12 ++ 5 files changed, 313 insertions(+) create mode 100644 apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue create mode 100644 apps/settings/src/components/PersonalInfo/LocaleSection/LocaleSection.vue (limited to 'apps/settings/src') diff --git a/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue b/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue new file mode 100644 index 00000000000..2e3ad64e769 --- /dev/null +++ b/apps/settings/src/components/PersonalInfo/LocaleSection/Locale.vue @@ -0,0 +1,208 @@ + + + + + + + diff --git a/apps/settings/src/components/PersonalInfo/LocaleSection/LocaleSection.vue b/apps/settings/src/components/PersonalInfo/LocaleSection/LocaleSection.vue new file mode 100644 index 00000000000..61c98f3a27a --- /dev/null +++ b/apps/settings/src/components/PersonalInfo/LocaleSection/LocaleSection.vue @@ -0,0 +1,88 @@ + + + + + + + diff --git a/apps/settings/src/constants/AccountPropertyConstants.js b/apps/settings/src/constants/AccountPropertyConstants.js index 41dd7e023bd..17166d1305f 100644 --- a/apps/settings/src/constants/AccountPropertyConstants.js +++ b/apps/settings/src/constants/AccountPropertyConstants.js @@ -106,11 +106,13 @@ export const PROPERTY_READABLE_KEYS_ENUM = Object.freeze({ */ export const ACCOUNT_SETTING_PROPERTY_ENUM = Object.freeze({ LANGUAGE: 'language', + LOCALE: 'locale', }) /** Enum of account setting properties to human readable setting properties */ export const ACCOUNT_SETTING_PROPERTY_READABLE_ENUM = Object.freeze({ LANGUAGE: t('settings', 'Language'), + LOCALE: t('settings', 'Locale'), }) /** Enum of scopes */ diff --git a/apps/settings/src/main-personal-info.js b/apps/settings/src/main-personal-info.js index 077bad3b5f7..8342015c560 100644 --- a/apps/settings/src/main-personal-info.js +++ b/apps/settings/src/main-personal-info.js @@ -35,6 +35,7 @@ import LocationSection from './components/PersonalInfo/LocationSection.vue' import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue' import TwitterSection from './components/PersonalInfo/TwitterSection.vue' import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue' +import LocaleSection from './components/PersonalInfo/LocaleSection/LocaleSection.vue' import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue' import OrganisationSection from './components/PersonalInfo/OrganisationSection.vue' import RoleSection from './components/PersonalInfo/RoleSection.vue' @@ -61,6 +62,7 @@ const LocationView = Vue.extend(LocationSection) const WebsiteView = Vue.extend(WebsiteSection) const TwitterView = Vue.extend(TwitterSection) const LanguageView = Vue.extend(LanguageSection) +const LocaleView = Vue.extend(LocaleSection) new AvatarView().$mount('#vue-avatar-section') new DetailsView().$mount('#vue-details-section') @@ -71,6 +73,7 @@ new LocationView().$mount('#vue-location-section') new WebsiteView().$mount('#vue-website-section') new TwitterView().$mount('#vue-twitter-section') new LanguageView().$mount('#vue-language-section') +new LocaleView().$mount('#vue-locale-section') if (profileEnabledGlobally) { const ProfileView = Vue.extend(ProfileSection) diff --git a/apps/settings/src/utils/validate.js b/apps/settings/src/utils/validate.js index 7d0cf1d9e33..4ea95593fbc 100644 --- a/apps/settings/src/utils/validate.js +++ b/apps/settings/src/utils/validate.js @@ -74,6 +74,18 @@ export function validateLanguage(input) { && input.name !== undefined } +/** + * Validate the locale input + * + * @param {object} input the input + * @return {boolean} + */ +export function validateLocale(input) { + return input.code !== '' + && input.name !== '' + && input.name !== undefined +} + /** * Validate boolean input * -- cgit v1.2.3