feat: Added templates for macro, list, and view for recipe

- feat: Added list and view commands for recipe
This commit is contained in:
Aerex
2019-08-04 23:59:28 -05:00
parent 6af9bef334
commit 05089108a9
11 changed files with 282 additions and 118 deletions

11
templates/recipe/list.yml Normal file
View File

@@ -0,0 +1,11 @@
{% from 'recipe/macro.yml' import render_recipe_fulfilment %}
{% for recipe in grocy.recipes %}
name: {{ recipe.fields.name }}
servings: {{ recipe.fields.base_servings }}
required_fulfilled: {{ render_recipe_fulfilment(recipe.fields.fulfillment, grocy.meta.fa_icons) }}
description: |-
{{ recipe.fields.description }}
{% if loop.nextitem %}
---
{%endif%}
{%endfor %}

View File

@@ -0,0 +1,17 @@
{% macro render_stock_fulfilment(ingredient, fa_icons) -%}
{% if ingredient.need_fulfilled == "1" %} {{ 'Enough in stock' }} {{ fa_icons['check'] }}
{% elif ingredient.need_fulfilled_with_shopping_list == "1" %} {{ 'Not enough in stock, %s missing %s already in stock' | format(ingredient.missing_amount, ingredient.amount_on_shopping_list | int) }} {{ fa_icons['exclamation'] }}
{% else %} {{ 'Not enough in stock, %s missing' | format(ingredient.missing_amount) }} {{ fa_icons['times'] }}
{% endif %}
{%- endmacro %}
{% macro render_recipe_fulfilment(recipe, fa_icons) -%}
{% if recipe.need_fulfilled == "1" %} {{ 'Enough in stock' }} {{ fa_icons['check'] }}
{% else %} {{ 'Not enough in stock, %s ingredients missing' | format(recipe.missing_products_count) }} {{ fa_icons['times'] }}
{% endif %}
{%- endmacro %}
{% macro ingredient_label(ingredient) -%}
{{ ingredient.recipe_amount }} {% if ingredient.recipe_amount | int > 1 %} {{ ingredient.quantity_unit.name_plural }} {% else %} {{ ingredient.quantity_unit.name }} {% endif %} {{ ingredient.name }}
{%- endmacro %}

View File

@@ -1,17 +1,10 @@
{% from 'recipe/macro.yml' import ingredient_label, render_stock_fulfilment %}
name: {{ grocy.fields.name }}
servings: {{ grocy.fields.base_servings }}
servings: {{ grocy.fields.base_servings }}
costs: {{ grocy.fields.fulfillment.costs }}
ingredients: {% for ingredient in grocy.fields.ingredients %}
- product_id: {{ ingredient.id }}
name: {{ ingredient.name}}
description: {{ ingredient.description | default(null) }}
note: {{ ingredient.note }}
amount: {{ ingredient.amount }}
qu_id: {{ ingredient.qu_id }}
only_check_single_unit_in_stock: {{ ingredient.only_check_single_unit_in_stock }}
ingredient_group: {{ ingredient.ingredient_group | default(null) }}
not_check_stock_fulfillment: {{ ingredient.not_check_stock_fulfillment }}{% endfor %}
ingredients: {% for ingredient in grocy.meta.recipes.ingredients.valid_values %}
{{ ingredient_label(ingredient) }} {{ render_stock_fulfilment(ingredient, grocy.meta.fa_icons) }}
note: {{ ingredient.note }} {% endfor %}
description: |-
{{ grocy.fields.description }}