Use AI assistant to create records in the system, added configurable list views
This commit is contained in:
@@ -20,6 +20,9 @@ export const useFields = () => {
|
||||
// Hide system fields and auto-generated fields on edit
|
||||
const shouldHideOnEdit = isSystemField || isAutoGeneratedField
|
||||
|
||||
// Hide 'id' field from list view by default (check both apiName and id field)
|
||||
const shouldHideOnList = fieldDef.apiName === 'id' || fieldDef.label === 'Id' || fieldDef.label === 'ID'
|
||||
|
||||
return {
|
||||
id: fieldDef.id,
|
||||
apiName: fieldDef.apiName,
|
||||
@@ -37,7 +40,7 @@ export const useFields = () => {
|
||||
validationRules: fieldDef.validationRules || [],
|
||||
|
||||
// View options - only hide system and auto-generated fields by default
|
||||
showOnList: fieldDef.showOnList ?? true,
|
||||
showOnList: fieldDef.showOnList ?? !shouldHideOnList,
|
||||
showOnDetail: fieldDef.showOnDetail ?? true,
|
||||
showOnEdit: fieldDef.showOnEdit ?? !shouldHideOnEdit,
|
||||
sortable: fieldDef.sortable ?? true,
|
||||
@@ -67,12 +70,36 @@ export const useFields = () => {
|
||||
|
||||
/**
|
||||
* Build a ListView configuration from object definition
|
||||
* @param objectDef - The object definition containing fields
|
||||
* @param customConfig - Optional custom configuration
|
||||
* @param listLayoutConfig - Optional list view layout configuration from page_layouts
|
||||
*/
|
||||
const buildListViewConfig = (
|
||||
objectDef: any,
|
||||
customConfig?: Partial<ListViewConfig>
|
||||
customConfig?: Partial<ListViewConfig>,
|
||||
listLayoutConfig?: { fields: Array<{ fieldId: string; order?: number }> } | null
|
||||
): ListViewConfig => {
|
||||
const fields = objectDef.fields?.map(mapFieldDefinitionToConfig) || []
|
||||
let fields = objectDef.fields?.map(mapFieldDefinitionToConfig) || []
|
||||
|
||||
// If a list layout is provided, filter and order fields according to it
|
||||
if (listLayoutConfig && listLayoutConfig.fields && listLayoutConfig.fields.length > 0) {
|
||||
// Sort layout fields by order
|
||||
const sortedLayoutFields = [...listLayoutConfig.fields].sort((a, b) => (a.order ?? 0) - (b.order ?? 0))
|
||||
|
||||
// Map layout fields to actual field configs, preserving order
|
||||
const orderedFields: FieldConfig[] = []
|
||||
for (const layoutField of sortedLayoutFields) {
|
||||
const fieldConfig = fields.find((f: FieldConfig) => f.id === layoutField.fieldId)
|
||||
if (fieldConfig) {
|
||||
orderedFields.push(fieldConfig)
|
||||
}
|
||||
}
|
||||
|
||||
// Use ordered fields if we found any, otherwise fall back to all fields
|
||||
if (orderedFields.length > 0) {
|
||||
fields = orderedFields
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
objectApiName: objectDef.apiName,
|
||||
|
||||
Reference in New Issue
Block a user