3359a8db13
Модель/сервисы HR-заявок с заменами, приглашения на установку пароля (инвайты), обновлённая страница профиля сотрудника и правки 2FA. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
3.3 KiB
JavaScript
80 lines
3.3 KiB
JavaScript
function empProfileRoot() {
|
|
return document.querySelector('#main-content .page-content[data-profile-active-tab]');
|
|
}
|
|
|
|
function empProfileTabSwitch(tab) {
|
|
var root = empProfileRoot();
|
|
if (!root) return;
|
|
root.querySelectorAll('.emp-profile-panel').forEach(function (panel) {
|
|
panel.style.display = panel.id === 'emp-profile-panel-' + tab ? 'block' : 'none';
|
|
});
|
|
root.querySelectorAll('.emp-profile-tab-btn').forEach(function (btn) {
|
|
var active = btn.getAttribute('data-tab') === tab;
|
|
btn.classList.toggle('emp-profile-tab-active', active);
|
|
btn.style.background = active ? 'var(--color-card)' : 'transparent';
|
|
btn.style.color = active ? 'var(--color-card-foreground)' : 'var(--color-muted-foreground)';
|
|
btn.style.boxShadow = active ? '0 1px 2px rgb(0 0 0/0.08)' : '';
|
|
});
|
|
if (typeof history !== 'undefined' && history.replaceState) {
|
|
var url = new URL(window.location.href);
|
|
url.searchParams.set('tab', tab);
|
|
history.replaceState(null, '', url.pathname + url.search);
|
|
}
|
|
}
|
|
|
|
function empProfileInit() {
|
|
var root = empProfileRoot();
|
|
if (!root) return;
|
|
var tab = root.getAttribute('data-profile-active-tab') || 'overview';
|
|
empProfileTabSwitch(tab);
|
|
var reqType = document.getElementById('emp-hr-request-type');
|
|
if (reqType) {
|
|
empProfileRequestTypeToggle(reqType.value);
|
|
if (!document.getElementById('emp-hr-request-type-label').textContent.trim()) {
|
|
var btn = document.querySelector('.emp-hr-type-btn[data-request-type="' + reqType.value + '"]');
|
|
if (btn) document.getElementById('emp-hr-request-type-label').textContent = btn.getAttribute('data-request-label') || btn.textContent.trim();
|
|
}
|
|
}
|
|
}
|
|
|
|
function empProfileShowRequestForm(type, label) {
|
|
var wrap = document.getElementById('emp-hr-request-form-wrap');
|
|
var input = document.getElementById('emp-hr-request-type');
|
|
var labelEl = document.getElementById('emp-hr-request-type-label');
|
|
if (wrap) wrap.style.display = 'block';
|
|
if (input && type) {
|
|
input.value = type;
|
|
empProfileRequestTypeToggle(type);
|
|
}
|
|
if (labelEl && label) labelEl.textContent = label;
|
|
}
|
|
|
|
function empProfileHideRequestForm() {
|
|
var wrap = document.getElementById('emp-hr-request-form-wrap');
|
|
if (wrap) wrap.style.display = 'none';
|
|
}
|
|
|
|
function empProfileRequestTypeToggle(type) {
|
|
var needsDates = ['vacation', 'additional_vacation', 'sick_leave', 'day_off'].indexOf(type) !== -1;
|
|
var datesWrap = document.getElementById('emp-hr-request-dates-wrap');
|
|
var dateToWrap = document.getElementById('emp-hr-request-date-to-wrap');
|
|
var dateFrom = document.getElementById('emp-hr-request-date-from');
|
|
var dateTo = document.getElementById('emp-hr-request-date-to');
|
|
if (datesWrap) datesWrap.style.display = needsDates ? '' : 'none';
|
|
if (dateToWrap) dateToWrap.style.display = needsDates ? '' : 'none';
|
|
if (dateFrom) dateFrom.required = needsDates;
|
|
if (dateTo) dateTo.required = needsDates;
|
|
}
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', empProfileInit);
|
|
} else {
|
|
empProfileInit();
|
|
}
|
|
document.addEventListener('htmx:afterSwap', function (ev) {
|
|
var target = ev.detail && ev.detail.target;
|
|
if (target && target.id === 'main-content') {
|
|
empProfileInit();
|
|
}
|
|
});
|