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 | 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 5x 5x 5x 5x 5x 132x 132x 132x 132x 131x 132x 132x 132x 132x 132x 132x 132x 132x 132x 133x 133x 133x 131x 131x 131x 131x 133x 133x 133x 133x 133x 133x 133x 133x 133x 133x 133x 133x 133x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 132x 134x 134x 134x 132x 134x 134x 132x 132x 132x 132x 132x | import { SPLIT_GROUPS, FormData, NodeConfig, FlowTypes } from '../types';
import { Node, Category, Exit } from '../../store/flow-definition';
import { generateUUID } from '../../utils';
export const wait_for_audio: NodeConfig = {
type: 'wait_for_audio',
name: 'Make Recording',
group: SPLIT_GROUPS.wait,
flowTypes: [FlowTypes.VOICE],
form: {
result_name: {
type: 'text',
label: 'Result Name',
required: false,
maxLength: 64,
placeholder: '(optional)',
helpText: 'The name to use to reference this result in the flow'
}
},
layout: ['result_name'],
toFormData: (node: Node) => {
return {
uuid: node.uuid,
result_name: node.router?.result_name || ''
};
},
fromFormData: (formData: FormData, originalNode: Node): Node => {
// Preserve or create "All Responses" category
const existingCategories = originalNode.router?.categories || [];
const existingExits = originalNode.exits || [];
let allResponsesCategory = existingCategories.find(
(cat: Category) => cat.name === 'All Responses'
);
let allResponsesExit: Exit;
if (allResponsesCategory) {
allResponsesExit = existingExits.find(
(exit: Exit) => exit.uuid === allResponsesCategory!.exit_uuid
) || {
uuid: allResponsesCategory.exit_uuid,
destination_uuid: null
};
} else {
const exitUuid = generateUUID();
allResponsesCategory = {
uuid: generateUUID(),
name: 'All Responses',
exit_uuid: exitUuid
};
allResponsesExit = {
uuid: exitUuid,
destination_uuid: null
};
}
const router: any = {
type: 'switch',
operand: '@input',
default_category_uuid: allResponsesCategory.uuid,
cases: [],
categories: [allResponsesCategory],
wait: {
type: 'msg',
hint: {
type: 'audio'
}
}
};
if (formData.result_name && formData.result_name.trim() !== '') {
router.result_name = formData.result_name.trim();
}
return {
...originalNode,
router,
exits: [allResponsesExit]
};
},
localizable: 'categories',
nonTranslatableCategories: 'all'
};
|