mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-06-15 10:30:40 +00:00
Update settings
This commit is contained in:
@ -44,8 +44,8 @@
|
||||
Your profile
|
||||
</a>
|
||||
</li>
|
||||
<li {% if request.path == url_for('settings.settings') %}class="active"{% endif %}>
|
||||
<a href="{{ url_for('settings.settings') }}">
|
||||
<li {% if request.path == url_for('settings.index') %}class="active"{% endif %}>
|
||||
<a href="{{ url_for('settings.index') }}">
|
||||
<i class="material-icons">settings</i>
|
||||
Settings
|
||||
</a>
|
||||
|
@ -13,6 +13,7 @@
|
||||
'js/app/endpoints/index.js',
|
||||
'js/app/endpoints/corpora.js',
|
||||
'js/app/endpoints/jobs.js',
|
||||
'js/app/endpoints/settings.js',
|
||||
'js/app/endpoints/users.js',
|
||||
'js/app/extensions/index.js',
|
||||
'js/app/extensions/toaster.js',
|
||||
|
@ -85,8 +85,8 @@
|
||||
</li>
|
||||
|
||||
{# settings #}
|
||||
<li {% if request.path == url_for('settings.settings') %}class="active"{% endif %}>
|
||||
<a class="waves-effect" href="{{ url_for('settings.settings') }}"><i class="material-icons">settings</i>Settings</a>
|
||||
<li {% if request.path == url_for('settings.index') %}class="active"{% endif %}>
|
||||
<a class="waves-effect" href="{{ url_for('settings.index') }}"><i class="material-icons">settings</i>Settings</a>
|
||||
</li>
|
||||
|
||||
{# log out #}
|
||||
|
@ -46,19 +46,19 @@
|
||||
<div class="row" style="margin-left: 24px;">
|
||||
<div class="col s12 l3">
|
||||
<label>
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_EMAIL') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="SHOW_EMAIL" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_EMAIL') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="ProfileShowEmail" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<span>Email</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col s12 l3">
|
||||
<label>
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_LAST_SEEN') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="SHOW_LAST_SEEN" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_LAST_SEEN') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="ProfileShowLastSeen" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<span>Last seen</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="col s12 l3">
|
||||
<label>
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_MEMBER_SINCE') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="SHOW_MEMBER_SINCE" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<input {% if user.has_profile_privacy_setting('SHOW_MEMBER_SINCE') %}checked{% endif %} class="profile-privacy-setting-checkbox" data-profile-privacy-setting-name="ProfileShowMemberSince" {% if not user.is_public %}disabled{% endif %} type="checkbox">
|
||||
<span>Member since</span>
|
||||
</label>
|
||||
</div>
|
||||
@ -74,7 +74,7 @@
|
||||
<form method="POST">
|
||||
{{ update_profile_information_form.hidden_tag() }}
|
||||
{{ wtf.render_field(update_profile_information_form.full_name, material_icon='badge') }}
|
||||
{{ wtf.render_field(update_profile_information_form.about_me, material_icon='description', id='about-me-textfield') }}
|
||||
{{ wtf.render_field(update_profile_information_form.about_me, material_icon='description') }}
|
||||
{{ wtf.render_field(update_profile_information_form.website, material_icon='laptop') }}
|
||||
{{ wtf.render_field(update_profile_information_form.organization, material_icon='business') }}
|
||||
{{ wtf.render_field(update_profile_information_form.location, material_icon='location_on') }}
|
||||
@ -252,28 +252,28 @@ for (let collapsibleElement of document.querySelectorAll('.collapsible.no-autoin
|
||||
// #region Profile Privacy settings
|
||||
let profileIsPublicSwitchElement = document.querySelector('#profile-is-public-switch');
|
||||
let profilePrivacySettingCheckboxElements = document.querySelectorAll('.profile-privacy-setting-checkbox');
|
||||
profileIsPublicSwitchElement.addEventListener('change', (event) => {
|
||||
let newEnabled = profileIsPublicSwitchElement.checked;
|
||||
nopaque.requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, 'is-public', newEnabled)
|
||||
.then(
|
||||
(response) => {
|
||||
for (let profilePrivacySettingCheckboxElement of document.querySelectorAll('.profile-privacy-setting-checkbox')) {
|
||||
profilePrivacySettingCheckboxElement.disabled = !newEnabled;
|
||||
}
|
||||
},
|
||||
(response) => {
|
||||
profileIsPublicSwitchElement.checked = !newEnabled;
|
||||
}
|
||||
);
|
||||
profileIsPublicSwitchElement.addEventListener('change', async (event) => {
|
||||
const newEnabled = profileIsPublicSwitchElement.checked;
|
||||
try {
|
||||
const message = await app.settings.updateProfileIsPublic(newEnabled);
|
||||
for (let profilePrivacySettingCheckboxElement of profilePrivacySettingCheckboxElements) {
|
||||
profilePrivacySettingCheckboxElement.disabled = !newEnabled;
|
||||
}
|
||||
app.ui.flash(message);
|
||||
} catch (e) {
|
||||
profileIsPublicSwitchElement.checked = !newEnabled;
|
||||
app.ui.flash(e.message, 'error');
|
||||
}
|
||||
});
|
||||
for (let profilePrivacySettingCheckboxElement of profilePrivacySettingCheckboxElements) {
|
||||
profilePrivacySettingCheckboxElement.addEventListener('change', (event) => {
|
||||
let newEnabled = profilePrivacySettingCheckboxElement.checked;
|
||||
let valueName = profilePrivacySettingCheckboxElement.dataset.profilePrivacySettingName;
|
||||
nopaque.requests.users.entity.settings.profilePrivacy.update({{ user.hashid|tojson }}, valueName, newEnabled)
|
||||
.catch((response) => {
|
||||
profilePrivacySettingCheckboxElement.addEventListener('change', async (event) => {
|
||||
const newEnabled = profilePrivacySettingCheckboxElement.checked;
|
||||
const valueName = profilePrivacySettingCheckboxElement.dataset.profilePrivacySettingName;
|
||||
try {
|
||||
app.settings[`update${valueName}`](newEnabled)
|
||||
} catch (error) {
|
||||
profilePrivacySettingCheckboxElement.checked = !newEnabled;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// #endregion Profile Privacy settings
|
Reference in New Issue
Block a user