mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-08-07 04:09:17 +02:00
15 demo of global dialog with reactive state
This commit is contained in:
@@ -1,10 +1,12 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import MenuBar from "./components/MenuBar.vue";
|
import MenuBar from "./components/MenuBar.vue";
|
||||||
|
import CalendarPreview from "./components/CalendarPreview.vue";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<MenuBar />
|
<MenuBar />
|
||||||
<router-view></router-view>
|
<router-view></router-view>
|
||||||
|
<CalendarPreview />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
@@ -111,6 +111,7 @@ function selectChange() {
|
|||||||
rounded
|
rounded
|
||||||
outlined
|
outlined
|
||||||
aria-label="Information"
|
aria-label="Information"
|
||||||
|
class="small-button"
|
||||||
@click.stop="showInfo(slotProps.option)"
|
@click.stop="showInfo(slotProps.option)"
|
||||||
></Button>
|
></Button>
|
||||||
<DynamicDialog />
|
<DynamicDialog />
|
||||||
|
86
frontend/src/components/CalendarPreview.vue
Normal file
86
frontend/src/components/CalendarPreview.vue
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { Ref, computed, ref } from "vue";
|
||||||
|
import moduleStore from "../store/moduleStore";
|
||||||
|
|
||||||
|
const dialogVisible: Ref<boolean> = ref(false);
|
||||||
|
const mobilePage = ref(true);
|
||||||
|
|
||||||
|
const store = moduleStore();
|
||||||
|
const tableData = computed(() =>
|
||||||
|
store.getAllModules().map((module) => {
|
||||||
|
return {
|
||||||
|
Course: module.course,
|
||||||
|
Module: module.userDefinedName
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const previewOn: Ref<boolean> = computed(() => {
|
||||||
|
return moduleStore().modules.size > 0;
|
||||||
|
})
|
||||||
|
|
||||||
|
const columns = ref([
|
||||||
|
{ field: "Course", header: "Course" },
|
||||||
|
{ field: "Module", header: "Module" },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const updateMobile = () => {
|
||||||
|
mobilePage.value = window.innerWidth <= 992;
|
||||||
|
};
|
||||||
|
|
||||||
|
updateMobile();
|
||||||
|
|
||||||
|
window.addEventListener("resize", updateMobile);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Dialog
|
||||||
|
id="calendar-dialog"
|
||||||
|
ref="calendar"
|
||||||
|
:visible="dialogVisible && previewOn"
|
||||||
|
@update:visible="dialogVisible = $event"
|
||||||
|
:maximizable=!mobilePage
|
||||||
|
:draggable=false
|
||||||
|
header="Kalendervorschau"
|
||||||
|
class="w-full lg:w-30rem lg:h-auto m-0 lg:m-2"
|
||||||
|
position="bottomright"
|
||||||
|
>
|
||||||
|
Hier könnte Ihre Werbung stehen!
|
||||||
|
|
||||||
|
<DataTable
|
||||||
|
:value="tableData"
|
||||||
|
edit-mode="cell"
|
||||||
|
table-class="editable-cells-table"
|
||||||
|
responsive-layout="scroll"
|
||||||
|
>
|
||||||
|
<Column
|
||||||
|
v-for="column in columns"
|
||||||
|
:key="column.field"
|
||||||
|
:field="column.field"
|
||||||
|
:header="column.header"
|
||||||
|
:row-editor="false"
|
||||||
|
>
|
||||||
|
<template #body="{ data, field }">
|
||||||
|
{{ data[field] }}
|
||||||
|
</template>
|
||||||
|
</Column>
|
||||||
|
|
||||||
|
</DataTable>
|
||||||
|
</Dialog>
|
||||||
|
<SpeedDial
|
||||||
|
:style="{ position: 'fixed', bottom: '2rem', right: '2rem' }"
|
||||||
|
v-if="previewOn && !dialogVisible"
|
||||||
|
>
|
||||||
|
<template #button>
|
||||||
|
<Button
|
||||||
|
icon="pi pi-calendar"
|
||||||
|
label="Preview"
|
||||||
|
class="p-button-rounded p-button-primary"
|
||||||
|
@click="dialogVisible = true"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</SpeedDial>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
@@ -4,6 +4,7 @@ import { Module } from "../model/module.ts";
|
|||||||
import moduleStore from "../store/moduleStore";
|
import moduleStore from "../store/moduleStore";
|
||||||
import router from "../router";
|
import router from "../router";
|
||||||
|
|
||||||
|
const store = moduleStore();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modules: {
|
modules: {
|
||||||
type: Array as PropType<Module[]>,
|
type: Array as PropType<Module[]>,
|
||||||
@@ -18,9 +19,7 @@ const modulesWithSelection: Ref<ModuleWithSelection[]> = ref(
|
|||||||
props.modules.map((propModule) => {
|
props.modules.map((propModule) => {
|
||||||
return {
|
return {
|
||||||
module: propModule,
|
module: propModule,
|
||||||
selected: moduleStore().modules.some((module: Module) =>
|
selected: store.hasModule(propModule)
|
||||||
module.isEqual ? module.isEqual(propModule) : false,
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@@ -48,11 +47,12 @@ watch(currentModules, (newValue: Module[]) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function nextStep() {
|
// TODO: Refactor and directly use store hashmap
|
||||||
selectedModules.value.forEach((module: Module) => {
|
watch(selectedModules, (newValue: Module[]) => {
|
||||||
moduleStore().addModule(module);
|
store.overwriteModules(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function nextStep() {
|
||||||
router.push("/additional-modules");
|
router.push("/additional-modules");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@@ -47,9 +47,5 @@ const placeholders = ref([
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.small-button.p-button {
|
|
||||||
width: 2rem;
|
|
||||||
height: 2rem;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -6,8 +6,9 @@ import tokenStore from "../store/tokenStore.ts";
|
|||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import ModuleTemplateDialog from "./ModuleTemplateDialog.vue";
|
import ModuleTemplateDialog from "./ModuleTemplateDialog.vue";
|
||||||
|
|
||||||
|
const store = moduleStore();
|
||||||
const tableData = ref(
|
const tableData = ref(
|
||||||
moduleStore().modules.map((module) => {
|
store.getAllModules().map((module) => {
|
||||||
return {
|
return {
|
||||||
Course: module.course,
|
Course: module.course,
|
||||||
Module: module,
|
Module: module,
|
||||||
@@ -22,7 +23,7 @@ const columns = ref([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
async function finalStep() {
|
async function finalStep() {
|
||||||
const token: string = await createIndividualFeed(moduleStore().modules);
|
const token: string = await createIndividualFeed(store.getAllModules());
|
||||||
tokenStore().setToken(token);
|
tokenStore().setToken(token);
|
||||||
await router.push("/calendar-link");
|
await router.push("/calendar-link");
|
||||||
}
|
}
|
||||||
@@ -122,9 +123,4 @@ async function finalStep() {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.small-button.p-button {
|
|
||||||
width: 2rem;
|
|
||||||
height: 2rem;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -8,8 +8,9 @@ import tokenStore from "../../store/tokenStore";
|
|||||||
import router from "../../router";
|
import router from "../../router";
|
||||||
import ModuleTemplateDialog from "../ModuleTemplateDialog.vue";
|
import ModuleTemplateDialog from "../ModuleTemplateDialog.vue";
|
||||||
|
|
||||||
|
const store = moduleStore();
|
||||||
const tableData = computed(() =>
|
const tableData = computed(() =>
|
||||||
moduleStore().modules.map((module: Module) => {
|
store.getAllModules().map((module: Module) => {
|
||||||
return {
|
return {
|
||||||
Course: module.course,
|
Course: module.course,
|
||||||
Module: module,
|
Module: module,
|
||||||
@@ -42,7 +43,7 @@ fetchedModules().then(
|
|||||||
);
|
);
|
||||||
|
|
||||||
async function finalStep() {
|
async function finalStep() {
|
||||||
await saveIndividualFeed(tokenStore().token, moduleStore().modules);
|
await saveIndividualFeed(tokenStore().token, store.getAllModules());
|
||||||
await router.push("/calendar-link");
|
await router.push("/calendar-link");
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -150,9 +151,4 @@ async function finalStep() {
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.small-button.p-button {
|
|
||||||
width: 2rem;
|
|
||||||
height: 2rem;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
@@ -15,6 +15,7 @@ import "primevue/resources/themes/viva-dark/theme.css";
|
|||||||
import "primeicons/primeicons.css";
|
import "primeicons/primeicons.css";
|
||||||
import "primeflex/primeflex.css";
|
import "primeflex/primeflex.css";
|
||||||
import router from "./router";
|
import router from "./router";
|
||||||
|
import SpeedDial from "primevue/speeddial";
|
||||||
import TabView from "primevue/tabview";
|
import TabView from "primevue/tabview";
|
||||||
import TabPanel from "primevue/tabpanel";
|
import TabPanel from "primevue/tabpanel";
|
||||||
import Tag from "primevue/tag";
|
import Tag from "primevue/tag";
|
||||||
@@ -47,6 +48,7 @@ app.component("InputSwitch", InputSwitch);
|
|||||||
app.component("Card", Card);
|
app.component("Card", Card);
|
||||||
app.component("DataView", DataView);
|
app.component("DataView", DataView);
|
||||||
app.component("ToggleButton", ToggleButton);
|
app.component("ToggleButton", ToggleButton);
|
||||||
|
app.component("SpeedDial", SpeedDial);
|
||||||
app.component("TabView", TabView);
|
app.component("TabView", TabView);
|
||||||
app.component("TabPanel", TabPanel);
|
app.component("TabPanel", TabPanel);
|
||||||
app.component("MultiSelect", MultiSelect);
|
app.component("MultiSelect", MultiSelect);
|
||||||
|
@@ -12,7 +12,7 @@ export class Module {
|
|||||||
public events: Event[] = [],
|
public events: Event[] = [],
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
isEqual(module: Module): Boolean {
|
isEqual(module: Module): boolean {
|
||||||
return this.name === module.name && this.course === module.course;
|
return this.name === module.name && this.course === module.course;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,17 +3,30 @@ import { defineStore } from "pinia";
|
|||||||
|
|
||||||
const moduleStore = defineStore("moduleStore", {
|
const moduleStore = defineStore("moduleStore", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
modules: [] as Module[],
|
modules: new Map<string, Module>(),
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
addModule(module: Module) {
|
addModule(module: Module) {
|
||||||
this.modules.push(module);
|
this.modules.set(module.uuid, module);
|
||||||
},
|
},
|
||||||
removeModule(module: Module) {
|
removeModule(module: Module) {
|
||||||
this.modules.splice(this.modules.indexOf(module), 1);
|
this.modules.delete(module.uuid);
|
||||||
|
},
|
||||||
|
hasModule(module: Module): boolean {
|
||||||
|
return this.modules.has(module.uuid) &&
|
||||||
|
(this.modules.get(module.uuid)?.isEqual(module) ?? false);
|
||||||
},
|
},
|
||||||
removeAllModules() {
|
removeAllModules() {
|
||||||
this.modules = [];
|
this.modules.clear();
|
||||||
|
},
|
||||||
|
overwriteModules(modules: Module[]) {
|
||||||
|
this.modules.clear();
|
||||||
|
modules.forEach((module) => {
|
||||||
|
this.modules.set(module.uuid, module);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
getAllModules(): Module[] {
|
||||||
|
return Array.from(this.modules.values());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@@ -1,3 +1,10 @@
|
|||||||
body {
|
body {
|
||||||
font-family: var(--font-family);
|
font-family: var(--font-family);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.small-button.p-button.p-button-icon-only,
|
||||||
|
.small-button.p-button.p-button-icon-only.p-button-rounded {
|
||||||
|
width: 2rem;
|
||||||
|
height: 2rem;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user