@ -46,13 +46,14 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
! sharedView . value ||
! sharedView . value ||
sharedView . value ? . type === ViewTypes . GALLERY ||
sharedView . value ? . type === ViewTypes . GALLERY ||
sharedView . value ? . type === ViewTypes . KANBAN ||
sharedView . value ? . type === ViewTypes . KANBAN ||
_row . value . rowMeta . new
_row . value ? . rowMeta ? . new
? _row . value
? _row . value
: ( { row : { } , oldRow : { } , rowMeta : { } } as Row ) ,
: ( { row : { } , oldRow : { } , rowMeta : { } } as Row ) ,
)
)
row . value . rowMeta . fromExpandedForm = true
if ( row . value ? . rowMeta ? . fromExpandedForm ) {
row . value . rowMeta . fromExpandedForm = true
}
const rowStore = useProvideSmartsheetRowStore ( row )
const rowStore = useProvideSmartsheetRowStore ( row )
const activeView = inject ( ActiveViewInj , ref ( ) )
const activeView = inject ( ActiveViewInj , ref ( ) )
@ -349,53 +350,67 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
}
}
const loadRow = async ( rowId? : string , onlyVirtual = false , onlyNewColumns = false ) = > {
const loadRow = async ( rowId? : string , onlyVirtual = false , onlyNewColumns = false ) = > {
if ( row . value . rowMeta . new || isPublic . value || ! meta . value ? . id ) return
if ( row ? . value ? . rowMeta ? . new || isPublic . value || ! meta . value ? . id ) return
const recordId = rowId ? ? extractPkFromRow ( row . value . row , meta . value . columns as ColumnType [ ] )
const recordId = rowId ? ? extractPkFromRow ( row . value . row , meta . value . columns as ColumnType [ ] )
if ( ! recordId ) return
if ( ! recordId ) return
let record : Record < string , any > = { }
let record = await $api . dbTableRow . read (
try {
NOCO ,
record = await $api . dbTableRow . read (
// todo: base_id missing on view type
NOCO ,
( ( base ? . value ? . id ? ? meta . value ? . base_id ) || ( sharedView . value ? . view as any ) ? . base_id ) as string ,
// todo: base_id missing on view type
meta . value . id as string ,
( ( base ? . value ? . id ? ? meta . value ? . base_id ) || ( sharedView . value ? . view as any ) ? . base_id ) as string ,
encodeURIComponent ( recordId ) ,
meta . value . id as string ,
{
encodeURIComponent ( recordId ) ,
getHiddenColumn : true ,
{
} ,
getHiddenColumn : true ,
)
} ,
)
// update only virtual columns value if `onlyVirtual` is true
} catch ( err : any ) {
if ( onlyVirtual ) {
if ( err . response ? . status === 404 ) {
record = {
const router = useRouter ( )
. . . row . value . row ,
message . error ( t ( 'msg.noRecordFound' ) )
. . . ( meta . value . columns ? ? [ ] ) . reduce ( ( partialRecord , col ) = > {
router . replace ( { query : { } } )
if ( isVirtualCol ( col ) && col . title && col . title in record ) {
} else {
partialRecord [ col . title ] = ( record as Record < string , any > ) [ col . title as string ]
message . error ( ` ${ await extractSdkResponseErrorMsg ( err ) } ` )
}
return partialRecord
} , { } as Record < string , any > ) ,
}
}
}
}
// update only new/duplicated/renamed columns value if `onlyNewColumns` is true
try {
if ( onlyNewColumns ) {
// update only virtual columns value if `onlyVirtual` is true
record = Object . keys ( record ) . reduce ( ( acc , curr ) = > {
if ( onlyVirtual ) {
if ( ! Object . prototype . hasOwnProperty . call ( row . value . row , curr ) ) {
record = {
acc [ curr ] = record ( record as Record < string , any > ) [ curr ]
. . . row . value . row ,
} else {
. . . ( meta . value . columns ? ? [ ] ) . reduce ( ( partialRecord , col ) = > {
acc [ curr ] = row . value . row [ curr ]
if ( isVirtualCol ( col ) && col . title && col . title in record ) {
partialRecord [ col . title ] = ( record as Record < string , any > ) [ col . title as string ]
}
return partialRecord
} , { } as Record < string , any > ) ,
}
}
return acc
}
} , { } as Record < string , any > )
}
// update only new/duplicated/renamed columns value if `onlyNewColumns` is true
if ( onlyNewColumns ) {
record = Object . keys ( record ) . reduce ( ( acc , curr ) = > {
if ( ! Object . prototype . hasOwnProperty . call ( row . value . row , curr ) ) {
acc [ curr ] = record [ curr ]
} else {
acc [ curr ] = row . value . row [ curr ]
}
return acc
} , { } as Record < string , any > )
}
Object . assign ( row . value , {
Object . assign ( row . value , {
row : record ,
row : record ,
oldRow : { . . . record } ,
oldRow : { . . . record } ,
rowMeta : { } ,
rowMeta : { } ,
} )
} )
} catch ( e : any ) {
message . error ( ` ${ t ( 'msg.error.errorLoadingRecord' ) } ` )
}
}
}
const deleteRowById = async ( rowId? : string ) = > {
const deleteRowById = async ( rowId? : string ) = > {