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/qg-146: Тестовый вариант модального окна #182

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

DaemonFoen
Copy link
Contributor

Чеклист

  • Пулл-реквест
    • Я проверил, что в ПРе нет лишних коммитов и мёржей
    • Я убедился, что все проверки пршли успешно
    • Я сделал анонс в Telegram-канале QYoga
  • Дизайн
    • Я проверил, что модули (классы сервисов) зависят не более чем от трёх других модулей
    • Я разделил ввод-вывод, вычисления и оркестрацию
  • Тестирование
    • Я видел, как каждый тест превратился из красного в зелёный

@DaemonFoen DaemonFoen force-pushed the qg-146/programm-exercise-view branch from 81d6373 to 4b101c5 Compare May 5, 2024 14:44
@d-r-q d-r-q self-requested a review May 27, 2024 02:36
@@ -8,8 +8,11 @@ import pro.azhidkov.platform.spring.http.hxRedirect
import pro.azhidkov.platform.spring.mvc.modelAndView
import pro.qyoga.app.platform.ResponseEntityExt
import pro.qyoga.app.platform.notFound
import pro.qyoga.app.therapist.therapy.exercises.EditExercisePageController.ExerciseStepProcessor.processSteps
Copy link
Owner

Choose a reason for hiding this comment

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

Первым делом, надо ребейзнуть ветку на актуальный мастер

import pro.qyoga.core.therapy.exercises.ExercisesService
import pro.qyoga.core.therapy.exercises.dtos.ExerciseSummaryDto
import pro.qyoga.core.therapy.exercises.model.ExerciseStep
Copy link
Owner

Choose a reason for hiding this comment

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

Вторым делом - написать тест на эндпоинт модалки, чтобы koverVerify проходил

@@ -3,6 +3,22 @@
<head>
<div th:replace="~{fragments/header.html}"></div>
<title th:text="${program?.title ?: 'Новая программа'}">Новая программа</title>
<style>
Copy link
Owner

Choose a reason for hiding this comment

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

Кажется, это стоит утащить в exercise-model.html

@@ -26,7 +42,9 @@ <h1 class="mt-4 pb-2 mb-3 border-bottom" th:text="${program?.title ?: 'Нова
document.addEventListener('alpine:init', () => {
Alpine.data('programForm', () => ({
exercises: initialExercises,

loadPage() {
Copy link
Owner

Choose a reason for hiding this comment

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

Как пример обходится без кастомных скриптов? Подозреваю, благодаря data-bs-toggle="modal" - сделай так же, пожалуйста.

exerciseId
)

return modelAndView("therapist/therapy/exercises/exercise-modal") {
Copy link
Owner

Choose a reason for hiding this comment

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

Тут надо возвращать фрагмент с html-ем модалки, без заголовка и т.д.

Comment on lines +106 to +111
<input accept="image/*"
class="form-control d-none"
th:disabled="${true}"
th:id="|stepImageInput${iterStat.index}|"
th:name="|stepImage${iterStat.index}|"
type="file"/>
Copy link
Owner

Choose a reason for hiding this comment

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

Выкинуть целиком

</div>
<div class="row align-items-center px-3 mb-3">
<div class="col-sm-2 mb-3 text-center mx-auto">
<label class="align-items-center"
Copy link
Owner

@d-r-q d-r-q May 31, 2024

Choose a reason for hiding this comment

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

label тоже надо выкинуть, но изображение оставить и засунуть в <p> с описанием

Comment on lines +113 to +122
<div class="col-sm-10 form-floating gx-2">
<textarea class="form-control"
placeholder="Глубоко вдохните..."
readonly
required
style="height: 15rem"
th:disabled="${true}"
th:name="|steps[${iterStat.index}].description|">[[${step.description}]]</textarea>
<label th:for="|steps[${iterStat.index}].description|">Описание шага</label>
</div>
Copy link
Owner

@d-r-q d-r-q May 31, 2024

Choose a reason for hiding this comment

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

Заменить на <p> с картинкой и описанием.

Comment on lines +34 to +51
object ExerciseStepProcessor {
const val NO_IMAGE = "/img/no-image.png"
fun processSteps(
steps: List<ExerciseStep>?,
exerciseId: Long
): List<ProcessingExerciseStep> {
return if (steps.isNullOrEmpty()) {
listOf(ProcessingExerciseStep("", NO_IMAGE))
} else {
steps.mapIndexed { idx, step ->
val imageUrl =
step.imageId?.let { "/therapist/exercises/$exerciseId/step-images/$idx" }
?: NO_IMAGE
ProcessingExerciseStep(description = step.description, imageUrl = imageUrl)
}
}
}
}
Copy link
Owner

Choose a reason for hiding this comment

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

Чёт у меня такое ощущение, что это всё добро вместе с ProcessingExerciseStep можно выкинуть.

Ты передаёшь упражнение в темплейт, там бежишь по exercise.steps, там у тебя есть step.description для описания и exercise.id + each:idx для формирования урла картинки.

Либо, надо сформировать отдельную View-модель с ExerciseView + ExerciseStepView, которая уже целиком содержит все полностью отформатированные данные (имя типа, длительность, урл картинки) и сборку этой модели перенести в конструкторы соответствующих классов

<section class="container px-4">
<h1 class="mt-4 pb-2 mb-3 border-bottom"
th:text="${exercise?.title ?: 'Новое упражнение'}">Новое упражнение</h1>
<form class="mt-4"
Copy link
Owner

Choose a reason for hiding this comment

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

Выкинуть целиком

</head>
<body class="sb-nav-fixed">

<div class="modal-body">
Copy link
Owner

Choose a reason for hiding this comment

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

Надо отцентировать модалку на мобилках:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants