Skip to content

Commit 2edf87d

Browse files
author
Martha King
committed
use temp name for index column
1 parent 39fc8ea commit 2edf87d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

app/gui/src/project-view/components/visualizations/TableVisualization.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,15 @@ function formatText(params: ICellRendererParams) {
255255
256256
const createRowsForTable = (data: unknown[][], shift: number, isSSrm: boolean) => {
257257
const rows = data && data.length > 0 ? (data[0]?.length ?? 0) : 0
258-
console.log({rows})
259-
console.log({data})
258+
const getIndexInfo = (i : number) => {
259+
return isSSrm ? data?.[0]?.[i] : i
260+
}
260261
return Array.from({ length: rows }, (_, i) => {
261262
return Object.fromEntries(
262263
columnDefs.value.map((h, j) => {
263264
return [
264265
h.field,
265-
toRender(data?.[j - shift]?.[i]),
266+
h.field === INDEX_FIELD_NAME ? getIndexInfo(i) : toRender(data?.[j - shift]?.[i]),
266267
]
267268
}),
268269
)

distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,8 @@ apply_sort_to_table x sort_col_index_list sort_direction_list =
256256
- filter_action: list of filter actions
257257
- filter_val: values to filter
258258

259-
apply__single_filter_to_table : Table -> Text -> Filter_Condition -> Any -> Any -> Table
260-
apply__single_filter_to_table table filter_col filter_action filter_val filter_to_val =
259+
apply_single_filter_to_table : Table -> Text -> Filter_Condition -> Any -> Any -> Table
260+
apply_single_filter_to_table table filter_col filter_action filter_val filter_to_val =
261261
result = case filter_action of
262262
Filter_Condition.Between _ _ _ -> table.filter (filter_col+1) (Filter_Condition.Between filter_val filter_to_val)
263263
Filter_Condition.Is_In _ _ -> if filter_val.length > 0 then table.filter (filter_col+1) (Filter_Condition.Is_In filter_val) else table.filter filter_col (Filter_Condition.Is_In [""])
@@ -281,7 +281,7 @@ apply_filter_to_table table i filter_col filter_action filter_val filter_to_val
281281
action = filter_action.get i
282282
val = filter_val.get i
283283
to_val = filter_to_val.get i
284-
filtered_table = apply__single_filter_to_table table col action val to_val
284+
filtered_table = apply_single_filter_to_table table col action val to_val
285285
@Tail_Call apply_filter_to_table filtered_table i+1 filter_col filter_action filter_val filter_to_val
286286

287287
## PRIVATE
@@ -294,8 +294,9 @@ apply_filter_to_table table i filter_col filter_action filter_val filter_to_val
294294
get_rows_for_table : Any -> Integer -> List -> List -> List -> List -> List -> List -> JS_Object
295295
get_rows_for_table x start_number sort_col_index_list=Nothing sort_direction_list=Nothing filter_col=Nothing filter_action=Nothing filter_val=Nothing filter_extra_val=Nothing =
296296
max_rows=100
297-
table_with_index = x.add_row_number '#'
298-
table_with_index_ordered = table_with_index.reorder_columns ['#'] ..Before_Other_Columns
297+
col_name = x.make_temp_column_name
298+
table_with_index = x.add_row_number col_name
299+
table_with_index_ordered = table_with_index.reorder_columns [col_name] ..Before_Other_Columns
299300
filtered_table = if filter_col.is_nothing then table_with_index_ordered else apply_filter_to_table table_with_index_ordered 0 filter_col filter_action filter_val filter_extra_val
300301
sorted_table = if sort_col_index_list.is_nothing then filtered_table else apply_sort_to_table filtered_table sort_col_index_list sort_direction_list
301302
all_rows_count = filtered_table.row_count

0 commit comments

Comments
 (0)