aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-08-29 14:53:27 +0200
committerGitHub <noreply@github.com>2022-08-29 14:53:27 +0200
commitd7deeb4e02121e2b4f07b4b02c9c6fc7fd70b137 (patch)
tree8b698aaa2fb11c3805b935685e9ad27bed68eb6c /apps
parent1b577d348b32149b06493dd860a937ec8b7a6cc2 (diff)
parentd7821f8474be0146b9ac67d130f497bcb776ed9e (diff)
downloadnextcloud-server-d7deeb4e02121e2b4f07b4b02c9c6fc7fd70b137.tar.gz
nextcloud-server-d7deeb4e02121e2b4f07b4b02c9c6fc7fd70b137.zip
Merge pull request #33311 from nextcloud/enh/27869/phone
Remake phone number property saving with Vue
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/js/federationsettingsview.js3
-rw-r--r--apps/settings/lib/Settings/Personal/PersonalInfo.php3
-rw-r--r--apps/settings/src/components/PersonalInfo/PhoneSection.vue59
-rw-r--r--apps/settings/src/main-personal-info.js3
-rw-r--r--apps/settings/templates/settings/personal/personal.info.php15
5 files changed, 66 insertions, 17 deletions
diff --git a/apps/settings/js/federationsettingsview.js b/apps/settings/js/federationsettingsview.js
index 98659ac8f5c..a4a1a31223e 100644
--- a/apps/settings/js/federationsettingsview.js
+++ b/apps/settings/js/federationsettingsview.js
@@ -133,7 +133,8 @@
field === 'displayname' ||
field === 'twitter' ||
field === 'address' ||
- field === 'website'
+ field === 'website' ||
+ field === 'phone'
) {
return;
}
diff --git a/apps/settings/lib/Settings/Personal/PersonalInfo.php b/apps/settings/lib/Settings/Personal/PersonalInfo.php
index 4484433bacf..11d3f8b1e09 100644
--- a/apps/settings/lib/Settings/Personal/PersonalInfo.php
+++ b/apps/settings/lib/Settings/Personal/PersonalInfo.php
@@ -147,8 +147,6 @@ class PersonalInfo implements ISettings {
'federationEnabled' => $federationEnabled,
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
- 'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
- 'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
'groups' => $this->getGroups($user),
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
@@ -158,6 +156,7 @@ class PersonalInfo implements ISettings {
'userId' => $uid,
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
'emailMap' => $this->getEmailMap($account),
+ 'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
diff --git a/apps/settings/src/components/PersonalInfo/PhoneSection.vue b/apps/settings/src/components/PersonalInfo/PhoneSection.vue
new file mode 100644
index 00000000000..45641cd8e14
--- /dev/null
+++ b/apps/settings/src/components/PersonalInfo/PhoneSection.vue
@@ -0,0 +1,59 @@
+<!--
+ - @copyright 2022 Christopher Ng <chrng8@gmail.com>
+ -
+ - @author Christopher Ng <chrng8@gmail.com>
+ -
+ - @license AGPL-3.0-or-later
+ -
+ - This program is free software: you can redistribute it and/or modify
+ - it under the terms of the GNU Affero General Public License as
+ - published by the Free Software Foundation, either version 3 of the
+ - License, or (at your option) any later version.
+ -
+ - This program is distributed in the hope that it will be useful,
+ - but WITHOUT ANY WARRANTY; without even the implied warranty of
+ - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ - GNU Affero General Public License for more details.
+ -
+ - You should have received a copy of the GNU Affero General Public License
+ - along with this program. If not, see <http://www.gnu.org/licenses/>.
+ -
+-->
+
+<template>
+ <AccountPropertySection v-bind.sync="phone"
+ :placeholder="t('settings', 'Your phone number')"
+ type="tel"
+ :on-validate="onValidate" />
+</template>
+
+<script>
+import { isValidPhoneNumber } from 'libphonenumber-js'
+import { loadState } from '@nextcloud/initial-state'
+
+import AccountPropertySection from './shared/AccountPropertySection.vue'
+
+import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
+
+const { phone } = loadState('settings', 'personalInfoParameters', {})
+
+export default {
+ name: 'PhoneSection',
+
+ components: {
+ AccountPropertySection,
+ },
+
+ data() {
+ return {
+ phone: { ...phone, readable: NAME_READABLE_ENUM[phone.name] },
+ }
+ },
+
+ methods: {
+ onValidate(value) {
+ return isValidPhoneNumber(value)
+ },
+ },
+}
+</script>
diff --git a/apps/settings/src/main-personal-info.js b/apps/settings/src/main-personal-info.js
index 1b6d56a262a..32d8bfc8b45 100644
--- a/apps/settings/src/main-personal-info.js
+++ b/apps/settings/src/main-personal-info.js
@@ -28,6 +28,7 @@ import '@nextcloud/dialogs/styles/toast.scss'
import DisplayNameSection from './components/PersonalInfo/DisplayNameSection.vue'
import EmailSection from './components/PersonalInfo/EmailSection/EmailSection.vue'
+import PhoneSection from './components/PersonalInfo/PhoneSection.vue'
import LocationSection from './components/PersonalInfo/LocationSection.vue'
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
@@ -51,6 +52,7 @@ Vue.mixin({
const DisplayNameView = Vue.extend(DisplayNameSection)
const EmailView = Vue.extend(EmailSection)
+const PhoneView = Vue.extend(PhoneSection)
const LocationView = Vue.extend(LocationSection)
const WebsiteView = Vue.extend(WebsiteSection)
const TwitterView = Vue.extend(TwitterSection)
@@ -58,6 +60,7 @@ const LanguageView = Vue.extend(LanguageSection)
new DisplayNameView().$mount('#vue-displayname-section')
new EmailView().$mount('#vue-email-section')
+new PhoneView().$mount('#vue-phone-section')
new LocationView().$mount('#vue-location-section')
new WebsiteView().$mount('#vue-website-section')
new TwitterView().$mount('#vue-twitter-section')
diff --git a/apps/settings/templates/settings/personal/personal.info.php b/apps/settings/templates/settings/personal/personal.info.php
index b379400c14b..9c18ec71d4a 100644
--- a/apps/settings/templates/settings/personal/personal.info.php
+++ b/apps/settings/templates/settings/personal/personal.info.php
@@ -120,20 +120,7 @@ script('settings', [
<div id="vue-email-section"></div>
</div>
<div class="personal-settings-setting-box">
- <form id="phoneform" class="section">
- <h3>
- <label for="phone"><?php p($l->t('Phone number')); ?></label>
- <a href="#" class="federation-menu" aria-label="<?php p($l->t('Change privacy level of phone number')); ?>">
- <span class="icon-federation-menu icon-password">
- <span class="icon-triangle-s"></span>
- </span>
- </a>
- </h3>
- <input type="tel" id="phone" name="phone" value="<?php p($_['phone']) ?>" placeholder="<?php p($l->t('Your phone number')); ?>" autocomplete="on" autocapitalize="none" autocorrect="off" />
- <span class="icon-checkmark hidden"></span>
- <span class="icon-error hidden"></span>
- <input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>">
- </form>
+ <div id="vue-phone-section"></div>
</div>
<div class="personal-settings-setting-box">
<div id="vue-location-section"></div>