Skip to content

Commit

Permalink
Fix for years buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrotsmnrd committed Aug 25, 2024
1 parent 2255842 commit eded684
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions web/dashboard/main_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,28 +432,35 @@ def update_pubdate_slider(event):
self.end_pubdate_input.param.watch(update_pubdate_slider, "value")

self.last_year_button = pn.widgets.Button(
name="Last year", width=80, button_type="light", button_style="solid"
name="Last year", width=80, css_classes=["last-year-button", "year-button"]
)
self.past_5years_button = pn.widgets.Button(
name="Past 5 years", width=80, button_type="light", button_style="solid"
name="Past 5 years",
width=80,
css_classes=["past-5years-button", "year-button"],
)
self.past_10years_button = pn.widgets.Button(
name="Past 10 years", width=80, button_type="light", button_style="solid"
name="Past 10 years",
width=80,
css_classes=["past-10years-button", "year-button"],
)

def did_click_shortcut_button(event):
print(event)
if event.obj.name == "Last year":
self.pubdate_slider.value = (datetime.now().year, datetime.now().year)
self.start_pubdate_input.value, self.end_pubdate_input.value = (
str(datetime.now().year),
str(datetime.now().year),
)
elif event.obj.name == "Past 5 years":
self.pubdate_slider.value = (
datetime.now().year - 5,
datetime.now().year,
self.start_pubdate_input.value, self.end_pubdate_input.value = (
str(datetime.now().year - 5),
str(datetime.now().year),
)
elif event.obj.name == "Past 10 years":
self.pubdate_slider.value = (
datetime.now().year - 10,
datetime.now().year,
self.start_pubdate_input.value, self.end_pubdate_input.value = (
str(datetime.now().year - 10),
str(datetime.now().year),
)

self.last_year_button.on_click(did_click_shortcut_button)
Expand All @@ -480,8 +487,8 @@ def get_sidebar(self):

items = [
pn.pane.Markdown("## Filters"),
pn.pane.Markdown("### Applied Filters"),
pn.pane.Markdown("(todo)"),
# pn.pane.Markdown("### Applied Filters"),
# pn.pane.Markdown("(todo)"),
pn.layout.Divider(),
pn.pane.Markdown(
"### Publication Details", css_classes=["filters-section-header"]
Expand All @@ -493,6 +500,7 @@ def get_sidebar(self):
self.last_year_button,
self.past_5years_button,
self.past_10years_button,
css_classes=["years-buttons"],
),
),
pn.layout.Divider(),
Expand Down

0 comments on commit eded684

Please sign in to comment.