Skip to content

Commit dd7cb97

Browse files
committed
Remake location property saving with Vue
Signed-off-by: Christopher Ng <[email protected]>
1 parent 38d0419 commit dd7cb97

File tree

10 files changed

+65
-25
lines changed

10 files changed

+65
-25
lines changed

apps/settings/js/federationsettingsview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@
131131
field === 'avatar' ||
132132
field === 'email' ||
133133
field === 'displayname' ||
134-
field === 'twitter'
134+
field === 'twitter' ||
135+
field === 'address'
135136
) {
136137
return;
137138
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ public function getForm(): TemplateResponse {
149149
'avatarScope' => $account->getProperty(IAccountManager::PROPERTY_AVATAR)->getScope(),
150150
'phone' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getValue(),
151151
'phoneScope' => $account->getProperty(IAccountManager::PROPERTY_PHONE)->getScope(),
152-
'address' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getValue(),
153-
'addressScope' => $account->getProperty(IAccountManager::PROPERTY_ADDRESS)->getScope(),
154152
'website' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getValue(),
155153
'websiteScope' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getScope(),
156154
'websiteVerification' => $account->getProperty(IAccountManager::PROPERTY_WEBSITE)->getVerified(),
@@ -162,8 +160,9 @@ public function getForm(): TemplateResponse {
162160
$personalInfoParameters = [
163161
'userId' => $uid,
164162
'displayName' => $this->getProperty($account, IAccountManager::PROPERTY_DISPLAYNAME),
165-
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
166163
'emailMap' => $this->getEmailMap($account),
164+
'location' => $this->getProperty($account, IAccountManager::PROPERTY_ADDRESS),
165+
'twitter' => $this->getProperty($account, IAccountManager::PROPERTY_TWITTER),
167166
'languageMap' => $this->getLanguageMap($user),
168167
'profileEnabledGlobally' => $this->profileManager->isProfileEnabled(),
169168
'profileEnabled' => $this->profileManager->isProfileEnabled($user),
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<!--
2+
- @copyright 2022 Christopher Ng <[email protected]>
3+
-
4+
- @author Christopher Ng <[email protected]>
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="location"
25+
:placeholder="t('settings', 'Your location')" />
26+
</template>
27+
28+
<script>
29+
import { loadState } from '@nextcloud/initial-state'
30+
31+
import AccountPropertySection from './shared/AccountPropertySection.vue'
32+
33+
import { NAME_READABLE_ENUM } from '../../constants/AccountPropertyConstants.js'
34+
35+
const { location } = loadState('settings', 'personalInfoParameters', {})
36+
37+
export default {
38+
name: 'LocationSection',
39+
40+
components: {
41+
AccountPropertySection,
42+
},
43+
44+
data() {
45+
return {
46+
location: { ...location, readable: NAME_READABLE_ENUM[location.name] },
47+
}
48+
},
49+
}
50+
</script>

apps/settings/src/constants/AccountPropertyConstants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const ACCOUNT_PROPERTY_ENUM = Object.freeze({
4646

4747
/** Enum of account properties to human readable account property names */
4848
export const ACCOUNT_PROPERTY_READABLE_ENUM = Object.freeze({
49-
ADDRESS: t('settings', 'Address'),
49+
ADDRESS: t('settings', 'Location'),
5050
AVATAR: t('settings', 'Avatar'),
5151
BIOGRAPHY: t('settings', 'About'),
5252
DISPLAYNAME: t('settings', 'Full name'),

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

Lines changed: 3 additions & 0 deletions
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 LocationSection from './components/PersonalInfo/LocationSection.vue'
3132
import TwitterSection from './components/PersonalInfo/TwitterSection.vue'
3233
import LanguageSection from './components/PersonalInfo/LanguageSection/LanguageSection.vue'
3334
import ProfileSection from './components/PersonalInfo/ProfileSection/ProfileSection.vue'
@@ -49,11 +50,13 @@ Vue.mixin({
4950

5051
const DisplayNameView = Vue.extend(DisplayNameSection)
5152
const EmailView = Vue.extend(EmailSection)
53+
const LocationView = Vue.extend(LocationSection)
5254
const TwitterView = Vue.extend(TwitterSection)
5355
const LanguageView = Vue.extend(LanguageSection)
5456

5557
new DisplayNameView().$mount('#vue-displayname-section')
5658
new EmailView().$mount('#vue-email-section')
59+
new LocationView().$mount('#vue-location-section')
5760
new TwitterView().$mount('#vue-twitter-section')
5861
new LanguageView().$mount('#vue-language-section')
5962

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

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,7 @@
136136
</form>
137137
</div>
138138
<div class="personal-settings-setting-box">
139-
<form id="addressform" class="section">
140-
<h3>
141-
<label for="address"><?php p($l->t('Address')); ?></label>
142-
<a href="#" class="federation-menu" aria-label="<?php p($l->t('Change privacy level of address')); ?>">
143-
<span class="icon-federation-menu icon-password">
144-
<span class="icon-triangle-s"></span>
145-
</span>
146-
</a>
147-
</h3>
148-
<input type="text" id="address" name="address" placeholder="<?php p($l->t('Your postal address')); ?>" value="<?php p($_['address']) ?>" autocomplete="on" autocapitalize="none" autocorrect="off" />
149-
<span class="icon-checkmark hidden"></span>
150-
<span class="icon-error hidden"></span>
151-
<input type="hidden" id="addressscope" value="<?php p($_['addressScope']) ?>">
152-
</form>
139+
<div id="vue-location-section"></div>
153140
</div>
154141
<div class="personal-settings-setting-box">
155142
<form id="websiteform" class="section">

dist/settings-vue-settings-admin-basic-settings.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/settings-vue-settings-admin-basic-settings.js.map

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)