Skip to content

Commit

Permalink
refactor: refactor salad menu to use jinja
Browse files Browse the repository at this point in the history
'salad menu' is now named 'additional details' and can be altered from config file
additional_items_to_concat is now a dict
additional details listed in user tab arenow created from a for loop in jinja in a standardized way
  • Loading branch information
Michele-Alberti committed Dec 30, 2023
1 parent c99c450 commit 6631856
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 29 deletions.
57 changes: 39 additions & 18 deletions data_lunch_app/conf/panel/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,49 @@ lunch_times_options:
- "13:30"
- "14:00"
- "14:30"
menu_items_to_concat:
- Insalatona Primavera
- Insalatona Valtellina
- Insalatona Sorrento
- Insalatona Chicken Salad
- Insalatona Esplosiva
- Insalatona Follie
- Dolce
- Caffé
- Altro
salad_list: |
🌱 <strong>Primavera:</strong> 🥬 + <i>pomodorini, mozzarella, carciofi, funghi, olive.</i> <br>
⛰️ <strong>Valtellina:</strong> 🥬 + <i>rucola, pomodorini, bresaola, grana.</i> <br>
🍋 <strong>Sorrento:</strong> 🥬 + <i>pomodorini, bufala, olive, noci, carciofi.</i> <br>
🍗 <strong>Chicken Salad:</strong> 🥬 + <i>pomodorini, mozzarella, mais, pollo.</i> <br>
🧨 <strong>Esplosiva:</strong> 🥬 + <i>pomodorini, tonno, fagioli, cipolle.</i> <br>
🤪 <strong>Follie:</strong> 🥬 + <i>pomodori secchi, melanzane, tonno, acciughe.</i> <br>
additional_items_to_concat:
# Set description to null to exclude from additional items details in gui
- name: Insalatona Primavera
short_name: Primavera
icon: 🌱
description: 🥬 + pomodorini, mozzarella, carciofi, funghi, olive.
- name: Insalatona Valtellina
short_name: Valtellina
icon: ⛰️
description: 🥬 + rucola, pomodorini, bresaola, grana.
- name: Insalatona Sorrento
short_name: Sorrento
icon: 🍋
description: 🥬 + pomodorini, bufala, olive, noci, carciofi.
- name: Insalatona Chicken Salad
short_name: Chicken Salad
icon: 🍗
description: 🥬 + pomodorini, mozzarella, mais, pollo.
- name: Insalatona Esplosiva
short_name: Esplosiva
icon: 🧨
description: 🥬 + pomodorini, tonno, fagioli, cipolle.
- name: Insalatona Follie
short_name: Follie
icon: 🤪
description: 🥬 + pomodori secchi, melanzane, tonno, acciughe.
- name: Dolce
short_name: null
icon: null
description: null
- name: Caffé
short_name: null
icon:
description: null
- name: Altro
short_name: Altro
icon: 🃏
description: richieste speciali (da specificare nelle note).
guest_types: # Check also guests icons in panel/gui
- Edison Guest
- External Guest

# Notifications
# NOTIFICATIONS
notifications:
duration: 0
# Drop unused menus entries in orders tables (drop unused if true)
Expand Down
11 changes: 11 additions & 0 deletions data_lunch_app/conf/panel/gui/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,16 @@ total_column_name: totale
# e.g: _target_: panel.pane.HTML with _args_: - <img src="${panel.favicon_path}">
header_object: null

# ADDITIONAL ITEMS DETAILS
additional_item_details_template: |
<details>
<summary><strong>Menu Details</strong></summary>
{% for item in items %}
{% if item.description is not none %}
{{ item.icon }} <strong>{{ item.short_name }}:</strong> <i>{{ item.description }}</i> <br>
{% endif %}
{% endfor %}
</details>
# PASSWORD
psw_text: "### Password rules\n- Minimum eight characters\n- At least one lower case letter\n- At least one upper case letter\n- At least one number\n- At least one special character."
18 changes: 16 additions & 2 deletions data_lunch_app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,14 @@ def build_menu(
df = pd.concat(
[
df,
pd.DataFrame({"item": config.panel.menu_items_to_concat}),
pd.DataFrame(
{
"item": [
item["name"]
for item in config.panel.additional_items_to_concat
]
}
),
],
axis="index",
)
Expand All @@ -199,7 +206,14 @@ def build_menu(
df = pd.concat(
[
df,
pd.DataFrame({"item": config.panel.menu_items_to_concat}),
pd.DataFrame(
{
"item": [
item["name"]
for item in config.panel.additional_items_to_concat
]
}
),
],
axis="index",
ignore_index=True,
Expand Down
19 changes: 10 additions & 9 deletions data_lunch_app/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime
from hydra.utils import instantiate
import jinja2
import logging
from omegaconf import DictConfig, OmegaConf
import pandas as pd
Expand Down Expand Up @@ -463,14 +464,14 @@ def reload_on_no_more_order_callback(

# SIDEBAR -------------------------------------------------------------
# TEXTS
# Foldable salad menu
self.salad_menu = pn.pane.HTML(
f"""
<details>
<summary><strong>Salad menu</strong></summary>
{config.panel.salad_list}
</details>
""",
# Foldable additional item details dropdown menu
jinja_template = jinja2.Environment(
loader=jinja2.BaseLoader
).from_string(config.panel.gui.additional_item_details_template)
self.additional_items_details = pn.pane.HTML(
jinja_template.render(
items=config.panel.additional_items_to_concat
),
width=sidebar_content_width,
)

Expand Down Expand Up @@ -582,7 +583,7 @@ def reload_on_no_more_order_callback(
)
# Add salads
self.sidebar_person_column.append(
self.salad_menu,
self.additional_items_details,
)
# Leave an empty widget for the 'other info' section
self.sidebar_person_column.append(
Expand Down

0 comments on commit 6631856

Please sign in to comment.