TPTIP-40: подпись «нужно для расчёта норм» вместо «обязательно» на первом шаге
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
0761af60cf
commit
1b3f953b48
@ -42,3 +42,4 @@
|
|||||||
|
|
||||||
|
|
||||||
- TPTIP-3: каталог /recipes.html (ru/kk/en), локальные фото assets; npm run build перед npm start; браузер npx playwright test. Сохранить маршруты recipes и сборку telemetry при объединении server.js/Dockerfile.
|
- TPTIP-3: каталог /recipes.html (ru/kk/en), локальные фото assets; npm run build перед npm start; браузер npx playwright test. Сохранить маршруты recipes и сборку telemetry при объединении server.js/Dockerfile.
|
||||||
|
- TPTIP-40: numField(o.reqText) задаёт пометку; поля возраст/рост/вес — «нужно для расчёта норм», «обязательно» только у норм шага 2; CACHE tpt-v20-field-label.
|
||||||
|
|||||||
@ -540,7 +540,7 @@ function numField(label, o) {
|
|||||||
const el = field(label, input, o.hint);
|
const el = field(label, input, o.hint);
|
||||||
el.input = input;
|
el.input = input;
|
||||||
if (o.what && o.required) {
|
if (o.what && o.required) {
|
||||||
el.querySelector('.lbl').append(h('span', { class: 'req' }, ' · обязательно'));
|
el.querySelector('.lbl').append(h('span', { class: 'req' }, o.reqText || ' · обязательно'));
|
||||||
input.setAttribute('aria-required', 'true');
|
input.setAttribute('aria-required', 'true');
|
||||||
input.addEventListener('blur', () => el.read());
|
input.addEventListener('blur', () => el.read());
|
||||||
input.addEventListener('input', () => { if (el.classList.contains('bad')) el.read(); });
|
input.addEventListener('input', () => { if (el.classList.contains('bad')) el.read(); });
|
||||||
@ -1220,9 +1220,9 @@ function viewStats() {
|
|||||||
function calcFields(pr, hints) {
|
function calcFields(pr, hints) {
|
||||||
hints = hints || {};
|
hints = hints || {};
|
||||||
const sex = selectField('Пол', [['m', 'Мужской'], ['f', 'Женский']], pr.sex);
|
const sex = selectField('Пол', [['m', 'Мужской'], ['f', 'Женский']], pr.sex);
|
||||||
const age = numField('Возраст, лет', { value: pr.age, placeholder: hints.age, required: true, int: true, min: 10, max: 100, what: 'возраст', hint: 'От 10 до 100 лет' });
|
const age = numField('Возраст, лет', { value: pr.age, placeholder: hints.age, required: true, int: true, min: 10, max: 100, reqText: ' · нужно для расчёта норм', what: 'возраст', hint: 'От 10 до 100 лет' });
|
||||||
const height = numField('Рост, см', { value: pr.height, placeholder: hints.height, required: true, min: 100, max: 250, what: 'рост', hint: 'От 100 до 250 см' });
|
const height = numField('Рост, см', { value: pr.height, placeholder: hints.height, required: true, min: 100, max: 250, reqText: ' · нужно для расчёта норм', what: 'рост', hint: 'От 100 до 250 см' });
|
||||||
const weight = numField('Вес, кг', { value: pr.weight, placeholder: hints.weight, required: true, min: 25, max: 400, what: 'вес', hint: 'От 25 до 400 кг' });
|
const weight = numField('Вес, кг', { value: pr.weight, placeholder: hints.weight, required: true, min: 25, max: 400, reqText: ' · нужно для расчёта норм', what: 'вес', hint: 'От 25 до 400 кг' });
|
||||||
const act = selectField('Активность', ACTIVITY, pr.activity);
|
const act = selectField('Активность', ACTIVITY, pr.activity);
|
||||||
return {
|
return {
|
||||||
el: h('div', null, h('div', { class: 'grid2' }, sex, age), h('div', { class: 'grid2' }, height, weight), act),
|
el: h('div', null, h('div', { class: 'grid2' }, sex, age), h('div', { class: 'grid2' }, height, weight), act),
|
||||||
|
|||||||
@ -0,0 +1 @@
|
|||||||
|
numField получает опцию reqText (текст пометки); calcFields передаёт «нужно для расчёта норм». Проверка пустого поля и кнопка «Пропустить» не менялись; в «Настройки» поля те же. CACHE tpt-v20-field-label.
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
## Why
|
||||||
|
Рядом с полями возраста, роста и веса написано «обязательно», а выше сказано, что их можно пропустить.
|
||||||
|
## What Changes
|
||||||
|
Подпись у этих полей — «нужно для расчёта норм». «Обязательно» остаётся только на втором шаге (нормы), где без них нельзя нажать «Готово».
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
## ADDED Requirements
|
||||||
|
### Requirement: Подписи полей первого шага не противоречат «Пропустить»
|
||||||
|
Поля возраста, роста и веса SHALL быть подписаны «нужно для расчёта норм», а не «обязательно».
|
||||||
|
|
||||||
|
#### Scenario: Подписи на первом шаге
|
||||||
|
- **GIVEN** новый пользователь открыл мастер
|
||||||
|
- **WHEN** он смотрит на первый шаг
|
||||||
|
- **THEN** рядом с полями написано «нужно для расчёта норм»
|
||||||
|
- **AND** слова «обязательно» нет
|
||||||
|
|
||||||
|
#### Scenario: Пропуск
|
||||||
|
- **GIVEN** открыт первый шаг мастера
|
||||||
|
- **WHEN** пользователь нажимает «Пропустить»
|
||||||
|
- **THEN** открывается главный экран
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
- [x] Заменить подпись у полей первого шага
|
||||||
|
- [x] Тест и CACHE
|
||||||
@ -23,3 +23,17 @@ TBD - created by archiving change tptip-34-field-error-text. Update Purpose afte
|
|||||||
- **GIVEN** под полем возраста видна ошибка
|
- **GIVEN** под полем возраста видна ошибка
|
||||||
- **WHEN** пользователь вводит 30
|
- **WHEN** пользователь вводит 30
|
||||||
- **THEN** сообщение исчезает
|
- **THEN** сообщение исчезает
|
||||||
|
|
||||||
|
### Requirement: Подписи полей первого шага не противоречат «Пропустить»
|
||||||
|
Поля возраста, роста и веса SHALL быть подписаны «нужно для расчёта норм», а не «обязательно».
|
||||||
|
|
||||||
|
#### Scenario: Подписи на первом шаге
|
||||||
|
- **GIVEN** новый пользователь открыл мастер
|
||||||
|
- **WHEN** он смотрит на первый шаг
|
||||||
|
- **THEN** рядом с полями написано «нужно для расчёта норм»
|
||||||
|
- **AND** слова «обязательно» нет
|
||||||
|
|
||||||
|
#### Scenario: Пропуск
|
||||||
|
- **GIVEN** открыт первый шаг мастера
|
||||||
|
- **WHEN** пользователь нажимает «Пропустить»
|
||||||
|
- **THEN** открывается главный экран
|
||||||
|
|||||||
2
sw.js
2
sw.js
@ -1,5 +1,5 @@
|
|||||||
// Сервис-воркер: приложение открывается без интернета (сначала сеть, при отсутствии — копия из кэша).
|
// Сервис-воркер: приложение открывается без интернета (сначала сеть, при отсутствии — копия из кэша).
|
||||||
const CACHE = 'tpt-v19-wizard-why';
|
const CACHE = 'tpt-v20-field-label';
|
||||||
const FILES = ['./', 'index.html', 'gym-plan.i18n.js', 'manifest.webmanifest', 'icon.svg', 'recipes.html', 'recipes.css', 'recipes.js', 'recipes-core.js', 'recipes-status.i18n.js', 'recipes.data.json', 'recipes.i18n.json', 'telemetry.js', 'assets/oats.jpg', 'assets/chicken.jpg', 'assets/salad.jpg'];
|
const FILES = ['./', 'index.html', 'gym-plan.i18n.js', 'manifest.webmanifest', 'icon.svg', 'recipes.html', 'recipes.css', 'recipes.js', 'recipes-core.js', 'recipes-status.i18n.js', 'recipes.data.json', 'recipes.i18n.json', 'telemetry.js', 'assets/oats.jpg', 'assets/chicken.jpg', 'assets/salad.jpg'];
|
||||||
self.addEventListener('install', e => { e.waitUntil(caches.open(CACHE).then(c => c.addAll(FILES)).then(() => self.skipWaiting())); });
|
self.addEventListener('install', e => { e.waitUntil(caches.open(CACHE).then(c => c.addAll(FILES)).then(() => self.skipWaiting())); });
|
||||||
self.addEventListener('activate', e => {
|
self.addEventListener('activate', e => {
|
||||||
|
|||||||
@ -218,3 +218,13 @@ test('Сценарий: первый шаг объясняет, зачем да
|
|||||||
btn(document, 'Набор').click();
|
btn(document, 'Набор').click();
|
||||||
assert.match(note(), /Выбрано: Набор/);
|
assert.match(note(), /Выбрано: Набор/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('Сценарий: на первом шаге вместо «обязательно» подпись «нужно для расчёта норм», «Пропустить» открывает главный экран', t => {
|
||||||
|
const { dom, document } = open(); t.after(() => dom.window.close());
|
||||||
|
const marks = [...document.querySelectorAll('.sheet .req')].map(m => m.textContent);
|
||||||
|
assert.equal(marks.length, 3);
|
||||||
|
for (const m of marks) assert.match(m, /нужно для расчёта норм/);
|
||||||
|
assert.doesNotMatch(document.querySelector('.sheet').textContent, /обязательно/);
|
||||||
|
btn(document, 'Пропустить').click();
|
||||||
|
assert.equal(document.querySelector('.sheet'), null);
|
||||||
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user