Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: limited audit form score inputs [WTEL-4505] #231

Merged
merged 4 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@webitel/ui-sdk",
"version": "24.4.36",
"version": "24.4.37",
"private": false,
"scripts": {
"dev": "vite",
Expand Down
1 change: 1 addition & 0 deletions src/locale/en/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ export default {
score: 'Score',
},
clearSelection: 'Clear selection',
scoreInputTooltip: 'Value should be more than {min} and less than {max}',
},
deleteConfirmationPopup: {
title: 'Confirm deletion',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ru/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export default {
score: 'Бал',
},
clearSelection: 'Очистить выбор',
scoreInputTooltip: 'Значение должно быть не меньше {min} и не больше {max}',
},
deleteConfirmationPopup: {
title: 'Подтвердите удаление',
Expand Down
1 change: 1 addition & 0 deletions src/locale/ua/ua.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export default {
score: 'Бал',
},
clearSelection: 'Очистити вибір',
scoreInputTooltip: 'Значення повинно бути не менше {min} та не більше {max}',
},
deleteConfirmationPopup: {
title: 'Підтвердіть видалення',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('AuditFormQuestionOptionsWriteRow', () => {
option: {},
},
});
const deleteBtn = wrapper.findComponent({ name: 'wt-icon-btn' });
const deleteBtn = wrapper.findComponent('.audit-form-question-options-write-row__tooltip').findComponent({ name: 'wt-icon-btn' });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Мені ось тут не дуже подобається findComponent 2 рази(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Згодна(( вчора шукала інші способи, вивчала доку, пробувала.
Питання в тому, що там треба знайти іконку в конкретному блоці. І я навть думала потрібній іконці псотавити просто клас, шоб шукати по ньому. Але, блін, цей клас не потрібен для стилів. Додавати лише для тестів звучить як фіговий варіант...

Спробую знайти, як це можна скоротити

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Оце я гоню, звісно...там же просто роботою з селекторами можна порєшать..

expect(deleteBtn.attributes().icon).toBe('bucket');
deleteBtn.vm.$emit('click');
expect(wrapper.emitted().delete).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
/>
<wt-input
:label="$t('webitelUI.auditForm.score', 1)"
:label-props="{ hint: $t('scorecards.scoreInputTooltip', { min: '0', max: '10'}), hintPosition: 'right' }"
:value="option.score"
:v="v$.option.score"
:number-min="0"
:number-max="10"
type="number"
@input="emit('update:option', { name: option.name, score: $event })"
@input="changeScore"
/>
<wt-tooltip class="audit-form-question-options-write-row__tooltip">
<template #activator>
Expand Down Expand Up @@ -72,6 +75,11 @@ const v$ = useVuelidate(
{ $autoDirty: true },
);

function changeScore (value) {
const score = value > 10 ? 10 : Number(Math.abs(value)); // to prevent -1, 000 or string value
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я би додала посилання на таску, бо невідомо звідки саме 10 взялось

  • 10 - винести у веріаблу
    Але може це не обовязково, на твій розсуд

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

слушно, дякую!

emit('update:option', { name: props.option.name, score });
}

// init validation
onMounted(() => v$.value.$touch());
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
:value="question.min"
:v="v$.question.min"
:number-min="0"
:number-max="19"
:number-max="9"
:label="$t('reusable.from')"
:label-props="{ hint: $t('scorecards.scoreInputTooltip', { min: '0', max: '9'}), hintPosition: 'right' }"
type="number"
required
@input="updateQuestion({ path: 'min', value: $event })"
Expand All @@ -18,8 +19,9 @@
:value="question.max"
:v="v$.question.max"
:number-min="1"
:number-max="20"
:number-max="10"
:label="$t('reusable.to')"
:label-props="{ hint: $t('scorecards.scoreInputTooltip', { min: '1', max: '10'}), hintPosition: 'right' }"
type="number"
required
@input="updateQuestion({ path: 'max', value: $event })"
Expand Down Expand Up @@ -109,7 +111,8 @@ const scoreRange = computed(() => {
const isResult = computed(() => !isEmpty(props.result));

function updateQuestion({ path, value }) {
emit('change:question', updateObject({ obj: props.question, path, value }));
const number = value > 10 ? 10 : Number(Math.abs(value)); // to prevent -1, 000 or string value
emit('change:question', updateObject({ obj: props.question, path, value: number }));
}

// init validation
Expand Down
Loading