Browse Source

feat(nnocodb): hide copy hook btn for v1 and add version label in hook list

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
92ea751c45
  1. 38
      packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts

38
packages/nocodb/src/lib/meta/helpers/populateSamplePayload.ts

@ -7,7 +7,43 @@ import type LinkToAnotherRecordColumn from '../../models/LinkToAnotherRecordColu
import type LookupColumn from '../../models/LookupColumn';
import type SelectOption from '../../models/SelectOption';
export default async function populateSamplePayload(
export async function populateSamplePayload(
viewOrModel: View | Model,
includeNested = false,
operation = 'insert'
) {
const out = {};
let columns: Column[] = [];
let model: Model;
if (viewOrModel instanceof View) {
const viewColumns = await viewOrModel.getColumns();
for (const col of viewColumns) {
if (col.show) columns.push(await Column.get({ colId: col.fk_column_id }));
}
model = await viewOrModel.getModel();
await model.getColumns();
} else if (viewOrModel instanceof Model) {
columns = await viewOrModel.getColumns();
model = viewOrModel;
}
for (const column of columns) {
if (
!includeNested &&
[UITypes.LinkToAnotherRecord, UITypes.Lookup].includes(column.uidt)
)
continue;
if (operation === 'delete' && model.primaryKey?.title !== column.title)
continue;
out[column.title] = await getSampleColumnValue(column);
}
return out;
}
export default async function populateSamplePayloadV2(
viewOrModel: View | Model,
includeNested = false,
operation = 'insert',

Loading…
Cancel
Save