From 97f6a603f56548db6f7ae3c93f280429ea22f1ab Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Sun, 18 May 2025 14:40:37 +0200 Subject: [PATCH] feat(frontend): UI vragen & antwoorden verbeterd. --- frontend/src/components/QandA.vue | 1 - frontend/src/components/QuestionBox.vue | 76 ++---- frontend/src/components/SingleQuestion.vue | 223 +++++++----------- frontend/src/i18n/locale/de.json | 8 +- frontend/src/i18n/locale/en.json | 8 +- frontend/src/i18n/locale/fr.json | 8 +- frontend/src/i18n/locale/nl.json | 8 +- .../views/discussions/SingleDiscussion.vue | 35 ++- .../views/learning-paths/LearningPathPage.vue | 14 +- 9 files changed, 164 insertions(+), 217 deletions(-) diff --git a/frontend/src/components/QandA.vue b/frontend/src/components/QandA.vue index 815afc68..0c669d9d 100644 --- a/frontend/src/components/QandA.vue +++ b/frontend/src/components/QandA.vue @@ -15,7 +15,6 @@
diff --git a/frontend/src/components/QuestionBox.vue b/frontend/src/components/QuestionBox.vue index 00186057..8072df16 100644 --- a/frontend/src/components/QuestionBox.vue +++ b/frontend/src/components/QuestionBox.vue @@ -19,6 +19,7 @@ language: Language; learningObjectHruid?: string; forGroup?: GroupDTOId | undefined; + withTitle?: boolean; }>(); const { t } = useI18n(); @@ -65,6 +66,8 @@ const createQuestionMutation = useCreateQuestionMutation(loID); const groupsQueryResult = useStudentGroupsQuery(authService.authState.user?.profile.preferred_username); + const showQuestionBox = computed(() => authService.authState.activeRole === AccountType.Student && pathIsAssignment.value); + function submitQuestion(): void { const assignments = studentAssignmentsQueryResult.data.value?.assignments as AssignmentDTO[]; const assignment = assignments.find( @@ -93,24 +96,26 @@ @@ -119,40 +124,5 @@ width: 100%; max-width: 400px; margin: 20px auto; - font-family: sans-serif; - } - - .input-wrapper { - display: flex; - align-items: center; - border: 1px solid #ccc; - border-radius: 999px; - padding: 8px 12px; - box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); - } - - .question-input { - flex: 1; - border: none; - outline: none; - font-size: 14px; - background-color: transparent; - } - - .question-input::placeholder { - color: #999; - } - - .send-button { - background: none; - border: none; - cursor: pointer; - font-size: 16px; - color: #555; - transition: color 0.2s ease; - } - - .send-button:hover { - color: #000; } diff --git a/frontend/src/components/SingleQuestion.vue b/frontend/src/components/SingleQuestion.vue index 03f4e28e..2367b536 100644 --- a/frontend/src/components/SingleQuestion.vue +++ b/frontend/src/components/SingleQuestion.vue @@ -5,9 +5,10 @@ import UsingQueryResult from "./UsingQueryResult.vue"; import type { AnswersResponse } from "@/controllers/answers"; import type { AnswerData, AnswerDTO } from "@dwengo-1/common/interfaces/answer"; + import type { UserDTO } from "@dwengo-1/common/interfaces/user"; import authService from "@/services/auth/auth-service"; import { useI18n } from "vue-i18n"; - import { AccountType } from "@dwengo-1/common/util/account-types" + import { AccountType } from "@dwengo-1/common/util/account-types"; const { t } = useI18n(); @@ -65,161 +66,119 @@ createAnswerMutation.mutate(answerData, { onSuccess: async () => { answer.value = ""; + expanded.value = true; await answersQuery.refetch(); }, }); } } + + function displayNameFor(user: UserDTO) { + if (user.firstName && user.lastName) { + return `${user.firstName} ${user.lastName}`; + } else { + return user.username; + } + } diff --git a/frontend/src/i18n/locale/de.json b/frontend/src/i18n/locale/de.json index eb70f9f4..0ab6550e 100644 --- a/frontend/src/i18n/locale/de.json +++ b/frontend/src/i18n/locale/de.json @@ -169,10 +169,12 @@ "hintKeywordsSeparatedBySpaces": "Schlüsselwörter durch Leerzeichen getrennt", "questions": "Fragen", "view-questions": "Fragen anzeigen auf ", - "question-input-placeholder": "Frage...", - "answer-input-placeholder": "Antwort...", + "question-input-placeholder": "Ihre Frage...", + "answer-input-placeholder": "Ihre Antwort...", "answers-toggle-hide": "Antworten verstecken", "answers-toggle-show": "Antworten anzeigen", "no-questions": "Keine Fragen", - "no-discussion-tip": "Wählen Sie ein Lernobjekt aus, um dessen Fragen anzuzeigen" + "no-discussion-tip": "Wählen Sie ein Lernobjekt aus, um dessen Fragen anzuzeigen", + "askAQuestion": "Eine Frage stellen", + "questionsCapitalized": "Fragen" } diff --git a/frontend/src/i18n/locale/en.json b/frontend/src/i18n/locale/en.json index 52e70595..ee5fb951 100644 --- a/frontend/src/i18n/locale/en.json +++ b/frontend/src/i18n/locale/en.json @@ -169,10 +169,12 @@ "hintKeywordsSeparatedBySpaces": "Keywords separated by spaces", "questions": "questions", "view-questions": "View questions in ", - "question-input-placeholder": "question...", - "answer-input-placeholder": "answer...", + "question-input-placeholder": "Your question...", + "answer-input-placeholder": "Your answer...", "answers-toggle-hide": "Hide answers", "answers-toggle-show": "Show answers", "no-questions": "No questions asked yet", - "no-discussion-tip": "Choose a learning object to view its questions" + "no-discussion-tip": "Choose a learning object to view its questions", + "askAQuestion": "Ask a question", + "questionsCapitalized": "Questions" } diff --git a/frontend/src/i18n/locale/fr.json b/frontend/src/i18n/locale/fr.json index 0669f029..1711c91d 100644 --- a/frontend/src/i18n/locale/fr.json +++ b/frontend/src/i18n/locale/fr.json @@ -170,10 +170,12 @@ "hintKeywordsSeparatedBySpaces": "Mots-clés séparés par des espaces", "questions": "Questions", "view-questions": "Voir les questions dans ", - "question-input-placeholder": "question...", - "answer-input-placeholder": "réponse...", + "question-input-placeholder": "Votre question...", + "answer-input-placeholder": "Votre réponse...", "answers-toggle-hide": "Masquer réponses", "answers-toggle-show": "Afficher réponse", "no-questions": "Aucune question trouvée", - "no-discussion-tip": "Sélectionnez un objet d'apprentissage pour afficher les questions qui s'y rapportent" + "no-discussion-tip": "Sélectionnez un objet d'apprentissage pour afficher les questions qui s'y rapportent", + "askAQuestion": "Pose une question", + "questionsCapitalized": "Questions" } diff --git a/frontend/src/i18n/locale/nl.json b/frontend/src/i18n/locale/nl.json index acc19cca..c3aaf111 100644 --- a/frontend/src/i18n/locale/nl.json +++ b/frontend/src/i18n/locale/nl.json @@ -169,10 +169,12 @@ "hintKeywordsSeparatedBySpaces": "Trefwoorden gescheiden door spaties", "questions": "vragen", "view-questions": "Bekijk vragen in ", - "question-input-placeholder": "vraag...", - "answer-input-placeholder": "antwoord...", + "question-input-placeholder": "Uw vraag...", + "answer-input-placeholder": "Uw antwoord...", "answers-toggle-hide": "Verberg antwoorden", "answers-toggle-show": "Toon antwoorden", "no-questions": "Nog geen vragen gesteld", - "no-discussion-tip": "Kies een leerobject om zijn vragen te bekijken" + "no-discussion-tip": "Kies een leerobject om zijn vragen te bekijken", + "askAQuestion": "Stel een vraag", + "questionsCapitalized": "Vragen" } diff --git a/frontend/src/views/discussions/SingleDiscussion.vue b/frontend/src/views/discussions/SingleDiscussion.vue index cd6e4b64..698b5688 100644 --- a/frontend/src/views/discussions/SingleDiscussion.vue +++ b/frontend/src/views/discussions/SingleDiscussion.vue @@ -15,6 +15,9 @@ import type { QuestionDTO } from "@dwengo-1/common/interfaces/question"; import DiscussionsSideBar from "@/components/DiscussionsSideBar.vue"; import QuestionBox from "@/components/QuestionBox.vue"; + import { useI18n } from "vue-i18n"; + + const { t } = useI18n(); const route = useRoute(); @@ -120,21 +123,29 @@