WIP - more progress with permissions
This commit is contained in:
@@ -32,6 +32,7 @@ const view = computed(() => {
|
||||
|
||||
// State
|
||||
const objectDefinition = ref<any>(null)
|
||||
const objectAccess = ref<any>(null)
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
@@ -118,9 +119,23 @@ const detailConfig = computed(() => {
|
||||
|
||||
const editConfig = computed(() => {
|
||||
if (!objectDefinition.value) return null
|
||||
return buildEditViewConfig(objectDefinition.value)
|
||||
const config = buildEditViewConfig(objectDefinition.value)
|
||||
console.log('[PAGE] editConfig computed:', config ? 'EXISTS' : 'NULL')
|
||||
return config
|
||||
})
|
||||
|
||||
// Debug current view state
|
||||
watch([view, recordId, editConfig, currentRecord, loading, dataLoading], ([v, rid, ec, cr, l, dl]) => {
|
||||
console.log('[PAGE] View state changed:')
|
||||
console.log(' - view:', v)
|
||||
console.log(' - recordId:', rid)
|
||||
console.log(' - editConfig exists?', !!ec)
|
||||
console.log(' - currentRecord exists?', !!cr)
|
||||
console.log(' - loading:', l)
|
||||
console.log(' - dataLoading:', dl)
|
||||
console.log(' - Should show EditView?', (v === 'edit' || rid === 'new') && !!ec)
|
||||
}, { immediate: true })
|
||||
|
||||
// Fetch object definition
|
||||
const fetchObjectDefinition = async () => {
|
||||
try {
|
||||
@@ -128,6 +143,21 @@ const fetchObjectDefinition = async () => {
|
||||
error.value = null
|
||||
const response = await api.get(`/setup/objects/${objectApiName.value}`)
|
||||
objectDefinition.value = response
|
||||
|
||||
// Fetch access permissions
|
||||
try {
|
||||
const accessResponse = await api.get(`/setup/objects/${objectApiName.value}/access`)
|
||||
objectAccess.value = accessResponse
|
||||
} catch (e) {
|
||||
console.warn('Failed to fetch access permissions:', e)
|
||||
// Set defaults if fetch fails
|
||||
objectAccess.value = {
|
||||
publicCreate: true,
|
||||
publicRead: true,
|
||||
publicUpdate: true,
|
||||
publicDelete: true,
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to load object definition'
|
||||
console.error('Error fetching object definition:', e)
|
||||
@@ -261,6 +291,7 @@ onMounted(async () => {
|
||||
:data="records"
|
||||
:loading="dataLoading"
|
||||
:base-url="`/runtime/objects`"
|
||||
:can-create="objectAccess?.publicCreate !== false"
|
||||
selectable
|
||||
@row-click="handleRowClick"
|
||||
@create="handleCreate"
|
||||
@@ -282,18 +313,20 @@ onMounted(async () => {
|
||||
/>
|
||||
|
||||
<!-- Edit View -->
|
||||
<EditView
|
||||
v-else-if="(view === 'edit' || recordId === 'new') && editConfig"
|
||||
:config="editConfig"
|
||||
:data="currentRecord || {}"
|
||||
:loading="dataLoading"
|
||||
:saving="saving"
|
||||
:object-id="objectDefinition?.id"
|
||||
:base-url="`/runtime/objects`"
|
||||
@save="handleSaveRecord"
|
||||
@cancel="handleCancel"
|
||||
@back="handleBack"
|
||||
/>
|
||||
<div v-else-if="(view === 'edit' || recordId === 'new') && editConfig">
|
||||
<div v-if="false">DEBUG: EditView should render here. view={{ view }}, recordId={{ recordId }}, editConfig={{ !!editConfig }}, currentRecord={{ !!currentRecord }}</div>
|
||||
<EditView
|
||||
:config="editConfig"
|
||||
:data="currentRecord || {}"
|
||||
:loading="dataLoading"
|
||||
:saving="saving"
|
||||
:object-id="objectDefinition?.id"
|
||||
:base-url="`/runtime/objects`"
|
||||
@save="handleSaveRecord"
|
||||
@cancel="handleCancel"
|
||||
@back="handleBack"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</NuxtLayout>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user