WIP - more progress with permissions
This commit is contained in:
@@ -12,6 +12,8 @@ import {
|
||||
CollapsibleTrigger,
|
||||
} from '@/components/ui/collapsible'
|
||||
|
||||
console.log('[EditView] COMPONENT MOUNTING')
|
||||
|
||||
interface Props {
|
||||
config: EditViewConfig
|
||||
data?: any
|
||||
@@ -25,6 +27,8 @@ const props = withDefaults(defineProps<Props>(), {
|
||||
saving: false,
|
||||
})
|
||||
|
||||
console.log('[EditView] Props received on mount:', JSON.stringify(props, null, 2))
|
||||
|
||||
const emit = defineEmits<{
|
||||
'save': [data: any]
|
||||
'cancel': []
|
||||
@@ -35,10 +39,16 @@ const emit = defineEmits<{
|
||||
const formData = ref<Record<string, any>>({ ...props.data })
|
||||
const errors = ref<Record<string, string>>({})
|
||||
|
||||
console.log('[EditView] Initial props.data:', JSON.stringify(props.data, null, 2))
|
||||
console.log('[EditView] props.data.id:', props.data?.id)
|
||||
|
||||
// Watch for data changes (useful for edit mode)
|
||||
watch(() => props.data, (newData) => {
|
||||
console.log('[EditView] Data changed:', JSON.stringify(newData, null, 2))
|
||||
console.log('[EditView] newData.id:', newData?.id)
|
||||
console.log('[EditView] Keys in newData:', Object.keys(newData))
|
||||
formData.value = { ...newData }
|
||||
}, { deep: true })
|
||||
}, { deep: true, immediate: true })
|
||||
|
||||
// Organize fields into sections
|
||||
const sections = computed<FieldSection[]>(() => {
|
||||
@@ -137,7 +147,11 @@ const validateForm = (): boolean => {
|
||||
|
||||
const handleSave = () => {
|
||||
if (validateForm()) {
|
||||
emit('save', { ...formData.value })
|
||||
// Preserve id and other system fields from original data when saving
|
||||
emit('save', {
|
||||
id: props.data?.id, // Preserve the record ID for updates
|
||||
...formData.value
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user