diff --git a/app/static/guide.js b/app/static/guide.js index 956e92c..1c77ed1 100644 --- a/app/static/guide.js +++ b/app/static/guide.js @@ -25,7 +25,7 @@ ]}, {id: 'employee-profile', path: directory, title: 'Откройте карточку сотрудника', region: '.directory__header', tips: [ ['[data-columns-open]', 'Выберите столбцы: например, должности, контакты и число публикаций.'], - ['.directory__help', 'Нажмите на ФИО в таблице, чтобы открыть контакты, степени, публикации и другие данные профиля.'], + ['.directory-table__cell[data-column="full_name"] a', 'Нажмите на ФИО, чтобы открыть контакты, степени и публикации сотрудника.'], ]}, {id: 'council-filters', path: council, title: 'Задайте параметры подбора', region: '.council__search', tips: [ ['#council-branch', 'Отрасль определяет публикационный минимум для доктора наук. Варианты зависят от специальности ВАК.'], @@ -42,6 +42,11 @@ ['[data-guide-count="total"]', 'Уникальные работы Q1/Q2/К1/RSCI. Для докторов учитывается также К2.', 'inside'], ['[data-guide-count="all"]', 'Публикации из ЛК и выгрузки ВШЭ за все годы, без дублей.', 'inside'], ]}, + {id: 'council-sources', path: council, title: 'Сравните счётчики публикаций', region: '.council__list-heading', + intro: 'В раскрытой карточке можно проверить источник записи, DOI и основания зачёта.', tips: [ + ['[data-guide-count="q1"]', 'Одна работа может входить сразу в несколько счётчиков Q1, Q2 и К1.', 'inside'], + ['[data-guide-count="hse"]', 'Здесь только публикации из личного кабинета сотрудника ВШЭ за все годы.', 'inside'], + ]}, {id: 'council-export', path: council, title: 'Проверьте расчёт и выгрузите список', region: '.council__notice', tips: [ ['.council__notice', 'Здесь описаны период оценки, минимумы по отраслям и правила учёта работ.'], ['[formaction="/admin/council/export.xlsx"]', 'В XLSX попадут все найденные сотрудники и их публикации, включая другие страницы списка.'], @@ -68,13 +73,15 @@ const heading = guide.querySelector('#guide-title'); const progress = guide.querySelector('[data-guide-progress]'); const intro = guide.querySelector('[data-guide-intro]'); + const reference = guide.querySelector('[data-guide-reference]'); const back = guide.querySelector('[data-guide-back]'); const next = guide.querySelector('[data-guide-next]'); const close = guide.querySelector('[data-guide-close]'); const error = guide.querySelector('[data-guide-error]'); const unsaved = guide.querySelector('[data-guide-unsaved]'); - const hashFor = step => '#guide-' + step.id; + const storageKey = 'workers-guide:' + guide.dataset.guideUser; let index = 0; + let paused = false; let saving = false; let removeTips = []; @@ -119,19 +126,24 @@ function showStep(focus = true) { const step = steps[index]; + paused = Boolean(step.path && step.path !== location.pathname); clearTips(); - const region = step.region && main.querySelector(step.region); + const region = !paused && step.region && main.querySelector(step.region); if (region) region.before(guide); else main.prepend(guide); - heading.textContent = step.title; + heading.textContent = paused ? 'Продолжите обучение' : step.title; progress.textContent = `Шаг ${index + 1} из ${steps.length}`; - intro.textContent = step.intro || ''; - intro.hidden = !step.intro; + intro.textContent = paused ? step.title + '.' : step.intro || ''; + intro.hidden = !intro.textContent; + reference.hidden = index !== 0; error.hidden = unsaved.hidden = true; + back.hidden = paused; back.disabled = index === 0; - next.textContent = index === steps.length - 1 ? 'Завершить подсказки' : 'Далее'; - step.tips?.forEach((tip, number) => addTip(tip, number)); - step.editorTips?.forEach((tip, number) => addTip(tip, 'editor-' + number, true)); + next.textContent = paused ? 'Продолжить' : index === steps.length - 1 ? 'Завершить подсказки' : 'Далее'; + if (!paused) { + step.tips?.forEach((tip, number) => addTip(tip, number)); + step.editorTips?.forEach((tip, number) => addTip(tip, 'editor-' + number, true)); + } guide.hidden = false; if (focus) { heading.focus({preventScroll: true}); @@ -140,20 +152,20 @@ } function goTo(number, path = steps[number].path || '/admin/account') { - const step = steps[number]; + sessionStorage.setItem(storageKey, steps[number].id); if (path !== location.pathname) { - location.assign(path + hashFor(step)); + location.assign(path); return; } index = number; - history.replaceState(history.state, '', hashFor(step)); showStep(); } - function hide() { + function hide(remember = true) { clearTips(); guide.hidden = true; - history.replaceState(history.state, '', location.pathname + location.search); + if (remember) sessionStorage.setItem(storageKey, 'closed'); + else sessionStorage.removeItem(storageKey); trigger?.focus(); } @@ -195,36 +207,34 @@ }); back.addEventListener('click', () => goTo(index - 1)); next.addEventListener('click', () => { - if (index === steps.length - 1) finish(); + if (paused) goTo(index); + else if (index === steps.length - 1) finish(); else goTo(index + 1); }); close.addEventListener('click', finish); - unsaved.addEventListener('click', hide); - document.addEventListener('keydown', event => { - if (event.key !== 'Escape' || event.defaultPrevented || guide.hidden || document.querySelector('dialog[open]')) return; + unsaved.addEventListener('click', () => hide(false)); + guide.addEventListener('keydown', event => { + if (event.key !== 'Escape' || event.defaultPrevented) return; event.preventDefault(); finish(); }); - main.addEventListener('submit', event => { - const form = event.target; - if (guide.hidden || !steps[index].path || form.method !== 'get' || event.submitter?.hasAttribute('formaction')) return; - const action = new URL(form.action); - if (action.origin !== location.origin || action.pathname !== location.pathname) return; - const original = form.getAttribute('action'); - action.hash = hashFor(steps[index]); - form.action = action; - setTimeout(() => { - if (original === null) form.removeAttribute('action'); - else form.setAttribute('action', original); - }); - }); - - const requested = steps.findIndex(step => hashFor(step) === location.hash && (!step.path || step.path === location.pathname)); - if (requested >= 0) { - index = requested; - showStep(); - } else if (guide.dataset.guidePending === 'true') { - history.replaceState(history.state, '', hashFor(steps[0])); - showStep(false); + function restore(allowAutoStart) { + const active = sessionStorage.getItem(storageKey); + const requested = steps.findIndex(step => step.id === active); + if (requested >= 0) { + index = requested; + showStep(!allowAutoStart || index > 0); + } else if (allowAutoStart && active !== 'closed' && guide.dataset.guidePending === 'true') { + sessionStorage.setItem(storageKey, steps[0].id); + showStep(false); + } else { + clearTips(); + guide.hidden = true; + } } + + window.addEventListener('pageshow', event => { + if (event.persisted) restore(false); + }); + restore(true); })(); diff --git a/app/templates/council.html b/app/templates/council.html index f3497a6..a2b4de9 100644 --- a/app/templates/council.html +++ b/app/templates/council.html @@ -81,11 +81,11 @@ {{ candidate.name }}{{ candidate.degree }}{% if candidate.dismissed %} · Уволен{% endif %}{{ candidate.assessment_status }} · подтверждено {{ candidate.confirmed_count }} - {{ candidate.q1_count }}Q1 + {{ candidate.q1_count }}Q1 {{ candidate.q2_count }}Q2 {{ candidate.k1_count }}К1 {{ candidate.total_count }}ВСЕГО (предв.) - {{ candidate.db_count }}ЛК сотрудника ВШЭ + {{ candidate.db_count }}ЛК сотрудника ВШЭ {{ candidate.count }}Все публикации diff --git a/app/templates/guide_walkthrough.html b/app/templates/guide_walkthrough.html index 746971b..6af8763 100644 --- a/app/templates/guide_walkthrough.html +++ b/app/templates/guide_walkthrough.html @@ -1,4 +1,4 @@ -