Skip to content

Commit

Permalink
Remake phone number property saving with Vue
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Jul 21, 2022
1 parent 446b83f commit 9fcb6a6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
3 changes: 2 additions & 1 deletion apps/settings/js/federationsettingsview.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
field === 'avatar' ||
field === 'email' ||
field === 'displayname' ||
field === 'twitter'
field === 'twitter' ||
field === 'phone'
) {
return;
}
Expand Down
3 changes: 1 addition & 2 deletions apps/settings/lib/Settings/Personal/PersonalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public function getForm(): TemplateResponse {
'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(),
'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(),
'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(),
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
Expand All @@ -162,6 +160,7 @@ public function getForm(): TemplateResponse {
$personalInfoParameters = [
'userId' => $uid,
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
'phone' => $this->getProperty($account, IAccountManager::PROPERTY_PHONE),
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
'emailMap' => $this->getEmailMap($account),
'languageMap' => $this->getLanguageMap($user),
Expand Down
50 changes: 50 additions & 0 deletions apps/settings/src/components/PersonalInfo/PhoneSection.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!--
- @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 :property="phone"
:placeholder="t('settings', 'Your phone number')" />
</template>

<script>
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] },
}
},
}
</script>
3 changes: 3 additions & 0 deletions apps/settings/src/main-personal-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 TwitterSection from './components/PersonalInfo/TwitterSection.vue'
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
Expand All @@ -49,11 +50,13 @@ Vue.mixin({

const DisplayNameView = Vue.extend(DisplayNameSection)
const EmailView = Vue.extend(EmailSection)
const PhoneView = Vue.extend(PhoneSection)
const TwitterView = Vue.extend(TwitterSection)
const LanguageView = Vue.extend(LanguageSection)

new DisplayNameView().$mount('#vue-displayname-section')
new EmailView().$mount('#vue-email-section')
new PhoneView().$mount('#vue-phone-section')
new TwitterView().$mount('#vue-twitter-section')
new LanguageView().$mount('#vue-language-section')

Expand Down
15 changes: 1 addition & 14 deletions apps/settings/templates/settings/personal/personal.info.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,7 @@
<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">
<form id="addressform" class="section">
Expand Down

0 comments on commit 9fcb6a6

Please sign in to comment.