Use AI assistant to create records in the system, added configurable list views
This commit is contained in:
@@ -3,6 +3,7 @@ import { ref, computed, onMounted, onBeforeUnmount, watch } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useApi } from '@/composables/useApi'
|
||||
import { useFields, useViewState } from '@/composables/useFieldViews'
|
||||
import { usePageLayouts } from '@/composables/usePageLayouts'
|
||||
import ListView from '@/components/views/ListView.vue'
|
||||
import DetailView from '@/components/views/DetailView.vue'
|
||||
import EditView from '@/components/views/EditView.vue'
|
||||
@@ -11,6 +12,7 @@ const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { api } = useApi()
|
||||
const { buildListViewConfig, buildDetailViewConfig, buildEditViewConfig } = useFields()
|
||||
const { getDefaultPageLayout } = usePageLayouts()
|
||||
|
||||
// Get object API name from route
|
||||
const objectApiName = computed(() => route.params.objectName as string)
|
||||
@@ -25,6 +27,7 @@ const view = computed(() => {
|
||||
|
||||
// State
|
||||
const objectDefinition = ref<any>(null)
|
||||
const listViewLayout = ref<any>(null)
|
||||
const loading = ref(true)
|
||||
const error = ref<string | null>(null)
|
||||
|
||||
@@ -66,11 +69,13 @@ onBeforeUnmount(() => {
|
||||
// View configs
|
||||
const listConfig = computed(() => {
|
||||
if (!objectDefinition.value) return null
|
||||
// Pass the list view layout config to buildListViewConfig if available
|
||||
const layoutConfig = listViewLayout.value?.layout_config || listViewLayout.value?.layoutConfig
|
||||
return buildListViewConfig(objectDefinition.value, {
|
||||
searchable: true,
|
||||
exportable: true,
|
||||
filterable: true,
|
||||
})
|
||||
}, layoutConfig)
|
||||
})
|
||||
|
||||
const detailConfig = computed(() => {
|
||||
@@ -93,6 +98,16 @@ const fetchObjectDefinition = async () => {
|
||||
error.value = null
|
||||
const response = await api.get(`/setup/objects/${objectApiName.value}`)
|
||||
objectDefinition.value = response
|
||||
|
||||
// Fetch the default list view layout for this object
|
||||
if (response?.id) {
|
||||
try {
|
||||
listViewLayout.value = await getDefaultPageLayout(response.id, 'list')
|
||||
} catch (e) {
|
||||
// No list view layout configured, will use default behavior
|
||||
listViewLayout.value = null
|
||||
}
|
||||
}
|
||||
} catch (e: any) {
|
||||
error.value = e.message || 'Failed to load object definition'
|
||||
console.error('Error fetching object definition:', e)
|
||||
|
||||
Reference in New Issue
Block a user