Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 1x 1x 1x 1x 1x 132x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x | import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';
import { Node } from '../../store/flow-definition';
import { createRulesRouter } from '../../utils';
import {
getDigitOperators,
operatorsToSelectOptions,
getOperatorConfig
} from '../operators';
import {
resultNameField,
localizeRulesField,
localizeCategoriesField,
nodeOptionsAccordion
} from './shared';
import {
createRulesArrayConfig,
extractUserRules,
casesToFormRules
} from './shared-rules';
export const wait_for_digits: NodeConfig = {
type: 'wait_for_digits',
name: 'Wait for Digits',
group: SPLIT_GROUPS.wait,
flowTypes: [FlowTypes.VOICE],
dialogSize: 'large',
form: {
rules: createRulesArrayConfig(
operatorsToSelectOptions(getDigitOperators()),
''
),
result_name: resultNameField,
localizeRules: localizeRulesField,
localizeCategories: localizeCategoriesField
},
layout: [
{
type: 'text',
text: 'Rules match against all digits pressed by the caller followed by the # sign.'
},
'rules',
nodeOptionsAccordion
],
validate: (_formData: FormData) => {
return {
valid: true,
errors: {}
};
},
toFormData: (node: Node, nodeUI?: any) => {
const rules = casesToFormRules(node);
return {
uuid: node.uuid,
rules,
result_name: node.router?.result_name || '',
localizeRules: nodeUI?.config?.localizeRules || false,
localizeCategories: nodeUI?.config?.localizeCategories || false
};
},
toUIConfig: (formData: FormData) => {
const config: Record<string, any> = {};
config.localizeRules = !!formData.localizeRules;
config.localizeCategories = formData.result_name
? !!formData.localizeCategories
: false;
return config;
},
fromFormData: (formData: FormData, originalNode: Node): Node => {
const userRules = extractUserRules(formData);
const existingCategories = originalNode.router?.categories || [];
const existingExits = originalNode.exits || [];
const existingCases = originalNode.router?.cases || [];
const { router, exits } = createRulesRouter(
'@input.text',
userRules,
getOperatorConfig,
existingCategories,
existingExits,
existingCases
);
const finalRouter: any = {
...router,
wait: {
type: 'msg',
hint: {
type: 'digits'
}
}
};
if (formData.result_name && formData.result_name.trim() !== '') {
finalRouter.result_name = formData.result_name.trim();
}
return {
...originalNode,
router: finalRouter,
exits
};
},
localizable: 'categories'
};
|