@progress/sitefinity-nextjs-sdk
Version:
Provides OOB widgets developed using the Next.js framework, which includes an abstraction layer for Sitefinity communication. Additionally, it offers an expanded API, typings, and tools for further development and integration.
29 lines (28 loc) • 1.07 kB
JavaScript
import { FormRuleAction } from './interfaces/form-rule-action';
const formRuleActionsToEncrypt = {
[FormRuleAction.ShowMessage]: 0,
[FormRuleAction.SendNotification]: 0
};
export function getFormRulesViewProps(form) {
if (!form.Rules) {
return form.Rules;
}
const actionIndexList = { ...formRuleActionsToEncrypt };
const rules = JSON.parse(form.Rules);
for (const rule of rules) {
for (const action of rule['Actions']) {
const ruleAction = action['Action'];
if (Object.keys(formRuleActionsToEncrypt).includes(ruleAction)) {
action['Target'] = `sf_${ruleAction}_${actionIndexList[ruleAction]}`;
actionIndexList[ruleAction]++;
}
}
}
return JSON.stringify(rules);
}
export function getFormHiddenFields(formModel) {
const hiddenFields = formModel.ComponentContext.Components
.filter((x) => x.Properties.Hidden === 'True' || x.Properties.Hidden === 'true')
.map((x) => x.Properties.SfFieldName);
return hiddenFields;
}