Skip to content

Commit 3e78482

Browse files
committed
fix bugs and add interface for start with instruction
1 parent a1d53a3 commit 3e78482

File tree

7 files changed

+637
-121
lines changed

7 files changed

+637
-121
lines changed

src/app/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
519519
//user is not logged in, do not show logout button
520520
//console.error(err)
521521
});
522-
}, [])
522+
}, []);
523523

524524
useEffect(() => {
525525
document.title = toolName;

src/app/dfSlice.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,11 @@ import { handleSSEMessage } from './SSEActions';
1616

1717
enableMapSet();
1818

19-
export const generateFreshChart = (tableRef: string, chartType?: string, source: "user" | "trigger" = "user") : Chart => {
20-
let realChartType = chartType || "?"
19+
export const generateFreshChart = (tableRef: string, chartType: string, source: "user" | "trigger" = "user") : Chart => {
2120
return {
2221
id: `chart-${Date.now()- Math.floor(Math.random() * 10000)}`,
23-
chartType: realChartType,
24-
encodingMap: Object.assign({}, ...getChartChannels(realChartType).map((channel) => ({ [channel]: { channel: channel, bin: false } }))),
22+
chartType: chartType,
23+
encodingMap: Object.assign({}, ...getChartChannels(chartType).map((channel) => ({ [channel]: { channel: channel, bin: false } }))),
2524
tableRef: tableRef,
2625
saved: false,
2726
source: source,
@@ -48,10 +47,8 @@ export interface ModelConfig {
4847
export const MODEL_SLOT_TYPES = ['generation', 'hint'] as const;
4948
export type ModelSlotType = typeof MODEL_SLOT_TYPES[number];
5049

51-
export interface ModelSlots {
52-
generation?: string; // model id assigned to generation tasks
53-
hint?: string; // model id assigned to hint tasks
54-
}
50+
// Derive ModelSlots interface from the constant
51+
export type ModelSlots = Partial<Record<ModelSlotType, string>>;
5552

5653
// Define a type for the slice state
5754
export interface DataFormulatorState {
@@ -359,11 +356,13 @@ export const dataFormulatorSlice = createSlice({
359356
},
360357
loadTable: (state, action: PayloadAction<DictTable>) => {
361358
let table = action.payload;
359+
let freshChart = generateFreshChart(table.id, '?') as Chart;
362360
state.tables = [...state.tables, table];
361+
state.charts = [...state.charts, freshChart];
363362
state.conceptShelfItems = [...state.conceptShelfItems, ...getDataFieldItems(table)];
364363

365364
state.focusedTableId = table.id;
366-
state.focusedChartId = undefined;
365+
state.focusedChartId = freshChart.id;
367366
},
368367
deleteTable: (state, action: PayloadAction<string>) => {
369368
let tableId = action.payload;
@@ -453,7 +452,7 @@ export const dataFormulatorSlice = createSlice({
453452
});
454453
}
455454
},
456-
createNewChart: (state, action: PayloadAction<{chartType?: string, tableId?: string}>) => {
455+
createNewChart: (state, action: PayloadAction<{chartType: string, tableId: string}>) => {
457456
let chartType = action.payload.chartType;
458457
let tableId = action.payload.tableId || state.tables[0].id;
459458
let freshChart = generateFreshChart(tableId, chartType, "user") as Chart;

0 commit comments

Comments
 (0)