Skip to content

Commit 400d250

Browse files
committedFeb 3, 2025
refactor code for guid
1 parent 45fecb9 commit 400d250

File tree

3 files changed

+318
-158
lines changed

3 files changed

+318
-158
lines changed
 

Diff for: ‎webapp/src/components/home/Home.vue

+7-5
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ import DISCOllaboratives from "@/components/simple/DISCOllaboratives.vue";
182182
import ButtonsCard from "@/components/containers/ButtonsCard.vue";
183183
import { driver, type DriveStep } from "driver.js";
184184
import "driver.js/dist/driver.css";
185-
import { watch } from "vue";
185+
import { nextTick, watch } from "vue";
186186
import { useGuideStore } from "@/store/guide";
187187
188188
const router = useRouter();
@@ -253,11 +253,13 @@ driverObj.drive();
253253
254254
watch(
255255
() => guideStoreTraining.showGuide,
256-
(newValue) => {
257-
driverObj.destroy();
258-
console.log(router.currentRoute.value.path);
259-
if (router.currentRoute.value.path == "/") {
256+
async (newValue) => {
257+
if (driverObj.isActive()) {
258+
await driverObj.destroy();
259+
}
260+
if (router.currentRoute.value.path === "/") {
260261
driverObj.setSteps(steps);
262+
await nextTick();
261263
driverObj.drive();
262264
}
263265
},

Diff for: ‎webapp/src/components/testing/Testing.vue

+17-21
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<script lang="ts" setup>
145145
import createDebug from "debug";
146146
import { List } from "immutable";
147-
import { computed, ref, onActivated, watch } from "vue";
147+
import { computed, ref, onActivated, watch, nextTick } from "vue";
148148
import { RouterLink, useRouter } from "vue-router";
149149
import { VueSpinner } from "vue3-spinners";
150150
@@ -296,7 +296,7 @@ function taskTitle(taskID: string): string | undefined {
296296
297297
return titled.displayInformation.taskTitle;
298298
}
299-
// Define the steps for the guide when no user's models are available
299+
//Define the steps for the guide when no user's models are available
300300
const modelEmptySteps: DriveStep[] = [
301301
{
302302
popover: {
@@ -425,27 +425,23 @@ const evaluationSteps: DriveStep[] = [
425425
];
426426
watch(
427427
() => guideStoreTesting.showGuide,
428-
(newValue) => {
429-
driverTesting.destroy();
430-
if (router.currentRoute.value.path == "/evaluate") {
431-
if (validationStore.step === 0) {
432-
if (models.infos.isEmpty()) {
433-
driverTesting.setSteps(modelEmptySteps);
434-
} else {
435-
driverTesting.setSteps(modelSteps);
436-
}
428+
async (newValue) => {
429+
if (driverTesting.isActive()) {
430+
await driverTesting.destroy();
431+
}
432+
if (router.currentRoute.value.path === "/evaluate") {
433+
const stepsMap: Record<number, DriveStep[]> = {
434+
0: models.infos.isEmpty() ? modelEmptySteps : modelSteps,
435+
1: dataSteps,
436+
2: evaluationSteps,
437+
};
438+
439+
const steps = stepsMap[validationStore.step] || [];
440+
if (steps.length) {
441+
driverTesting.setSteps(steps);
442+
await nextTick();
437443
driverTesting.drive();
438444
}
439-
if (validationStore.step !== 0) {
440-
if (validationStore.step === 1) {
441-
driverTesting.setSteps(dataSteps);
442-
driverTesting.drive();
443-
}
444-
if (validationStore.step === 2) {
445-
driverTesting.setSteps(evaluationSteps);
446-
driverTesting.drive();
447-
}
448-
}
449445
}
450446
},
451447
);

0 commit comments

Comments
 (0)