WIP - more progress with permissions
This commit is contained in:
@@ -45,11 +45,16 @@ const errors = ref<Record<string, string>>({})
|
||||
|
||||
// Watch for data changes (useful for edit mode)
|
||||
watch(() => props.data, (newData) => {
|
||||
console.log('[EditViewEnhanced] Data changed:', newData)
|
||||
console.log('[EditViewEnhanced] Data has id?', newData?.id)
|
||||
formData.value = { ...newData }
|
||||
}, { deep: true })
|
||||
}, { deep: true, immediate: true })
|
||||
|
||||
// Fetch page layout if objectId is provided
|
||||
onMounted(async () => {
|
||||
console.log('[EditViewEnhanced] Component mounted')
|
||||
console.log('[EditViewEnhanced] Props:', props)
|
||||
|
||||
if (props.objectId) {
|
||||
try {
|
||||
loadingLayout.value = true
|
||||
@@ -159,13 +164,27 @@ const validateForm = (): boolean => {
|
||||
}
|
||||
|
||||
const handleSave = () => {
|
||||
console.log('[EditViewEnhanced] handleSave called')
|
||||
console.log('[EditViewEnhanced] props.data:', props.data)
|
||||
console.log('[EditViewEnhanced] props.data?.id:', props.data?.id)
|
||||
console.log('[EditViewEnhanced] formData before processing:', { ...formData.value })
|
||||
|
||||
if (validateForm()) {
|
||||
// Filter out system fields from save data
|
||||
// Preserve the id from props.data if it exists (needed for updates)
|
||||
// Filter out other system fields that are auto-managed
|
||||
const saveData = { ...formData.value }
|
||||
const systemFields = ['id', 'tenantId', 'ownerId', 'created_at', 'updated_at', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy']
|
||||
for (const field of systemFields) {
|
||||
const systemFieldsToRemove = ['tenantId', 'ownerId', 'created_at', 'updated_at', 'createdAt', 'updatedAt', 'createdBy', 'updatedBy']
|
||||
for (const field of systemFieldsToRemove) {
|
||||
delete saveData[field]
|
||||
}
|
||||
|
||||
// Explicitly preserve id if it exists in the original data
|
||||
if (props.data?.id) {
|
||||
saveData.id = props.data.id
|
||||
console.log('[EditViewEnhanced] Preserved id from props:', saveData.id)
|
||||
}
|
||||
|
||||
console.log('[EditViewEnhanced] Final saveData:', saveData)
|
||||
emit('save', saveData)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user