From acac6402d785541218cd17af595780a03ddb421c Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Wed, 14 May 2025 11:02:58 +0200 Subject: [PATCH] feat: copy link --- frontend/src/views/classes/TeacherClasses.vue | 93 ++++++++++++------- 1 file changed, 62 insertions(+), 31 deletions(-) diff --git a/frontend/src/views/classes/TeacherClasses.vue b/frontend/src/views/classes/TeacherClasses.vue index 3ca32264..0f5b35c1 100644 --- a/frontend/src/views/classes/TeacherClasses.vue +++ b/frontend/src/views/classes/TeacherClasses.vue @@ -132,17 +132,13 @@ // Show the teacher, copying of the code was a successs const copied = ref(false); - // Copy the generated code to the clipboard - async function copyToClipboard(): Promise { - await navigator.clipboard.writeText(code.value); - copied.value = true; - } + async function copyToClipboard(code: string, isDialog: boolean = false, isLink: boolean = false): Promise { + const content = isLink ? `${window.location.origin}/user/class?code=${code}` : code; + await navigator.clipboard.writeText(content); + copied.value = isDialog; - async function copyCode(selectedCode: string): Promise { - code.value = selectedCode; - await copyToClipboard(); - showSnackbar(t("copied"), "white"); - copied.value = false; + if (!isDialog) + showSnackbar(t("copied"), "white"); } // Custom breakpoints @@ -235,20 +231,25 @@ - - {{ c.id }} - - + + + {{ c.id }} + + + mdi-link-variant + + + + + {{ c.students.length }} @@ -310,14 +311,29 @@ max-width="400px" > - code + {{ t("code") }} + > + +
+ > + +