Skip to content

Commit

Permalink
upgrade(): update libs and deps
Browse files Browse the repository at this point in the history
  • Loading branch information
CarloGauss33 committed Sep 28, 2023
1 parent e179408 commit e63bc78
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 79 deletions.
94 changes: 21 additions & 73 deletions app/javascript/components/assignment-form.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { defineProps, withDefaults, computed, ref, onMounted } from 'vue';
import { defineProps, withDefaults, computed, ref, watch, onMounted } from 'vue';
import { useMutation } from '@tanstack/vue-query';
import AssignmentResponseApi, {
type AssignmentQuestionUploadResponse,
Expand Down Expand Up @@ -188,6 +188,12 @@ function submitLastStep() {
mutate();
}
watch(currentQuestionIndex, (val: number) => {
if (val > numberOfQuestions.value && ableToUpload.value) {
submitLastStep();
}
});
</script>
<template>
<div class="w-full rounded-lg bg-slate-100 px-4 py-6 text-justify shadow-lg">
Expand All @@ -203,6 +209,7 @@ function submitLastStep() {
<div v-else>
<div class="mb-4 grid grid-cols-5 items-center">
<base-button
v-if="currentQuestionIndex <= numberOfQuestions"
variant="tertiary"
class="col-span-1 py-1 text-2xl"
:href="currentQuestionIndex === 0 || !ableToUpload ? '/' : undefined"
Expand All @@ -211,11 +218,14 @@ function submitLastStep() {
</base-button>

<div class="col-span-3 text-center">
<div
class="col-span-3 text-center"
:class="{ 'col-span-5 mb-16': currentQuestionIndex > numberOfQuestions }"
>
<h2 class="text-2xl font-bold text-black">
{{
currentQuestionIndex > numberOfQuestions ?
'Resumen' :
'Enviando Respuestas' :
props.assignmentQuestions[currentQuestionIndex].title
}}
{{ currentStepSubmitted ? " (Respondida)" : "" }}
Expand Down Expand Up @@ -250,6 +260,7 @@ function submitLastStep() {
</base-notice>

<base-button
v-if="currentQuestionIndex <= numberOfQuestions"
size="sm"
class="mb-4 w-full md:w-auto"
variant="secondary"
Expand All @@ -260,78 +271,15 @@ function submitLastStep() {
<div v-if="currentQuestionIndex > numberOfQuestions">
<div
v-if="!isLastStep"
class="flex flex-col justify-center"
class="flex w-full flex-col items-center justify-center"
>
<p class="mb-4 text-justify font-medium">
<span v-if="ableToUpload">
Tus respuestas fueron enviadas correctamente
En caso de querer modificar alguna respuesta, puedes volver hacia atrás y realizarlo.
</span>
<span v-else>
La evaluación se encuentra cerrada, no puedes realizar más respuestas.
</span>
</p>

<base-button
v-if="ableToUpload"
:disabled="isSubmitting || isSubmitLoading || isSubmitSuccess"
class="mb-8"
@click.prevent="submitLastStep"
>
Terminar interrogación
</base-button>
<base-button
v-else
:href="`/assignments/${props.assignment.id}/assignment_responses`"
class="mb-8"
variant="secondary"
>
Ir al detalle de la entrega
</base-button>

<h1 class="mb-8 text-left text-lg font-bold text-edd-blue-800">
Resumen Respuestas
</h1>
<div
class="mb-12 grid grid-cols-1 gap-4 md:grid-cols-4"
>
<a
v-for="(uploadedResponse, index) in uploadResponses"
:key="uploadedResponse.id"
:disabled="!uploadedResponse.file"
:href="uploadedResponse.file ? uploadedResponse.file.url : '#'"
:target="uploadedResponse.file ? '_blank' : ''"
class="flex flex-col items-center justify-center rounded-lg p-4 shadow-lg"
:class="{
'bg-edd-blue-100 text-edd-blue-800 hover:text-white hover:bg-edd-blue-800': uploadedResponse.file,
'cursor-default bg-slate-100 text-slate-500': !uploadedResponse.file,
}"
>
<h3 class="text-center text-xl font-semibold">
{{ props.assignmentQuestions[index].title }}
</h3>
<h2 class="text-center">
Estado: {{ uploadedResponse.file ? "Respondida" : "No respondida" }}
</h2>
</a>
</div>
<base-button
v-if="isSubmitSuccess || !ableToUpload"
:disabled="isSubmitting || !anyNewResponse"
href="/"
variant="secondary"
>
Volver al inicio
</base-button>
<h2
v-if="isSubmitSuccess"
class="mt-4 text-center text-xl font-bold text-edd-blue-800"
>
Tus respuestas fueron enviadas correctamente!
</h2>
<div v-if="isSubmitLoading">
Enviando...
</div>
v-if="ableToUpload"
class="h-32 w-32 animate-spin rounded-full border-b-2 border-gray-900"
/>
<span v-else>
La evaluación se encuentra cerrada, no puedes realizar más respuestas.
</span>
</div>
<div v-else>
Cargando...
Expand Down
13 changes: 7 additions & 6 deletions app/javascript/components/base-scanner.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const props = withDefaults(defineProps<Props>(), {
minAttachments: 1,
downloadAfterScan: false,
attachmentBaseName: 'attachment',
submitLabel: 'Guardar y enviar',
submitLabel: 'Enviar',
numberOfSteps: 1,
currentStep: 1,
isSubmitting: false,
Expand Down Expand Up @@ -69,7 +69,7 @@ const uploadMessage = computed(() => {
return 'Actualizar respuesta';
}

return props.submitLabel;
return `Enviar pregunta ${props.currentStep}`;
});

async function generatePDF() {
Expand Down Expand Up @@ -180,9 +180,10 @@ async function handleFileUpload(event: Event) {
<div v-else>
<div class="flex h-96 w-64 flex-col items-center justify-center rounded-md bg-edd-blue-100 hover:cursor-pointer">
<i class="fas fa-file-upload text-4xl text-edd-blue-800" />
<span class="p-2 text-2xl text-edd-blue-800">
Agregar Captura
</span>
<div class="p-2 text-center text-edd-blue-800 flex flex-col">
<p class="text-2xl"> Añadir captura</p>
<p class="text-lg"> (Pregunta {{ currentStep }})</p>
</div>
</div>
</div>
</label>
Expand Down Expand Up @@ -218,7 +219,7 @@ async function handleFileUpload(event: Event) {
:disabled="isLoading"
@click="submit"
>
{{ ableToSubmit ? uploadMessage : skipMessage }} ({{ props.currentStep }}/{{ props.numberOfSteps }})
{{ ableToSubmit ? uploadMessage : skipMessage }}
</base-button>
</div>
<base-notice
Expand Down

0 comments on commit e63bc78

Please sign in to comment.