|
|
|
@ -1930,6 +1930,46 @@ class BaseModelSqlv2 {
|
|
|
|
|
if (hookName === 'After.insert' && view.type === ViewTypes.FORM) { |
|
|
|
|
try { |
|
|
|
|
const formView = await view.getView<FormView>(); |
|
|
|
|
const { columns } = await FormView.getWithInfo(formView.fk_view_id); |
|
|
|
|
const allColumns = await this.model.getColumns(); |
|
|
|
|
const fieldById = columns.reduce( |
|
|
|
|
(o: Record<string, any>, f: Record<string, any>) => ({ |
|
|
|
|
...o, |
|
|
|
|
[f.fk_column_id]: f, |
|
|
|
|
}), |
|
|
|
|
{} |
|
|
|
|
); |
|
|
|
|
let order = 1; |
|
|
|
|
const filteredColumns = allColumns |
|
|
|
|
?.map((c: Record<string, any>) => ({ |
|
|
|
|
...c, |
|
|
|
|
fk_column_id: c.id, |
|
|
|
|
fk_view_id: formView.fk_view_id, |
|
|
|
|
...(fieldById[c.id] ? fieldById[c.id] : {}), |
|
|
|
|
order: (fieldById[c.id] && fieldById[c.id].order) || order++, |
|
|
|
|
id: fieldById[c.id] && fieldById[c.id].id, |
|
|
|
|
})) |
|
|
|
|
.sort( |
|
|
|
|
(a: Record<string, any>, b: Record<string, any>) => |
|
|
|
|
a.order - b.order |
|
|
|
|
) |
|
|
|
|
.filter( |
|
|
|
|
(f: Record<string, any>) => |
|
|
|
|
f.show && |
|
|
|
|
f.uidt !== UITypes.Rollup && |
|
|
|
|
f.uidt !== UITypes.Lookup && |
|
|
|
|
f.uidt !== UITypes.Formula && |
|
|
|
|
f.uidt !== UITypes.SpecificDBType |
|
|
|
|
) |
|
|
|
|
.sort( |
|
|
|
|
(a: Record<string, any>, b: Record<string, any>) => |
|
|
|
|
a.order - b.order |
|
|
|
|
) |
|
|
|
|
.map((c: Record<string, any>) => ({ |
|
|
|
|
...c, |
|
|
|
|
required: !!(c.required || 0), |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
const emails = Object.entries(JSON.parse(formView?.email) || {}) |
|
|
|
|
.filter((a) => a[1]) |
|
|
|
|
.map((a) => a[0]); |
|
|
|
@ -1937,9 +1977,8 @@ class BaseModelSqlv2 {
|
|
|
|
|
const transformedData = _transformSubmittedFormDataForEmail( |
|
|
|
|
data, |
|
|
|
|
formView, |
|
|
|
|
await this.model.getColumns() |
|
|
|
|
filteredColumns |
|
|
|
|
); |
|
|
|
|
// todo: notification template
|
|
|
|
|
(await NcPluginMgrv2.emailAdapter())?.mailSend({ |
|
|
|
|
to: emails.join(','), |
|
|
|
|
subject: 'NocoDB Form', |
|
|
|
|