Changes
This commit is contained in:
@@ -3,9 +3,48 @@ definePageMeta({
|
||||
middleware: "auth"
|
||||
})
|
||||
|
||||
//const {find, findOne,create, update} = useStrapi4()
|
||||
const supabase = useSupabaseClient()
|
||||
const route = useRoute()
|
||||
//let project = (await findOne('projects',route.params.id)).data
|
||||
|
||||
const {getProjectById, getFormSubmitsWithLabelProp} = useDataStore()
|
||||
const {forms, formSubmits} = storeToRefs(useDataStore())
|
||||
|
||||
const currentProject = getProjectById(Number(route.params.id))
|
||||
|
||||
|
||||
const formSubmissionsComposed = getFormSubmitsWithLabelProp
|
||||
const formModalOpen = ref(false)
|
||||
const newFormSubmissionData = ref({
|
||||
formType: "",
|
||||
values: {},
|
||||
submitted: false
|
||||
})
|
||||
|
||||
const addNewFormSubmission = async () => {
|
||||
//Add Form Submission
|
||||
const {data:insertData,error:insertError} = await supabase
|
||||
.from("formSubmits")
|
||||
.insert([newFormSubmissionData.value])
|
||||
.select()
|
||||
|
||||
console.log(insertData)
|
||||
console.log(insertError)
|
||||
|
||||
let projectForms = [...currentProject.forms, insertData[0].id ]
|
||||
console.log(projectForms)
|
||||
|
||||
//Add Form ID to project.forms
|
||||
const {data:updateData,error:updateError} = await supabase
|
||||
.from("projects")
|
||||
.update({forms: projectForms})
|
||||
.eq('id',currentProject.id)
|
||||
.select()
|
||||
|
||||
console.log(updateData)
|
||||
console.log(updateError)
|
||||
|
||||
}
|
||||
|
||||
const tabItems = [
|
||||
{
|
||||
key: "phases",
|
||||
@@ -25,6 +64,8 @@ const selectedPhase = ref({})
|
||||
const changesSaved = ref(true)
|
||||
|
||||
|
||||
|
||||
|
||||
const default_data = {
|
||||
time: 1660335428612,
|
||||
blocks: [
|
||||
@@ -43,87 +84,25 @@ const default_data = {
|
||||
text: "This is a nuxt3 plugin for editorjs.",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "R3o5BpI-r9",
|
||||
type: "paragraph",
|
||||
data: {
|
||||
text: "<b>A paragraph of text:</b> Lorem ipsum dolor sit amet consectetur adipisicing elit. Labore perspiciatis molestias neque autem cumque provident? Laudantium ad, quisquam quos nulla amet, perferendis recusandae voluptates eligendi cupiditate consectetur veniam! Ipsum, ullam?",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "b9mkw6ZO92",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 1",
|
||||
level: 1,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "P2PZsHo2lq",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 2",
|
||||
level: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "hHJZjkW-TO",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 3",
|
||||
level: 3,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "k8EDwa0oVG",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 4",
|
||||
level: 4,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "62ciFnEFjZ",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 5",
|
||||
level: 5,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "YCBcKhNqib",
|
||||
type: "header",
|
||||
data: {
|
||||
text: "Heading 6",
|
||||
level: 6,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "s_J3d5U8DA",
|
||||
type: "list",
|
||||
data: {
|
||||
style: "ordered",
|
||||
items: [
|
||||
"An ordered list item",
|
||||
"Another ordered list item",
|
||||
"One more",
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "kMyQbO156y",
|
||||
type: "list",
|
||||
data: {
|
||||
style: "unordered",
|
||||
items: ["An unordered list item!", "In italics?", "Or bold?"],
|
||||
},
|
||||
},
|
||||
|
||||
],
|
||||
version: "2.25.0",
|
||||
};
|
||||
const dat = ref(default_data);
|
||||
const save = () => {
|
||||
console.log(foo);
|
||||
const newProjectDescription = ref(currentProject.description || default_data.value);
|
||||
|
||||
const saveProjectDescription = async () => {
|
||||
//Update Project Description
|
||||
const {data:updateData,error:updateError} = await supabase
|
||||
.from("projects")
|
||||
.update({description: newProjectDescription.value})
|
||||
.eq('id',currentProject.id)
|
||||
.select()
|
||||
|
||||
console.log(updateData)
|
||||
console.log(updateError)
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -182,12 +161,68 @@ const phaseInfo = ref({
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div v-else-if="item.key === 'password'" class="space-y-3">
|
||||
<div v-else-if="item.key === 'forms'" class="space-y-3">
|
||||
<UButton
|
||||
@click="formModalOpen = true"
|
||||
>
|
||||
+ Formular
|
||||
</UButton>
|
||||
<UModal
|
||||
v-model="formModalOpen"
|
||||
>
|
||||
<UCard>
|
||||
<template #header>
|
||||
Formular hinzufügen
|
||||
</template>
|
||||
<UFormGroup>
|
||||
<USelectMenu
|
||||
:options="forms"
|
||||
option-attribute="name"
|
||||
value-attribute="id"
|
||||
v-model="newFormSubmissionData.formType"
|
||||
/>
|
||||
</UFormGroup>
|
||||
<template #footer>
|
||||
<UButton
|
||||
@click="addNewFormSubmission"
|
||||
>
|
||||
Hinzufügen
|
||||
</UButton>
|
||||
</template>
|
||||
</UCard>
|
||||
</UModal>
|
||||
|
||||
|
||||
<UAccordion :items="formSubmissionsComposed">
|
||||
<template #item="{item}">
|
||||
|
||||
<p class="my-3">Formular Link: <a :href="'https://app.spaces.software/formSubmissions/' + item.id">{{'https://app.spaces.software/formSubmissions/' + item.id}}</a></p>
|
||||
|
||||
|
||||
<div v-if="Object.keys(item.values).length == 0">
|
||||
<p>Es wurden noch keine Daten über das Formular abgegeben</p>
|
||||
</div>
|
||||
|
||||
<table v-else>
|
||||
<tr v-for="key in Object.keys(item.values)">
|
||||
<td>{{key}}</td>
|
||||
<td>{{ item.values[key] }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</template>
|
||||
</UAccordion>
|
||||
</div>
|
||||
<div v-else-if="item.key === 'description'" class="space-y-3">
|
||||
<client-only><editor-js v-model="dat" /></client-only>
|
||||
<UButton
|
||||
:disabled="false/*newProjectDescription.time === currentProject.description.time*/"
|
||||
@click="saveProjectDescription"
|
||||
>
|
||||
Speichern
|
||||
</UButton>
|
||||
<client-only><editor-js v-model="newProjectDescription" /></client-only>
|
||||
</div>
|
||||
{{item}}
|
||||
</template>
|
||||
</UTabs>
|
||||
<!-- <div id="left">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div id="main">
|
||||
<div id="left">
|
||||
|
||||
<!-- TODO: Projekt Auflistung überarbeiten, Rechte Seite wird nicht genutzt -->
|
||||
<UButton @click="showCreateProject = true">+ Projekt</UButton>
|
||||
<UModal v-model="showCreateProject">
|
||||
<UCard>
|
||||
@@ -89,8 +89,11 @@ definePageMeta({
|
||||
|
||||
const supabase = useSupabaseClient()
|
||||
|
||||
const projects = (await supabase.from("projects").select()).data
|
||||
const customers = (await supabase.from("customers").select()).data
|
||||
const {projects,customers} = storeToRefs(useDataStore())
|
||||
const {fetchProjects} = useDataStore()
|
||||
|
||||
//const projects = (await supabase.from("projects").select()).data
|
||||
//const customers = (await supabase.from("customers").select()).data
|
||||
|
||||
const showCreateProject = ref(false)
|
||||
const createProjectData = ref({
|
||||
@@ -114,6 +117,8 @@ const createProject = async () => {
|
||||
|
||||
showCreateProject.value = false
|
||||
createProjectData.value = {phases: []}
|
||||
fetchProjects()
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user