@ -1,5 +1,5 @@
< script setup lang = "ts" >
import { ModelTypes , MssqlUi , RelationTypes , SqliteUi , UITypes , ViewTypes } from 'nocodb-sdk'
import { type LinkToAnotherRecordType , ModelTypes , MssqlUi , RelationTypes , SqliteUi , UITypes , ViewTypes } from 'nocodb-sdk'
const props = defineProps < {
value : any
@ -48,12 +48,33 @@ if (!isEdit.value) {
if ( ! vModel . value . virtual ) vModel . value . virtual = sqlUi === SqliteUi / / a p p I n f o . i s C l o u d | | s q l U i = = = S q l i t e U i
if ( ! vModel . value . alias ) vModel . value . alias = vModel . value . column _name
} else {
if ( ! vModel . value . childId )
vModel . custom = {
ref _model _id : vModel . value ? . colOptions ? . fk _related _model _id ,
const colOptions = vModel . value ? . colOptions as LinkToAnotherRecordType
if ( vModel . value ? . meta ? . custom && isEeUI ) {
let ref _column _id = colOptions . fk _child _column _id
let column _id = colOptions . fk _parent _column _id
/ / e x t r a c t r e f c o l u m n i d f r o m c o l O p t i o n s
if (
colOptions . type === RelationTypes . MANY _TO _MANY ||
colOptions . type === RelationTypes . BELONGS _TO ||
vModel ? . value ? . meta ? . bt
) {
ref _column _id = colOptions . fk _parent _column _id
column _id = colOptions . fk _child _column _id
}
vModel . value . custom = {
ref _model _id : colOptions ? . fk _related _model _id ,
base _id : meta . value ? . base _id ,
junc _base _id : meta . value ? . base _id ,
junc _model _id : colOptions ? . fk _mm _model _id ,
junc _ref _column _id : colOptions ? . fk _mm _parent _column _id ,
junc _column _id : colOptions ? . fk _mm _child _column _id ,
ref _column _id ,
column _id ,
}
}
vModel . value . is _custom _link = vModel . value ? . meta ? . custom
if ( ! vModel . value . childViewId ) vModel . value . childViewId = vModel . value ? . colOptions ? . fk _target _view _id || null
}
if ( ! vModel . value . childId ) vModel . value . childId = vModel . value ? . colOptions ? . fk _related _model _id || null
@ -182,13 +203,14 @@ const cusJuncTableValidations = {
}
const onCustomSwitchToggle = ( ) => {
if ( vModel . value ? . is _custom _link )
if ( vModel . value ? . is _custom _link ) {
setAdditionalValidations ( {
childId : [ ] ,
... cusValidators ,
... ( vModel . value . type === RelationTypes . MANY _TO _MANY ? cusJuncTableValidations : { } ) ,
} )
else
vModel . value . virtual = true
} else
setAdditionalValidations ( {
childId : [ { required : true , message : t ( 'general.required' ) } ] ,
} )
@ -413,7 +435,7 @@ const handleShowAdvanceOptions = () => {
< div class = "flex flex-row" >
< a -form -item >
< div class = "flex items-center gap-1" >
< NcSwitch v -model :checked ="vModel.virtual" @change ="onDataTypeChange" >
< NcSwitch v -model :checked ="vModel.virtual" :disabled ="vModel.is_custom_link" @change ="onDataTypeChange" >
< div class = "text-sm text-gray-800 select-none" >
{ { $t ( 'title.virtualRelation' ) } }
< / div >