feat: flow form editor shows all types with proper selects
PHP form for flows tab now renders: - Type select grouped: Respuesta / Navegar / Acción directa / Formulario - 💬 Texto fijo: textarea - 📑 Mostrar menú: dropdown of company menus - ⚡ Función especial: goodbye / api_report / IA / Agente - api_report expands: endpoint dropdown, period, filename, caption - ✏️ Pedir dato (collect_input): prompt, meta_group, meta_key, next-node select - 📋 Lista dinámica (dynamic_list): endpoint select, value/label fields, header, body, next-node - 🚀 Enviar formulario (submit_form): endpoint, meta_group, filename, caption Save handler in index.php reads all new field arrays and builds correct flow JSON. flowTabChange()/flowFnTabChange() toggle sections on type/function change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
316d9ce73e
commit
eeda883bd9
+75
-10
@@ -382,20 +382,85 @@ $routes = [
|
||||
if (!empty($menus)) $config['menus'] = $menus;
|
||||
|
||||
// Flows
|
||||
$flowKeys = $_POST['flow_key'] ?? [];
|
||||
$flowTypes = $_POST['flow_type'] ?? [];
|
||||
$flowMessages = $_POST['flow_message'] ?? [];
|
||||
$flowFunctions = $_POST['flow_function'] ?? [];
|
||||
$flowMenus = $_POST['flow_menu'] ?? [];
|
||||
$flowKeys = $_POST['flow_key'] ?? [];
|
||||
$flowTypes = $_POST['flow_type'] ?? [];
|
||||
$flowMessages = $_POST['flow_message'] ?? [];
|
||||
$flowFunctions = $_POST['flow_function'] ?? [];
|
||||
$flowMenus = $_POST['flow_menu'] ?? [];
|
||||
$flowEpKeys = $_POST['flow_ep_key'] ?? [];
|
||||
$flowDateModes = $_POST['flow_date_mode'] ?? [];
|
||||
$flowFilenames = $_POST['flow_filename'] ?? [];
|
||||
$flowCaptions = $_POST['flow_caption'] ?? [];
|
||||
$flowPrompts = $_POST['flow_prompt'] ?? [];
|
||||
$flowMetaGrps = $_POST['flow_meta_group'] ?? [];
|
||||
$flowMetaKeys = $_POST['flow_meta_key'] ?? [];
|
||||
$flowNextNodes = $_POST['flow_next_node'] ?? [];
|
||||
$flowDlEps = $_POST['flow_dl_ep'] ?? [];
|
||||
$flowValFields = $_POST['flow_val_field'] ?? [];
|
||||
$flowLblFields = $_POST['flow_lbl_field'] ?? [];
|
||||
$flowHeaders = $_POST['flow_header'] ?? [];
|
||||
$flowBodies = $_POST['flow_body'] ?? [];
|
||||
$flowSecTitles = $_POST['flow_sec_title'] ?? [];
|
||||
$flowDlGroups = $_POST['flow_dl_meta_group']?? [];
|
||||
$flowDlKeys = $_POST['flow_dl_meta_key'] ?? [];
|
||||
$flowDlNexts = $_POST['flow_dl_next'] ?? [];
|
||||
$flowSfEps = $_POST['flow_sf_ep'] ?? [];
|
||||
$flowSfGroups = $_POST['flow_sf_meta_group']?? [];
|
||||
$flowSfFnames = $_POST['flow_sf_filename'] ?? [];
|
||||
$flowSfCaps = $_POST['flow_sf_caption'] ?? [];
|
||||
|
||||
$flows = [];
|
||||
foreach ($flowKeys as $i => $fk) {
|
||||
$fk = trim($fk);
|
||||
if ($fk === '') continue;
|
||||
$fk = trim($fk);
|
||||
$ftype = $flowTypes[$i] ?? 'text';
|
||||
if ($fk === '') continue;
|
||||
|
||||
$f = ['type' => $ftype];
|
||||
if ($ftype === 'text') $f['message'] = trim($flowMessages[$i] ?? '');
|
||||
elseif ($ftype === 'function') $f['function'] = trim($flowFunctions[$i] ?? 'forward_to_ai');
|
||||
elseif ($ftype === 'menu') $f['menu'] = trim($flowMenus[$i] ?? '');
|
||||
|
||||
if ($ftype === 'text') {
|
||||
$f['message'] = trim($flowMessages[$i] ?? '');
|
||||
|
||||
} elseif ($ftype === 'menu') {
|
||||
$f['menu'] = trim($flowMenus[$i] ?? '');
|
||||
|
||||
} elseif ($ftype === 'function') {
|
||||
$fn = trim($flowFunctions[$i] ?? 'forward_to_ai');
|
||||
$f['function'] = $fn;
|
||||
if ($fn === 'api_report') {
|
||||
$f['params'] = [
|
||||
'endpoint_key' => trim($flowEpKeys[$i] ?? ''),
|
||||
'date_mode' => trim($flowDateModes[$i] ?? ''),
|
||||
'caption' => trim($flowCaptions[$i] ?? ''),
|
||||
'filename' => trim($flowFilenames[$i] ?? ''),
|
||||
];
|
||||
}
|
||||
|
||||
} elseif ($ftype === 'collect_input') {
|
||||
$nn = trim($flowNextNodes[$i] ?? '');
|
||||
$f['prompt'] = trim($flowPrompts[$i] ?? '');
|
||||
$f['meta_group'] = trim($flowMetaGrps[$i] ?? '');
|
||||
$f['meta_key'] = trim($flowMetaKeys[$i] ?? '');
|
||||
$f['next_node'] = $nn !== '' ? $nn : null;
|
||||
|
||||
} elseif ($ftype === 'dynamic_list') {
|
||||
$nn = trim($flowDlNexts[$i] ?? '');
|
||||
$f['source_endpoint_key'] = trim($flowDlEps[$i] ?? '');
|
||||
$f['value_field'] = trim($flowValFields[$i] ?? 'id');
|
||||
$f['label_field'] = trim($flowLblFields[$i] ?? 'nombre');
|
||||
$f['header'] = trim($flowHeaders[$i] ?? '');
|
||||
$f['body'] = trim($flowBodies[$i] ?? '');
|
||||
$f['section_title'] = trim($flowSecTitles[$i] ?? '');
|
||||
$f['meta_group'] = trim($flowDlGroups[$i] ?? '');
|
||||
$f['meta_key'] = trim($flowDlKeys[$i] ?? '');
|
||||
$f['next_node'] = $nn !== '' ? $nn : null;
|
||||
|
||||
} elseif ($ftype === 'submit_form') {
|
||||
$f['endpoint_key'] = trim($flowSfEps[$i] ?? '');
|
||||
$f['meta_group'] = trim($flowSfGroups[$i] ?? '');
|
||||
$f['filename'] = trim($flowSfFnames[$i] ?? '');
|
||||
$f['caption'] = trim($flowSfCaps[$i] ?? '');
|
||||
}
|
||||
|
||||
$flows[$fk] = $f;
|
||||
}
|
||||
if (!empty($flows)) $config['flows'] = $flows;
|
||||
|
||||
Reference in New Issue
Block a user