Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Render nutrition plans with listviews

Roland Geider9dc11d594fdf
diff --git a/wger/nutrition/templates/mobile/plan/view.html b/wger/nutrition/templates/mobile/plan/view.html
index 88776ba30..6ea3c598e 100644
--- a/wger/nutrition/templates/mobile/plan/view.html
+++ b/wger/nutrition/templates/mobile/plan/view.html
@@ -35,119 +35,137 @@ $(document).ready(function() {
{% block content %}
{% if plan.description %}
<p>
- <strong>{% trans "Goal" %}:</strong>
<span class="dimmed">{{plan.description}}</span>
</p>
{% endif %}
-<table class="bordertable">
- <thead>
- <tr>
- <th class="ym-g15">{% trans "Meal" %}</th>
- <th>{% trans "Contents" %}</th>
- </tr>
- </thead>
- <tbody>
+
{% for meal in plan.meal_set.select_related %}
- <tr>
- <td>
- {% trans "Nr."%} {{ forloop.counter }}
- {% if meal.time %} &ndash; {{meal.time|time:"H:i"}}{% endif %}
+<div data-role="popup"
+ id="editoptions-meal-{{ meal.id }}"
+ data-theme="d"
+ data-overlay-theme="a"
+ class="ui-content">
+ <div>
+ <h3>{% trans "Options" %}</h3>
+ <a href="{% url 'wger.nutrition.views.meal.delete_meal' meal.id %}"
+ title="{% trans 'Delete' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/trash.svg' %}"
+ width="22"
+ height="22"
+ alt="{% trans 'Delete meal' %}"
+ title="{% trans 'Delete meal' %}">
+ {% trans "Delete meal" %}
+ </a>
+ <a href="{% url 'meal-edit' meal.id %}"
+ title="{% trans 'Edit' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/edit.svg' %}"
+ width="22"
+ height="22"
+ alt="{% trans 'Edit meal' %}"
+ title="{% trans 'Edit meal' %}">
+ {% trans "Edit meal" %}
+ </a>
+ <a href="{% url 'mealitem-add' meal.id %}"
+ title="{% trans 'Add' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/add.svg' %}"
+ width="22"
+ height="22"
+ alt="{% trans 'Add item to meal' %}"
+ title="{% trans 'Add item to meal' %}">
+ {% trans "Add item to meal" %}
+ </a>
+ </div>
+</div>
- <div class="editoptions">
- <a href="{% url 'wger.nutrition.views.meal.delete_meal' meal.id %}"
- title="{% trans 'Delete' %}">
- <img src="{% static 'images/icons/trash.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Delete meal' %}"
- title="{% trans 'Delete meal' %}">
- </a>
- <a href="{% url 'meal-edit' meal.id %}"
- title="{% trans 'Edit' %}"
- class="modal-dialog">
- <img src="{% static 'images/icons/edit.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Edit meal' %}"
- title="{% trans 'Edit meal' %}">
- </a>
- <a href="{% url 'mealitem-add' meal.id %}"
- title="{% trans 'Add' %}"
- class="modal-dialog edit-meal">
- <img src="{% static 'images/icons/add.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Add item to meal' %}"
- title="{% trans 'Add item to meal' %}">
- </a>
- </div>
- </td>
- <td>
- <ul>
- {% for item in meal.mealitem_set.select_related %}
- <li>
- {% if item.get_unit_type == MEALITEM_WEIGHT_GRAM %}{{ item.amount|floatformat:"0" }}g
- {% else %}
- {{ item.amount|floatformat:"0" }}{{ item.weight_unit.unit.name }}
- {% endif %}
- {{ item.ingredient.name }}
-
- <span class="editoptions">
- <a href="{% url 'wger.nutrition.views.meal_item.delete_meal_item' item.id %}"
- title="{% trans 'Delete' %}"
- class="delete-mealitem">
- <img src="{% static 'images/icons/trash.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Delete' %}">
- </a>
- <a href="{% url 'mealitem-edit' item.id %}"
- title="{% trans 'Edit' %}"
- class="modal-dialog edit-meal edit-mealitem">
- <img src="{% static 'images/icons/edit.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Edit' %}">
- </a>
- </span>
- </li>
- {% empty %}
- <a href="{% url 'mealitem-add' meal.id %}"
- title="{% trans 'Add one now.' %}"
- class="modal-dialog edit-meal btn btn-block">
- {% trans "No items for this meal." %}
- {% trans "Add one now."%}
- </a>
- {% endfor %}
- </ul>
- </td>
- </tr>
+{% for item in meal.mealitem_set.select_related %}
+ <div data-role="popup"
+ id="editoptions-item-{{ item.id }}"
+ data-theme="d"
+ data-overlay-theme="a"
+ class="ui-content">
+ <div>
+ <h3>{% trans "Options" %}</h3>
-{% empty %}
-<p>
- <a href="{% url 'meal-add' plan.id %}"
- class="modal-dialog btn btn-block">
- {% trans "No meals for this plan." %}
- {% trans "Add one now." %}
- </a>
-</p>
+ <a href="{% url 'wger.nutrition.views.meal_item.delete_meal_item' item.id %}"
+ title="{% trans 'Delete' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/trash.svg' %}"
+ width="16"
+ height="16"
+ alt="{% trans 'Delete' %}">
+ {% trans "Delete" %}
+ </a>
+ <a href="{% url 'mealitem-edit' item.id %}"
+ title="{% trans 'Edit' %}"
+ data-role="button">
+ <img src="{% static 'images/icons/edit.svg' %}"
+ width="16"
+ height="16"
+ alt="{% trans 'Edit' %}">
+ {% trans "Edit" %}
+ </a>
+ </div>
+ </div>
{% endfor %}
- <tr>
- <td colspan="2">
- <a href="{% url 'meal-add' plan.id %}"
- data-role="button" data-mini="true">
- <img src="{% static 'images/icons/edit.svg' %}"
- width="16"
- height="16"
- alt="{% trans 'Add a new meal' %}"
- title="{% trans 'Add a new meal' %}">
- {% trans "Add a new meal" %}
+
+{% endfor %}
+
+
+{% for meal in plan.meal_set.select_related %}
+<ul data-role="listview"
+ data-split-icon="grid"
+ data-split-theme="b"
+ style="margin-top: 3em;">
+
+ <li data-theme="b" data-icon="false">
+ <a href="#editoptions-meal-{{ meal.id }}" data-rel="popup">
+ {% trans "Nr."%} {{ forloop.counter }}
+ {% if meal.time %} &ndash; {{meal.time|time:"H:i"}}{% endif %}
+ </a>
+ </li>
+ {% for item in meal.mealitem_set.select_related %}
+ <li data-icon="false">
+ <a href="#editoptions-item-{{ item.id }}" data-rel="popup">
+ {% if item.get_unit_type == MEALITEM_WEIGHT_GRAM %}{{ item.amount|floatformat:"0" }}g
+ {% else %}
+ {{ item.amount|floatformat:"0" }}{{ item.weight_unit.unit.name }}
+ {% endif %}
+ {{ item.ingredient.name }}
</a>
- </td>
- <tr>
- </tbody>
-</table>
+ </li>
+ {% if forloop.last %}
+ <li>
+ <a href="{% url 'mealitem-add' meal.id %}">{% trans "Add item to meal" %}</a>
+ </li>
+ {% endif %}
+ {% empty %}
+ <li>
+ <a href="{% url 'mealitem-add' meal.id %}"
+ title="{% trans 'Add one now.' %}">
+ {% trans "No items for this meal." %}
+ {% trans "Add one now."%}
+ </a>
+ </li>
+ {% endfor %}
+</ul>
+{% empty %}
+<a href="{% url 'meal-add' plan.id %}"
+ data-role="button">
+ {% trans "No meals for this plan." %}
+ {% trans "Add one now." %}
+</a>
+{% endfor %}
+
+<p style="margin-top:2em;">
+ <a href="{% url 'meal-add' plan.id %}"
+ data-role="button"
+ data-mini="true">{% trans "Add a new meal" %}</a>
+</p>
+
{% if language.short_name != 'en' %}
<p>