SHA256
UI: доработать профиль и связи
This commit is contained in:
@@ -81,7 +81,7 @@ function openProfileInfoModal({ title, text }) {
|
||||
|
||||
function officialInfoText() {
|
||||
return 'Можно создавать несколько альтернативных или анонимных каналов. '
|
||||
+ 'Но для корректного учёта голосов на одного реального человека используется только один официальный канал.';
|
||||
+ 'Но для корректного учёта голосов на одного реального человека используется только один основной аккаунт.';
|
||||
}
|
||||
|
||||
function shineInfoText() {
|
||||
@@ -143,20 +143,21 @@ export function render({ navigate, chrome }) {
|
||||
const badgesRow = document.createElement('div');
|
||||
badgesRow.className = 'row';
|
||||
badgesRow.innerHTML = `
|
||||
<button class="badge profile-toggle-btn is-no" type="button" data-toggle="official">Официальный: No</button>
|
||||
<button class="badge profile-toggle-btn is-no" type="button" data-toggle="shine">Сияющий: No</button>
|
||||
<button class="badge profile-toggle-btn is-no" type="button" data-status="account_role">Аккаунт: Не указано</button>
|
||||
<button class="badge profile-toggle-btn is-no" type="button" data-status="shine">Сияние: Не указано</button>
|
||||
`;
|
||||
|
||||
const listWrap = document.createElement('div');
|
||||
listWrap.className = 'stack profile-param-list';
|
||||
|
||||
const officialBtn = badgesRow.querySelector('[data-toggle="official"]');
|
||||
const shineBtn = badgesRow.querySelector('[data-toggle="shine"]');
|
||||
const accountRoleBtn = badgesRow.querySelector('[data-status="account_role"]');
|
||||
const shineBtn = badgesRow.querySelector('[data-status="shine"]');
|
||||
const identityEl = topRow.querySelector('[data-profile-identity="true"]');
|
||||
const avatarSlotEl = topRow.querySelector('[data-profile-avatar-slot="true"]');
|
||||
|
||||
let currentFields = [];
|
||||
let currentToggles = [];
|
||||
let currentAccountRole = '';
|
||||
let currentShineStatus = '';
|
||||
let currentGender = 'unknown';
|
||||
let currentAvatar = { value: '', source: '', txId: '', sha256Hex: '', timeMs: 0 };
|
||||
let currentStats = {
|
||||
@@ -193,22 +194,19 @@ export function render({ navigate, chrome }) {
|
||||
}));
|
||||
}
|
||||
|
||||
function updateToggleButton(button, prefix, enabled) {
|
||||
button.textContent = `${prefix}: ${toggleText(enabled)}`;
|
||||
button.classList.remove('is-no', 'is-yes-official', 'is-yes-shine');
|
||||
if (!enabled) {
|
||||
button.classList.add('is-no');
|
||||
return;
|
||||
function updateStatusesUi() {
|
||||
if (accountRoleBtn) {
|
||||
const label = currentAccountRole === 'primary' ? 'Основной аккаунт' : currentAccountRole === 'non_voting' ? 'Не учитывать мой голос' : 'Не указано';
|
||||
accountRoleBtn.textContent = `Аккаунт: ${label}`;
|
||||
accountRoleBtn.classList.remove('is-no', 'is-yes-official', 'is-yes-shine', 'is-not-interested');
|
||||
accountRoleBtn.classList.add(currentAccountRole === 'primary' ? 'is-yes-official' : 'is-no');
|
||||
}
|
||||
if (shineBtn) {
|
||||
const label = currentShineStatus === 'shining' ? 'Сияющий' : currentShineStatus === 'not_interested' ? 'Сияние неинтересно' : currentShineStatus === 'unknown' ? 'Неизвестно' : 'Не указано';
|
||||
shineBtn.textContent = `Сияние: ${label}`;
|
||||
shineBtn.classList.remove('is-no', 'is-yes-official', 'is-yes-shine', 'is-not-interested');
|
||||
shineBtn.classList.add(currentShineStatus === 'shining' ? 'is-yes-shine' : currentShineStatus === 'not_interested' ? 'is-not-interested' : 'is-no');
|
||||
}
|
||||
if (prefix === 'Официальный') button.classList.add('is-yes-official');
|
||||
else button.classList.add('is-yes-shine');
|
||||
}
|
||||
|
||||
function updateTogglesUi() {
|
||||
const official = currentToggles.find((item) => item.key === 'official') || { enabled: false };
|
||||
const shine = currentToggles.find((item) => item.key === 'shine') || { enabled: false };
|
||||
updateToggleButton(officialBtn, 'Официальный', official.enabled);
|
||||
updateToggleButton(shineBtn, 'Сияющий', shine.enabled);
|
||||
}
|
||||
|
||||
function renderStats() {
|
||||
@@ -226,11 +224,11 @@ export function render({ navigate, chrome }) {
|
||||
});
|
||||
}
|
||||
|
||||
officialBtn?.classList.add('profile-badge-trigger');
|
||||
accountRoleBtn?.classList.add('profile-badge-trigger');
|
||||
shineBtn?.classList.add('profile-badge-trigger');
|
||||
officialBtn?.addEventListener('click', () => {
|
||||
accountRoleBtn?.addEventListener('click', () => {
|
||||
openProfileInfoModal({
|
||||
title: 'Официальный канал',
|
||||
title: 'Основной аккаунт',
|
||||
text: officialInfoText(),
|
||||
});
|
||||
});
|
||||
@@ -269,10 +267,8 @@ export function render({ navigate, chrome }) {
|
||||
{ key: 'website', label: 'Веб', value: '127.0.0.1' },
|
||||
{ key: 'phone', label: 'Телефон', value: profile.phone },
|
||||
];
|
||||
currentToggles = [
|
||||
{ key: 'official', enabled: false },
|
||||
{ key: 'shine', enabled: false },
|
||||
];
|
||||
currentAccountRole = '';
|
||||
currentShineStatus = '';
|
||||
currentGender = 'unknown';
|
||||
currentAvatar = { value: '', source: '', txId: '', sha256Hex: '', timeMs: 0 };
|
||||
currentStats = {
|
||||
@@ -283,7 +279,7 @@ export function render({ navigate, chrome }) {
|
||||
};
|
||||
syncIdentity();
|
||||
updateAvatarUi();
|
||||
updateTogglesUi();
|
||||
updateStatusesUi();
|
||||
renderFields(currentFields);
|
||||
return;
|
||||
}
|
||||
@@ -294,7 +290,8 @@ export function render({ navigate, chrome }) {
|
||||
authService.getUser(login).catch(() => ({})),
|
||||
]);
|
||||
currentFields = Array.isArray(snapshot.fields) ? snapshot.fields : [];
|
||||
currentToggles = Array.isArray(snapshot.toggles) ? snapshot.toggles : [];
|
||||
currentAccountRole = snapshot.accountRole || '';
|
||||
currentShineStatus = snapshot.shineStatus || '';
|
||||
currentGender = snapshot.gender || 'unknown';
|
||||
currentAvatar = snapshot.avatar || { value: '', source: '', txId: '', sha256Hex: '', timeMs: 0 };
|
||||
currentStats = {
|
||||
@@ -305,7 +302,7 @@ export function render({ navigate, chrome }) {
|
||||
};
|
||||
syncIdentity();
|
||||
updateAvatarUi();
|
||||
updateTogglesUi();
|
||||
updateStatusesUi();
|
||||
renderFields(currentFields);
|
||||
} catch (error) {
|
||||
// ignore status row in profile-view
|
||||
|
||||
Reference in New Issue
Block a user