91 responsive changes

This commit is contained in:
survellow
2023-12-06 10:22:43 +01:00
parent 1d656b2653
commit 4377faa40e
11 changed files with 219 additions and 113 deletions

View File

@@ -3,15 +3,25 @@ import MenuBar from "./components/MenuBar.vue";
import {RouteRecordName, RouterView} from "vue-router"; import {RouteRecordName, RouterView} from "vue-router";
import CalendarPreview from "./components/CalendarPreview.vue"; import CalendarPreview from "./components/CalendarPreview.vue";
import moduleStore from "./store/moduleStore.ts"; import moduleStore from "./store/moduleStore.ts";
import { provide, ref } from "vue";
const disabledPages = ["room-finder", "faq", "imprint", "privacy-policy", "edit", "edit-calendar"]; const disabledPages = ["room-finder", "faq", "imprint", "privacy-policy", "edit", "edit-calendar"];
const store = moduleStore(); const store = moduleStore();
const mobilePage = ref(true);
provide("mobilePage", mobilePage);
const isDisabled = (routeName: RouteRecordName | null | undefined) => { const isDisabled = (routeName: RouteRecordName | null | undefined) => {
return !disabledPages.includes(routeName as string) && store.modules.size > 0 return !disabledPages.includes(routeName as string) && store.modules.size > 0
}; };
const updateMobile = () => {
mobilePage.value = window.innerWidth <= 992;
};
updateMobile();
window.addEventListener("resize", updateMobile);
</script> </script>
<template> <template>

View File

@@ -1,10 +1,10 @@
<script lang="ts" setup> <script lang="ts" setup>
import { Ref, computed, ref } from "vue"; import { Ref, computed, inject, ref } from "vue";
import moduleStore from "../store/moduleStore"; import moduleStore from "../store/moduleStore";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
const dialogVisible: Ref<boolean> = ref(false); const dialogVisible: Ref<boolean> = ref(false);
const mobilePage = ref(true); const mobilePage = inject("mobilePage") as Ref<boolean>;
const { t } = useI18n({ useScope: "global" }); const { t } = useI18n({ useScope: "global" });
const store = moduleStore(); const store = moduleStore();
@@ -26,13 +26,6 @@ const columns = computed(() => [
{ field: "Module", header: t("calendarPreview.module") }, { field: "Module", header: t("calendarPreview.module") },
]); ]);
const updateMobile = () => {
mobilePage.value = window.innerWidth <= 992;
};
updateMobile();
window.addEventListener("resize", updateMobile);
</script> </script>
<template> <template>

View File

@@ -1,12 +1,16 @@
<script lang="ts" setup> <script lang="ts" setup>
import { inject } from "vue"; import { Ref, inject } from "vue";
import { Module } from "../model/module.ts"; import { Module } from "../model/module.ts";
import { Event } from "../model/event.ts"; import { Event } from "../model/event.ts";
import moment from "moment-timezone"; import moment from "moment-timezone";
import { useI18n } from "vue-i18n";
const { t } = useI18n({ useScope: "global" });
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const dialogRef = inject("dialogRef") as any; const dialogRef = inject("dialogRef") as any;
const module = dialogRef.value.data.module as Module; const module = dialogRef.value.data.module as Module;
const mobilePage = inject("mobilePage") as Ref<boolean>;
// formats 2023-10-26 11:45:00.000Z to DD-MM-YYYY HH:MM // formats 2023-10-26 11:45:00.000Z to DD-MM-YYYY HH:MM
function formatTimestamp(timestampString: string): string { function formatTimestamp(timestampString: string): string {
@@ -25,6 +29,12 @@ function sortModuleEventsByStart(events: Event[]) {
return a.start.localeCompare(b.start); return a.start.localeCompare(b.start);
}); });
} }
function formatWeekday(weekday: string) {
const template = "moduleInformation.weekday." + weekday;
const translation = t(template);
return translation !== template ? translation : weekday;
}
</script> </script>
<template> <template>
@@ -44,8 +54,10 @@ function sortModuleEventsByStart(events: Event[]) {
<td> <td>
<div class="card"> <div class="card">
<DataTable <DataTable
v-if="!mobilePage"
:value="sortModuleEventsByStart(module.events)" :value="sortModuleEventsByStart(module.events)"
table-style="min-width: 50rem" table-style="min-width: 50rem"
:size="mobilePage ? 'small' : 'large'"
> >
<Column <Column
field="day" field="day"
@@ -74,6 +86,56 @@ function sortModuleEventsByStart(events: Event[]) {
:header="$t('moduleInformation.week')" :header="$t('moduleInformation.week')"
></Column> ></Column>
</DataTable> </DataTable>
<DataView
v-else
:value="sortModuleEventsByStart(module.events)"
:data-key="module.name"
layout="grid"
>
<template #grid="slotProps">
<div class="col-12 sm:col-6 p-1">
<Card class="border-2 surface-border border-round surface-card">
<template #title>
<Badge
:value="slotProps.data.eventType"
:severity="slotProps.data.eventType === 'V' ? 'success' : 'warning'"
class="flex-shrink-0 flex-grow-0"
/>
</template>
<template #content>
<div class="flex flex-row gap-4 flex-wrap">
<div class="flex flex-column">
<div class="mr-2">{{ formatWeekday(slotProps.data.day) }}</div>
<div class="mr-2">{{ $t("moduleInformation.nthWeek", {count: slotProps.data.week}) }}</div>
</div>
<div class="flex flex-column">
<table>
<tr>
<td class="mr-2">
<b>{{ $t("moduleInformation.start") }}:</b>
</td>
<td>{{ formatTimestamp(slotProps.data.start) }}</td>
</tr>
<tr>
<td class="mr-2">
<b>{{ $t("moduleInformation.end") }}:</b>
</td>
<td>{{ formatTimestamp(slotProps.data.end) }}</td>
</tr>
<tr>
<td class="mr-2">
<b>{{ $t("moduleInformation.room") }}:</b>
</td>
<td>{{ slotProps.data.rooms }}</td>
</tr>
</table>
</div>
</div>
</template>
</Card>
</div>
</template>
</DataView>
</div> </div>
</td> </td>
</tr> </tr>

View File

@@ -10,9 +10,14 @@ const props = defineProps({
type: Array as PropType<Module[]>, type: Array as PropType<Module[]>,
required: true, required: true,
}, },
selectedCourse: {
type: String as PropType<string>,
required: true,
},
}); });
const modules : ComputedRef<Module[]> = computed(() => props.modules); const modules : ComputedRef<Module[]> = computed(() => props.modules);
const selectedCourse : ComputedRef<string> = computed(() => props.selectedCourse);
store.modules.clear(); store.modules.clear();
@@ -54,22 +59,22 @@ function nextStep() {
:value="modules" :value="modules"
data-key="uuid" data-key="uuid"
:class=" :class="
[modules.length === 0? [selectedCourse === ''?
['opacity-0', 'pointer-events-none'] : ['opacity-0', 'pointer-events-none'] :
['opacity-100', 'transition-all', 'transition-duration-500', 'transition-ease-in-out'] ['opacity-100', 'transition-all', 'transition-duration-500', 'transition-ease-in-out']
, ,
'w-full']" 'w-full']"
> >
<template #header> <template #header>
<div class="flex justify-content-between align-items-center flex-wrap"> <div class="flex justify-content-between align-items-center flex-wrap md:mx-4">
<h3> <h3>
{{ $t("moduleSelection.modules") }} - {{ $t("moduleSelection.modules") }} -
{{ store.countModules() }} {{ store.countModules() }}
</h3> </h3>
<div class="flex flex-1 align-items-center justify-content-end white-space-nowrap"> <div class="flex align-items-center justify-content-end white-space-nowrap">
{{ allSelected ? $t('moduleSelection.deselectAll') : $t('moduleSelection.selectAll')}} <p>{{ allSelected ? $t('moduleSelection.deselectAll') : $t('moduleSelection.selectAll')}}</p>
<InputSwitch <InputSwitch
class="mx-4" class="mx-2"
:disabled="modules.length === 0" :disabled="modules.length === 0"
:model-value="allSelected" :model-value="allSelected"
@update:model-value="toggleAllModules()" @update:model-value="toggleAllModules()"
@@ -84,7 +89,7 @@ function nextStep() {
</template> </template>
<template #list="slotProps"> <template #list="slotProps">
<div class="col-12"> <div class="col-12">
<div class="flex flex-column sm:flex-row justify-content-between align-items-center flex-1 column-gap-4 mx-2"> <div class="flex flex-column sm:flex-row justify-content-between align-items-center flex-1 column-gap-4 mx-2 md:mx-4">
<p class="text-lg flex-1 align-self-stretch">{{ slotProps.data.name }}</p> <p class="text-lg flex-1 align-self-stretch">{{ slotProps.data.name }}</p>
<ToggleButton <ToggleButton
class="w-9rem align-self-end my-2" class="w-9rem align-self-end my-2"

View File

@@ -32,7 +32,7 @@ const placeholders = computed(() => [
<template> <template>
<Button <Button
icon="pi pi-info" icon="pi pi-info"
class="m-2 small-button" class="m-2 small-button flex-shrink-0"
severity="help" severity="help"
rounded rounded
outlined outlined
@@ -42,6 +42,7 @@ const placeholders = computed(() => [
/> />
<Dialog <Dialog
v-model:visible="helpVisible" v-model:visible="helpVisible"
class="w-full md:w-auto"
:header="$t('moduleTemplateDialog.moduleConfiguration')" :header="$t('moduleTemplateDialog.moduleConfiguration')"
> >
<p> <p>

View File

@@ -3,7 +3,7 @@ import moduleStore from "../store/moduleStore.ts";
import { createIndividualFeed } from "../api/createFeed.ts"; import { createIndividualFeed } from "../api/createFeed.ts";
import router from "../router"; import router from "../router";
import tokenStore from "../store/tokenStore.ts"; import tokenStore from "../store/tokenStore.ts";
import { computed, ref } from "vue"; import { Ref, computed, inject, ref } from "vue";
import ModuleTemplateDialog from "./ModuleTemplateDialog.vue"; import ModuleTemplateDialog from "./ModuleTemplateDialog.vue";
import { onlyWhitespace } from "../helpers/strings.ts"; import { onlyWhitespace } from "../helpers/strings.ts";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@@ -18,6 +18,7 @@ const tableData = ref(
}; };
}), }),
); );
const mobilePage = inject("mobilePage") as Ref<boolean>;
const columns = computed(() => [ const columns = computed(() => [
{ field: "Course", header: t("moduleInformation.course") }, { field: "Course", header: t("moduleInformation.course") },
@@ -33,95 +34,102 @@ async function finalStep() {
</script> </script>
<template> <template>
<div class="flex flex-column"> <div class="flex flex-column align-items-center">
<div class="flex align-items-center justify-content-center h-4rem m-2"> <div class="flex align-items-center justify-content-center m-2 gap-2">
<h3>{{ $t("renameModules.subTitle") }}</h3> <h3>{{ $t("renameModules.subTitle") }}</h3>
<ModuleTemplateDialog /> <ModuleTemplateDialog class=""/>
</div> </div>
<div class="card flex align-items-center justify-content-center m-2"> <div class="w-full lg:w-8 flex flex-column">
<DataTable <div class="card flex align-items-center justify-content-center my-2">
:value="tableData" <DataTable
edit-mode="cell" :value="tableData"
table-class="editable-cells-table" edit-mode="cell"
responsive-layout="scroll" table-class="editable-cells-table"
> responsive-layout="scroll"
<template #header> :size="mobilePage ? 'small' : 'large'"
<div class="flex align-items-center justify-content-end"> class="w-full"
{{ $t("renameModules.enableAllNotifications") }}
<InputSwitch
class="mx-4"
:model-value="
tableData.reduce(
(acc, curr) => acc && curr.Module.reminder,
true,
)
"
@update:model-value="
tableData.forEach((module) => (module.Module.reminder = $event))
"
/>
</div>
</template>
<Column
v-for="col of columns"
:key="col.field"
:field="col.field"
:header="col.header"
:class="col.field === 'Reminder' ? 'text-center' : ''"
> >
<!-- Text Body --> <template #header>
<template #body="{ data, field }"> <div class="flex align-items-center justify-content-end flex-wrap gap-2 px-2">
<template v-if="field === 'Module'"> {{ $t("renameModules.enableAllNotifications") }}
{{ <InputSwitch
onlyWhitespace(data[field].userDefinedName) :model-value="
? data[field].name tableData.reduce(
: data[field].userDefinedName (acc, curr) => acc && curr.Module.reminder,
}} true,
</template> )
<template v-else-if="field === 'Reminder'"> "
<Button @update:model-value="
:icon="data.Module.reminder ? 'pi pi-bell' : 'pi pi-times'" tableData.forEach((module) => (module.Module.reminder = $event))
:severity="data.Module.reminder ? 'warning' : 'secondary'" "
rounded
outlined
class="small-button"
@click="data.Module.reminder = !data.Module.reminder"
></Button>
</template>
<template v-else>
{{ data[field] }}
</template>
</template>
<!-- Editor Body -->
<template #editor="{ data, field }">
<template v-if="field === 'Module'">
<InputText
v-model="data[field].userDefinedName"
class="w-full"
autofocus
/> />
</template> </div>
<template v-else-if="field === 'Reminder'">
<Button
:icon="data.Module.reminder ? 'pi pi-bell' : 'pi pi-times'"
:severity="data.Module.reminder ? 'warning' : 'secondary'"
rounded
outlined
class="small-button"
@click="data.Module.reminder = !data.Module.reminder"
></Button>
</template>
<template v-else>
<div>{{ data[field] }}</div>
</template>
</template> </template>
</Column> <Column
</DataTable> v-for="col of columns"
</div> :key="col.field"
:field="col.field"
:header="col.header"
:class="col.field === 'Reminder' ? 'text-center' : ''"
>
<!-- Text Body -->
<template #body="{ data, field }">
<template v-if="field === 'Module'">
{{
onlyWhitespace(data[field].userDefinedName)
? data[field].name
: data[field].userDefinedName
}}
</template>
<template v-else-if="field === 'Reminder'">
<Button
:icon="data.Module.reminder ? 'pi pi-bell' : 'pi pi-times'"
:severity="data.Module.reminder ? 'warning' : 'secondary'"
rounded
outlined
class="small-button"
@click="data.Module.reminder = !data.Module.reminder"
></Button>
</template>
<template v-else>
{{ data[field] }}
</template>
</template>
<!-- Editor Body -->
<template #editor="{ data, field }">
<template v-if="field === 'Module'">
<InputText
v-model="data[field].userDefinedName"
class="w-full"
autofocus
/>
</template>
<template v-else-if="field === 'Reminder'">
<Button
:icon="data.Module.reminder ? 'pi pi-bell' : 'pi pi-times'"
:severity="data.Module.reminder ? 'warning' : 'secondary'"
rounded
outlined
class="small-button"
@click="data.Module.reminder = !data.Module.reminder"
></Button>
</template>
<template v-else>
<div>{{ data[field] }}</div>
</template>
</template>
</Column>
</DataTable>
</div>
<div class="flex align-items-center justify-content-center h-4rem m-2"> <Button
<Button @click="finalStep()">{{ $t("renameModules.nextStep") }}</Button> :disabled="store.isEmpty()"
</div> class="col-12 md:col-4 mb-3 align-self-end"
@click="finalStep()"
icon="pi pi-save"
:label="$t('renameModules.nextStep')"
/>
</div>
</div> </div>
</template> </template>

View File

@@ -44,7 +44,17 @@
"end": "Ende", "end": "Ende",
"room": "Raum", "room": "Raum",
"type": "Art", "type": "Art",
"week": "Woche" "week": "Woche",
"nthWeek": "{count}. Woche",
"weekday": {
"Montag": "Montag",
"Dienstag": "Dienstag",
"Mittwoch": "Mittwoch",
"Donnerstag": "Donnerstag",
"Freitag": "Freitag",
"Samstag": "Samstag",
"Sonntag": "Sonntag"
}
}, },
"editCalendarView": { "editCalendarView": {
"error": "Fehler", "error": "Fehler",

View File

@@ -44,7 +44,17 @@
"end": "end", "end": "end",
"room": "room", "room": "room",
"type": "type", "type": "type",
"week": "week" "week": "week",
"nthWeek": "week {count}",
"weekday": {
"Montag": "monday",
"Dienstag": "tuesday",
"Mittwoch": "wednesday",
"Donnerstag": "thursday",
"Freitag": "friday",
"Samstag": "saturday",
"Sonntag": "sunday"
}
}, },
"editCalendarView": { "editCalendarView": {
"error": "error", "error": "error",

View File

@@ -2,6 +2,7 @@ import { createApp } from "vue";
import "./style.css"; import "./style.css";
import App from "./App.vue"; import App from "./App.vue";
import PrimeVue from "primevue/config"; import PrimeVue from "primevue/config";
import Badge from "primevue/badge";
import Button from "primevue/button"; import Button from "primevue/button";
import Dropdown from "primevue/dropdown"; import Dropdown from "primevue/dropdown";
import Menu from "primevue/menu"; import Menu from "primevue/menu";
@@ -43,6 +44,7 @@ app.use(pinia);
app.use(DialogService); app.use(DialogService);
i18n.setup(); i18n.setup();
app.use(i18n.vueI18n); app.use(i18n.vueI18n);
app.component("Badge", Badge);
app.component("Button", Button); app.component("Button", Button);
app.component("Menu", Menu); app.component("Menu", Menu);
app.component("Menubar", Menubar); app.component("Menubar", Menubar);

View File

@@ -1,5 +1,5 @@
<script lang="ts" setup> <script lang="ts" setup>
import { defineAsyncComponent, ref, Ref} from "vue"; import { defineAsyncComponent, inject, ref, Ref} from "vue";
import { Module } from "../model/module.ts"; import { Module } from "../model/module.ts";
import { fetchAllModules } from "../api/fetchCourse.ts"; import { fetchAllModules } from "../api/fetchCourse.ts";
import moduleStore from "../store/moduleStore.ts"; import moduleStore from "../store/moduleStore.ts";
@@ -22,6 +22,7 @@ if (store.isEmpty()) {
router.replace("/"); router.replace("/");
} }
const mobilePage = inject("mobilePage") as Ref<boolean>;
const modules: Ref<Module[]> = ref([]); const modules: Ref<Module[]> = ref([]);
const filters = ref({ const filters = ref({
course: { course: {
@@ -58,16 +59,17 @@ async function showInfo(module: Module) {
module = data; module = data;
}); });
dialog.open(ModuleInformation, { dialog.open(ModuleInformation, {
class: "w-full m-0",
props: { props: {
style: { style: {
width: "50vw", width: "80vw",
},
breakpoints: {
"992px": "100vw",
"640px": "100vw",
},
modal: true,
}, },
breakpoints: {
"960px": "75vw",
"640px": "90vw",
},
modal: true,
},
data: { data: {
module: module, module: module,
}, },
@@ -94,6 +96,7 @@ function unselectModule(event: DataTableRowUnselectEvent) {
<div class="m-2 lg:w-10 w-full"> <div class="m-2 lg:w-10 w-full">
<DynamicDialog /> <DynamicDialog />
<DataTable <DataTable
id="dt-responsive-table"
v-model:filters="filters" v-model:filters="filters"
:selection="store.getAllModules()" :selection="store.getAllModules()"
:value="modules" :value="modules"
@@ -116,6 +119,7 @@ function unselectModule(event: DataTableRowUnselectEvent) {
:show-gridlines="true" :show-gridlines="true"
:striped-rows="true" :striped-rows="true"
:select-all="false" :select-all="false"
:size="mobilePage ? 'small' : 'large'"
@row-select="selectModule" @row-select="selectModule"
@row-unselect="unselectModule" @row-unselect="unselectModule"
> >

View File

@@ -54,7 +54,7 @@ async function getModules() {
<template> <template>
<div <div
class="flex flex-column align-items-center transition-all transition-duration-500 transition-ease-in-out mt-0" class="flex flex-column align-items-center transition-all transition-duration-500 transition-ease-in-out mt-0"
:class="{'md:mt-8': modules.length === 0}" :class="{'md:mt-8': selectedCourse.name === ''}"
> >
<div class="flex align-items-center justify-content-center gap-2 mx-2"> <div class="flex align-items-center justify-content-center gap-2 mx-2">
<h3 class="text-4xl"> <h3 class="text-4xl">
@@ -95,6 +95,7 @@ async function getModules() {
</div> </div>
<ModuleSelection <ModuleSelection
:modules="modules" :modules="modules"
:selected-course="selectedCourse.name"
class="lg:w-8" class="lg:w-8"
/> />
</div> </div>