@@ -134,27 +134,27 @@ export default class extends AdminForthPlugin {
134134
135135 // ** HOOKS FOR DELETE **//
136136 if ( ! this . options . dontDeleteJunctionRecords ) {
137- resourceConfig . hooks . delete . beforeSave . push ( async ( { recordId, record } : { recordId : any , record : any } ) => {
137+ resourceConfig . hooks . delete . beforeSave . push ( async ( { recordId, record, adminUser } : { recordId : any , record : any , adminUser : any } ) => {
138138 const existingJunctionRecords = await this . adminforth . resource ( junctionResource . resourceId ) . list ( [ Filters . EQ ( resourceColumnNameInJunctionResource , recordId ) ] ) ;
139139 for ( const jr of existingJunctionRecords ) {
140140 await this . adminforth . deleteResourceRecord ( {
141141 resource : junctionResource ,
142142 recordId : jr [ junctionResource . columns . find ( c => c . primaryKey ) . name ] ,
143143 record : jr ,
144- adminUser : null
144+ adminUser
145145 } ) ;
146146 }
147147 return { ok : true } ;
148148 } ) ;
149149 const linkedResource = this . adminforth . config . resources . find ( r => r . resourceId === this . options . linkedResourceId ) ;
150- linkedResource . hooks . delete . beforeSave . push ( async ( { recordId, record } : { recordId : any , record : any } ) => {
150+ linkedResource . hooks . delete . beforeSave . push ( async ( { recordId, record, adminUser } : { recordId : any , record : any , adminUser : any } ) => {
151151 const existingJunctionRecords = await this . adminforth . resource ( junctionResource . resourceId ) . list ( [ Filters . EQ ( linkedColumnNameInJunctionResource , recordId ) ] ) ;
152152 for ( const jr of existingJunctionRecords ) {
153153 await this . adminforth . deleteResourceRecord ( {
154154 resource : junctionResource ,
155155 recordId : jr [ junctionResource . columns . find ( c => c . primaryKey ) . name ] ,
156156 record : jr ,
157- adminUser : null
157+ adminUser
158158 } ) ;
159159 }
160160 return { ok : true } ;
@@ -178,6 +178,9 @@ export default class extends AdminForthPlugin {
178178 path : `/plugin/${ this . pluginInstanceId } /get-junctionResource-records` ,
179179 handler : async ( { body } ) => {
180180 const { recordId, returnLabels } = body ;
181+ if ( recordId === undefined || recordId === null || recordId === '' ) {
182+ return { ok : true , data : [ ] } ;
183+ }
181184 const junctionRecords = await this . adminforth . resource ( junctionResource . resourceId ) . list ( [ Filters . EQ ( resourceColumnNameInJunctionResource , recordId ) ] ) ;
182185 let dataToReturn = [ ] ;
183186 const junctionResourcePkColumn = junctionResource . columns . find ( c => c . primaryKey ) ;
0 commit comments