7eb7b3d0c8
Snapshot de WIP acumulado de sesiones previas antes de merge wave 1 del flow 0008 (kanban_cpp + agent_runner_api + DoD schema). Incluye: - dev/flows/0008-kanban-cpp-and-agent-workflows.md - dev/issues/0112-0119*.md (7 sub-issues) - WIP previo en cmd/fn/doctor.go, registry/*, modules/, cpp/, etc. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
164 lines
7.9 KiB
C++
164 lines
7.9 KiB
C++
#pragma once
|
|
// data_table_chips — barra de chips superior de la tabla TQL.
|
|
// Sub-funcion extraida de modules/data_table/data_table.cpp (issue 0107c).
|
|
//
|
|
// Responsabilidad:
|
|
// Toda la UI de chips que aparece en el area de chrome de la tabla:
|
|
// - draw_joins_chips : chips de join con tablas secundarias.
|
|
// - draw_filter_chips : chips de filtros activos (con boton de borrar).
|
|
// - draw_breakout_chips : chips de breakout (group-by) activos.
|
|
// - draw_aggregation_chips: chips de agregaciones activas.
|
|
// - draw_sort_chips : chips de ordenamiento activos.
|
|
// - draw_header_menu : popup menu al hacer right-click en cabecera de col.
|
|
// - apply_header_sort_click: procesa click en cabecera (sort / multi-sort con Shift).
|
|
//
|
|
// Popups de anadir/editar chips (activados desde los chips o botones "+"):
|
|
// - draw_add_filter_popup / draw_edit_filter_popup
|
|
// - draw_add_breakout_popup / draw_edit_breakout_popup
|
|
// - draw_add_aggregation_popup / draw_edit_agg_popup
|
|
// - draw_add_sort_popup / draw_edit_sort_popup
|
|
//
|
|
// TQL preview / save / load (area de chrome stage 0):
|
|
// - draw_tql_bar (NEW helper que engloba Show TQL, Apply TQL, Save/Load .tql)
|
|
//
|
|
// Helpers de tipo/op para los popups:
|
|
// - draw_typed_ops: dibuja radio buttons de Op segun ColumnType.
|
|
// - type_supports_range: retorna true si el tipo soporta Op::Range.
|
|
//
|
|
// Rangos del fuente original:
|
|
// - draw_joins_chips : lineas 1897-2003
|
|
// - draw_filter_chips : lineas 2009-2093
|
|
// - draw_breakout_chips : lineas 2095-2188
|
|
// - draw_aggregation_chips : lineas 2189-2238
|
|
// - draw_sort_chips : lineas 2240-2309
|
|
// - apply_header_sort_click : lineas 2311-2327
|
|
// - draw_edit_filter_popup : lineas 2329-2370
|
|
// - draw_edit_breakout_popup : lineas 2372-2395
|
|
// - draw_edit_agg_popup : lineas 2397-2445
|
|
// - draw_edit_sort_popup : lineas 2447-2472
|
|
// - draw_typed_ops : lineas 2503-2510
|
|
// - type_supports_range : lineas 2512-2514
|
|
// - draw_add_filter_popup : lineas 2516-2569
|
|
// - draw_add_breakout_popup : lineas 2571-2604
|
|
// - draw_add_aggregation_popup: lineas 2606-2655
|
|
// - draw_add_sort_popup : lineas 2657-2682
|
|
// - draw_header_menu : lineas 2684-2892
|
|
// - TQL preview/save/load : lineas 3272-3366 (dentro de render() stage 0)
|
|
//
|
|
// Dependencias: data_table_types.h, tql_emit.h, tql_apply.h, imgui.h.
|
|
|
|
#include "core/data_table_types.h"
|
|
#include "imgui.h"
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace data_table {
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Helpers de tipo/operacion
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// draw_typed_ops: dibuja radio buttons para los operadores compatibles con el
|
|
// tipo `t`. Rellena `out` con el op seleccionado. Retorna true si se selecciono.
|
|
bool draw_typed_ops(ColumnType t, Op& out);
|
|
|
|
// type_supports_range: true si el tipo admite Op::Range (Int, Float, Date).
|
|
bool type_supports_range(ColumnType t);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Sort
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// apply_header_sort_click: registra un click en el header de col_name.
|
|
// Sin Shift: sort primario (reemplaza todos los sorts).
|
|
// Con Shift: sort secundario (agrega al sort primario existente).
|
|
// Ciclo: Asc -> Desc -> none.
|
|
void apply_header_sort_click(Stage& stg, const std::string& col_name, bool shift);
|
|
|
|
void draw_sort_chips(Stage& stg);
|
|
void draw_add_sort_popup(Stage& stg, const char* const* headers, int n_cols,
|
|
const std::vector<ColumnType>& types);
|
|
void draw_edit_sort_popup(Stage& stg, const char* const* headers, int n_cols);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Filtros
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void draw_filter_chips(Stage& stg, const char* const* eff_headers, int eff_cols,
|
|
const std::vector<ColumnType>& eff_types);
|
|
void draw_add_filter_popup(Stage& stg, const char* const* eff_headers, int eff_cols,
|
|
const std::vector<ColumnType>& eff_types);
|
|
void draw_edit_filter_popup(Stage& stg, const char* const* headers, int n_cols,
|
|
const std::vector<ColumnType>& types);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Breakouts (group-by)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void draw_breakout_chips(Stage& stg, const char* const* in_headers, int in_cols,
|
|
const std::vector<ColumnType>& in_types);
|
|
void draw_add_breakout_popup(Stage& stg, const char* const* in_headers, int in_cols,
|
|
const std::vector<ColumnType>& in_types,
|
|
const char* const* cur_cells, int cur_rows);
|
|
void draw_edit_breakout_popup(Stage& stg, const char* const* headers, int n_cols);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Agregaciones
|
|
// ---------------------------------------------------------------------------
|
|
|
|
void draw_aggregation_chips(Stage& stg, const char* const* in_headers, int in_cols);
|
|
void draw_add_aggregation_popup(Stage& stg, const char* const* in_headers, int in_cols,
|
|
const std::vector<ColumnType>& in_types);
|
|
void draw_edit_agg_popup(Stage& stg, const char* const* headers, int n_cols);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Joins
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// draw_joins_chips: chips de join con las tablas joinables. Solo visible si
|
|
// joinables no esta vacio. Mutates st.stages y la configuracion de join.
|
|
void draw_joins_chips(State& st, const std::vector<TableInput>& joinables,
|
|
const char* const* eff_headers, int eff_cols,
|
|
const std::vector<ColumnType>& eff_types);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Header menu (right-click en cabecera de columna)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// draw_header_menu: popup que aparece al right-click en el header de columna
|
|
// `col`. Incluye sort, filter, conditional color, type change, etc.
|
|
// is_raw_stage: true si estamos en stage 0 (permite "Change type" / "Derived").
|
|
void draw_header_menu(State& st, Stage& stg, int col,
|
|
const char* const* eff_headers_arr, int eff_cols,
|
|
const std::vector<ColumnType>& eff_types,
|
|
int orig_cols, bool is_raw_stage);
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// TQL bar (Show TQL / Apply TQL / Save .tql / Load .tql)
|
|
// Area de chrome adicional en stage 0. Nuevo helper que extrae el bloque
|
|
// de lineas 3272-3366 del render() original.
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// TqlBarState: estado del area TQL (vive en UiState).
|
|
struct TqlBarState {
|
|
bool show_open = false;
|
|
std::string show_text;
|
|
bool apply_open = false;
|
|
std::string apply_text;
|
|
std::string apply_error;
|
|
char file_path[256] = "table.tql";
|
|
std::string io_status; // "saved: ..." / "loaded: ..." / "load FAILED: ..."
|
|
};
|
|
|
|
// draw_tql_bar: dibuja los botones Show TQL, Apply TQL, Save .tql, Load .tql
|
|
// y los modales correspondientes. Mutates st via tql::apply en Apply.
|
|
// active_headers/types/cells/row_count/orig_cols: necesarios para tql::emit + apply.
|
|
void draw_tql_bar(TqlBarState& tql_bar,
|
|
State& st,
|
|
const std::vector<std::string>& orig_headers,
|
|
const std::vector<ColumnType>& orig_types,
|
|
const char* const* cells,
|
|
int row_count, int orig_cols);
|
|
|
|
} // namespace data_table
|