|
|
@ -3,6 +3,7 @@ import { CacheGetType, CacheScope, MetaTable } from '../utils/globals'; |
|
|
|
import { GalleryColumnType, GalleryType, UITypes } from 'nocodb-sdk'; |
|
|
|
import { GalleryColumnType, GalleryType, UITypes } from 'nocodb-sdk'; |
|
|
|
import View from './View'; |
|
|
|
import View from './View'; |
|
|
|
import NocoCache from '../cache/NocoCache'; |
|
|
|
import NocoCache from '../cache/NocoCache'; |
|
|
|
|
|
|
|
import { extractProps } from '../meta/helpers/extractProps'; |
|
|
|
|
|
|
|
|
|
|
|
export default class GalleryView implements GalleryType { |
|
|
|
export default class GalleryView implements GalleryType { |
|
|
|
fk_view_id?: string; |
|
|
|
fk_view_id?: string; |
|
|
@ -51,21 +52,23 @@ export default class GalleryView implements GalleryType { |
|
|
|
.then((v) => v?.getModel(ncMeta)) |
|
|
|
.then((v) => v?.getModel(ncMeta)) |
|
|
|
.then((m) => m.getColumns(ncMeta)); |
|
|
|
.then((m) => m.getColumns(ncMeta)); |
|
|
|
|
|
|
|
|
|
|
|
const insertObj = { |
|
|
|
const insertObj = extractProps(view, [ |
|
|
|
project_id: view.project_id, |
|
|
|
'project_id', |
|
|
|
base_id: view.base_id, |
|
|
|
'base_id', |
|
|
|
fk_view_id: view.fk_view_id, |
|
|
|
'fk_view_id', |
|
|
|
fk_cover_image_col_id: |
|
|
|
'next_enabled', |
|
|
|
|
|
|
|
'prev_enabled', |
|
|
|
|
|
|
|
'cover_image_idx', |
|
|
|
|
|
|
|
'cover_image', |
|
|
|
|
|
|
|
'restrict_types', |
|
|
|
|
|
|
|
'restrict_size', |
|
|
|
|
|
|
|
'restrict_number', |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
insertObj.fk_cover_image_col_id = |
|
|
|
view?.fk_cover_image_col_id || |
|
|
|
view?.fk_cover_image_col_id || |
|
|
|
columns?.find((c) => c.uidt === UITypes.Attachment)?.id, |
|
|
|
columns?.find((c) => c.uidt === UITypes.Attachment)?.id; |
|
|
|
next_enabled: view.next_enabled, |
|
|
|
|
|
|
|
prev_enabled: view.prev_enabled, |
|
|
|
|
|
|
|
cover_image_idx: view.cover_image_idx, |
|
|
|
|
|
|
|
cover_image: view.cover_image, |
|
|
|
|
|
|
|
restrict_types: view.restrict_types, |
|
|
|
|
|
|
|
restrict_size: view.restrict_size, |
|
|
|
|
|
|
|
restrict_number: view.restrict_number, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (!(view.project_id && view.base_id)) { |
|
|
|
if (!(view.project_id && view.base_id)) { |
|
|
|
const viewRef = await View.get(view.fk_view_id); |
|
|
|
const viewRef = await View.get(view.fk_view_id); |
|
|
|
insertObj.project_id = viewRef.project_id; |
|
|
|
insertObj.project_id = viewRef.project_id; |
|
|
@ -90,16 +93,19 @@ export default class GalleryView implements GalleryType { |
|
|
|
) { |
|
|
|
) { |
|
|
|
// get existing cache
|
|
|
|
// get existing cache
|
|
|
|
const key = `${CacheScope.GALLERY_VIEW}:${galleryId}`; |
|
|
|
const key = `${CacheScope.GALLERY_VIEW}:${galleryId}`; |
|
|
|
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); |
|
|
|
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); |
|
|
|
|
|
|
|
const updateObj = extractProps(body, [ |
|
|
|
|
|
|
|
'next_enabled', |
|
|
|
|
|
|
|
'prev_enabled', |
|
|
|
|
|
|
|
'cover_image_idx', |
|
|
|
|
|
|
|
'cover_image', |
|
|
|
|
|
|
|
'restrict_types', |
|
|
|
|
|
|
|
'restrict_size', |
|
|
|
|
|
|
|
'restrict_number', |
|
|
|
|
|
|
|
'fk_cover_image_col_id', |
|
|
|
|
|
|
|
]); |
|
|
|
if (o) { |
|
|
|
if (o) { |
|
|
|
o.next_enabled = body.next_enabled; |
|
|
|
o = { ...o, ...updateObj }; |
|
|
|
o.prev_enabled = body.prev_enabled; |
|
|
|
|
|
|
|
o.cover_image_idx = body.cover_image_idx; |
|
|
|
|
|
|
|
o.cover_image = body.cover_image; |
|
|
|
|
|
|
|
o.restrict_types = body.restrict_types; |
|
|
|
|
|
|
|
o.restrict_size = body.restrict_size; |
|
|
|
|
|
|
|
o.restrict_number = body.restrict_number; |
|
|
|
|
|
|
|
o.fk_cover_image_col_id = body.fk_cover_image_col_id; |
|
|
|
|
|
|
|
// set cache
|
|
|
|
// set cache
|
|
|
|
await NocoCache.set(key, o); |
|
|
|
await NocoCache.set(key, o); |
|
|
|
} |
|
|
|
} |
|
|
@ -108,16 +114,7 @@ export default class GalleryView implements GalleryType { |
|
|
|
null, |
|
|
|
null, |
|
|
|
null, |
|
|
|
null, |
|
|
|
MetaTable.GALLERY_VIEW, |
|
|
|
MetaTable.GALLERY_VIEW, |
|
|
|
{ |
|
|
|
updateObj, |
|
|
|
next_enabled: body.next_enabled, |
|
|
|
|
|
|
|
prev_enabled: body.prev_enabled, |
|
|
|
|
|
|
|
cover_image_idx: body.cover_image_idx, |
|
|
|
|
|
|
|
cover_image: body.cover_image, |
|
|
|
|
|
|
|
restrict_types: body.restrict_types, |
|
|
|
|
|
|
|
restrict_size: body.restrict_size, |
|
|
|
|
|
|
|
restrict_number: body.restrict_number, |
|
|
|
|
|
|
|
fk_cover_image_col_id: body.fk_cover_image_col_id, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
fk_view_id: galleryId, |
|
|
|
fk_view_id: galleryId, |
|
|
|
} |
|
|
|
} |
|
|
|