From 3d673864958b799117f42a0f7ee9c60b581855d8 Mon Sep 17 00:00:00 2001 From: mashehu Date: Tue, 15 Oct 2024 16:55:08 +0200 Subject: [PATCH] add toggle all switch --- nf_core/pipelines/create/custompipeline.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/nf_core/pipelines/create/custompipeline.py b/nf_core/pipelines/create/custompipeline.py index 5debcfee7..e433db41e 100644 --- a/nf_core/pipelines/create/custompipeline.py +++ b/nf_core/pipelines/create/custompipeline.py @@ -2,9 +2,9 @@ from textual import on from textual.app import ComposeResult -from textual.containers import Center, ScrollableContainer +from textual.containers import Center, Horizontal, ScrollableContainer from textual.screen import Screen -from textual.widgets import Button, Footer, Header, Markdown, Switch +from textual.widgets import Button, Footer, Header, Markdown, Static, Switch from nf_core.pipelines.create.utils import PipelineFeature @@ -22,7 +22,13 @@ def compose(self) -> ComposeResult: """ ) ) + yield Horizontal( + Switch(id="toggle_all", value=True), + Static("Toggle all features", classes="feature_title"), + classes="custom_grid", + ) yield ScrollableContainer(id="features") + yield Center( Button("Back", id="back", variant="default"), Button("Continue", id="continue", variant="success"), @@ -35,6 +41,7 @@ def on_mount(self) -> None: self.query_one("#features").mount( PipelineFeature(feature["help_text"], feature["short_description"], feature["description"], name) ) + self.query_one("#toggle_all", Switch).value = True @on(Button.Pressed, "#continue") def on_button_pressed(self, event: Button.Pressed) -> None: @@ -45,3 +52,10 @@ def on_button_pressed(self, event: Button.Pressed) -> None: if not this_switch.value: skip.append(this_switch.id) self.parent.TEMPLATE_CONFIG.__dict__.update({"skip_features": skip, "is_nfcore": False}) + + @on(Switch.Changed, "#toggle_all") + def on_toggle_all(self, event: Switch.Changed) -> None: + """Handle toggling all switches.""" + new_state = event.value + for feature in self.query("PipelineFeature"): + feature.query_one(Switch).value = new_state