Skip to content

Commit d7deeb4

Browse files
authored
Merge pull request #33311 from nextcloud/enh/27869/phone
Remake phone number property saving with Vue
2 parents 1b577d3 + d7821f8 commit d7deeb4

11 files changed

+84
-23
lines changed

apps/settings/js/federationsettingsview.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@
133133
field === 'displayname' ||
134134
field === 'twitter' ||
135135
field === 'address' ||
136-
field === 'website'
136+
field === 'website' ||
137+
field === 'phone'
137138
) {
138139
return;
139140
}

apps/settings/lib/Settings/Personal/PersonalInfo.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,6 @@ public function getForm(): TemplateResponse {
147147
'federationEnabled' => $federationEnabled,
148148
'lookupServerUploadEnabled' => $lookupServerUploadEnabled,
149149
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
150-
'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
151-
'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
152150
'groups' => $this->getGroups($user),
153151
'isFairUseOfFreePushService' => $this->isFairUseOfFreePushService(),
154152
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
@@ -158,6 +156,7 @@ public function getForm(): TemplateResponse {
158156
'userId' => $uid,
159157
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
160158
'emailMap' => $this->getEmailMap($account),
159+
'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
161160
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
162161
'website' => $this->getProperty($account, IAccountManager::PROPERTY_WEBSITE),
163162
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<!--
2+
- @copyright 2022 Christopher Ng <chrng8@gmail.com>
3+
-
4+
- @author Christopher Ng <chrng8@gmail.com>
5+
-
6+
- @license AGPL-3.0-or-later
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
23+
<template>
24+
<AccountPropertySection v-bind.sync="phone"
25+
:placeholder="t('settings', 'Your phone number')"
26+
type="tel"
27+
:on-validate="onValidate" />
28+
</template>
29+
30+
<script>
31+
import { isValidPhoneNumber } from 'libphonenumber-js'
32+
import { loadState } from '@nextcloud/initial-state'
33+
34+
import AccountPropertySection from './shared/AccountPropertySection.vue'
35+
36+
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
37+
38+
const { phone } = loadState('settings', 'personalInfoParameters', {})
39+
40+
export default {
41+
name: 'PhoneSection',
42+
43+
components: {
44+
AccountPropertySection,
45+
},
46+
47+
data() {
48+
return {
49+
phone: { ...phone, readable: NAME_READABLE_ENUM[phone.name] },
50+
}
51+
},
52+
53+
methods: {
54+
onValidate(value) {
55+
return isValidPhoneNumber(value)
56+
},
57+
},
58+
}
59+
</script>

apps/settings/src/main-personal-info.js

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import '@nextcloud/dialogs/styles/toast.scss'
2828

2929
import DisplayNameSection from './components/PersonalInfo/DisplayNameSection.vue'
3030
import EmailSection from './components/PersonalInfo/EmailSection/EmailSection.vue'
31+
import PhoneSection from './components/PersonalInfo/PhoneSection.vue'
3132
import LocationSection from './components/PersonalInfo/LocationSection.vue'
3233
import WebsiteSection from './components/PersonalInfo/WebsiteSection.vue'
3334
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
@@ -51,13 +52,15 @@ Vue.mixin({
5152

5253
const DisplayNameView = Vue.extend(DisplayNameSection)
5354
const EmailView = Vue.extend(EmailSection)
55+
const PhoneView = Vue.extend(PhoneSection)
5456
const LocationView = Vue.extend(LocationSection)
5557
const WebsiteView = Vue.extend(WebsiteSection)
5658
const TwitterView = Vue.extend(TwitterSection)
5759
const LanguageView = Vue.extend(LanguageSection)
5860

5961
new DisplayNameView().$mount('#vue-displayname-section')
6062
new EmailView().$mount('#vue-email-section')
63+
new PhoneView().$mount('#vue-phone-section')
6164
new LocationView().$mount('#vue-location-section')
6265
new WebsiteView().$mount('#vue-website-section')
6366
new TwitterView().$mount('#vue-twitter-section')

apps/settings/templates/settings/personal/personal.info.php

+1-14
Original file line numberDiff line numberDiff line change
@@ -120,20 +120,7 @@
120120
<div id="vue-email-section"></div>
121121
</div>
122122
<div class="personal-settings-setting-box">
123-
<form id="phoneform" class="section">
124-
<h3>
125-
<label for="phone"><?php p($l->t('Phone number')); ?></label>
126-
<a href="#" class="federation-menu" aria-label="<?php p($l->t('Change privacy level of phone number')); ?>">
127-
<span class="icon-federation-menu icon-password">
128-
<span class="icon-triangle-s"></span>
129-
</span>
130-
</a>
131-
</h3>
132-
<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" />
133-
<span class="icon-checkmark hidden"></span>
134-
<span class="icon-error hidden"></span>
135-
<input type="hidden" id="phonescope" value="<?php p($_['phoneScope']) ?>">
136-
</form>
123+
<div id="vue-phone-section"></div>
137124
</div>
138125
<div class="personal-settings-setting-box">
139126
<div id="vue-location-section"></div>

dist/core-common.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/core-common.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-info.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-personal-info.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"jquery-ui": "^1.13.2",
7070
"jquery-ui-dist": "^1.13.1",
7171
"jstimezonedetect": "^1.0.7",
72+
"libphonenumber-js": "^1.10.13",
7273
"lodash": "^4.17.21",
7374
"marked": "^4.0.14",
7475
"moment": "^2.29.2",

0 commit comments

Comments
 (0)