Skip to content

Commit

Permalink
add an option to open panels by default when redirecting
Browse files Browse the repository at this point in the history
  • Loading branch information
davwas committed Oct 11, 2023
1 parent 17c5dee commit 2cf817d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/organisms/administration/AuthSystems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
$t("pages.administration.school.index.authSystems.deleteAuthSystem")
}}
</h2>
<template slot="content">
<template #content>
<p class="text-md mt-2">
{{
$t(
Expand Down
33 changes: 32 additions & 1 deletion src/pages/administration/SchoolSettings.page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
</v-alert>
<template>
<v-divider></v-divider>
<v-expansion-panels hover accordion flat multiple class="mb-9">
<v-expansion-panels
hover
accordion
flat
multiple
class="mb-9"
v-model="openedPanels"
>
<v-expansion-panel data-testid="general-settings-panel">
<v-expansion-panel-header hide-actions>
<template v-slot:default="{ open }">
Expand Down Expand Up @@ -191,6 +198,7 @@ import {
SCHOOLS_MODULE_KEY,
} from "@/utils/inject";
import { computed, ComputedRef, defineComponent, ref, Ref, watch } from "vue";
import { useRoute } from "vue-router/composables";
export default defineComponent({
name: "SchoolSettings",
Expand All @@ -207,6 +215,7 @@ export default defineComponent({
const { t } = useI18n();
const schoolsModule = injectStrict(SCHOOLS_MODULE_KEY);
const envConfigModule = injectStrict(ENV_CONFIG_MODULE_KEY);
const route = useRoute();
const headline: Ref<string> = ref(
t("pages.administration.school.index.title")
Expand Down Expand Up @@ -245,6 +254,27 @@ export default defineComponent({
{ immediate: true }
);
const openedPanels: ComputedRef<number[]> = computed(() => {
// those need to be in order of code appearance since index is needed for panels v-model
const panels: string[] = [
"general",
"privacy",
"terms",
"migration",
"authentication",
"tools",
];
let openedPanelsArr: number[] = [];
if (route.query.openPanels) {
openedPanelsArr = route.query.openPanels
.toString()
.split(",")
.map((panelName) => panels.findIndex((p) => p === panelName));
}
return openedPanelsArr;
});
const systems: ComputedRef<any[]> = computed(
() => schoolsModule.getSystems
);
Expand Down Expand Up @@ -277,6 +307,7 @@ export default defineComponent({
t,
headline,
breadcrumbs,
openedPanels,
school,
systems,
isLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ export default defineComponent({
status: "success",
});
await router.push({ path: schoolSetting.to });
await router.push({
path: schoolSetting.to,
query: { openPanels: "tools" },
});
}
};
Expand Down

0 comments on commit 2cf817d

Please sign in to comment.