feat(frontend): Add applicationFormTemplate, add list for application froms, refactoring
This commit is contained in:
@@ -6,15 +6,7 @@
|
||||
<UDashboardSidebarCollapse />
|
||||
</template>
|
||||
|
||||
<template #right>
|
||||
<UTooltip text="Notifications" :shortcuts="['N']">
|
||||
<UButton color="neutral" variant="ghost" square>
|
||||
<UChip color="error" inset>
|
||||
<UIcon name="i-lucide-bell" class="size-5 shrink-0" />
|
||||
</UChip>
|
||||
</UButton>
|
||||
</UTooltip>
|
||||
</template>
|
||||
<template #right />
|
||||
</UDashboardNavbar>
|
||||
|
||||
<UDashboardToolbar>
|
||||
@@ -23,11 +15,18 @@
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
Ampel Status: {{ validationStatus }}
|
||||
<UForm class="space-y-4" :state="{}" @submit="onSubmit">
|
||||
<FormEngine v-model="formElements" />
|
||||
<UButton type="submit">Submit</UButton>
|
||||
</UForm>
|
||||
<div class="flex flex-col gap-4 sm:gap-6 lg:gap-12 w-full lg:max-w-2xl mx-auto">
|
||||
<UPageCard title="Ampelstatus" variant="naked" orientation="horizontal" class="mb-4">
|
||||
{{ ampelStatusEmoji }}
|
||||
</UPageCard>
|
||||
|
||||
<UPageCard variant="subtle">
|
||||
<UForm class="space-y-4" :state="{}" @submit="onSubmit">
|
||||
<FormEngine v-model="formElements" />
|
||||
<UButton type="submit">Submit</UButton>
|
||||
</UForm>
|
||||
</UPageCard>
|
||||
</div>
|
||||
</template>
|
||||
</UDashboardPanel>
|
||||
</template>
|
||||
@@ -37,11 +36,11 @@ import { ComplianceStatus, type PagedApplicationFormDto } from '~/.api-client'
|
||||
import { useApplicationFormValidator } from '~/composables/useApplicationFormValidator'
|
||||
import type { FormElementId } from '~/types/FormElement'
|
||||
|
||||
const { getAllApplicationForms, updateApplicationForm } = useApplicationForm()
|
||||
const { getAllApplicationFormTemplates, updateApplicationFormTemplate } = useApplicationFormTemplate()
|
||||
const { validateFormElements, getHighestComplianceStatus } = useApplicationFormValidator()
|
||||
|
||||
const { data } = await useAsyncData<PagedApplicationFormDto>(async () => {
|
||||
return await getAllApplicationForms()
|
||||
return await getAllApplicationFormTemplates()
|
||||
})
|
||||
|
||||
const formElements = computed({
|
||||
@@ -64,7 +63,20 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const ampelStatusEmoji = computed(() => {
|
||||
switch (validationStatus.value) {
|
||||
case ComplianceStatus.Critical:
|
||||
return '🔴'
|
||||
case ComplianceStatus.Warning:
|
||||
return '🟡'
|
||||
case ComplianceStatus.NonCritical:
|
||||
return '🟢'
|
||||
default:
|
||||
return '🟢'
|
||||
}
|
||||
})
|
||||
|
||||
async function onSubmit() {
|
||||
await updateApplicationForm(data?.value?.content[0].id, data?.value?.content[0])
|
||||
await updateApplicationFormTemplate(data?.value?.content[0].id, data?.value?.content[0])
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -7,15 +7,9 @@
|
||||
</template>
|
||||
|
||||
<template #right>
|
||||
<UTooltip text="Notifications" :shortcuts="['N']">
|
||||
<UButton color="neutral" variant="ghost" square>
|
||||
<UChip color="error" inset>
|
||||
<UIcon name="i-lucide-bell" class="size-5 shrink-0" />
|
||||
</UChip>
|
||||
</UButton>
|
||||
</UTooltip>
|
||||
|
||||
<UButton icon="i-lucide-plus" size="md" class="rounded-full" @click="navigateTo('/create')" />
|
||||
<UDropdownMenu :items="items">
|
||||
<UButton icon="i-lucide-plus" size="md" class="rounded-full" />
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
</UDashboardNavbar>
|
||||
|
||||
@@ -25,17 +19,47 @@
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div>
|
||||
<pre>{{ session }}</pre>
|
||||
<h1>{{ session.data ? 'Du bist eingeloggt' : 'Nicht eingeloggt' }}</h1>
|
||||
<button v-if="session?.data" @click="authClient.signOut()">Sign out</button>
|
||||
</div>
|
||||
<Register />
|
||||
<Login />
|
||||
<UPageList>
|
||||
<UPageCard
|
||||
v-for="(applicationFormElem, index) in applicationForm"
|
||||
:key="index"
|
||||
variant="ghost"
|
||||
:to="`application-forms/${applicationFormElem.id}`"
|
||||
>
|
||||
<template #body>
|
||||
#{{ index }} {{ applicationFormElem.id }} {{ applicationFormElem.createdAt }}
|
||||
{{ applicationFormElem.isTemplate }}
|
||||
</template>
|
||||
</UPageCard>
|
||||
</UPageList>
|
||||
</template>
|
||||
</UDashboardPanel>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const session = authClient.useSession()
|
||||
import type { PagedApplicationFormDto } from '~/.api-client'
|
||||
const { getAllApplicationForms } = useApplicationForm()
|
||||
|
||||
const items = [
|
||||
[
|
||||
{
|
||||
label: 'Neuer Mitbestimmungsantrag',
|
||||
icon: 'i-lucide-send',
|
||||
to: '/create'
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
const { data } = await useAsyncData<PagedApplicationFormDto>(async () => {
|
||||
return await getAllApplicationForms()
|
||||
})
|
||||
|
||||
const applicationForm = computed({
|
||||
get: () => data?.value?.content ?? [],
|
||||
set: (val) => {
|
||||
if (val && data.value) {
|
||||
data.value.content = val
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
45
legalconsenthub/pages/login.vue
Normal file
45
legalconsenthub/pages/login.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<UDashboardPanel id="home">
|
||||
<template #header>
|
||||
<UDashboardNavbar title="Home" :ui="{ right: 'gap-3' }">
|
||||
<template #leading>
|
||||
<UDashboardSidebarCollapse />
|
||||
</template>
|
||||
|
||||
<template #right>
|
||||
<UDropdownMenu :items="items">
|
||||
<UButton icon="i-lucide-plus" size="md" class="rounded-full" />
|
||||
</UDropdownMenu>
|
||||
</template>
|
||||
</UDashboardNavbar>
|
||||
|
||||
<UDashboardToolbar>
|
||||
<template #left> toolbar left </template>
|
||||
</UDashboardToolbar>
|
||||
</template>
|
||||
|
||||
<template #body>
|
||||
<div>
|
||||
<pre>{{ session }}</pre>
|
||||
<h1>{{ session.data ? 'Du bist eingeloggt' : 'Nicht eingeloggt' }}</h1>
|
||||
<button v-if="session?.data" @click="authClient.signOut()">Sign out</button>
|
||||
</div>
|
||||
<Register />
|
||||
<Login />
|
||||
</template>
|
||||
</UDashboardPanel>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const session = authClient.useSession()
|
||||
|
||||
const items = [
|
||||
[
|
||||
{
|
||||
label: 'Neuer Mitbestimmungsantrag',
|
||||
icon: 'i-lucide-send',
|
||||
to: '/create'
|
||||
}
|
||||
]
|
||||
]
|
||||
</script>
|
||||
Reference in New Issue
Block a user