mirror of https://github.com/nocodb/nocodb
Pranav C
9 months ago
10 changed files with 1567 additions and 130 deletions
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,46 @@
|
||||
import request from 'supertest'; |
||||
import type View from '../../../src/models/View'; |
||||
|
||||
const updateViewColumns = async ( |
||||
context, |
||||
{ |
||||
view, |
||||
viewColumns, |
||||
}: { |
||||
view: View; |
||||
viewColumns: Record<string, any>[] | Record<string, Record<string, any>[]>; |
||||
}, |
||||
) => { |
||||
// generate key-value pair of column id and column
|
||||
const fields = Array.isArray(viewColumns) |
||||
? viewColumns.reduce((acc, column) => { |
||||
acc[column.fk_column_id] = column; |
||||
return acc; |
||||
}, {}) |
||||
: viewColumns; |
||||
|
||||
// configure view to hide selected fields
|
||||
await request(context.app) |
||||
.patch(`/api/v3/meta/views/${view.id}/columns`) |
||||
.set('xc-auth', context.token) |
||||
.send(fields) |
||||
.expect(200); |
||||
}; |
||||
|
||||
const getViewColumns = async ( |
||||
context, |
||||
{ |
||||
view, |
||||
}: { |
||||
view: View; |
||||
}, |
||||
) => { |
||||
return ( |
||||
await request(context.app) |
||||
.get(`/api/v3/meta/views/${view.id}/columns`) |
||||
.set('xc-auth', context.token) |
||||
.expect(200) |
||||
).body; |
||||
}; |
||||
|
||||
export { updateViewColumns, getViewColumns }; |
Loading…
Reference in new issue