Skip to content

Commit 9f9075a

Browse files
committed
Add clear and noop column transformations to enhance column menu functionality
1 parent ba7870b commit 9f9075a

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

src/haz3lcore/projectors/implementations/TableRenderer.re

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,48 @@ let add_column_after =
304304
);
305305
};
306306

307+
/* Replace column values with expression holes for manual reentry */
308+
let clear_column = (info: info, column: string): Base.segment => {
309+
IdTagged.FreshGrammar.(
310+
Exp.(
311+
apply_rowwise_transformation(
312+
info,
313+
fn(
314+
Pat.var("r"),
315+
tuple_extension(
316+
var("r"),
317+
tuple([tup_label(label(column), empty_hole())]),
318+
),
319+
None,
320+
None,
321+
),
322+
)
323+
)
324+
);
325+
};
326+
327+
/* No-op: places the field projection back into the field for reference */
328+
let noop_column = (info: info, column: string): Base.segment => {
329+
IdTagged.FreshGrammar.(
330+
Exp.(
331+
apply_rowwise_transformation(
332+
info,
333+
fn(
334+
Pat.var("r"),
335+
tuple_extension(
336+
var("r"),
337+
tuple([
338+
tup_label(label(column), dot(var("r"), label(column))),
339+
]),
340+
),
341+
None,
342+
None,
343+
),
344+
)
345+
)
346+
);
347+
};
348+
307349
let group_by_column = (info: info, column: string): Base.segment => {
308350
IdTagged.FreshGrammar.(
309351
apply_transformation(
@@ -754,6 +796,30 @@ let build_column_menu =
754796
}
755797
| None => []
756798
}
799+
| ["Transform"] =>
800+
// Show transform submenu
801+
[
802+
Action({
803+
text: "← Back",
804+
action: () => local(ShowSubmenu([])) // Go back to main menu
805+
}),
806+
Action({
807+
text: "Clear",
808+
action: () =>
809+
Effect.Many([
810+
local(CloseMenu),
811+
parent(SetSyntax(clear_column(info, h))),
812+
]),
813+
}),
814+
Action({
815+
text: "Identity",
816+
action: () =>
817+
Effect.Many([
818+
local(CloseMenu),
819+
parent(SetSyntax(noop_column(info, h))),
820+
]),
821+
}),
822+
]
757823
| ["Sort"] =>
758824
// Show sort submenu
759825
[
@@ -842,6 +908,14 @@ let build_column_menu =
842908
| None => []
843909
};
844910

911+
/* Transform submenu is always available */
912+
let transform_submenu = [
913+
Action({
914+
text: "Transform →",
915+
action: () => local(ShowSubmenu(["Transform"])) // Navigate to transform submenu
916+
}),
917+
];
918+
845919
let move_items =
846920
(can_move_left ? [true] : [])
847921
@ (can_move_right ? [false] : [])
@@ -928,6 +1002,7 @@ let build_column_menu =
9281002
}),
9291003
]
9301004
@ conversion_submenu
1005+
@ transform_submenu
9311006
@ move_items
9321007
@ sort_submenu
9331008
@ filter_submenu

0 commit comments

Comments
 (0)