Skip to content

Commit 1d92bd7

Browse files
committed
fix issue with table choice in creating new charts
1 parent f9ed277 commit 1d92bd7

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

src/app/App.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
311311
useEffect(() => {
312312
const subscription: ActionSubscription = {
313313
loadData: (table: DictTable) => {
314-
dispatch(dfActions.addTable(table));
314+
dispatch(dfActions.loadTable(table));
315315
dispatch(fetchFieldSemanticType(table));
316316
},
317317
setAppConfig: (config) => {
@@ -346,8 +346,6 @@ export const AppFC: FC<AppFCProps> = function AppFC(appProps) {
346346
});
347347
}, [])
348348

349-
const [resetDialogOpen, setResetDialogOpen] = useState<boolean>(false);
350-
351349
useEffect(() => {
352350
document.title = toolName;
353351
dispatch(fetchAvailableModels());

src/app/dfSlice.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,14 @@ export const dataFormulatorSlice = createSlice({
301301
{id: id, status, message}
302302
];
303303
},
304-
addTable: (state, action: PayloadAction<DictTable>) => {
304+
loadTable: (state, action: PayloadAction<DictTable>) => {
305305
let table = action.payload;
306306
state.tables = [...state.tables, table];
307307
state.conceptShelfItems = [...state.conceptShelfItems, ...getDataFieldItems(table)];
308+
309+
state.focusedTableId = table.id;
310+
state.focusedChartId = undefined;
311+
state.activeThreadChartId = undefined;
308312
},
309313
deleteTable: (state, action: PayloadAction<string>) => {
310314
let tableId = action.payload;

src/views/DataThread.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ export const DataThread: FC<{}> = function ({ }) {
479479
display: 'flex',
480480
flexDirection: drawerOpen ? 'row-reverse' : 'column',
481481
minHeight: '100%',
482+
transition: 'all 0.3s ease',
482483
}}>
483484
{leafTables.map((lt, i) => {
484485
let usedTableIds = leafTables.slice(0, i)
@@ -493,10 +494,12 @@ export const DataThread: FC<{}> = function ({ }) {
493494
sx={{
494495
backgroundColor: (i % 2 == 1 ? "rgba(0, 0, 0, 0.03)" : 'white'),
495496
padding: '8px 8px',
496-
flex: 1,
497+
flex: drawerOpen ? 1 : 'none',
497498
display: 'flex',
498499
flexDirection: 'column',
499-
height: 'calc(100% - 16px)'
500+
height: 'calc(100% - 16px)',
501+
width: '208px',
502+
transition: 'all 0.3s ease',
500503
}} />
501504
})}
502505
</Box>

src/views/TableSelectionView.tsx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ export const TableSelectionDialog: React.FC<{ buttonElement: any }> = function T
223223
.then((text) => {
224224
let fullTable = createTableFromFromObjectArray(tableChallenges.table.id, JSON.parse(text));
225225
if (fullTable) {
226-
dispatch(dfActions.addTable(fullTable));
226+
dispatch(dfActions.loadTable(fullTable));
227227
dispatch(fetchFieldSemanticType(fullTable));
228228
dispatch(dfActions.addChallenges({
229229
tableId: tableChallenges.table.id,
@@ -279,7 +279,7 @@ export const TableUploadDialog: React.FC<TableUploadDialogProps> = ({ buttonElem
279279
const uniqueName = getUniqueTableName(file.name, existingNames);
280280
let table = loadDataWrapper(uniqueName, text, file.type);
281281
if (table) {
282-
dispatch(dfActions.addTable(table));
282+
dispatch(dfActions.loadTable(table));
283283
dispatch(fetchFieldSemanticType(table));
284284
}
285285
});
@@ -353,7 +353,7 @@ export const TableURLDialog: React.FC<TableURLDialogProps> = ({ buttonElement, d
353353
}
354354

355355
if (table) {
356-
dispatch(dfActions.addTable(table));
356+
dispatch(dfActions.loadTable(table));
357357
dispatch(fetchFieldSemanticType(table));
358358
}
359359
})
@@ -449,7 +449,7 @@ export const TableCopyDialogV2: React.FC<TableCopyDialogProps> = ({ buttonElemen
449449
table = createTableFromText(uniqueName, tableStr);
450450
}
451451
if (table) {
452-
dispatch(dfActions.addTable(table));
452+
dispatch(dfActions.loadTable(table));
453453
dispatch(fetchFieldSemanticType(table));
454454
}
455455
};
@@ -585,7 +585,8 @@ export const TableCopyDialogV2: React.FC<TableCopyDialogProps> = ({ buttonElemen
585585
flexDirection: "column",
586586
"& .MuiOutlinedInput-root.Mui-disabled": {backgroundColor: 'rgba(0,0,0,0.05)'}}} dividers>
587587
<Box sx={{width: '100%', marginBottom: 1, display:'flex'}}>
588-
<TextField sx={{flex: 1}} disabled={loadFromURL} size="small" value={tableName} onChange={(event) => { setTableName(event.target.value); }}
588+
<TextField sx={{flex: 1}} disabled={loadFromURL} size="small"
589+
value={tableName} onChange={(event) => { setTableName(event.target.value); }}
589590
autoComplete='off' id="outlined-basic" label="dataset name" variant="outlined" />
590591
<Divider sx={{margin: 1}} flexItem orientation='vertical'/>
591592
<Button sx={{marginLeft: 0, textTransform: 'none'}} onClick={() => {setLoadFromURL(!loadFromURL)}}
@@ -611,16 +612,6 @@ export const TableCopyDialogV2: React.FC<TableCopyDialogProps> = ({ buttonElemen
611612
{cleaningInProgress && tableContentType == "text" ? <LinearProgress sx={{ width: '100%', height: "calc(100% - 8px)", marginTop: 1, minHeight: 200, opacity: 0.1, position: 'absolute', zIndex: 1 }} /> : ""}
612613
{viewTable ?
613614
<>
614-
{/* <ReactDiffViewer
615-
leftTitle={'source'}
616-
rightTitle={'cleaning suggestions'}
617-
styles={newStyles}
618-
oldValue={tableContent}
619-
showDiffOnly={false}
620-
newValue={cleanTableContent.content}
621-
splitView={true}
622-
renderContent={renderLines}
623-
/> */}
624615
<CustomReactTable
625616
rows={viewTable.rows}
626617
rowsPerPageNum={-1} compact={false}

src/views/VisualizationView.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ export const VisualizationViewFC: FC<VisPanelProps> = function VisualizationView
711711
let tables = useSelector((state: DataFormulatorState) => state.tables);
712712
let charts = useSelector((state: DataFormulatorState) => state.charts);
713713
let focusedChartId = useSelector((state: DataFormulatorState) => state.focusedChartId);
714+
let focusedTableId = useSelector((state: DataFormulatorState) => state.focusedTableId);
714715

715716
let visViewMode = useSelector((state: DataFormulatorState) => state.visViewMode);
716717

@@ -736,7 +737,7 @@ export const VisualizationViewFC: FC<VisPanelProps> = function VisualizationView
736737
if (focusedChart?.chartType == "?") {
737738
dispatch(dfActions.updateChartType({chartType: t.chart, chartId: focusedChartId as string}));
738739
} else {
739-
dispatch(dfActions.createNewChart({chartType: t.chart, tableId: tables[0].id}));
740+
dispatch(dfActions.createNewChart({chartType: t.chart, tableId: focusedTableId}));
740741
}
741742
}}
742743
>
@@ -758,12 +759,6 @@ export const VisualizationViewFC: FC<VisPanelProps> = function VisualizationView
758759
cachedCandidates={cachedCandidates.find(l => l.chartId == focusedChartId)?.tables || []}
759760
handleUpdateCandidates={handleUpdateCandidates} />
760761

761-
//console.log(tables);
762-
763-
//let vegaSpec: any = createVegaObj(markType, encodingMap, conceptShelfItems)[0];
764-
// if (tables.length > 0) {
765-
// vegaSpec = createVegaObj(markType, encodingMap, conceptShelfItems)[0];
766-
// }
767762
let derivedFields = conceptShelfItems.filter(f => f.source == "derived");
768763

769764
let finalView = <Box></Box>;

0 commit comments

Comments
 (0)