|
|
@ -1930,6 +1930,46 @@ class BaseModelSqlv2 { |
|
|
|
if (hookName === 'After.insert' && view.type === ViewTypes.FORM) { |
|
|
|
if (hookName === 'After.insert' && view.type === ViewTypes.FORM) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
const formView = await view.getView<FormView>(); |
|
|
|
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) || {}) |
|
|
|
const emails = Object.entries(JSON.parse(formView?.email) || {}) |
|
|
|
.filter((a) => a[1]) |
|
|
|
.filter((a) => a[1]) |
|
|
|
.map((a) => a[0]); |
|
|
|
.map((a) => a[0]); |
|
|
@ -1937,9 +1977,8 @@ class BaseModelSqlv2 { |
|
|
|
const transformedData = _transformSubmittedFormDataForEmail( |
|
|
|
const transformedData = _transformSubmittedFormDataForEmail( |
|
|
|
data, |
|
|
|
data, |
|
|
|
formView, |
|
|
|
formView, |
|
|
|
await this.model.getColumns() |
|
|
|
filteredColumns |
|
|
|
); |
|
|
|
); |
|
|
|
// todo: notification template
|
|
|
|
|
|
|
|
(await NcPluginMgrv2.emailAdapter())?.mailSend({ |
|
|
|
(await NcPluginMgrv2.emailAdapter())?.mailSend({ |
|
|
|
to: emails.join(','), |
|
|
|
to: emails.join(','), |
|
|
|
subject: 'NocoDB Form', |
|
|
|
subject: 'NocoDB Form', |
|
|
|