@@ -156,32 +156,35 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
156
156
if ( ! resourceConfig . columns [ pathColumnIndex ] . components ) {
157
157
resourceConfig . columns [ pathColumnIndex ] . components = { } ;
158
158
}
159
+ const pathColumn = resourceConfig . columns [ pathColumnIndex ] ;
159
160
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
+ } ;
167
166
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
+ } ;
174
171
175
172
// insert virtual column after path column if it is not already there
176
173
const virtualColumnIndex = resourceConfig . columns . findIndex ( ( column : any ) => column . name === virtualColumn . name ) ;
177
174
if ( virtualColumnIndex === - 1 ) {
178
175
resourceConfig . columns . splice ( pathColumnIndex + 1 , 0 , virtualColumn ) ;
179
176
}
180
177
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 } ;
185
188
}
186
189
187
190
virtualColumn . required = pathColumn . required ;
@@ -229,30 +232,33 @@ getBucketLifecycleConfiguration on bucket ${this.options.s3Bucket} in region ${t
229
232
230
233
231
234
// 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 ) {
243
236
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
+ } ) ;
246
251
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
+ }
251
257
252
258
// ** HOOKS FOR LIST **//
253
259
254
260
255
- if ( this . options . preview ?. showInList || this . options . preview ?. showInList === undefined ) {
261
+ if ( pathColumn . showIn . list ) {
256
262
resourceConfig . hooks . list . afterDatasourceResponse . push ( async ( { response } : { response : any } ) => {
257
263
const s3 = new S3 ( {
258
264
credentials : {
0 commit comments