2023-10-13 16:08:39 +08:00
|
|
|
<template>
|
|
|
|
<div class="content-pane flexible with-grey-background">
|
|
|
|
<div class="content-header">
|
|
|
|
<div class="title-row">
|
|
|
|
<h1 class="mt-0">
|
|
|
|
{{ i18n.t('users.settings.account.preferences.title') }}
|
|
|
|
</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="p-4 mb-4 bg-sn-white rounded">
|
2023-10-13 19:54:59 +08:00
|
|
|
<div>
|
|
|
|
<h2 class="mt-0">{{ i18n.t("users.settings.account.preferences.edit.time_zone_label") }}</h2>
|
|
|
|
<div class="text-sn-dark-grey mb-4">
|
|
|
|
<p>{{ i18n.t("users.settings.account.preferences.edit.time_zone_sublabel") }}</p>
|
|
|
|
</div>
|
|
|
|
<SelectSearch
|
|
|
|
class="max-w-[40ch]"
|
|
|
|
:value="selectedTimeZone"
|
|
|
|
@change="setTimeZone"
|
|
|
|
:options="timeZones"
|
|
|
|
/>
|
2023-10-13 16:08:39 +08:00
|
|
|
</div>
|
2023-10-13 19:54:59 +08:00
|
|
|
<div class="sci-divider my-6 inline-block"></div>
|
|
|
|
<div>
|
|
|
|
<h2 class="mt-0">{{ i18n.t("users.settings.account.preferences.edit.date_format_label") }}</h2>
|
|
|
|
<div class="text-sn-dark-grey mb-4">
|
|
|
|
<p>{{ i18n.t("users.settings.account.preferences.edit.date_format_sublabel") }}</p>
|
|
|
|
</div>
|
|
|
|
<SelectSearch
|
|
|
|
class="max-w-[40ch]"
|
|
|
|
:value="selectedDateFormat"
|
|
|
|
@change="setDateFormat"
|
|
|
|
:options="dateFormats"
|
|
|
|
/>
|
2023-10-13 16:08:39 +08:00
|
|
|
</div>
|
2023-10-13 19:54:59 +08:00
|
|
|
</div>
|
|
|
|
<div class="p-4 mb-4 bg-sn-white rounded">
|
|
|
|
<h2 class="mt-0">{{ i18n.t('notifications.title') }}</h2>
|
|
|
|
<div class="text-sn-dark-grey">
|
|
|
|
<p>{{ i18n.t('notifications.sub_title') }}</p>
|
|
|
|
</div>
|
|
|
|
<table v-if="notificationsSettings">
|
|
|
|
<template v-for="(_subGroups, group) in notificationsGroups" >
|
|
|
|
<div class="contents" :key="group">
|
|
|
|
<tr>
|
|
|
|
<td colspan=3 class="pt-6"><h3>{{ i18n.t(`notifications.groups.${group}`) }}</h3></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td></td>
|
|
|
|
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.in_app') }}</td>
|
|
|
|
<td class="p-2.5 text-base w-32">{{ i18n.t('notifications.email') }}</td>
|
|
|
|
</tr>
|
|
|
|
</div>
|
|
|
|
<template v-for="(_notifications, subGroup, i) in notificationsGroups[group]" >
|
|
|
|
<tr :key="subGroup"
|
|
|
|
class="text-base border-transparent border-b-sn-super-light-grey border-solid"
|
|
|
|
:class="{'border-t-sn-super-light-grey': i == 0}"
|
|
|
|
>
|
|
|
|
<td class="p-2.5 pr-10">{{ i18n.t(`notifications.sub_groups.${subGroup}`) }}</td>
|
|
|
|
<td class="p-2.5">
|
|
|
|
<div class="sci-toggle-checkbox-container">
|
|
|
|
<input v-model="notificationsSettings[subGroup]['in_app']" type="checkbox" class="sci-toggle-checkbox" @change="setNotificationsSettings"/>
|
|
|
|
<label class="sci-toggle-checkbox-label"></label>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
<td class="p-2.5">
|
|
|
|
<div class="sci-toggle-checkbox-container">
|
|
|
|
<input v-model="notificationsSettings[subGroup]['email']" type="checkbox" class="sci-toggle-checkbox" @change="setNotificationsSettings"/>
|
|
|
|
<label class="sci-toggle-checkbox-label"></label>
|
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
</table>
|
2023-10-13 16:08:39 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
import SelectSearch from "../shared/select_search.vue";
|
|
|
|
import axios from '../../packs/custom_axios.js';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: "UserPreferences",
|
|
|
|
props: {
|
|
|
|
userSettings: Object,
|
|
|
|
timeZones: Array,
|
|
|
|
dateFormats: Array,
|
2023-10-13 19:54:59 +08:00
|
|
|
updateUrl: String,
|
|
|
|
notificationsGroups: Object
|
2023-10-13 16:08:39 +08:00
|
|
|
},
|
|
|
|
data: function() {
|
|
|
|
return {
|
|
|
|
selectedTimeZone: null,
|
2023-10-13 19:54:59 +08:00
|
|
|
selectedDateFormat: null,
|
|
|
|
notificationsSettings: null
|
2023-10-13 16:08:39 +08:00
|
|
|
};
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.selectedTimeZone = this.userSettings.time_zone;
|
|
|
|
this.selectedDateFormat = this.userSettings.date_format;
|
2023-10-13 19:54:59 +08:00
|
|
|
this.notificationsSettings = {...this.emptySettings, ...this.userSettings.notifications_settings};
|
|
|
|
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
emptySettings() {
|
|
|
|
let settings = {};
|
|
|
|
for (const group in this.notificationsGroups) {
|
|
|
|
for (const subGroup in this.notificationsGroups[group]) {
|
|
|
|
settings[subGroup] = { in_app: false, email: false };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return settings;
|
|
|
|
}
|
2023-10-13 16:08:39 +08:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
SelectSearch,
|
|
|
|
PerfectScrollbar
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
setTimeZone(value) {
|
|
|
|
this.selectedTimeZone = value;
|
|
|
|
axios.put(this.updateUrl, {
|
|
|
|
user: { time_zone: value }
|
|
|
|
})
|
|
|
|
},
|
|
|
|
setDateFormat(value) {
|
|
|
|
this.selectedDateFormat = value;
|
|
|
|
axios.put(this.updateUrl, {
|
|
|
|
user: { date_format: value }
|
|
|
|
})
|
2023-10-13 19:54:59 +08:00
|
|
|
},
|
|
|
|
setNotificationsSettings() {
|
|
|
|
axios.put(this.updateUrl, {
|
|
|
|
user: { notifications_settings: this.notificationsSettings }
|
|
|
|
})
|
2023-10-13 16:08:39 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
2023-10-13 19:54:59 +08:00
|
|
|
</script>
|