@@ -150,38 +150,41 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
150150 list : false ,
151151 show : false ,
152152 filter : false ,
153- }
153+ } ,
154154 } ;
155155
156156 if ( ! resourceConfig . columns [ pathColumnIndex ] . components ) {
157157 resourceConfig . columns [ pathColumnIndex ] . components = { } ;
158158 }
159+ const pathColumn = resourceConfig . columns [ pathColumnIndex ] ;
159160
160- if ( this . options . preview ?. showInList || this . options . preview ?. showInList === undefined ) {
161- // add preview column to list
162- resourceConfig . columns [ pathColumnIndex ] . components . list = {
163- file : this . componentPath ( 'preview.vue' ) ,
164- meta : pluginFrontendOptions ,
165- } ;
166- }
161+ // add preview column to list
162+ resourceConfig . columns [ pathColumnIndex ] . components . list = {
163+ file : this . componentPath ( 'preview.vue' ) ,
164+ meta : pluginFrontendOptions ,
165+ } ;
167166
168- if ( this . options . preview ?. showInShow || this . options . preview ?. showInShow === undefined ) {
169- resourceConfig . columns [ pathColumnIndex ] . components . show = {
170- file : this . componentPath ( 'preview.vue' ) ,
171- meta : pluginFrontendOptions ,
172- } ;
173- }
167+ resourceConfig . columns [ pathColumnIndex ] . components . show = {
168+ file : this . componentPath ( 'preview.vue' ) ,
169+ meta : pluginFrontendOptions ,
170+ } ;
174171
175172 // insert virtual column after path column if it is not already there
176173 const virtualColumnIndex = resourceConfig . columns . findIndex ( ( column : any ) => column . name === virtualColumn . name ) ;
177174 if ( virtualColumnIndex === - 1 ) {
178175 resourceConfig . columns . splice ( pathColumnIndex + 1 , 0 , virtualColumn ) ;
179176 }
180177
181- // if showIn of path column has 'create' or 'edit' remove it
182- const pathColumn = resourceConfig . columns [ pathColumnIndex ] ;
183- if ( pathColumn . showIn && ( pathColumn . showIn . create || pathColumn . showIn . edit ) ) {
184- pathColumn . showIn = { ...pathColumn . showIn , create : false , edit : false } ;
178+
179+ // if showIn of path column has 'create' or 'edit' remove it but use it for virtual column
180+ if ( pathColumn . showIn && ( pathColumn . showIn . create !== undefined ) ) {
181+ virtualColumn . showIn = { ...virtualColumn . showIn , create : pathColumn . showIn . create } ;
182+ pathColumn . showIn = { ...pathColumn . showIn , create : false } ;
183+ }
184+
185+ if ( pathColumn . showIn && ( pathColumn . showIn . edit !== undefined ) ) {
186+ virtualColumn . showIn = { ...virtualColumn . showIn , edit : pathColumn . showIn . edit } ;
187+ pathColumn . showIn = { ...pathColumn . showIn , edit : false } ;
185188 }
186189
187190 virtualColumn . required = pathColumn . required ;
@@ -229,30 +232,33 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
229232
230233
231234 // add show hook to get presigned URL
232- resourceConfig . hooks . show . afterDatasourceResponse . push ( async ( { response } : { response : any } ) => {
233- const record = response [ 0 ] ;
234- if ( ! record ) {
235- return { ok : true } ;
236- }
237- if ( record [ pathColumnName ] ) {
238- const s3 = new S3 ( {
239- credentials : {
240- accessKeyId : this . options . s3AccessKeyId ,
241- secretAccessKey : this . options . s3SecretAccessKey ,
242- } ,
235+ if ( pathColumn . showIn . show ) {
243236
244- region : this . options . s3Region ,
245- } ) ;
237+ resourceConfig . hooks . show . afterDatasourceResponse . push ( async ( { response } : { response : any } ) => {
238+ const record = response [ 0 ] ;
239+ if ( ! record ) {
240+ return { ok : true } ;
241+ }
242+ if ( record [ pathColumnName ] ) {
243+ const s3 = new S3 ( {
244+ credentials : {
245+ accessKeyId : this . options . s3AccessKeyId ,
246+ secretAccessKey : this . options . s3SecretAccessKey ,
247+ } ,
248+
249+ region : this . options . s3Region ,
250+ } ) ;
246251
247- await this . genPreviewUrl ( record , s3 ) ;
248- }
249- return { ok : true } ;
250- } ) ;
252+ await this . genPreviewUrl ( record , s3 ) ;
253+ }
254+ return { ok : true } ;
255+ } ) ;
256+ }
251257
252258 // ** HOOKS FOR LIST **//
253259
254260
255- if ( this . options . preview ?. showInList || this . options . preview ?. showInList === undefined ) {
261+ if ( pathColumn . showIn . list ) {
256262 resourceConfig . hooks . list . afterDatasourceResponse . push ( async ( { response } : { response : any } ) => {
257263 const s3 = new S3 ( {
258264 credentials : {
0 commit comments