mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
Merge pull request #34026 from nextcloud/port-profile-section-checkbox
Port Profile section checbox to NcCheckoxRadioSwitch component
This commit is contained in:
commit
52dbfcf74c
11 changed files with 35 additions and 44 deletions
|
|
@ -78,9 +78,9 @@
|
|||
{{ t('files_sharing', 'Allow resharing') }}
|
||||
</NcActionCheckbox>
|
||||
|
||||
<NcActionCheckbox ref="canDownload"
|
||||
<NcActionCheckbox v-if="isSetDownloadButtonVisible"
|
||||
ref="canDownload"
|
||||
:checked.sync="canDownload"
|
||||
v-if="isSetDownloadButtonVisible"
|
||||
:disabled="saving || !canSetDownload">
|
||||
{{ allowDownloadText }}
|
||||
</NcActionCheckbox>
|
||||
|
|
|
|||
|
|
@ -22,14 +22,12 @@
|
|||
|
||||
<template>
|
||||
<div class="checkbox-container">
|
||||
<input id="enable-profile"
|
||||
class="checkbox"
|
||||
type="checkbox"
|
||||
:checked="profileEnabled"
|
||||
@change="onEnableProfileChange">
|
||||
<label for="enable-profile">
|
||||
<NcCheckboxRadioSwitch type="switch"
|
||||
:checked.sync="isProfileEnabled"
|
||||
:loading="loading"
|
||||
@update:checked="saveEnableProfile">
|
||||
{{ t('settings', 'Enable Profile') }}
|
||||
</label>
|
||||
</NcCheckboxRadioSwitch>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -38,13 +36,17 @@ import { showError } from '@nextcloud/dialogs'
|
|||
import { emit } from '@nextcloud/event-bus'
|
||||
|
||||
import { savePrimaryAccountProperty } from '../../../service/PersonalInfo/PersonalInfoService.js'
|
||||
import { validateBoolean } from '../../../utils/validate.js'
|
||||
import { ACCOUNT_PROPERTY_ENUM } from '../../../constants/AccountPropertyConstants.js'
|
||||
import logger from '../../../logger.js'
|
||||
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
|
||||
|
||||
export default {
|
||||
name: 'ProfileCheckbox',
|
||||
|
||||
components: {
|
||||
NcCheckboxRadioSwitch,
|
||||
},
|
||||
|
||||
props: {
|
||||
profileEnabled: {
|
||||
type: Boolean,
|
||||
|
|
@ -54,25 +56,18 @@ export default {
|
|||
|
||||
data() {
|
||||
return {
|
||||
initialProfileEnabled: this.profileEnabled,
|
||||
isProfileEnabled: this.profileEnabled,
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async onEnableProfileChange(e) {
|
||||
const isEnabled = e.target.checked
|
||||
this.$emit('update:profile-enabled', isEnabled)
|
||||
|
||||
if (validateBoolean(isEnabled)) {
|
||||
await this.updateEnableProfile(isEnabled)
|
||||
}
|
||||
},
|
||||
|
||||
async updateEnableProfile(isEnabled) {
|
||||
async saveEnableProfile() {
|
||||
this.loading = true
|
||||
try {
|
||||
const responseData = await savePrimaryAccountProperty(ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED, isEnabled)
|
||||
const responseData = await savePrimaryAccountProperty(ACCOUNT_PROPERTY_ENUM.PROFILE_ENABLED, this.isProfileEnabled)
|
||||
this.handleResponse({
|
||||
isEnabled,
|
||||
isProfileEnabled: this.isProfileEnabled,
|
||||
status: responseData.ocs?.meta?.status,
|
||||
})
|
||||
} catch (e) {
|
||||
|
|
@ -83,19 +78,15 @@ export default {
|
|||
}
|
||||
},
|
||||
|
||||
handleResponse({ isEnabled, status, errorMessage, error }) {
|
||||
handleResponse({ isProfileEnabled, status, errorMessage, error }) {
|
||||
if (status === 'ok') {
|
||||
// Ensure that local state reflects server state
|
||||
this.initialProfileEnabled = isEnabled
|
||||
emit('settings:profile-enabled:updated', isEnabled)
|
||||
emit('settings:profile-enabled:updated', isProfileEnabled)
|
||||
} else {
|
||||
showError(errorMessage)
|
||||
logger.error(errorMessage, error)
|
||||
}
|
||||
this.loading = false
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@
|
|||
<label class="hidden-visually" for="user_status_message">
|
||||
{{ t('user_status', 'What is your status?') }}
|
||||
</label>
|
||||
<input ref="input"
|
||||
id="user_status_message"
|
||||
<input id="user_status_message"
|
||||
ref="input"
|
||||
maxlength="80"
|
||||
:disabled="disabled"
|
||||
:placeholder="$t('user_status', 'What is your status?')"
|
||||
|
|
|
|||
4
dist/files_sharing-files_sharing_tab.js
vendored
4
dist/files_sharing-files_sharing_tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files_sharing-files_sharing_tab.js.map
vendored
2
dist/files_sharing-files_sharing_tab.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/settings-vue-settings-personal-info.js
vendored
4
dist/settings-vue-settings-personal-info.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4
dist/user-status-modal-8299.js
vendored
4
dist/user-status-modal-8299.js
vendored
File diff suppressed because one or more lines are too long
2
dist/user-status-modal-8299.js.map
vendored
2
dist/user-status-modal-8299.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/user_status-menu.js
vendored
4
dist/user_status-menu.js
vendored
File diff suppressed because one or more lines are too long
2
dist/user_status-menu.js.map
vendored
2
dist/user_status-menu.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue