Skip to content

Commit 524027e

Browse files
committed
preparing for data-anchor design
1 parent 51a977a commit 524027e

13 files changed

+270
-164
lines changed

src/app/dfSlice.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ export const dataFormulatorSlice = createSlice({
340340
let anchored = action.payload.anchored;
341341
state.tables = state.tables.map(t => t.id == tableId ? {...t, anchored} : t);
342342
},
343+
updateTableDisplayId: (state, action: PayloadAction<{tableId: string, displayId: string}>) => {
344+
let tableId = action.payload.tableId;
345+
let displayId = action.payload.displayId;
346+
state.tables = state.tables.map(t => t.id == tableId ? {...t, displayId} : t);
347+
},
343348
addChallenges: (state, action: PayloadAction<{tableId: string, challenges: { text: string; difficulty: 'easy' | 'medium' | 'hard'; }[]}>) => {
344349
state.activeChallenges = [...state.activeChallenges, action.payload];
345350
},

src/app/utils.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,21 @@ export const resolveChartFields = (chart: Chart, currentConcepts: FieldItem[], r
549549
}
550550

551551
export let getTriggers = (leafTable: DictTable, tables: DictTable[]) => {
552-
// recursively find triggers that ends in leafTable
552+
// recursively find triggers that ends in leafTable (if the leaf table is anchored, we will find till the previous table is anchored)
553553
let triggers : Trigger[] = [];
554554
let t = leafTable;
555-
while(t.derive != undefined) {
555+
while(true) {
556+
557+
// this is when we find an original table
558+
if (t.derive == undefined) {
559+
break;
560+
}
561+
562+
// this is when we find an anchored table (which is not the leaf table)
563+
if (t !== leafTable && t.anchored) {
564+
break;
565+
}
566+
556567
let trigger = t.derive.trigger as Trigger;
557568
triggers = [trigger, ...triggers];
558569
let parentTable = tables.find(x => x.id == trigger.tableId);

src/components/ComponentType.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export interface Trigger {
5757

5858
export interface DictTable {
5959
id: string; // name/id of the table
60+
displayId: string; // display id of the table
6061
names: string[]; // column names
6162
types: Type[]; // column types
6263
rows: any[]; // table content, each entry is a row
@@ -84,6 +85,7 @@ export function createDictTable(
8485

8586
return {
8687
id,
88+
displayId: `${id}`,
8789
names,
8890
rows,
8991
types: names.map(name => inferTypeFromValueArray(rows.map(r => r[name]))),

src/data/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export const createTableFromFromObjectArray = (title: string, values: any[], anc
9595

9696
return {
9797
id: title,
98+
displayId: `${title}`,
9899
names: columnTable.names(),
99100
types: columnTable.names().map(name => (columnTable.column(name) as Column).type),
100101
rows: columnTable.objects(),

src/scss/EncodingShelf.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
.encoding-shelf-trigger-card {
2525
margin: 6px 2px;
26-
min-width: 160px;
26+
min-width: 80px;
2727
}
2828

2929
.encoding-shelf-compact {

src/views/ConceptShelf.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export const ConceptGroup: FC<{groupName: string, fields: FieldItem[]}> = functi
8585
{fields.map((field) => (
8686
<ConceptCard key={`concept-card-${field.id}`} field={field} />
8787
))}
88-
{fields.length > 5 && !expanded && (
88+
{fields.length > 6 && !expanded && (
8989
<Box sx={{
9090
position: 'relative',
9191
height: '40px',
@@ -99,11 +99,11 @@ export const ConceptGroup: FC<{groupName: string, fields: FieldItem[]}> = functi
9999
background: 'linear-gradient(to bottom, transparent, white)'
100100
}
101101
}}>
102-
<ConceptCard field={fields[5]} />
102+
<ConceptCard field={fields[6]} />
103103
</Box>
104104
)}
105105
</Box>
106-
{fields.length > 5 && !expanded && (
106+
{fields.length > 6 && !expanded && (
107107
<Button
108108
onClick={() => setExpanded(!expanded)}
109109
sx={{
@@ -165,7 +165,7 @@ export const ConceptShelf: FC<ConceptShelfProps> = function ConceptShelf() {
165165
}, [focusedTableId])
166166

167167
// group concepts based on types
168-
let conceptItemGroups = groupConceptItems(conceptShelfItems);
168+
let conceptItemGroups = groupConceptItems(conceptShelfItems, tables);
169169
let groupNames = [...new Set(conceptItemGroups.map(g => g.group))]
170170

171171
return (

0 commit comments

Comments
 (0)