Skip to content

Commit

Permalink
add toggle all switch
Browse files Browse the repository at this point in the history
  • Loading branch information
mashehu committed Oct 15, 2024
1 parent 4485fa0 commit 3d67386
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions nf_core/pipelines/create/custompipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"),
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 3d67386

Please sign in to comment.