From 853c8746ea5cdd5b34e11fffdf456e0ca63842c3 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Thu, 7 Sep 2023 16:54:21 +0200 Subject: [PATCH] VBV-329: Add link to competence certificate in circle view --- client/src/components/ui/ItCheckbox.vue | 20 ++++- .../circlePage/LearningSequence.vue | 87 ++++++++++++++++--- client/src/types.ts | 16 ++++ .../assignment/graphql/mutations.py | 2 +- .../vbv_lernwelt/assignment/graphql/types.py | 2 +- server/vbv_lernwelt/assignment/services.py | 20 +++-- .../assignment/tests/test_graphql.py | 4 +- server/vbv_lernwelt/learnpath/models.py | 16 ++++ server/vbv_lernwelt/learnpath/serializers.py | 57 +++++++++++- ...icon-lc-competence-certificate-checked.svg | 12 +++ .../icons/icon-lc-competence-certificate.svg | 11 +++ 11 files changed, 221 insertions(+), 26 deletions(-) create mode 100644 server/vbv_lernwelt/static/icons/icon-lc-competence-certificate-checked.svg create mode 100644 server/vbv_lernwelt/static/icons/icon-lc-competence-certificate.svg diff --git a/client/src/components/ui/ItCheckbox.vue b/client/src/components/ui/ItCheckbox.vue index 3cf3c57f..89fbcb59 100644 --- a/client/src/components/ui/ItCheckbox.vue +++ b/client/src/components/ui/ItCheckbox.vue @@ -2,10 +2,22 @@ import type { CheckboxItem } from "@/components/ui/checkbox.types"; import log from "loglevel"; -const props = defineProps<{ +interface Props { checkboxItem: CheckboxItem; disabled?: boolean; -}>(); + iconCheckedPath?: string; + iconCheckedHoverPath?: string; + iconUncheckedPath?: string; + iconUncheckedHoverPath?: string; +} + +const props = withDefaults(defineProps(), { + disabled: false, + iconCheckedPath: "/static/icons/icon-checkbox-checked.svg", + iconCheckedHoverPath: "/static/icons/icon-checkbox-checked-hover.svg", + iconUncheckedPath: "/static/icons/icon-checkbox-unchecked.svg", + iconUncheckedHoverPath: "/static/icons/icon-checkbox-unchecked-hover.svg", +}); const emit = defineEmits(["toggle"]); const toggle = () => { @@ -39,8 +51,8 @@ const input = () => { class="flex h-8 items-center bg-contain bg-no-repeat pl-8 disabled:opacity-50" :class=" checkboxItem.checked - ? 'bg-[url(/static/icons/icon-checkbox-checked.svg)] hover:bg-[url(/static/icons/icon-checkbox-checked-hover.svg)]' - : 'bg-[url(/static/icons/icon-checkbox-unchecked.svg)] hover:bg-[url(/static/icons/icon-checkbox-unchecked-hover.svg)]' + ? `bg-[url(${props.iconCheckedPath})] hover:bg-[url(${props.iconCheckedHoverPath})]` + : `bg-[url(${props.iconUncheckedPath})] hover:bg-[url(${props.iconUncheckedHoverPath})]` " tabindex="0" @keydown.stop="keydown" diff --git a/client/src/pages/learningPath/circlePage/LearningSequence.vue b/client/src/pages/learningPath/circlePage/LearningSequence.vue index 0eaaba36..17ec7657 100644 --- a/client/src/pages/learningPath/circlePage/LearningSequence.vue +++ b/client/src/pages/learningPath/circlePage/LearningSequence.vue @@ -5,6 +5,7 @@ import { showIcon } from "@/pages/learningPath/circlePage/learningSequenceUtils" import { useCircleStore } from "@/stores/circle"; import type { CourseCompletionStatus, + LearningContent, LearningContentInterface, LearningSequence, } from "@/types"; @@ -87,6 +88,45 @@ const learningSequenceBorderClass = computed(() => { return result; }); + +function belongsToCompetenceCertificate(lc: LearningContent) { + return ( + (lc.content_type === "learnpath.LearningContentAssignment" || + lc.content_type === "learnpath.LearningContentEdoniqTest") && + lc.competence_certificate?.frontend_url + ); +} + +function checkboxIconCheckedPath(lc: LearningContent) { + if (belongsToCompetenceCertificate(lc)) { + return "/static/icons/icon-lc-competence-certificate-checked.svg"; + } + return "/static/icons/icon-checkbox-checked.svg"; +} + +function checkboxIconCheckedHoverPath(lc: LearningContent) { + if (belongsToCompetenceCertificate(lc)) { + return "/static/icons/icon-lc-competence-certificate-checked.svg"; + } + + return "/static/icons/icon-checkbox-checked-hover.svg"; +} + +function checkboxIconUncheckedPath(lc: LearningContent) { + if (belongsToCompetenceCertificate(lc)) { + return "/static/icons/icon-lc-competence-certificate.svg"; + } + + return "/static/icons/icon-checkbox-unchecked.svg"; +} + +function checkboxIconUncheckedHoverPath(lc: LearningContent) { + if (belongsToCompetenceCertificate(lc)) { + return "/static/icons/icon-lc-competence-certificate.svg"; + } + + return "/static/icons/icon-checkbox-unchecked-hover.svg"; +}