Allow multi-circle selection in cockpit
This commit is contained in:
parent
b950f11942
commit
fb42625354
|
|
@ -27,7 +27,6 @@ function userCountStatus(userId: number) {
|
|||
}
|
||||
|
||||
const data = {
|
||||
circles: ["KMU Teil 1", "KMU Teil 2", "3-Säuli-Prinzip"],
|
||||
transferProgress: {
|
||||
fail: 0,
|
||||
success: 3,
|
||||
|
|
@ -35,17 +34,11 @@ const data = {
|
|||
},
|
||||
};
|
||||
|
||||
const selectedCircle = ref(1);
|
||||
|
||||
function setActiveClasses(id: number) {
|
||||
return cockpitStore.selectedCircle === id
|
||||
return cockpitStore.selectedCircles.indexOf(id) > -1
|
||||
? ["bg-blue-900", "text-white"]
|
||||
: ["text-bg-900"];
|
||||
}
|
||||
|
||||
function setActiveCircle(id: number) {
|
||||
cockpitStore.selectedCircle = id;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -62,7 +55,7 @@ function setActiveCircle(id: number) {
|
|||
<button
|
||||
class="border-2 border-blue-900 rounded-full px-4 mr-4 last:mr-0"
|
||||
:class="setActiveClasses(circle.id)"
|
||||
@click="setActiveCircle(circle.id)"
|
||||
@click="cockpitStore.toggleCourseSelection(circle.id)"
|
||||
>
|
||||
{{ circle.title }}
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { defineStore } from "pinia";
|
|||
export type CockpitStoreState = {
|
||||
courseSessionUsers: CourseSessionUser[] | undefined;
|
||||
cockpitSessionUser: ExpertSessionUser | undefined;
|
||||
selectedCircle: number;
|
||||
selectedCircles: number[];
|
||||
};
|
||||
|
||||
export const useCockpitStore = defineStore({
|
||||
|
|
@ -16,7 +16,7 @@ export const useCockpitStore = defineStore({
|
|||
return {
|
||||
courseSessionUsers: undefined,
|
||||
cockpitSessionUser: undefined,
|
||||
selectedCircle: -1,
|
||||
selectedCircles: [],
|
||||
} as CockpitStoreState;
|
||||
},
|
||||
getters: {
|
||||
|
|
@ -33,7 +33,7 @@ export const useCockpitStore = defineStore({
|
|||
this.cockpitSessionUser = data.cockpit_user;
|
||||
|
||||
if (this.cockpitSessionUser.circles?.length > 0) {
|
||||
this.selectedCircle = this.cockpitSessionUser.circles[0].id;
|
||||
this.selectedCircles = [this.cockpitSessionUser.circles[0].id];
|
||||
}
|
||||
|
||||
if (!this.courseSessionUsers) {
|
||||
|
|
@ -41,5 +41,16 @@ export const useCockpitStore = defineStore({
|
|||
}
|
||||
return this.courseSessionUsers;
|
||||
},
|
||||
toggleCourseSelection(id: number) {
|
||||
if (this.selectedCircles.indexOf(id) < 0) {
|
||||
this.selectedCircles.push(id);
|
||||
} else {
|
||||
if (this.selectedCircles.length === 1) {
|
||||
return;
|
||||
}
|
||||
const index = this.selectedCircles.indexOf(id);
|
||||
this.selectedCircles.splice(index, 1);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue