AW: theCure
This commit is contained in:
8
frontend/pages/runtime/[entity]/[id]/edit.vue
Normal file
8
frontend/pages/runtime/[entity]/[id]/edit.vue
Normal file
@@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<UCard>
|
||||
<template #header><h2 class="text-xl font-semibold">Edit Record</h2></template>
|
||||
<p>Placeholder. Implement edit form honoring field update permissions.</p>
|
||||
</UCard>
|
||||
</div>
|
||||
</template>
|
||||
8
frontend/pages/runtime/[entity]/[id]/view.vue
Normal file
8
frontend/pages/runtime/[entity]/[id]/view.vue
Normal file
@@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div class="p-6">
|
||||
<UCard>
|
||||
<template #header><h2 class="text-xl font-semibold">Record View</h2></template>
|
||||
<p>Placeholder. Implement detail view honoring field read permissions.</p>
|
||||
</UCard>
|
||||
</div>
|
||||
</template>
|
||||
53
frontend/pages/runtime/tickets/list.vue
Normal file
53
frontend/pages/runtime/tickets/list.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<script setup lang="ts">
|
||||
const entity = 'tickets'
|
||||
const baseURL = process.client ? (localStorage.getItem('API_BASE') || 'http://localhost:8000') : ''
|
||||
const items = ref<any[]>([])
|
||||
const error = ref<string | null>(null)
|
||||
const loading = ref(true)
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const res = await fetch(`${baseURL}/api/${entity}/records`)
|
||||
if (!res.ok) throw new Error(await res.text())
|
||||
items.value = await res.json()
|
||||
} catch (e: any) {
|
||||
error.value = e.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 space-y-4">
|
||||
<UCard>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold">Tickets</h2>
|
||||
<div class="flex gap-2">
|
||||
<UButton to="/runtime/tickets/new">New</UButton>
|
||||
<UButton to="/">Home</UButton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="loading" class="py-8"><ULoading /></div>
|
||||
|
||||
<ul v-else class="space-y-2">
|
||||
<li v-for="it in items" :key="it.id" class="p-3 border rounded">
|
||||
<div class="flex justify-between items-center">
|
||||
<div>
|
||||
<strong>{{ it.title }}</strong>
|
||||
<div class="text-sm text-gray-600">{{ it.status }}</div>
|
||||
</div>
|
||||
<div class="text-xs text-gray-500">{{ new Date(it.created_at).toLocaleString() }}</div>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<template #footer>
|
||||
<p v-if="error" class="text-red-600 text-sm">{{ error }}</p>
|
||||
</template>
|
||||
</UCard>
|
||||
</div>
|
||||
</template>
|
||||
55
frontend/pages/runtime/tickets/new.vue
Normal file
55
frontend/pages/runtime/tickets/new.vue
Normal file
@@ -0,0 +1,55 @@
|
||||
<script setup lang="ts">
|
||||
const entity = 'tickets'
|
||||
const baseURL = process.client ? (localStorage.getItem('API_BASE') || 'http://localhost:8000') : ''
|
||||
|
||||
const loading = ref(false)
|
||||
const error = ref<string | null>(null)
|
||||
const formLayout = ref<{ sections: Array<{ title?: string; fields: string[] }> }>({
|
||||
sections: [{ title: 'Ticket Info', fields: ['title', 'description', 'status'] }]
|
||||
})
|
||||
const fieldsMeta = ref<Record<string, any>>({
|
||||
title: { label: 'Title', type: 'string', required: true },
|
||||
description: { label: 'Description', type: 'textarea' },
|
||||
status: { label: 'Status', type: 'select', options: [{ label: 'Open', value: 'open' }, { label: 'Closed', value: 'closed' }] }
|
||||
})
|
||||
|
||||
async function handleSubmit(payload: Record<string, any>) {
|
||||
try {
|
||||
loading.value = true
|
||||
const res = await fetch(`${baseURL}/api/${entity}/records`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload)
|
||||
})
|
||||
if (!res.ok) throw new Error(await res.text())
|
||||
navigateTo(`/runtime/${entity}/list`)
|
||||
} catch (e: any) {
|
||||
error.value = e.message
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 space-y-4">
|
||||
<UCard>
|
||||
<template #header>
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-xl font-semibold">New Ticket</h2>
|
||||
<UButton variant="ghost" to="/runtime/tickets/list">Back to list</UButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<div v-if="loading" class="py-8"><ULoading /></div>
|
||||
<div v-else>
|
||||
<DynamicForm :layout="formLayout" :fields-meta="fieldsMeta" @submit="handleSubmit" />
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<p v-if="error" class="text-red-600 text-sm">{{ error }}</p>
|
||||
<p class="text-xs text-gray-500">Set localStorage API_BASE to your backend URL if not localhost:8000</p>
|
||||
</template>
|
||||
</UCard>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user