|
|
|
@ -5,6 +5,7 @@ import { deserializeJSON, serializeJSON } from '../utils/serialize';
|
|
|
|
|
import FormViewColumn from './FormViewColumn'; |
|
|
|
|
import View from './View'; |
|
|
|
|
import NocoCache from '../cache/NocoCache'; |
|
|
|
|
import { extractProps } from '../meta/helpers/extractProps'; |
|
|
|
|
|
|
|
|
|
export default class FormView implements FormType { |
|
|
|
|
show: boolean; |
|
|
|
@ -86,44 +87,34 @@ export default class FormView implements FormType {
|
|
|
|
|
) { |
|
|
|
|
// get existing cache
|
|
|
|
|
const key = `${CacheScope.FORM_VIEW}:${formId}`; |
|
|
|
|
const o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); |
|
|
|
|
let o = await NocoCache.get(key, CacheGetType.TYPE_OBJECT); |
|
|
|
|
const updateObj = extractProps(body, [ |
|
|
|
|
'heading', |
|
|
|
|
'subheading', |
|
|
|
|
'success_msg', |
|
|
|
|
'redirect_url', |
|
|
|
|
'redirect_after_secs', |
|
|
|
|
'email', |
|
|
|
|
'banner_image_url', |
|
|
|
|
'logo_url', |
|
|
|
|
'submit_another_form', |
|
|
|
|
'show_blank_form', |
|
|
|
|
'meta', |
|
|
|
|
]); |
|
|
|
|
if (o) { |
|
|
|
|
o.heading = body.heading; |
|
|
|
|
o.subheading = body.subheading; |
|
|
|
|
o.success_msg = body.success_msg; |
|
|
|
|
o.redirect_url = body.redirect_url; |
|
|
|
|
o.redirect_after_secs = body.redirect_after_secs; |
|
|
|
|
o.email = body.email; |
|
|
|
|
o.banner_image_url = body.banner_image_url; |
|
|
|
|
o.logo_url = body.logo_url; |
|
|
|
|
o.submit_another_form = body.submit_another_form; |
|
|
|
|
o.show_blank_form = body.show_blank_form; |
|
|
|
|
o.meta = body.meta; |
|
|
|
|
o = { ...o, ...updateObj }; |
|
|
|
|
// set cache
|
|
|
|
|
await NocoCache.set(key, o); |
|
|
|
|
o.meta = serializeJSON(body.meta); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (updateObj.meta) { |
|
|
|
|
updateObj.meta = serializeJSON(updateObj.meta); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update meta
|
|
|
|
|
return await ncMeta.metaUpdate( |
|
|
|
|
null, |
|
|
|
|
null, |
|
|
|
|
MetaTable.FORM_VIEW, |
|
|
|
|
{ |
|
|
|
|
heading: body.heading, |
|
|
|
|
subheading: body.subheading, |
|
|
|
|
success_msg: body.success_msg, |
|
|
|
|
redirect_url: body.redirect_url, |
|
|
|
|
redirect_after_secs: body.redirect_after_secs, |
|
|
|
|
email: body.email, |
|
|
|
|
banner_image_url: body.banner_image_url, |
|
|
|
|
logo_url: body.logo_url, |
|
|
|
|
submit_another_form: body.submit_another_form, |
|
|
|
|
show_blank_form: body.show_blank_form, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
fk_view_id: formId, |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
return await ncMeta.metaUpdate(null, null, MetaTable.FORM_VIEW, updateObj, { |
|
|
|
|
fk_view_id: formId, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async getColumns(ncMeta = Noco.ncMeta) { |
|
|
|
|