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

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

View File

@@ -1,12 +1,16 @@
<script lang="ts" setup>
import { inject } from "vue";
import { Ref, inject } from "vue";
import { Module } from "../model/module.ts";
import { Event } from "../model/event.ts";
import moment from "moment-timezone";
import { useI18n } from "vue-i18n";
const { t } = useI18n({ useScope: "global" });
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dialogRef = inject("dialogRef") as any;
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
function formatTimestamp(timestampString: string): string {
@@ -25,6 +29,12 @@ function sortModuleEventsByStart(events: Event[]) {
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>
<template>
@@ -44,8 +54,10 @@ function sortModuleEventsByStart(events: Event[]) {
<td>
<div class="card">
<DataTable
v-if="!mobilePage"
:value="sortModuleEventsByStart(module.events)"
table-style="min-width: 50rem"
:size="mobilePage ? 'small' : 'large'"
>
<Column
field="day"
@@ -74,6 +86,56 @@ function sortModuleEventsByStart(events: Event[]) {
:header="$t('moduleInformation.week')"
></Column>
</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>
</td>
</tr>

View File

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

View File

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

View File

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